Skip to content

Instantly share code, notes, and snippets.

Created June 23, 2013 14:04
Show Gist options
  • Save anonymous/5845134 to your computer and use it in GitHub Desktop.
Save anonymous/5845134 to your computer and use it in GitHub Desktop.
var bd = Assets.getBitmapData("img/sumachan.png");
var temp:BitmapData = new BitmapData(300, 300, true, 0);
temp.copyPixels(bd, new Rectangle(0, 0, 300, 300), new Point(0, 0));
#if flash
var data:Data = Tools.build32ARGB(temp.width, temp.height, Bytes.ofData(temp.getPixels(temp.rect)));
var bo:BytesOutput = new BytesOutput();
var writer:Writer = new Writer(bo);
writer.write(data);
var byteArray:ByteArray = bo.getBytes().getData();
var file:flash.net.FileReference = new flash.net.FileReference();
file.save(byteArray, "test.png");
#elseif cpp
var byteArray:ByteArray = temp.encode('x');
var file:FileOutput = File.write("test.png", true);
file.writeString(byteArray.toString());
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment