1

plateform -> cocos2D, iOS

Step1: Loading animations from FileName.pvr.ccz(TexturePacker) with ImageFormat="RGBA8888" Shows memory usage in x-code Instruments 10.0 MB.

Step1: Loading animations from FileName.pvr.ccz(TexturePacker) with ImageFormat="RGBA4444" Shows memory usage in x-code Instruments 10.0 MB.

Question -> why its not showing any difference in Memory Usage while using lower ImageFormat = "RGBA4444" instead of higher ImageFormat = "RGBA8888"?

TexturePacker file size = 2047 * 1348

Bhanu
  • 1,249
  • 10
  • 17
UA_PPS
  • 29
  • 9

2 Answers2

0

The default texture format is RGBA8888 so if you have a RGBA4444 texture you need to change the format before loading the texture (and perhaps change it back afterwards).

The method to change texture format for newly created textures is a class method of CCTexture2D:

 + (void) setDefaultAlphaPixelFormat:(CCTexture2DPixelFormat)format;
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • I changed the defaultFormat as RGBA4444 but when I used it for simple PNG its reduces its to half Memory Usage but for TexturePacker its Memory usage is same or there is no effect. I’m loading Animations with plist files using [CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile: …]. – UA_PPS Apr 01 '14 at 12:53
  • It should work the same, make sure to change the alpha pixel format before loading the sprite frames. If that doesn't help try searching for uses of the setDefaultAlphaPixelFormat method - perhaps sprite frame cache or some other code triggered from loading texture atlas changes the format. – CodeSmile Apr 01 '14 at 15:46
0

I found this error cause my memory size same in both format:-http://www.cocos2d-iphone.org/forum/topic/31092.

In CCTexturePVR.m ->

            // Not word aligned ?
            if( mod != 0 ) {

                NSUInteger neededBytes = (4 - mod ) / (bpp/8);
                printf("\n");
                NSLog(@"cocos2d: WARNING. Current texture size=(%tu,%tu). Convert it to size=(%tu,%tu) in order to save memory", _width, _height, _width + neededBytes, _height );
                NSLog(@"cocos2d: WARNING: File: %@", [path lastPathComponent] );
                NSLog(@"cocos2d: WARNING: For further info visit: http://www.cocos2d-iphone.org/forum/topic/31092");
                printf("\n");
            }

its cocos2d or iOS bug which can be handle by adjusting pvr.ccz size Size dimension should be divisible by 4 but not the Power Of two. it will resolve bug and get expected memory difference for Both Format

UA_PPS
  • 29
  • 9