I want to selectively get the Red, Green, or Blue value for a pixel. Ideally, I would like 3 functions: GetPixelRed(), GetPixelGreen(), and GetPixelBlue(). Each function would return a value from 0..255. This would better complement the existing SetPixel() function which takes 3 integers as arguments.
The existing GetPixel() function just returns a 32-bit value that I assume/suspect consists of the following byte fields
Byte 3 = 0xFF
Byte 2 = Red Value (0..255)
Byte 1 = Green Value (0..255)
Byte 0 = Blue Value (0..255)
I could extract the particular R, G, or B value from this 32-bit value using some bitwise manipulation, but am concerned that the compiler wouldn't optimize it fast enough for my needs.
Any ideas of what the fastest way to get a Red, Green, or Blue colour value from a pixel would be?
Thanks,
The existing GetPixel() function just returns a 32-bit value that I assume/suspect consists of the following byte fields
Byte 3 = 0xFF
Byte 2 = Red Value (0..255)
Byte 1 = Green Value (0..255)
Byte 0 = Blue Value (0..255)
I could extract the particular R, G, or B value from this 32-bit value using some bitwise manipulation, but am concerned that the compiler wouldn't optimize it fast enough for my needs.
Any ideas of what the fastest way to get a Red, Green, or Blue colour value from a pixel would be?
Thanks,