0

ステージを新しいビットマップとして描きたいです。
ステージのトップバー(トップバーの高さは100ピクセル)を切り取って、新しいビットマップとして描画するにはどうすればよいですか?

4

1 に答える 1

1

これを行うには、ビットマップに必要なすべてのものをスプライトに追加してから、次のようにします。

var stageSprite:Sprite = new Sprite();
addChild(stageSprite);

//Creates the sprite you want to draw

stageSprite.addChild(objectsYouWantToDraw);

//Here you add the objects you want to draw to the sprite

var bmd:BitmapData = new BitmapData(stage.stageWidth, 100, true, 0);
var bit:Bitmap = new Bitmap(bmd);
addChild(bit);

//Create a bitmap with your size

bmd.draw(stageSprite);

//Draw the objects to a bitmap

画面の別の部分を取得したい場合は、オプションでマトリックスを追加できます。

var m:Matrix = new Matrix();
m.translate(-xOffset, -yOffset);
bmd.draw(stageSprite, m);

//Draw the objects to a bitmap with the offsets you want
于 2012-09-13T11:37:23.317 に答える