Bitmap BitmapData

时间:2023-03-09 05:51:13
Bitmap BitmapData

var sp:Sprite=new Sprite();
sp.graphics.beginFill(0xffccdd);
sp.graphics.drawRect(0,0,100,100);
sp.graphics.beginFill(0x33eedd);
sp.graphics.drawRect(100,0,100,100);
addChild(sp);
sp.x=300;

var bmpdt:BitmapData=new BitmapData(200,100);
var bmp:Bitmap=new Bitmap();
//mt 是底板画的操作
var mt:Matrix=new Matrix();
//-100 左移
mt.translate(-100,0);
//rect是指定上面纸的绘制区
var rct:Rectangle=new Rectangle(0,0,100,100);
bmpdt.draw(sp,mt,null,null,rct);
mt.translate(200,0);
rct=new Rectangle(100,0,100,100);
bmpdt.draw(sp,mt,null,null,rct);

bmp.bitmapData=bmpdt;
addChild(bmp);