CopyPixels for BigAssCanvas
We needed to copy out the BitmapData from a BigAssCanvas so i added this to bit101s class. It doesnt really work like BitmapData's copyPixels - as that copys pixel INTO the bitmap object, so i've named it copyPixelsOut and it returns a new bitmapData of the rect.
You will notice the red lines at 2880 when you move the viewable region over them the data you are given is atually sourced from 2 bitmapData objects (inside the BigAssBitmap).
PS: Thanks to Jonno from Something Splendid for helping me when my maths brain had disappeared.
Its basically :
-
public function copyPixelsOut(rect:Rectangle, transparent:Boolean=true, fillColor:uint=0xff000000 ):BitmapData
-
{
-
var bitmapData:BitmapData = new BitmapData(rect.width, rect.height, transparent, fillColor);
-
-
for(var i:int = 0; i <_bitmaps.length; i++)
-
{
-
var bmp:Bitmap = _bitmaps[i] as Bitmap;
-
var temp:Rectangle = rect.clone();
-
temp.x -= bmp.x;
-
temp.y -= bmp.y;
-
-
if(temp.intersects(new Rectangle(0,0,2880,2880))){
-
bitmapData.copyPixels(bmp.bitmapData, temp, new Point());
-
}
-
}
-
-
return bitmapData;
-
}
This entry was posted on Friday, November 28th, 2008 at 4:03 pm and is filed under Flash. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
One comment
-
November 28th, 2008 at 4:08 pm[...] Touch My Pixel Blog Games + Web « CopyPixels for BigAssCanvas [...]