Saving memory by omitting transparency?

I'm processing some pretty massive images, and I want be frugal with RAM usage... am I correct to assume that a PNG with no transparency will take up half the memory when loaded (in Lua)?

Or does every image object consume 2 bits per pixel, regardless of the source file?

And for a generated (not loaded from PNG) image, do I need to initialize an image object in a certain way (like setting bgcolor NOT clear?) to make it need only 1 bit per pixel?

TIA!

4 Likes

That's correct, on both counts. If an image doesn't have transparency it'll take up about half as much space, in memory and on disk, and similarly if you create in image with gfx.image.new(width,height,gfx.kColorWhite/Black) instead of using the default clear background.

4 Likes

Terrific, thanks for the info!

Any informed guess on cpu usage for drawing 1 bit vs 2 bit images? I imagine you could do a direct memory copy to the screen buffer for 1 bit, without needing to do any masking

1 Like