Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Does a png use memory equal to its size?

  1. #1

    Does a png use memory equal to its size?

    I'm just wondering if a compressed file format such as png uses up memory equal to its size, or if it's "decompressed" before loaded into memory? I'm using OpenGL and SDL_image to open image files, by the way.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  2. #2

    Re: Does a png use memory equal to its size?

    At some point the png file has to be decompressed before being displayed. So yes, you'll usually only have the uncompressed data in memory.

    If you didn't have to decompress the data to display it, it wouldn't actually be compressed. Then you would have found a more effective way to represent the data.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  3. #3

    Re: Does a png use memory equal to its size?

    That makes sense.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  4. #4

    Re: Does a png use memory equal to its size?

    But there is also a way to use compressed textures with opengl without decompressing them. Do a search on GL_ARB_texture_compression and/or s3tc (http://www.gamedev.net/reference/pro...erpt/page2.asp)
    http://3das.noeska.com - create adventure games without programming

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: Does a png use memory equal to its size?

    PNG uses a form of LZH encoding. I've dabbled with libpng and even zlib to try and figure out how to make a simple screenshot function with it, but no luck so far.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6

    Re: Does a png use memory equal to its size?

    Quote Originally Posted by noeska
    But there is also a way to use compressed textures with opengl without decompressing them. Do a search on GL_ARB_texture_compression and/or s3tc (http://www.gamedev.net/reference/pro...erpt/page2.asp)
    That's very interesting. I'll play around with this and see how much memory I save. Thanks!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  7. #7

    Re: Does a png use memory equal to its size?

    GL_COMPRESSED_RGBA doesn't seem to be supported by the current gl.pas header file. Anybody know how to add this?

    EDIT: Never mind. I'm stupid.

    EDIT 2: The compression creates a lot of artifacts, so I can't use it for my player sprites, but I can use it for some big and blurry background sprites. Already saved me 15 MB by just compressing them. Nice!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  8. #8

    Re: Does a png use memory equal to its size?

    You don't have to keep all textures in memory same time. Especially if its about fullscreen sized images you should load them on demand if its like more than 4 of them.

  9. #9

    Re: Does a png use memory equal to its size?

    They're all used all the time, so loading them on demand is not an option, as that would cause a short lag while the program reads from disk.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  10. #10

    Re: Does a png use memory equal to its size?

    What kind of opengl unit are you using? Have a look at the delphigl site and at their dglopengl unit as that one is very complete.

    Oops forgot the url: http://www.delphigl.com/
    http://3das.noeska.com - create adventure games without programming

Page 1 of 2 12 LastLast

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
  •