Foundation > Image Processing Filters > IlvBitmapFilter: The Image Processing Class > The IlvFilterFlow Class
 
The IlvFilterFlow Class
The IlvFilterFlow class lets you chain IlvBitmapFilter instances using names as inputs and outputs. An example of such a flow is the creation of a drop shadow effect. You use the alpha channel of an image as the input for a Gaussian blur; you then offset the blurred image and merge this with the source image.
The IlvFilterFlow class can be created programmatically but it is much more convenient to use the XML representation of filter flows, in a similar way to the definition of filters in SVG.
An example of such a flow is given by the following XML file (see $ILVHOME/data/filters for many predefined XML filter flows):
<?xml version="1.0"?>
<filters>
<filter id="DropShadow2" x="-10" y="-10" width="125" height="125">
<desc>Applies a drop shadow effect</desc>
<feGaussianBlur in="SourceAlpha" stdDeviation="3"/>
<feOffset dx="2" dy="2" result="offsetBlur"/>
<feComposite in="SourceGraphic" in2="offsetBlur" operator="over"/>
</filter>
</filters>
Here is a line-by-line description:
<?xml version="1.0"?>
The definition of Rogue Wave Views filters follows XML conventions.
<filters>
Opening element for filters (the file can contain any number of filters)
<filter id="DropShadow2" x="-10" y="-10" width="125" height="125">
Opening element for a filter name DropShadow2.
Some filters extend the source image by some pixels in all dimensions, so we must specify the additional extension of the filter.
This filter grows the source image by 10 pixels at the left and top and extends the width and height by 25 pixels.
<desc>Applies a drop shadow effect</desc>
This tag contains a description of the filter.
<feGaussianBlur in="SourceAlpha" stdDeviation="3"/>
The first atomic filter to use in this flow is an IlvGaussianBlurFilter with a deviation of 3 in both directions.
Two predefined names are defined by the filter flow:
*SourceAlpha: contains only the Alpha values of the input image.
*SourceGraphic: contains the input image.
Here we only need to apply the blur on the alpha component of the image.
<feOffset dx="2" dy="2" result="offsetBlur"/>
The second atomic filter is an IlvOffsetFilter with displacement 2.
When not specified, the input from a filter is the output of the previous filter, so it does not need to be specified. The result will be an image stored with the name offsetBlur.
<feComposite in="SourceGraphic" in2="offsetBlur" operator="over"/>
The third and last atomic filter is an IlvComposeFilter that will compose the offset blurred image with the input image using the over operator.
</filter>
Closes the filter flow description.
</filters>
Closes the filters enumeration.
Such an IlvFilterFlow can be created by using the following lines. We suppose that the file containing the filter flow is stored on the disk under the name standard.xml:
IlIUrlStream input("standard.xml");
IlvFilterFlow* flow = new IlvFilterFlow(input, "DropShadow2");

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.