Function

vImageConvert_RGBA8888toRGBA5551

Converts an RGBA8888 image into an RGBA5551 image.

Declaration

vImage_Error vImageConvert_RGBA8888toRGBA5551(const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags);

Parameters

src

A pointer to a vImage buffer structure that contains the source image whose data you want to convert.

dest

A pointer to a vImage buffer data structure. You're responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, you must deallocate the memory.

flags

The options to use when performing the operation. If you plan to perform your own tiling or use multithreading, pass kvImageDoNotTile.

Return Value

kvImageNoError; otherwise, one of the error codes described in Data Types and Constants.

Discussion

The RGBA5551 format has 16-bit pixels with 1 bit for alpha and 5 bits each for red, green, and blue. The function calculates the 16-bit pixels in the destination image as follows:

    uint32_t alpha = (8bitAlphaChannel      + 127) / 255
    uint32_t red   = (8bitRedChannel   * 31 + 127) / 255
    uint32_t green = (8bitGreenChannel * 31 + 127) / 255
    uint32_t blue  = (8bitBlueChannel  * 31 + 127) / 255
    uint16_t ARGB1555pixel = (alpha << 15) | (red <<  10) | (green << 5) | blue

See Also

Converting from RGBA Formats

vImageConvert_BGRA8888toBGR888

Converts a four-channel BGRA8888 image to a three-channel BGR888 image by removing the alpha channel.

vImageConvert_RGBA8888toBGR888

Converts a four-channel RGBA8888 image to a three-channel BGR888 image by removing the alpha channel.

vImageConvert_RGBAFFFFtoRGBFFF

Converts a four-channel RGBAFFFF image to a three-channel RGBFFF image by removing the alpha channel.

vImageConvert_RGBA1010102ToARGB16Q12

Converts an RGBA1010102 format image to an ARGB16Q12 format image.

vImageConvert_RGBA1010102ToARGB16U

Converts an RGBA1010102 format image to an ARGB16U format image.

vImageConvert_RGBA1010102ToARGB8888

Converts an RGBA1010102 format image to an ARGB8888 format image.

vImageConvert_RGBA16UtoRGB16U

Converts an RGBA16U image to an RGB16U image.

vImageConvert_RGBA5551toRGB565

Converts an RGBA5551 image to an RGB565 image, with loss of alpha.

vImageConvert_RGBA5551toRGBA8888

Converts an RGBA5551 image to an RGBA8888 image.

vImageConvert_RGBA8888toRGB888

Converts a four-channel RGBA8888 image to a three-channel RGB888 image by removing the alpha channel.

vImageConvert_RGBA8888toRGBA5551_dithered

Converts an RGBA8888 image to an RGBA5551 image with dithering.

vImageConvert_RGBA8888toRGB565_dithered

Converts an RGBA8888 image to an RGB565 image with dithering.

vImageConvert_RGBA8888toRGB565

Converts an RGBA8888 image into an RGB565 image.