img_expand_getfunc()

Get a function to convert a palette format to a direct format

Synopsis:

#include <img.h>

img_expand_f *img_expand_getfunc( img_format_t src,
                                  img_format_t lut )

Arguments:

src
The palette-based img_format_t image format to convert from
lut
The img_format_t direct image format to convert to

Library:

img

Description:

This function returns a pointer to a data conversion function (or NULL if the requested conversion is not supported) which you can call to “expand” (that is, convert) a run of pixels from a palette-based format src to a “direct” format in a lookup table lut. A conversion function takes the form:

void img_expand_f( const uint8 *src,
                   uint8 *dst,
                   unsigned n,
                   const uint8 *lut);

Here is a sample procedure for converting from PAL8 to ARGB1555:

  1. Convert your lookup table to the destination format (ARGB1555). For example:
    img_convert_data(IMG_FMT_PKHE_ARGB8888, palette, IMG_FMT_PKLE_ARGB1555, palette, npalette);
  2. Get the handle to the expand function that will expand the data. For example:
    img_expand_getfunc(IMG_FMT_PAL8, IMG_FMT_PKLE_ARGB1555);
  3. Call the expand function for each run of indexed data you want to expand. For example:
    expand_f(sptr, dptr, npixels, palette);

Note: You can use img_dtransform_create() instead to abstract the details of expansion and conversion.

Returns:

IMG_ERR_OK
Success.
IMG_ERR_NOSUPPORT
One of the formats specified is invalid.

Classification:

Image library

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

img_convert_data(), img_dtransform_create(), IMG_FMT_BPL(), img_lib_attach()