I am trying to loop through a bitmap and determine if each pixel is lighter or darker than gray using getPixel(). Problem is, I am not sure how to tell whether the value returned by getPixel() is darker or lighter than gray.
Neutral gray is about 0x808080 or R:127, G:127, B:127. How would I need to modify the code below to accurately determine this?
for (var dx:int=0; dx < objectWidth; dx++)
{
for (var dy:int=0; dy < objectHeight; dy++)
{
if (testBmd.getPixel(dx, dy) > GRAY)
{
trace("Lighter than gray!");
} else {
trace("Darker than gray!");
}
}
}