PDA

View Full Version : Does BitmapData draw what's outside the stage area?


wu-tang
11-04-2008, 12:31 AM
Quick question. I have a MC with some over sized content in it (2000,2000). The content is at x=-1000, y=-1000;

This MC sits on the stage and can be moved around. Sometimes it is at a negative X,Y and it extended past the stage width & height.

In the MC class I have a function:


public function getBitmap():Bitmap
{
var bmpData:BitmapData = new BitmapData(grid.width, grid.height, false, 0xFFFF00);
bmpData.draw(this);
var bmp:Bitmap = new Bitmap(bmpData);

return bmp;
};


However, it seems to only capture the area visible on stage - from 0,0 to the width and height of the MC.

Anyone know if it's possible to capture the whole area of the MC?

Thanks:D

wu-tang
11-04-2008, 12:58 AM
I found the answer.... use a matrix.


public function getNodesBitmap():Bitmap
{
var bmpData:BitmapData = new BitmapData((grid.width + (node_width*2)), (grid.height + (node_height*2)), false, 0xFFFF00);

var rect:Rectangle = grid.getBounds(this);
var m:Matrix = new Matrix();
m.tx = -rect.x + node_width;
m.ty = -rect.y + node_height;


bmpData.draw(this,m);
var bmp:Bitmap = new Bitmap(bmpData);

return bmp;
};

lordofduct
11-04-2008, 02:02 AM
BitmapData.draw() is completely independent of the stage. And basically independent completely of the Root DisplayList in general. The only DisplayList it is dependent upon is its internal DisplayList. What I mean is that it really is only concerned about the children objects of itself because that is what makes up its visual look.

Your matrix method works, but that is merely coincidental.

Keep in mind a BitmapData object will only draw in a space of dimensions it considers itself to be. So make sure to set its width and height to what they need to be.

Secondly if the IBitmapDrawable you are passing to it isn't set off it (0,0) control position and you want the BitmapData to have this visual point, then use the Matrix to adjust from there.