How to store bitmaps in memory?

Posted by Geotarget on Game Development See other posts from Game Development or by Geotarget
Published on 2012-11-21T15:28:57Z Indexed on 2012/11/21 17:16 UTC
Read the original article Hit count: 260

I'm working with general purpose image rendering, and high-performance image processing, and so I need to know how to store bitmaps in-memory. (24bpp/32bpp, compressed/raw, etc)

I'm not working with 3D graphics or DirectX / OpenGL rendering and so I don't need to use graphics card compatible bitmap formats.

My questions:

  1. What is the "usual" or "normal" way to store bitmaps in memory? (in C++ engines/projects?)

  2. How to store bitmaps for high-performance algorithms, such that read/write times are the fastest? (fixed array? with/without padding? 24-bpp or 32-bpp?)

  3. How to store bitmaps for applications handling a lot of bitmap data, to minimize memory usage? (JPEG? or a faster [de]compression algorithm?)

Some possible methods:

  • Use a fixed packed 24-bpp or 32-bpp int[] array and simply access pixels using pointer access, all pixels are allocated in one continuous memory chunk (could be 1-10 MB)

  • Use a form of "sparse" data storage so each line of the bitmap is allocated separately, reusing more memory and requiring smaller contiguous memory segments

  • Store bitmaps in its compressed form (PNG, JPG, GIF, etc) and unpack only when its needed, reducing the amount of memory used. Delete the unpacked data if its not used for 10 secs.

© Game Development or respective owner

Related posts about c++

Related posts about graphics