i have some low level image/texture operations where 32-bit colors are stored as UInt32 or int and i need a really fast bitwise conversion between the two.
e.g.
int color = -2451337;
//exception
UInt32 cu = (UInt32)color;
any ideas?
thanks and regards
Those using a language like VB, which don't have a really convenient way of disabling overflow checks during the conversion, could use something like:
or
Versions for 32 bits would be very similar. I'm not sure which approach would be faster. The shifts are a little silly, but they avoid the need for 'if' tests.