The ConvolutionFilter class applies a matrix convolution filter effect. A convolution combines pixels
in the input image with neighboring pixels to produce an image. A wide variety of image
effects can be achieved through convolutions, including blurring, edge detection, sharpening,
embossing, and beveling. You can apply the filter to any display object (that is, objects that
inherit from the DisplayObject class),
such as MovieClip, SimpleButton, TextField, and Video objects, as well as to BitmapData objects.

To create a convolution filter, use the syntax new ConvolutionFilter().
The use of filters depends on the object to which you apply the filter:

To apply filters to movie clips, text fields, buttons, and video, use the
filters property (inherited from DisplayObject). Setting the filters
property of an object does not modify the object, and you can remove the filter by clearing the
filters property.

To apply filters to BitmapData objects, use the BitmapData.applyFilter() method.
Calling applyFilter() on a BitmapData object takes the source BitmapData object
and the filter object and generates a filtered image as a result.

If you apply a filter to a display object, the value of the cacheAsBitmap property of the
object is set to true. If you clear all filters, the original value of
cacheAsBitmap is restored.

A filter is not applied if the resulting image exceeds the maximum dimensions.
In AIR 1.5 and Flash Player 10, the maximum is 8,191 pixels in width or height,
and the total number of pixels cannot exceed 16,777,215 pixels. (So, if an image is 8,191 pixels
wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier and AIR 1.1 and earlier,
the limitation is 2,880 pixels in height and 2,880 pixels in width.
For example, if you zoom in on a large movie clip with a filter applied, the filter is
turned off if the resulting image exceeds maximum dimensions.

clamp

Indicates whether the image should be clamped. For pixels off the source image, a value of
true indicates that the input
image is extended along each of its borders as necessary by duplicating the color values at each
respective edge of the input image. A value of false indicates that another color should
be used, as specified in the color and alpha properties.
The default is true.

The following example creates two boxes using the BitmapData class, one of which is half the size of the other.
When the example first loads, the larger box is drawn inside mc using the attachBitmap().
When mc is clicked and the applyFilter() method is called, the largeBox instance of BitmapData is redrawn with smallBox as a source bitmap.
Since applyFilter() draws smallBox over a Rectangle whose width and height is specified as those of largeBox, the source bitmap is smaller than the drawing area.
The clamp property of ConvolutionFilter in this case is set to false and the area which is not covered by the source bitmap, smallBox, is a solid red as determined by the clampColor and clampAlpha variables.

divisor

The divisor used during matrix transformation. The default value is 1.
A divisor that is the sum of all the matrix values smooths out the overall color intensity of the
result. A value of 0 is ignored and the default is used instead.

Implementation public function get divisor():Number public function set divisor(value:Number):void

matrix

An array of values used for matrix transformation. The number of items
in the array must equal matrixX * matrixY.

A matrix convolution is based on an n x m matrix, which describes how a given pixel value in the
input image is combined with its neighboring pixel values to produce a resulting pixel value. Each
result pixel is determined by applying the matrix to the corresponding source pixel and its
neighboring pixels.

For a 3 x 3 matrix convolution, the following formula is used for each independent color channel:

Certain filter specifications perform faster when run by a processor
that offers SSE (Streaming SIMD Extensions). The following are criteria
for faster convolution operations:

The filter must be a 3x3 filter.

All the filter terms must be integers between -127 and +127.

The sum of all the filter terms must not have an absolute value greater than 127.

If any filter term is negative, the divisor must be between 2.00001 and 256.

If all filter terms are positive, the divisor must be between 1.1 and 256.

The bias must be an integer.

Note: If you create a ConvolutionFilter instance using the
constructor without parameters, the order you assign values to matrix properties affects
the behavior of the filter. In the following case, the matrix array is assigned while the
matrixX and matrixY properties are still set to 0
(the default value):

preserveAlpha

Indicates if the alpha channel is preserved without the filter effect
or if the convolution filter is applied
to the alpha channel as well as the color channels.
A value of false indicates that the
convolution applies to all channels, including the
alpha channel. A value of true indicates that the convolution applies only to the
color channels. The default value is true.

Implementation public function get preserveAlpha():Boolean public function set preserveAlpha(value:Boolean):void

Initializes a ConvolutionFilter instance with the specified parameters.

Parameters

matrixX:Number (default = 0) — The x dimension of the matrix (the number of columns in the matrix). The
default value is 0.

matrixY:Number (default = 0) — The y dimension of the matrix (the number of rows in the matrix). The
default value is 0.

matrix:Array (default = null) — The array of values used for matrix transformation. The number of
items in the array must equal matrixX * matrixY.

divisor:Number (default = 1.0) — The divisor used during matrix transformation. The default value is 1.
A divisor that is the sum of all the matrix values evens out the overall color intensity of the
result. A value of 0 is ignored and the default is used instead.

bias:Number (default = 0.0) — The bias to add to the result of the matrix transformation. The default value is 0.

preserveAlpha:Boolean (default = true) — A value of false indicates that the alpha value is not
preserved and that the convolution applies to all
channels, including the alpha channel. A value of true indicates that
the convolution applies only to the color channels. The default value is true.

clamp:Boolean (default = true) — For pixels that are off the source image, a value of true indicates that the
input image is extended along each of its borders as necessary by duplicating the color values
at the given edge of the input image. A value of false indicates that another
color should be used, as specified in the color and alpha properties.
The default is true.

color:uint (default = 0) — The hexadecimal color to substitute for pixels that are off the source image.

The following example applies different convolution filters to
an image file. The filter constructor calls
buildChild() four times to load and display four instances of the image.
Each call to buildChild() takes as an argument a function that applies
no filter to the first instance and a different convolution filter to each
subsequent instance.

The buildChild() function creates a new Loader object named
loader. For each call to buildChild(),
attach an event listener to the Loader object to listen for complete events,
which are handled by the function passed to buildChild().

The applyBrightness(), applySharpness(), and applyOutline()
functions use different values for the matrix array to achieve different
ConvolutionFilter effects.

Note: For best results, use an image approximately 80 pixels in width.
The name and location of the image file should match the value you pass to the
url property. For example, the value passed to url in the example
points to an image file named "Image.jpg" that is in the same directory as your SWF file.