Actionscript:
-
import com.adobe.images.JPGEncoder;
-
-
var jpgEncoder:JPGEncoder = new JPGEncoder(80);
-
var file:FileReference = new FileReference();
-
var id:int = 0;
-
-
var bit:BitmapData = new BitmapData(400, 400, false, 0x000000);
-
addChild(new Bitmap(bit));
-
-
stage.addEventListener(MouseEvent.CLICK, onClick);
-
function onClick(evt:MouseEvent):void{
-
// draw some perlin noise
-
bit.perlinNoise(200,200, 2, Math.random()*100, true, false,0, true);
-
//bit.draw(someClip);
-
//bit.draw(someVideo);
-
id++;
-
file.save(jpgEncoder.encode(bit), "image_" +id+".jpg");
-
}
This snippet uses the as3corelib which you can download on this page. It uses the JPGEncoder class to save a jpeg image to a users HD. It also makes use of the flash player 10 FileReference.save() method.
I used BitmapData.perlinNoise() to quickly create an arbitrary image.... as the code comments suggest you could easily snapshot a video or other DisplayObject.
One Comment
Is this only available in CS4? I don’t see a reference to FileReference.save in the help of my CS3
2 Trackbacks
[...] Save BitmapData to your HD [...]
[...] mit einem Skript. Wei