Urgent Really Emergency Question: Can I Load Non-32 Bit Images?

I REALLY, REALLY, REALLY need to load some big textures with few colors and no transparency on my games.

Can it be done? Because currently the game refuses to launch on the test device (it runs out of memory), and this is very problematic.

Maurício

Kidoteca

Hi Maurício,

Corona supports lower-bit images, so this is likely an issue that you’re exceeding the device’s texture atlas size. What are the sizes of these big textures you’re trying to load, and which are the target device(s)?

Brent

Hello Brent!

First, where I find documentation about lower-bit images? I read the manual several times over and over and I am not finding it, except some old information claiming that it DOES NOT support palleted and grayscale images. (it does not say anything about non-palleted images that are not 32 bits, and seemly the framebuffer always is 32 bit).

Now regarding the memory problem itself, I am trying to load a 2048x2048 texture, the function system.getInfo( “maxTextureSize” ) reports it supports 4096, but I can try to load only a single 2048x2048 image and it already crash out of memory… But if I load several 1024x1024 images I can load about 128mb of images before the thing crash… :confused:

In fact, one of my old games use 83mb of memory and works fine, but I don’t try to load 2048 textures on it.

Maurício Gomes

Kidoteca

Hi Maurício,

Corona doesn’t support grayscale (sorry if I implied that; I basically meant that you can load 8-bit images, not just 24-bit or 32-bit).

Is the image you’re trying to load embedded with an ICC profile? Is it saved at a high DPI like 300? Is it an “indexed” PNG? Is it a “progressive” JPEG? I’m wondering if there’s something internally different about the image itself, since you’re able to load several small images and not crash the app…

Brent

It has no ICC profile, no crazy DPI settings.

I tried to load the image as a normal 32-bit image (failed, tried to use 16mb of memory), tried as 24-bit image (tried to use 16mb of memory too, and failed) and as a indexed 8-bit image (also failed… and also tried to use 16mb of memory).

Extra info: The device with issue is a Xperia Play running Android 2.3

Another Extra info:

I remembered that the prototype that was made with Marmalade SDK loaded the same image files fine. Thus it is not Android’s fault, it is a issue with my code, or Corona.

Hi Maurício,

Did you try to load only this image and nothing else? Simply a new test project that loads this image first for testing purposes?

The issue might also be a “lazy” Java garbage collector issue on the device. Even though Corona has a lot of fallback mechanisms to attempt to force garbage collection and automatically down-sample/scale images, if there isn’t enough memory, some devices still refuse to allocate memory if the garbage collector isn’t granted enough time. If that’s indeed the issue, the only workaround is to load images based on a timer or effectively “on demand”.

Brent

Hello! I made this program, and it crashes on second line.

[lua]print(“image load attempt”);

local imgtest = display.newImageRect(“data/monkey.png”, 1920, 2016);

print(“image load success”);[/lua]

Also tried this:

[lua]print(“start”);

local imgjnk1 = display.newImageRect(“data/10240.png”, 1024, 1024);

local imgjnk2 = display.newImageRect(“data/10241.png”, 1024, 1024);

local imgjnk3 = display.newImageRect(“data/10242.png”, 1024, 1024);

local imgjnk4 = display.newImageRect(“data/10243.png”, 1024, 1024);

imgjnk1:removeSelf();

imgjnk2:removeSelf();

imgjnk3:removeSelf();

imgjnk4:removeSelf();

collectgarbage();

print(“image load attempt”);

local imgtest = display.newImageRect(“data/monkey.png”, 1920, 2016);

print(“image load success”);[/lua]

It crashes as soon as it reaches the imgtest line.

It is interesting to say that in this case it generates lots of messages of growing heap.

Among other tests: Tried to load much more images in the memory (like 100mb) before trying to loading this image. Tried to swamp the memory with doubles (creating a arrays of NUMBERs) of about 256mb before loading the image.

Tried to load the image later, earlier, in other ways…

None of that worked, the thing just crash with out of memory error, always, no matter where or when I try to load it, or what image as long it is bigger than 1024x1024

And like I said, it worked fine with the Marmalade version of the app (in fact to make the Corona version I copied and pasted most of Marmalade code and edited to make the syntax fit Lua instead of C)

Hi Maurício,

Can you e-mail me this image to test with? brent (at) coronalabs (dot) com. Obviously, I won’t use it for anything other than testing, if this is some artwork you’ve created or licensed from an artist.

Thanks,

Brent

Sure sure! But how I find your e-mail?

brent (at) coronalabs (dot) com is the email address

What device are you running it on? Different iPhones and different Android phones have a max texture size.

See here for the sizes http://www.uchidacoonga.com/2012/04/quick-tip-max-texture-size/

Matthew

I mentioned earlier that the device is a Xperia Play running Android 2.3 and that it reports maximum texture size of 4096

But thanks for the e-mail :slight_smile:

Doh! Totally missed that.

Hi Maurício,

Corona supports lower-bit images, so this is likely an issue that you’re exceeding the device’s texture atlas size. What are the sizes of these big textures you’re trying to load, and which are the target device(s)?

Brent

Hello Brent!

First, where I find documentation about lower-bit images? I read the manual several times over and over and I am not finding it, except some old information claiming that it DOES NOT support palleted and grayscale images. (it does not say anything about non-palleted images that are not 32 bits, and seemly the framebuffer always is 32 bit).

Now regarding the memory problem itself, I am trying to load a 2048x2048 texture, the function system.getInfo( “maxTextureSize” ) reports it supports 4096, but I can try to load only a single 2048x2048 image and it already crash out of memory… But if I load several 1024x1024 images I can load about 128mb of images before the thing crash… :confused:

In fact, one of my old games use 83mb of memory and works fine, but I don’t try to load 2048 textures on it.

Maurício Gomes

Kidoteca

Hi Maurício,

Corona doesn’t support grayscale (sorry if I implied that; I basically meant that you can load 8-bit images, not just 24-bit or 32-bit).

Is the image you’re trying to load embedded with an ICC profile? Is it saved at a high DPI like 300? Is it an “indexed” PNG? Is it a “progressive” JPEG? I’m wondering if there’s something internally different about the image itself, since you’re able to load several small images and not crash the app…

Brent

It has no ICC profile, no crazy DPI settings.

I tried to load the image as a normal 32-bit image (failed, tried to use 16mb of memory), tried as 24-bit image (tried to use 16mb of memory too, and failed) and as a indexed 8-bit image (also failed… and also tried to use 16mb of memory).

Extra info: The device with issue is a Xperia Play running Android 2.3

Another Extra info:

I remembered that the prototype that was made with Marmalade SDK loaded the same image files fine. Thus it is not Android’s fault, it is a issue with my code, or Corona.