View comments | RSS feed

copyChannel (BitmapData.copyChannel method)

public copyChannel(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, sourceChannel:Number, destChannel:Number) : Void

Transfers data from one channel of another BitmapData object or the current BitmapData object into a channel of the current BitmapData object. All of the data in the other channels in the destination BitmapData object are preserved.

The source channel value and destination channel value can be one of the following values or the sum of any of the values:

Availability: ActionScript 1.0; Flash Player 8

Parameters

sourceBitmap:flash.display.BitmapData - The input bitmap image to use. The source image can be a different BitmapData object or it can refer to the current BitmapData object.

sourceRect:flash.geom.Rectangle - The source Rectangle object. If you only want to copy channel data from a smaller area within the bitmap, specify a source rectangle that is smaller than the overall size of the BitmapData object.

destPoint:flash.geom.Point - The destination Point object that represents the upper-left corner of the rectangular area where the new channel data is placed. If you want to copy channel data from one area to a different area in the destination image, specify a point other than (0,0).

sourceChannel:Number - The source channel. Use a value from the set (1,2,4,8), which represent red, green, blue, and alpha channels, respectively, or a sum of any of the values.

destChannel:Number - The destination channel. Use a value from the set (1,2,4,8), which represent red, green, blue, and alpha channels, respectively, or a sum of any of the values.

Example

The following example shows how to copy a source ARGB channel from a BitmapData object back onto itself at a different location:

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;

var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

mc.onPress = function() {
    myBitmapData.copyChannel(myBitmapData, new Rectangle(0, 0, 50, 80), new Point(51, 0), 3, 1);
}

See also

Rectangle (flash.geom.Rectangle)


Version 8

Comments


No screen name said on Apr 18, 2006 at 10:23 PM :
I am using Macromedia Pro 8 and based on my testing with the copyChannel method summing the Channel numbers for example 1 (red) + 2 ( green) = 3 (red & green) does not cause the red and green channels to be copied. In fact it appears that the call is ignored if I use any numbers other than 1, 2, 4, or 8.

Has anyone had any other results? Am I reading the direction incorrectly?
No screen name said on Aug 8, 2006 at 7:53 PM :
Why is the source channel given as 3 in the example? Should it combine the red & green channels and copy them?

 

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

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