Hey list - I have been trying to get the dominant pixel color of an image.

I received this solution from someone, but I'm still not exactly sure what
flash is doing with this:


public static function GetColor(_bmd:BitmapData):uint{

var m: Matrix = new Matrix();
m.scale( 1 / _bmd.width, 1 / _bmd.height);
var colorBmd:BitmapData = new BitmapData(1, 1);
colorBmd.draw(_bmd, m);
var color:uint = colorBmd.getPixel(0,0);
//trace(color)

return color;
}



   - the matrix is scaling down _bmd  to a fraction
   - a 1x1 pixel BitmapData is created
   - the draw() method is drawing a scaled version of the bitmap, 1pixel by
   1 pixel
   - the pixel at 0,0 is selected

My question is how is that color determined? Basically the whole image gets
simplified down to one color by flash, how is that determined?

Ultimately I'm curious as I'd like to be able to get the dominant color and
the average color of an image separately.

Thanks!

Jared
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to