Function

vImageConvert_ARGB16Q12ToRGBA1010102(_:_:_:_:_:_:_:_:)

Converts an ARGB16Q12 format image to an RGBA1010102 format image.

Declaration

func vImageConvert_ARGB16Q12ToRGBA1010102(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ RGB101010RangeMin: Int32, _ RGB101010RangeMax: Int32, _ RGB101010Min: Int32, _ RGB101010Max: Int32, _ permuteMap: UnsafePointer<UInt8>!, _ flags: vImage_Flags) -> vImage_Error

Parameters

src

A pointer to the vImage buffer that references 16Q12 ARGB interleaved source pixels. ARGB16Q12 pixels must be at least 2-byte aligned.

dest

A pointer to the vImage buffer that references 10-bit RGB interleaved destination pixels. RGBA1010102 pixels must be at least 4-byte aligned.

RGB101010RangeMin

The minimum value for the range of 10-bit RGB pixels.

RGB101010RangeMax

The maximum value for the range of 10-bit RGB pixels.

RGB101010Min

The minimum value for 10-bit RGB pixels.

RGB101010Max

The maximum value for 10-bit RGB pixels.

permuteMap

An array of four 8-bit integers with the values 0, 1, 2, and 3, in some order. Each value specifies a channel from the source image that should be copied to that channel in the destination image. 0 denotes the alpha channel, 1 the red channel, 2 the green channel, and 3 the blue channel. 

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

RGB101010RangeMin and RGB101010RangeMax are available for non-full-range pixel values. You can set full-range pixel values as:

 RGB101010RangeMin  = 0;
 RGB101010RangeMax  = 1023;

RGB101010Min and RGB101010Max are available to specify the minimum and maximum of the representation. These parameters are needed because 16Q12 values can be outside of [0.0, 1.0] range and vImage converts those values into video range. In that case, numbers outside of 10-bit video range are converted to be as representable as possible.

The per-pixel operation is:

int16_t *srcPixel = src.data;
A16 = srcPixel[permuteMap[0]];
R16 = srcPixel[permuteMap[1]];
G16 = srcPixel[permuteMap[2]];
B16 = srcPixel[permuteMap[3]];
srcPixel += 4;
 
int32_t R10, G10, B10;
int32_t range10 = RGB101010RangeMax - RGB101010RangeMin;
R10 = CLAMP(RGB101010Min, ((R16 * range10 + 2048) >> 12) + RGB101010RangeMin, RGB101010Max);
G10 = CLAMP(RGB101010Min, ((G16 * range10 + 2048) >> 12) + RGB101010RangeMin, RGB101010Max);
B10 = CLAMP(RGB101010Min, ((B16 * range10 + 2048) >> 12) + RGB101010RangeMin, RGB101010Max);
A2  = CLAMP( 0, (A16 * 3 + 2048) >> 12), 3);
 
uint32_t *destPixel = dest.data;
destPixel[0] = htonl((R10 << 22) | (G10 << 12) | (B10 << 2) | A2);
destPixel += 1;

See Also

Converting from ARGB Formats

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

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

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

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