views:

349

answers:

2

I am trying to grab part of stage area using BitmapData and copyPixels method:

bmd = new BitmapData(stage.stageWidth, stage.stageHeight);

bmdRect = new BitmapData(320, 240);

rectangle = new Rectangle(360, 20, 320, 240); 

bmdRect.copyPixels(bmd, rectangle, new Point());

bmd.draw(bmp);
bmp = new Bitmap(bmdRect);   

var myEncoder:JPGEncoder = new JPGEncoder(100);
var byteArray:ByteArray = myEncoder.encode(bmd);

The result i get is an empty .jpg I m pretty sure that the error is in the Bitmap procedure and not the saving one...

A: 

Can't you just call bmd.draw(stage)?

lunixbochs
I ve used `bmd.draw(stage)` but this grabs the whole stage. I just need a part of the stage.
Dimitree
A: 

Finally used this solution to copy part of the stage

(I copied everything that is on stage from (360, 20) and after)

var bitmapdata:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);

bitmapdata.draw(stage);

var bitmapDataA: BitmapData = new BitmapData(300, 250);

bitmapDataA.copyPixels(bitmapdata, new Rectangle(360, 20, 320, 240), new Point(0, 0));

var myEncoder:JPGEncoder = new JPGEncoder(90);

var byteArray:ByteArray = myEncoder.encode(bitmapDataA);

Dimitree