PhotoControler provides a collection of image filter objects that you can use to process images. Each of them might have different parameters. You can load an embedded xml file or use a built-in object to determine those parameters range and type. Please refer to filter parameters tutorial. This tutorial will help you understand image filters and instruct you how to use them.
Understand Filter Hierarchy
In a nutshell, the fundamental object is called BaseFilter, which provides functionality to process an image, such as getPixel and setPixel. This is an abstract object. You must override the ApplyFilter method and put your process logic inside. There are other three base filter objects. See the following figure:
-
BaseColorFilter
Provides a base set of functionality for filters that are color transformations. Instead of ApplyFilter, you only need to override a simpler method transformColor, which convert the old color pixel to a new color pixel.
-
BaseOffsetFilter
Provides a base set of functionality for filters that are geometric transformations. Instead of ApplyFilter, you only need to override a simpler method transform, which transform the old pixel coordinate to a new pixel coordinate.
-
BaseCompositeFilter
Provides a set of functionality to do composite of two images. Instead of ApplyFilter, you only need to override a simpler method manipulateColor, which manipulates the foreground image color pixel and the background image color pixel.
Please go through the SDK for more details within those objects. Basically, all other filters inherit from those four base filters. If you want to know more about how to customize a filter, please refer to the tutorial: your own filter.
Use Image Filters
There are two ways to use an image filter. It is recommended to use the object call as follows:
1:
2: IC.PhotoController.Controller objpc = new Controller(img);
3: img = objpc.Filter(new InvertColorFilter());
4:
As you can see, the step is straightforward. Initialize the controller object first, then pass the filter object to the Filter method. Since InvertColorFilter does not need any parameter, you can simply create the filter object and pass to the method directly. Sometimes, even when a filter requires parameters, if you are happy to use the default setting, you can do this way too. Or you can do it step by step as follows:
1: IC.PhotoController.Controller objpc = new Controller(img);
2:
3: // create an EmbossFilter and specify the parameters
4: EmbossFilter filter = new EmbossFilter();
5: filter.Level = 3;
6: filter.Direction = 120;
7:
8: // apply the filter algorithm
9: img = objpc.Filter(filter);
Another way to apply filter is using an enumeration FilterStyle. The Filter method will simply create a filter object with default settings accordingly. However, composition filters cannot work in this way, because they need the caller to specify a background image, you will have to use the object call way. This alternate is provided mainly for backward compatibility. For some simple filters this way is very convenient and easy, but for complicated filter, it's not recommended.
[Back to Top]