通过ActionScript 3.0代码将DisplayObject对象转换成图片

很简单,就只写代码示例了

var displayObject:DisplayObject = stage;
var bitmapData:BitmapData = new BitmapData(displayObject.width,displayObject.height,true,0xffffff);
bitmapData.draw(displayObject);				
var bitmap:Bitmap = new Bitmap(bitmapData);				
var png:PNGEncoder = new PNGEncoder();
var pngStream:ByteArray = png.encode(bitmapData);
var f:File = File.desktopDirectory;
f = new File(f.resolvePath("a.png").nativePath);
f.save(pngStream,"a.png");

 

你可能感兴趣的:(F#,actionscript)