generateFilterRect (BitmapData.generateFilterRect method)

public generateFilterRect(sourceRect:Rectangle, filter:BitmapFilter) : Rectangle

Determines the destination rectangle that the applyFilter() method call affects, given a BitmapData object, a source rectangle, and a filter object.

For example, a blur filter normally affects an area larger than the size of the original image. A 100 x 200 pixel image that is being filtered by a default BlurFilter instance, where blurX = blurY = 4 generates a destination rectangle of (-2,-2,104,204). The generateFilterRect() method lets you find out the size of this destination rectangle in advance so that you can size the destination image appropriately before performing a filter operation.

Some filters clip their destination rectangle based on the source image size. For example, an inner DropShadow does not generate a larger result than its source image. In this API, the BitmapData object is used as the source bounds and not the source rect parameter.

Availability: ActionScript 1.0; Flash Player 8

Parameters

sourceRect:flash.geom.Rectangle - A rectangle defining the area of the source image to use as input.

filter:flash.filters.BitmapFilter - A filter object that you use to calculate the destination rectangle.

Returns

flash.geom.Rectangle - A destination rectangle computed by using an image, the sourceRect parameter, and a filter.

Example

The following example shows how to determine the destination rectangle that the applyfilter() method affects:

import flash.display.BitmapData;
import flash.filters.BevelFilter;
import flash.geom.Rectangle;

var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xCCCCCCCC);

var filter:BevelFilter = new BevelFilter(5, 45, 0xFFFF00, .8, 0x0000FF, .8, 20, 20, 1, 3, "outter", false);

var filterRect:Rectangle = myBitmapData.generateFilterRect(myBitmapData.rectangle, filter);

trace(filterRect); // (x=-31, y=-31, w=162, h=142)

Version 8

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001953.html