http://halicery.com/2Image Decoders/PNG/Decoder.html

PNG decoder in C

This decoder (png.c) is part of the image decompressor library RAINBOW, which can be found in a repository on BitBucket.

Thanks to Willem van Schaik's PngSuite (PngSuite-2017jul19.zip) I could test the decoder on a bunch of images. This is a snapshot of my folder with PNG and decoded-converted BMP equivalents of supported images by this decoder:

Supported PNG types:

Limitations:

The decoder converts a PNG file to scanlines of BM-pixels in-memory:

+---------------------------------+       Decoder           +-------------------+
|           PNG FILE              |    ---------------->    |                   |
+---------------------------------+                         |     BM-pixels     |
                                                            |                   |
                                                            |                   |
                                                            |                   |
                                                            |                   |
                                                            +-------------------+

This is a per-image-line decoder

But fully inflates PNG image data before conversion. (For large PNG-s, I also experimented with a byte-by-byte inflate using call-backs, the zlib-window. It reduced memory allocations, but simply made inflate.c so ugly.)

                                                                                  +-------------------+
                                                                                  |                   |
----------------+         filter              decoded pixel data       convert    |                   |
  inflated data |    ---------------->      +--------------------+    -------->   |xxxxxxxxxxxxxxxxxxx|
----------------+                           +--------------------+                |                   |
                                                   ||                             |                   |
                                                   ||                             |                   |
                                            +--------------------+                +-------------------+
                                            +--------------------+                        BITMAP
                                                 image line 
                                                filter buffer


Sun Jun 17 19:00:26 UTC+0200 2018 © A. Tarpai