Results 1 to 9 of 9

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

  1. #1

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

    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 :

    Code:
    OnCreate
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      AdPerCounter := TAdPerformanceCounter.Create;
      AdDraw := TAdDraw.Create(self);
      AdDraw.DllName := 'AndorraDX93D.dll';
    
    
    if AdDraw.Initialize then
      begin
        Application.OnIdle := Idle;
        AdImageList := TAdImageList.Create(AdDraw);
        AdImageList.LoadFromFile('BackGround.ail');
     
        //create the SpriteEngine
         AdSpriteEngine := TSpriteEngine.Create(nil);
         AdSpriteEngine.Surface := AdDraw;
     
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
       AdSpriteEngine.Free;
       AdImageList.Free;
       AdPerCounter.Free;
       AdDraw.Free;
    end;
    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

    Rob
    Last edited by WILL; 01-08-2011 at 06:36 PM. Reason: Put your code into a code block...

  2. #2
    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

  3. #3
    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?

  4. #4
    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

  5. #5
    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 ?

    Rob

  6. #6
    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
    Last edited by Daikrys; 01-08-2011 at 03:51 PM.

  7. #7
    Aladdin and Lion King for PC
    This games uses 256color palette. This mean only 1 byte per color instead of 4.
    Theory is - when you know everything but nothing works.
    Practice is - when all works, but you don't know why.
    We combine theory and practice - nothing works and nobody knows why

  8. #8
    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.

  9. #9
    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.
    Theory is - when you know everything but nothing works.
    Practice is - when all works, but you don't know why.
    We combine theory and practice - nothing works and nobody knows why

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •