Function

vImageConvert_RGB565toRGBA8888(_:_:_:_:)

Converts an RGB565 image into an RGBA8888 image, using the provided 8-bit alpha value.

Declaration

func vImageConvert_RGB565toRGBA8888(_ alpha: Pixel_8, _ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ flags: vImage_Flags) -> vImage_Error

Parameters

alpha

A value of type Pixel_8 to be used as the alpha value for all pixels in the destination image.

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 RGB565 format has 16-bit pixels with 5 bits for red, 6 for green, and 5 for blue. The function calculates the pixels in the destination image as follows:

    Pixel8 alpha = alpha
    Pixel8 red   = (5bitRedChannel   * 255 + 15) / 31
    Pixel8 green = (6bitGreenChannel * 255 + 31) / 63
    Pixel8 blue  = (5bitBlueChannel  * 255 + 15) / 31

See Also

Converting from RGB Formats

func vImageConvert_RGB565toRGBA5551(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, Int32, vImage_Flags) -> vImage_Error

Converts an RGB565 image to an RGBA5551 image with dithering, setting destination alpha to one.

func vImageConvert_RGB565toARGB1555(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, Int32, vImage_Flags) -> vImage_Error

Converts an RGB565 image to an ARGB1555 image with dithering, setting destination alpha to one.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software