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. The BlackBerry 10 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 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.
- Joint Photographic Experts Group file format codec. Supports 24-bit RGB, YUV, and grayscale.
- Portable Networks Graphics codec. Provides full PNG support with alpha, transparency, and interlacing support. This codec ignores the following chunks:
- background color
- physical pixel dimension
- significant bits
- text data
- image last-modified time
- Graphics Interchange Format codec. Supports GIF 87a and GIF 89a variants. This codec supports the graphics
control extension that provides most of the significant features for this format (transparency, interlacing,
multiframe, etc). It ignores other extensions that allow embedded text, comments, application data, etc., with
the exception of the "Netscape Application Block", which provides for the "loop count" for the animation (see
This codec supports encoding only a single frame at this time (for example, you cannot create an animated GIF using the encoder).
- SGI format codec. It supports black-and-white, grayscale, and color images (*sgi, *.rgb, *.rgba, *.bw).
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.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:
- 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.
Last modified: 2013-10-30