You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Hey, thanks for pointing this out. The code has been imported from cocos2d and I've never touched it or looked at it profoundly. I will merge your changes in one of the next versions of the framework.
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
The text was updated successfully, but these errors were encountered: