Texture Memory paranoia

I have a png that is 512*512 and 311kb. (grab it here… http://www.code-and-web.de/public/images/Competitor.png )

When creating a simple scene with this png as a display.newImage, a
print(" Texture Memory = "…system.getInfo(“textureMemoryUsed”))

…gives me an allocation of 1048576 (over a megabyte!).
The same happens with every image I load… it is accounted for 3-4X its real filesize…

Why?
What should I believe?
Any explanations?
[import]uid: 7356 topic_id: 2727 reply_id: 302727[/import]

Hi Magenda,

No matter the compressed size of a file, it resides uncompressed in memory. So, 512x512x4 = 1048576 (width * height * depth, where depth is 4 bytes/32 bits).

Ken [import]uid: 5742 topic_id: 2727 reply_id: 8116[/import]

Oh, I see…

Many thanks! [import]uid: 7356 topic_id: 2727 reply_id: 8133[/import]

Yip, that is what a lot of people forget. Inside the device, everything expands to its actual size. [import]uid: 5712 topic_id: 2727 reply_id: 8152[/import]

So if an image is 1024 x 32 will it still get a 1024 x 1024 memory slot? or a 1024 x 32 slot? [import]uid: 8192 topic_id: 2727 reply_id: 8166[/import]

@amigoni

Your example has an easy answer: 1024*32

But lets take an other example: an image of 180*300
It should be rounded to the closer “power of two” dimensions: 256*512
So it should have an uncompressed file size of 256*512*4 = 524.288 kb

However, a print(system.getInfo(“textureMemoryUsed”)) calculates it to 216.000 kb
( 180*300*4=216.000 )

I have submitted an issue for this bug. [import]uid: 7356 topic_id: 2727 reply_id: 8168[/import]

@Magenda. I see. So that’s why it would be now beneficial to add our graphics all into a spriteSheet now that we have a better sprite feature.

Would the maximum site of the spriteSheet still be 1024 x 1024? Or can it be anything? [import]uid: 8192 topic_id: 2727 reply_id: 8173[/import]

Yes, I am also going to host my graphics in spritesheets.
Max supported dimension is 1024*1024 for now. [import]uid: 7356 topic_id: 2727 reply_id: 8174[/import]

@DVD Guy

Why does Corona assume a depth of 4 bytes for images files that are rgb 8 bits?

[import]uid: 31039 topic_id: 2727 reply_id: 26474[/import]

the 4 bytes (32 bit) is RGBA (24-bit RGB + 8 bit alpha). This isn’t a Corona limitation - ios handles all uncompressed images this way. Hopefully, we’ll have the option of the much more efficient (albeit lossy) PVRTC texture support in a future release. [import]uid: 5742 topic_id: 2727 reply_id: 26516[/import]

@DVD Guy

Is that true for the android os? [import]uid: 31039 topic_id: 2727 reply_id: 26519[/import]

Sorry, I’m Android illiterate. [import]uid: 5742 topic_id: 2727 reply_id: 26534[/import]