Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malloc calls in ICTexture2D.m are not needed... #11

Open
jsfunfun opened this issue Jul 2, 2013 · 1 comment
Open

malloc calls in ICTexture2D.m are not needed... #11

jsfunfun opened this issue Jul 2, 2013 · 1 comment

Comments

@jsfunfun
Copy link

jsfunfun commented Jul 2, 2013

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

@starbugs
Copy link
Owner

starbugs commented Jul 8, 2013

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.

Thanks,
Tobias

@github-staff github-staff deleted a comment from mehdi-dev97 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants