Created
October 7, 2011 11:02
-
-
Save eiszfuchs/1270063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
import flash.display.*; | |
import flash.utils.*; | |
import mx.graphics.codec.*; | |
*/ | |
var bitmap:BitmapData = new BitmapData(128, 128, true); | |
var x:int, y:int; | |
for (y = 0; y < bitmap.height; y++) { | |
for (x = 0; x < bitmap.width; x++) { | |
bitmap.setPixel32(x, y, Math.random() * 0xFFFFFFFF); | |
} | |
} | |
var encoder:PNGEncoder = new PNGEncoder; | |
var raw:ByteArray = encoder.encode(bitmap); | |
var file:FileReference = new FileReference(); | |
file.save(raw, 'saveme.png'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment