Images

The BlackBerry 10 OS provides an image library, libimg, that you can use to work with images in your apps. This static library provides a common interface for image codecs, and you can use the library to encode and decode images in various formats, such as JPG, PNG, and so on.

If you want to get started right away and see the steps involved in working with images using the image library, see Working with images.

The BlackBerry 10 OS includes:

  • A configuration file, which is at /etc/system/config/img.conf. This file specifies the codecs that the image library should load. For more information about this file, see The configuration file.
  • A set of image codecs (img_codec_*.so). These codecs allow the image library to encode and decode images of various types. For more information about the codecs that are supported, see Supported codecs.

You can read about the various data types and functions in the image library by looking at the Image Library section of the API reference.

The configuration file

The image library uses a configuration file to determine which codecs to load. When you want to use the image library in your app, you need to call the img_lib_attach() function. This function initalizes the image library, searches for the configuration file, and loads the codecs that are listed in that file. In the BlackBerry 10 OS, this file is located in /etc/system/config/img.conf.

Codecs in the configuration file are specified as sections. Each section begins with the codec name, in square brackets, followed by an unordered list of properties that specify additional information about the codec. You must provide at least a MIME type and list of extensions to associate with the codec.

Here's an example of an entry in the configuration file for images in JPG format:

[img_codec_jpg.so]
mime=image/jpeg:image/jpg
ext=jpg:jpeg

Supported codecs

The following table lists the codecs that the image library uses. Each codec includes a description and any potential limitations.

Codec Description

img_codec_bmp.so

This codec represents the Windows Bitmap format. It provides full Microsoft BMP support for most known variants, including the older OS/2 variant.

Limitations

This codec does not support Header Version 5.x or the v1.x DDB format.

img_codec_jpg.so

This codec represents the Joint Photographic Experts Group (JPEG) file format. It supports 24-bit RGB, YUV, and grayscale.

img_codec_png.so

This codec represents the Portable Networks Graphics (PNG) format. It provides full PNG support with alpha, transparency, and interlacing support.

Limitations

This codec ignores the following chunks:

  • Background color
  • Chromaticity
  • Gamma
  • Histogram
  • Physical pixel dimension
  • Significant bits
  • Text data
  • Image last-modified time

img_codec_scaladogif.so

This codec represents the Graphics Interchange Format (GIF). It 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, and so on).

Limitations

This codec ignores other extensions that allow embedded text, comments, application data, and so on.

It also currently supports encoding only a single frame (for example, you cannot create an animated GIF using the encoder).

img_codec_sgi.so

This codec represents the Silicon Graphics Image (SGI) format. It supports black-and-white, grayscale, and color images (.sgi, .rgb, .rgba, and .bw file formats).

Limitations

This codec supports decoding only.

img_codec_tga.so

This codec represents the Truevision Graphics Adapter (TGA) format. 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_tiff.so

This codec represents the Tagged Image File Format (TIFF). It 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 (which enables fax image decoding), LZW compression, and associated alpha.

Limitations

This codec encodes only grayscale and RGB buffers.

Also, because 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 best results, you should decode a TIFF image from a file or full memory buffer.

img_codec_wbmp.so

This codec represents the Wireless Application Protocol Bitmap file format. It supports decoding and encoding of monochrome images.

Last modified: 2014-05-14



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus