4

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...

4

3 回答 3

6

终于用这个方案复制了部分stage

我从 (360, 20) 及之后复制了舞台上的所有内容

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);
于 2010-03-16T10:58:16.687 回答
0

你不能打电话bmd.draw(stage)吗?

于 2010-03-15T21:01:25.893 回答
0
  var stage_snapshot:BitmapData = new BitmapData(600, 120);

  var myRectangle:Rectangle = new Rectangle(0, 0, 600, 120);


  var myMatrix:Matrix = new Matrix();

  var translateMatrix:Matrix = new Matrix();

  translateMatrix.translate(-100, -225);

  myMatrix.concat(translateMatrix);

  stage_snapshot.draw(stage,myMatrix,null,null,myRectangle);

  var encoded_jpg:JPGEncoder = new JPGEncoder(100);

  var jpg_binary:ByteArray = new ByteArray();

  jpg_binary = encoded_jpg.encode(stage_snapshot);
于 2013-04-03T13:36:12.713 回答