Alternatively you can avoid most of that bit-fiddling by using unions:
struct Color
{
union
{
struct
{
unsigned char b,g,r,a;
};
unsigned int argb;
};
Color()
{
}
Color(unsigned int col)
{
argb= col;
}
};
This way the for bytes r,g,b,a occupy the same space as the integer argb.
Color col;
col= 0xffeeddcc;
printf("Color: %d,%d,%d,%d \n", col.a, col.r, col.g, col.b);