Function

vImageConvert_RGBA1010102ToARGB16U

Converts an RGBA1010102 format image to an ARGB16U format image.

Declaration

vImage_Error vImageConvert_RGBA1010102ToARGB16U(const vImage_Buffer *src, const vImage_Buffer *dest, int32_t RGB101010RangeMin, int32_t RGB101010RangeMax, const uint8_t permuteMap[4], vImage_Flags flags);

Parameters

src

A pointer to the vImage buffer that references 10-bit RGB interleaved source pixels.

dest

A pointer to the vImage buffer that references 16-bit ARGB interleaved destination pixels.

RGB101010RangeMin

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

RGB101010RangeMax

The maximum value for the range of 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;

The per-pixel operation is:

     uint32_t *srcPixel = src.data;
     uint32_t pixel = ntohl(srcPixel[0]);
     srcPixel += 1;
      
     int32_t A2  = pixel & 0x3;
     int32_t R10 = (pixel >> 22) & 0x3ff;
     int32_t G10 = (pixel >> 12) & 0x3ff;
     int32_t B10 = (pixel >>  2) & 0x3ff;
     int32_t range10 = RGB101010RangeMax - RGB101010RangeMin;
      
     A2  = (A2 * USHRT_MAX + 1) / 3;
     R10 = ((R10 - RGB101010RangeMin) * USHRT_MAX + (range10 >> 1)) / range10;
     G10 = ((G10 - RGB101010RangeMin) * USHRT_MAX + (range10 >> 1)) / range10;
     B10 = ((B10 - RGB101010RangeMin) * USHRT_MAX + (range10 >> 1)) / range10;
      
     uint16_t R16, G16, B16;
     R16 = CLAMP(0, R10, USHRT_MAX);
     G16 = CLAMP(0, G10, USHRT_MAX);
     B16 = CLAMP(0, B10, USHRT_MAX);
      
     uint16_t ARGB[4];
     ARGB[0] = A2;
     ARGB[1] = R16;
     ARGB[2] = G16;
     ARGB[3] = B16;
      
     uint16_t *destPixel = dest.data;
     destPixel[0] = ARGB[permuteMap[0]];
     destPixel[1] = ARGB[permuteMap[1]];
     destPixel[2] = ARGB[permuteMap[2]];
     destPixel[3] = ARGB[permuteMap[3]];
     destPixel += 4;

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_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.

vImageConvert_RGBA8888toRGBA5551

Converts an RGBA8888 image into an RGBA5551 image.