|Please see the Example A.102 - "Use multiple image filters".|
The ImageProcessingFilterCollection is a class that allows to apply an unlimited number of ImageProcessingFilters, so that each filter is executed in chain one after the other.
The image generated by a filter is used as input by the following filter in the chain.
For this reason it's very important the order in which an ImageProcessingFilter is added to the collection.
In fact if, for example, you add a ResizeConstraint filter after a Watermark filter, then also the watermark will be resized.
Vice-versa, if you add a ResizeConstraint filter before a Watermark filter, then the watermark will not be resized.
In other words, when you instantiate a new ImageProcessingFilterCollection and you add some filters to it, in the fact you are creating a new "complex" filter that is composed by the sum of other sub-filters.
|You can add any kind of filter to your ImageProcessingFilterCollection, even other collections of filters !|
This means can you can easily build complex trees of filters.
Once you added filters to the collection, you can process an image by using one of the image processing methods inherited by the ImageProcessingFilter base class:
Please note that all the filter contained in the collection is applied only when one of the image processing method is invoked.
In the following example, the image is first resized (50% of the original size) and then a TextWatermark is applied
ImageProcessingFilterCollection myFilter = new ImageProcessingFilterCollection();
myFilter.Add(new TextWatermark("My watermark"));
Another interesting thing to know is that the sum operator of the ImageProcessingFilter class is overloaded.
var myFilter = new ImageTransformation(50F) + new TextWatermark("My watermark");