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, 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:
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.
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.
Joint Photographic Experts Group file format codec. Supports 24-bit RGB, YUV, and grayscale.
Personal Computer Exchange Format decoder.
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
SGI format codec. It supports black-and-white, grayscale, and color images (*sgi, *.rgb, *.rgba, *.bw).
Note: This codec supports only decoding.
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.
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.

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.
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.