Thanks very much for your response Martin but I don't understand it. I don't
have three vars called R G and B. I just have a number which was retuned
from getPixel. Am I being stupid? I can't see how I should  do what you
sugest. Pease explain a little further.

That number you're getting is a color. You're just seeing it in decimal form, rather than hexadecimal form. It's the same thing. For example, the value for white is either 16777215 or 0xffffff (the two are the SAME number, just represented in two different ways).

On 0xffffff, the first "ff" pair is R, then G, then B. Like when you have html color, "#ffffff".

To extract the single R G and B values from a color, simply apply Martin's code to the color.

var color = 0xffc1e2; // or the one returned by getPixel, same thing
var r = color >> 16 & 0xFF
var g = color >> 8 & 0xFF
var b = color & 0xFF

Then R, G, and B will contain the values for each channel, going from 0 to 255.

Calculating brightness from that is one whole different matter, though.



- Zeh
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to