Why return an unsigned char instead of just "int"? Also, bitmap data can probably also be declared "int", since any math performed would usually be done on the extracted bytes. I use these macros instead of functions (for when the pixel format is fixed, and won't change):
Code:
#define makecol(b, g, r) (b | (g << 8) | (r << 16))
#define makecola(b, g, r, a) (b | (g << 8) | (r << 16) | (a << 24))
#define getr(c) ((c & 0x000000FF))
#define getg(c) ((c & 0x0000FF00) >> 8)
#define getb(c) ((c & 0x00FF0000) >> 16)
#define geta(c) ((c & 0xFF000000) >> 24)