Using BitmapData.lock( ) to improve performance : BitmapData : Graphics Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Graphics » BitmapData »

 

Using BitmapData.lock( ) to improve performance


 

package{
  import flash.display.*;
  
  public class Main extends Sprite{
    public function Main(){

        var imgData:BitmapData = new BitmapData(500500, true, 0x00000000);
        var bmp:Bitmap = new Bitmap(imgData);
        
        imgData.lock(  );
        
        var color:uint;
        for (var i:int 0; i < imgData.height ; i++) {
          for (var j:int 0; j < imgData.width; j++) {
            color =  Math.floor(Math.random(  )*0xFFFFFFFF);
            imgData.setPixel32(j, i, color);
          }
        }
        
        imgData.unlock(  );
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Graphics
» BitmapData