Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > BitmapData (flash.display.BitmapData) > applyFilter (BitmapData.applyFilter method) | |||
public applyFilter(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, filter:BitmapFilter) : Number
Takes a source image and a filter object and generates the filtered image.
This method relies on the behavior of built-in filter objects, which have code to determine the destination rectangle that is affected by an input source rectangle.
After a filter is applied, the resulting image can be larger than the input image. For example, if you use a BlurFilter class to blur a source rectangle of (50,50,100,100) and a destination point of (10,10), the area that changes in the destination image is larger than (10,10,60,60) because of the blurring. This happens internally during the applyFilter() call.
If the sourceRect parameter of the sourceBitmapData parameter is an interior region, such as (50,50,100,100) in a 200 x 200 image, the filter uses the source pixels outside the sourceRect parameter to generate the destination rectangle.
Availability: ActionScript 1.0; Flash Player 8
sourceBitmap:BitmapData - The input bitmap image to use. The source image can be a different BitmapData object or it can refer to the current BitmapData instance.
sourceRect:Rectangle - A rectangle that defines the area of the source image to use as input.
destPoint:Point - The point within the destination image (the current BitmapData instance) that corresponds to the upper-left corner of the source rectangle.
filter:BitmapFilter - The filter object that you use to perform the filtering operation. Each type of filter has certain requirements, as follows:
Number - A number that indicates whether the filter was applied successfully. If 0 is returned, the filter was applied successfully. If a negative number is returned, an error occurred during the application of the filter.
The following example shows how to apply a bevel filter to a BitmapData instance:
import flash.display.BitmapData;
import flash.filters.BevelFilter;
import flash.geom.Point;
var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xCCCCCCCC);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
var filter:BevelFilter = new BevelFilter(5, 45, 0xFFFF00, 0.8, 0x0000FF, 0.8, 20, 20, 1, 3, "inner", false);
mc.onPress = function() {
myBitmapData.applyFilter(myBitmapData, myBitmapData.rectangle, new Point(0, 0), filter);
}
BevelFilter (flash.filters.BevelFilter), BlurFilter (flash.filters.BlurFilter), ColorMatrixFilter (flash.filters.ColorMatrixFilter), ConvolutionFilter (flash.filters.ConvolutionFilter), DisplacementMapFilter (flash.filters.DisplacementMapFilter), DropShadowFilter (flash.filters.DropShadowFilter), GlowFilter (flash.filters.GlowFilter), filters (MovieClip.filters property)
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001394.html