Working with Images

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

The Neutrino image library is a static library that provides a common interface for image codecs. The BlackBerry Tablet OS includes:

  • the configuration file at /etc/system/config/img.conf (see its description in the documentation for img_lib_attach() )
  • the image codecs (img_codec_*.so)

The codecs used by the Neutrino image library are:

img_codec_bmp.so
Windows Bitmap format codec. Provides full Microsoft BMP support for all known variants as well as the older OS/2 variant. Does not support v1.x DDB format.
img_codec_gif.so
Graphics Interchange Format codec. Supports GIF 87a and GIF 89a variants. This codec supports 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.
The img_codec_gif.so supports decoding, but not encoding due to patent restrictions.
img_codec_jpg.so
Joint Photographic Experts Group file format codec. Supports 24-bit RGB, YUV and grayscale.
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
img_codec_sgi.so
SGI format codec. It supports black-and-white, grayscale, and color images (*sgi, *.rgb, *.rgba, *.bw).
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.

To to display an image, your application needs to:

  • attach to the image library
  • load the image file
  • clean up allocated resources and detach from the image library

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