Advertisement
henke37

PNG encoder

May 29th, 2013
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.Event;
  2. import flash.display.*;
  3. import flash.geom.*;
  4. import flash.utils.*;
  5. import flash.filesystem.*
  6.  
  7.  
  8. addEventListener(Event.ENTER_FRAME,eFrame);
  9.  
  10. var bmd:BitmapData=new BitmapData(stage.stageWidth,stage.stageHeight);
  11. var all:Rectangle=new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
  12. var opts:Object=new PNGEncoderOptions(true);
  13. var basePath:String=File.desktopDirectory.nativePath+File.separator+"dump"+File.separator;
  14.  
  15. var i:uint=0;
  16.  
  17. eFrame(null);
  18.  
  19. function eFrame(e:Event):void {
  20.     bmd.fillRect(all,0x00000000);
  21.     bmd.drawWithQuality(root,null,null,null,null,true,StageQuality.HIGH_16X16);
  22.    
  23.     var ba:ByteArray=bmd.encode(all,new PNGEncoderOptions(true));
  24.    
  25.     var f:File=new File(basePath+i+".png");
  26.     var fs:FileStream=new FileStream();
  27.     fs.open(f,FileMode.WRITE);
  28.     fs.writeBytes(ba);
  29.     fs.close();
  30.    
  31.     ++i;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement