Extracting color from 32-bit pixel...
So... I started programming again. Been almost two years since I've
done anything. Went back to the project I was working on before I
quit and totally forgot where I was... so I started over.
Anywho, I came across some functions that extract the Red, Green,
and Blue bytes from a 32-bit pixel, but don't understand *why* I did
what I did. Here's the function.
Code:
unsigned char Pixel32_ExtractR(unsigned int pixel)
{
return ((pixel >> 16) & 0xFF);
}
Thing is,I don't know why the & 0xFF is necessary. I know what & does,
but why did I do it here? Do I even need it? Wouldn't shifting the bits
alone be enough? Please explain why not, detailed.
Damnit, starting over blows. I don't remember *anything*. Hehe.
Thank ya,
ethic