Friday, July 10, 2009

Small code for JPG and PNG decode

Part of the art of embedded systems is having small code to fit into flash and DRAM. For image decoding, most devices, including set top boxes, must support JPEG and PNG images.

Libjpg and libpng seem obvious choices. They are tried and tested, in some sense, official libraries for jpg and png. Yet they have flaws. Firstly they are not easy to use. Even experienced programmers think twice when they first encounter the API. Secondly, they are simply heavyweight. Both include every possible variation of the image format, some of which are very rare in practice and secondly they also include encoding routines.

Of course it would be possible to delve into the code and begin removing unwanted sections. However this would result in losing the tried and tested added advantage.

Instead why not consider this using the code from this website. stb_image.c, (stb, suprisingly nothing to do with set top box but instead the name of the author) can be found on this website. Its light, solid, does what is needed and is about 1/20th of the size of the other libraries.

No comments:

Post a Comment