O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Copying Graphics to a BitmapData Object

Pixel color values can be copied to a BitmapData object from one of two sources: another BitmapData object, or any DisplayObject instance.

To copy any DisplayObject instance to a BitmapData object, we use the draw( ) method, which copies the color values from a source object to a destination BitmapData object. As part of the copying process, pixels written to the BitmapData object can be transformed, blended, and smoothed.

To copy color values from another BitmapData object, we can use either draw( ) or any of the following BitmapData-specific methods:

copyPixels( )

Copies the color values from a rectangular region of pixels in a source BitmapData object to a destination BitmapData object. The source and destination can be the same, allowing pixels to be copied from one area to another within the same image.

copyChannel( )

Copies a single color channel from a rectangular region of pixels in a source BitmapData object to a destination BitmapData object. The source and destination can be the same, allowing one channel to be copied into another channel within the same image.

clone( )

Creates a new BitmapData object by duplicating an existing BitmapData object.

merge( )

Blends the channels of two BitmapData objects together, producing a new image in which one image appears superimposed over the other. The source and destination BitmapData object can be the same, allowing two channels of the same image to be blended.

In this section, we'll focus on draw( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required