How do I expand the hexadecimal number 0x1234 to 0x11223344 in a high-performance way?
unsigned int c = 0x1234, b;
b = (c & 0xff) << 4 | c & 0xf |
If you are going to do this for OpenGL, I suggest you to use a glTexImageXD
function with type
parameter set to GL_UNSIGNED_SHORT_4_4_4_4
. Your OpenGL driver should do the rest. And about the transparency inversion you can always manipulate blending via the glBlendFunc
and glBlendEquation
functions.