Code: Select all
typedef struct
{
unsigned short red:5;
unsigned short green:6;
unsigned short blue:5;
} RGB16, *pRGB16;
Code: Select all
typedef struct
{
unsigned short red:5;
unsigned short green:6;
unsigned short blue:5;
} RGB16, *pRGB16;
To be completely correct, when storing it and viewing in a hex editor you would get:Nychold wrote: Would this produce a color in the form of rrrrr gggggg bbbbb or bbbbb gggggg rrrrr? I would check this myself, but I'm not anywhere near a C/C++ compiler at the moment. Thanks, and pardon the dumb question. ^_^
Code: Select all
gggbbbbb rrrrrggg
Code: Select all
rrrrrggg gggbbbbb
Note though that GCC doesn't really make clean code from that stuff using bitfields, at least not on -O2. Also, using MMX is not possible here since MMX only supports 2^n-sized amounts, not something like 5/6/5. MMX would extract just the same. Although, there is one method I can think of to speed up the process:Pype.Clicker wrote: note that the MMX certainly has faster ways to do this. Geting x=color.red will be much like doing x=(color&RED_MASK)>>RED_SHIFT except the compiler picks up the mask and shift automagically and hides the details. So yes, it is easier to write, but not faster to execute than a pmunpack() stuff ...