Function

vImageConvert_RGBA8888toRGBA5551_dithered(_:_:_:_:_:)

Converts an RGBA8888 image to an RGBA5551 image with dithering.

Declaration

func vImageConvert_RGBA8888toRGBA5551_dithered(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ tempBuffer: UnsafeMutableRawPointer!, _ dither: Int32, _ flags: vImage_Flags) -> vImage_Error

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.

tempBuffer

A pointer to a region of memory that vImage can use as a scratch space for storing temporary data.

dither
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

This function is similar to vImageConvert_RGBA8888toRGBA5551(_:_:_:), except the result is dithered instead of rounded to the nearest RGBA5551 value. It should provide more accurate overall color reproduction and less banding in low-frequency regions of the image.

This function supports the following dithering options:

kvImageConvert_DitherOrdered

Precomputed blue noise is added to the image before the values are rounded to the destination format. The offset into the blue noise is randomized per call to avoid visible artifacts if you do your own tiling or call the function on sequential frames of video.

kvImageConvert_DitherOrderedReproducible

Precomputed blue noise is added to the image before the values are rounded to the destination format. The offset into the blue noise is the same for every call to allow users to get reproducible results.

This function can work in place provided the following are true:

  • For each buffer, buf, that overlaps with dest, buf->data is equal to dest->data and buf->rowBytes >= dest->rowBytes.

  • If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile is also passed in the flags.

See Also

Converting from RGBA Formats

func vImageConvert_RGBAFFFFtoRGBFFF(UnsafePointer<vImage_Buffer>!, UnsafePointer<vImage_Buffer>!, vImage_Flags) -> vImage_Error

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

func vImageConvert_RGBA8888toRGB888(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, vImage_Flags) -> vImage_Error

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