Today I needed to found a way to create bitmap data object from a display object. I found a solution in Flex Cookbook (http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postId=1682) and having this I improved it and made it simpler.
The code follows…
public function makeBitmap(myDO:DisplayObject):BitmapData
{
var myBD:BitmapData = new BitmapData(myDO.width, myDO.height);
myBD.draw(myDO);
[...]
To isolate the color channels and alpha channel from a 32-bit color we use shifting and bitwise AND operator.
var colorValue:uint = 0xFFFFCC99;
// Isolate Alpha channel
var alpha:uint = ( colorValue << 24 ) & 0xFF;
// Isolate Red channel
var red:uint = ( colorValue << 16 ) & 0xFF;
// Isolate Green channel
var green:uint = ( colorValue << 8 [...]