Working with Images

This chapter shows you how to load and render images using the image library, libimg.

The image library is a static library that provides a common interface for image codecs. This means that while the library is linked into your executable, you need to put any required image codecs (and their dependencies), plus the image configuration file, onto targets running your application. You'll need to include (at least):

The codecs used by the image library are:

img_codec_bmp.so
Windows Bitmap format codec. Provides full Microsoft BMP support for all known variants (except Header Version 5.x) as well as the older OS/2 variant. Does not support v1.x DDB format.
img_codec_gif.so
Graphics Interchange Format codec. This codec supports GIF 87a and GIF 89a variants and the graphics control extension which provides most of the significant features for this format (transparency, interlacing, multiframe etc). It ignores other extensions which allow embedded text, comments, application data etc.

This codec requires the libgif.so.5 library.

img_codec_jpg.so
Joint Photographic Experts Group file format codec. Supports 24-bit RGB, YUV, and grayscale.

This codec requires the libjpeg.so.4 library.

img_codec_pcx.so
Personal Computer Exchange Format decoder.
img_codec_png.so
Portable Networks Graphics codec. Provides full PNG support with alpha, transparency, and interlacing support. This codec ignores the following chunks:
  • background color
  • chromaticity
  • gamma
  • histogram
  • physical pixel dimension
  • significant bits
  • text data
  • image last-modified time
This codec requires the following libraries:
  • libpng16.so.0
  • libz.so.2
img_codec_sgi.so
SGI format codec. It supports black-and-white, grayscale, and color images (*sgi, *.rgb, *.rgba, *.bw).
Note: This codec supports only decoding.
img_codec_tga.so
Truevision Graphics Adapter format codec. For decoding, this codec handles run length encoding (RLE) compression and supports these formats:
  • true color 16-, 24-, and 32-bit
  • cmap 15-, 16-, 24-, and 32-bit
  • black and white 8-bit

For encoding, this codec supports true color (8888) 32-bit RLE.

img_codec_tif.so
Tagged Image File Format codec. Supports full Baseline TIFF decoding from the Adobe TIFF Revision 6.0 specification (for example, bilevel, grayscale, RGB, multiple subfiles, PackBits and Huffman compression). Some TIFF extensions are supported, such as CCITT bilevel encodings (enables fax image decoding), LZW compression, and associated alpha.

The TIFF encoder is limited to encoding grayscale and RGB images only.

This codec requires the following libraries:
  • libtiff.so.5
  • libz.so.2
  • liblzma.so.5
Note: As TIFF images are not sequential streams of data, the TIFF decoder must be able to seek in the image stream to find image data. As a result, it may not be compatible with certain unidirectional or unbuffered IO streams. For the best results, decode a TIFF image from a file or a full memory buffer.
img_codec_wbmp.so
Wireless Application Protocol Bitmap file format codec. Supports decoding and encoding of monochrome images.

To display an image, your application needs to:

Let's look at each of these steps in a little more detail.