Re: Memory issues to load a png image - any ideas?
Bob Friesenhahn <[email protected]> Wed, 3 Jul 2019 17:45:34 -0500 (CDT)
| Newsgroups | gmane.comp.graphics.png.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 3 Jul 2019, Ulisses wrote: > > Once it's the first time I'm working with compressed images, I'm a little > lost: > > - Is there a way to display this image, even if I have no enough memory to > allocate it "at once"? (I mean, any buffering tricks or something like that > to work around this?) I am by no means an expert with the libpng API but I think that you will want to use "progressive" APIs which provide decoded strips of pixels to your own code as soon as they are decoded. Avoid simplified APIs which provide a whole decoded image to you in a simplified representation such as a large buffer. If your display hardware has its own internal storage then you may be able to avoid double-buffering and deliver the (subset of) pixels directly to the display hardware. PNG images are provided as a sequence of "chunks". Even larger images are split into multiple chunks, which helps decrease memory requirements. Each chunk is decoded/decompressed as it appears and if your code can accept input of the "chunk" size, then you can save lots of memory. If you have control of the PNG images provided, then you can assure that they are optimized for your use. If the height of the input image always matches the height of your display hardware, then this should help simplify the implementation since you can sub-sample the original image pixels into the horizontal resolution of your display hardware. Bob -- Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt