Return to Snippet

Revision: 47209
at June 2, 2011 19:52 by adrianparr


Initial Code
import flash.display.Bitmap;
import flash.display.BitmapData;
 
var bmpd:BitmapData = new LibraryBitmap(1,1);
var bitmap:Bitmap = new Bitmap();
bitmap.bitmapData = bmpd;
addChild(bitmap);
 
var wide:int = bmpd.width;
var tall:int = bmpd.height;
var totalPixels:int = wide * tall;
trace("wide: " + wide);
trace("tall: " + tall);
trace("totalPixels: " + totalPixels);
var index:int = totalPixels + 1;
var useIndex:int;
var xPixel:int;
var yPixel:int;
while (--index > 0) {
	useIndex = index - 1;
	xPixel = useIndex % wide;
	yPixel = int(useIndex / wide);
	bmpd.setPixel(xPixel, yPixel, 0xff0000);
}

Initial URL
http://spilled-milk.com/blog/2010/06/30/faster-pixel-loop-itteration/

Initial Description

                                

Initial Title
AS3 Loop Through Pixels In A Bitmap

Initial Tags

                                

Initial Language
ActionScript 3