Nadim is Simple

December 12, 2008

Bitmap Manipulation in ActionScript 3.0

Filed under: Creativity, Tutorial — Tags: , , , — Nadim Jahangir @ 5:22 pm

In ActionScript 3.0 I found very useful classes for bitmap manipulation. The classes are BitmapData and Bitmap. I can now do image processing from right inside ActionScript. Using the BitmapData class you can access each pixel in a bitmap individually. The bitmap data can contain any image data of any movie clip. The following is an example code for this,

var bmpData:BitmapData = new BitmapData(mc.width, mc.height);

bmpData.draw(mc);

// do image processing tasks by bmpData.getPixel(x, y) and bmpData.setPixel(x, y, color)

var bmp:Bitmap = new Bitmap(bmpData);

addChild(bmp);

Here mc is the instance name of a target movie clip of which you want to manipulate pixels. bmpData got the pixel info of mc by calling draw() method. To make the bitmap visible after processing, a new Bitmap instance (bmp) is created and added to the display list by addChild() method.

I’ve made a demo of this pixel manipulation, here I made a wavy effect to an image of Angelina Jolie. Check this in here AS3 Bitmap Manipulation Demo by Nadim. Here is the screenshot.

Wavy Effect of Image by AS3

Wavy Effect of Image by AS3

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Shocking Blue Green. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.