Flex - Bitmap vs BitmapDataAugust 23rd, 2009
So what's the difference between a Bitmap object and a BitmapData object? A BitmapData object holds information about each pixel in an image. You can access this pixel data to apply transformations or even create images from scratch by accessing the graphics property. The problem with a BitmapData object is that it is not a subclass of DisplayObject, which means that you can't directy add it to the display list. Here' where the Bitmap object come into play. It is a subclass of DisplayObject and it can be used as a wrapper around a BitmapData object so that your image can be added to a Container like this:
var myBitmap = new Bitmap(myBitmapData); addChild(myBitmap);
In fact, a Bitmap object has a bitmapData property, and you can set it like this:
myBitmap.bitmapData = myBitmapData;
You might be wondering why there is a separation of the two classes. Why can't you just make a BitmapData object so that it's able to be added directly to the display list? The reason is that keeping them separate allows for greater efficiency when it comes to rendering graphics on the screen. The BitmapData object can be manipulated without having to actually redraw it on the screen for each frame. So if you want to update a Bitmap on the screen, you can simply swap out its bitmapData property after it has been manipulated.
|
![]() RECENT ARTICLES
Stack Error 1023 - My Strange Encounter With Error 1023
Passing Values to a Custom ItemRenderer Using a File Reference to Upload to ASP.net Flex - Create a Dashboard That Allows Drag and Resize Using SharedObjects Strange Hack For Downloading With a FileReference Flex Checkbox TreeItemRenderer Flex - Dynamically Create Time Segments MORE... |
