Author Topic: How to decrease the usage of memory when converting some pictures to 2^n  (Read 1056 times)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
1, I have a 2D icon with an .png file of 512 * 128

2, I use framebuffer.blit() to show the icon, so i need convert the .png to 512*512, and the usage of memory will increase 3 times(from 512*128 to 512*512). And 3/4 of the file is filled with total-transparent pixels. That's waste.

3, Any suggestion to resolve this with little memory increasing? And I don't want to split the file of 512*128 to many small files(For examble: 4 files of 128*128).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How to decrease the usage of memory when converting some pictures to 2^n
« Reply #1 on: October 11, 2012, 07:35:04 am »
And you have to scale it up to 512*512...because? Why can't it stay at 512*128? Are you using GL ES 1.x or 2.0?

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: How to decrease the usage of memory when converting some pictures to 2^n
« Reply #2 on: October 12, 2012, 09:43:31 am »
2.0

Because jPCT-AE log say:

WARNING: Texture's size is 256/128, but textures should be square for OpenGL ES2.0! This may result in a black texture!


When i use 256*128(or other texture which isn't square),  all are fine, but because of the warning above, i prefer to make all textures to be square to avoid potential error.

Should I use (2^n * 2^m) or (2^n * 2^n)?

And to convert 512*128 -> 512*512, i won't use Bitmap.scale()(or other similar methods), i just use a file of 512*512 instead.
« Last Edit: October 12, 2012, 09:48:29 am by kiffa »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: How to decrease the usage of memory when converting some pictures to 2^n
« Reply #3 on: October 12, 2012, 11:19:39 am »
I couldn't find a rule when textures that aren't 2^n * 2^n work and when not. This is why the warning will be logged in that case. My gut feeling is that 2^n * 2^m usually works if n>m and more likely fails if n<m. If you want to be sure, you have to use 512*512 instead.
If the texture are used for blitting, you can disable mipmapping for them, which will save some memory. And maybe convert them to 16bit or enable texture compression on them.