Description
heh - just leaving a tip.. the malloc calls to create buffers for the 32 bit to 16 bit color conversion are entirely unnecessary. think about it.. you are 'compacting' data.. you can do an in-place 32 to 16 bit, adjust anything your code 'thinks' is 4 bytes wide on that 'inPixel32' mem block... code should be:
// no... tempData = malloc(POTHigh * POTWide * 2);
inPixel32 = (unsigned int_)data;
outPixel16 = (unsigned short_)data; // no... cast data to ushort* ... tempData;
for(unsigned int i = 0; i < POTWide * POTHigh; ++i, ++inPixel32)
_outPixel16++ =
((((_inPixel32 >> 0) & 0xFF) >> 3) << 11) | // R
((((_inPixel32 >> 8) & 0xFF) >> 3) << 6) | // G
((((_inPixel32 >> 16) & 0xFF) >> 3) << 1) | // B
((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A
// no... free(data);
// no... data = tempData;
Cheers - JS