yeah Thanks Dave. fyi here's a blog post on my findings so far with screenshots:
http://www.jaredstanley.com/blog/?p=40 On Tue, Jan 26, 2010 at 5:04 AM, Dave Mennenoh <[email protected]>wrote: > Jared, the 1x1 trick doesn't really work that well in Flash as you may have > already found out. I was using that myself for a project until I learned > that for some images it was pretty far off. So, I went to a more traditional > method - getting the average color of each pixel in the image, which > actually is faster than you might think. Here's the method I am using: > > private function averageRGB( source:BitmapData ):uint > { > var red:Number = 0; > var green:Number = 0; > var blue:Number = 0; > var count:int = 0; > var pixel:Number; > > for (var x:int = 0; x < source.width; x++) > { > for (var y:int = 0; y < source.height; y++) > { > pixel = source.getPixel(x, y); > > red += pixel >> 16 & 0xFF; > green += pixel >> 8 & 0xFF; > blue += pixel & 0xFF; > count++; > } > } > > red /= count; > green /= count; > blue /= count; > > return red << 16 | green << 8 | blue; > } > > HTH > > > Dave - > www.offroadfire.com > Adobe Community Expert > http://www.adobe.com/communities/experts/ > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

