View Full Version : Andorra 2D latest, Delphi7, resource (ail) file with 4x 2048x2048x16 PNG

01-08-2011, 07:47 AM
Hello Everyone,

I probably will not use this many animations for a long time but I was just testing , to see how much memory does it takes. And I'm a bit dissapointed , my program eats 50-60MB of memory if I use a resource file (ail) with 4x 2048x2048x16 PNG files ( the ail file itself is only 112K compressed with devilPNG, tried uncompressed as well no difference with memory usage... the file size changes to 16-20MB)

I load the ail file like this :


procedure TForm1.FormCreate(Sender: TObject);
AdPerCounter := TAdPerformanceCounter.Create;
AdDraw := TAdDraw.Create(self);
AdDraw.DllName := 'AndorraDX93D.dll';

if AdDraw.Initialize then
Application.OnIdle := Idle;
AdImageList := TAdImageList.Create(AdDraw);

//create the SpriteEngine
AdSpriteEngine := TSpriteEngine.Create(nil);
AdSpriteEngine.Surface := AdDraw;

procedure TForm1.FormDestroy(Sender: TObject);
Can someone explain to me how do you calculate how much memory does a PNG file takes up when you load it into memory? Is there a "magic" way to decrease my mem usage with so many PNG files or I'm forced to use a lot smaller images ... I've only used this large images because I created quiet a large animation... just got into pixelart and can't stop, wanted to create a menu that goes Bling... for fun...and learn in the process...

Thank you


01-08-2011, 09:57 AM
The fact that your are using png's is not relevant. All color information is decompressed when you load the file. So yes, each image of that size should calculate to 16mb

01-08-2011, 11:24 AM
Ok, so I'll arrange my images some other way... I guess I cannot simply escape this by using 8 1024x1024x16 images instead of 4 2048x2048x16 . In both cases I would end up with the same used memory ammount right?

01-08-2011, 12:29 PM
mh maybe i got something wrong but a 2048x2048x16 texture is four times 1024x1024x16, so it mean you can load 8 1024x1024x16 or 2 2048x2048x16 instead :>

thats why i wouldnt go over 1024x1024 unless i really need to

as traveler says the format doesnt matter for memory usage, its only for filesize

01-08-2011, 02:41 PM
Thank you, I just looked up a few older games Aladdin and Lion King for PC... and guess you are right I will probably never need to go over 1024x1024...

The only question i still have is : how do you calculate memory requirement for a 1024x1024 image for example ?


01-08-2011, 03:46 PM
i do some quick math and i think it should work
this is an example for a 1024x1024x16

1024 x 1024 = 1.048.576 total pixels
1.048.576 x 16 bits in each pixel = 16.777.216 total bits in the image
16.777.216 bits / 8 bits in every byte = 2.097.152 bytes

2.097.152 bytes x 1024 bytes = 2048 kilobytes
2048 kilobytes x 1024 bytes = excactly 2 megabyte

this example only work for uncompressed data ;)
but compressed data solutions like DXT are rarely used in non-comercial engines/frameworks

06-09-2011, 09:55 AM
Aladdin and Lion King for PC
This games uses 256color palette. This mean only 1 byte per color instead of 4.

06-09-2011, 10:16 AM
And their resolution was 320x240 i think.

Usually fullscreen media is built from numerous small images using scaling, rotating, multiplicating, tiling and all kinds of effects. Diablo 2 for example has a ton of very small tiles. One could from first glance think that a big house you see in game is an actual big image, but its not.

09-09-2011, 11:57 AM
The problem in old games was that they use DirectDraw. It not allows to use textures but Surfaces instead. And surface cannot exceed screen resolution. So even if image was big it slices when loading into smaller ones.