---
title: "vImageConvert_ARGBToYpCbCr_GenerateConversion(_:_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageconvert_argbtoypcbcr_generateconversion(_:_:_:_:_:_:)"
---

# vImageConvert_ARGBToYpCbCr_GenerateConversion(_:_:_:_:_:_:)

Generates the information that describes the conversion from ARGB to YpCbCr.

## Declaration

```swift
func vImageConvert_ARGBToYpCbCr_GenerateConversion(_ matrix: UnsafePointer<vImage_ARGBToYpCbCrMatrix>, _ pixelRange: UnsafePointer<vImage_YpCbCrPixelRange>, _ outInfo: UnsafeMutablePointer<vImage_ARGBToYpCbCr>, _ inARGBType: vImageARGBType, _ outYpCbCrType: vImageYpCbCrType, _ flags: vImage_Flags) -> vImage_Error
```

## Parameters

- `matrix`: A pointer to doc://com.apple.accelerate/documentation/Accelerate/vImage_ARGBToYpCbCrMatrix that contains the matrix coefficients for the conversion.
- `pixelRange`: A pointer to doc://com.apple.accelerate/documentation/Accelerate/vImage_YpCbCrPixelRange that contains the pixel range information for the conversion.
- `outInfo`: A pointer to doc://com.apple.accelerate/documentation/Accelerate/vImage_ARGBToYpCbCr that’s initialized with information for the conversion function to use later.
- `inARGBType`: A doc://com.apple.accelerate/documentation/Accelerate/vImageARGBType to specify the input (ARGB) format.
- `outYpCbCrType`: A doc://com.apple.accelerate/documentation/Accelerate/vImageYpCbCrType to specify the output (YpCbCr) format.
- `flags`: The options to use when performing this operation. Set the doc://com.apple.accelerate/documentation/Accelerate/kvImagePrintDiagnosticsToConsole flag to print debug messages when a problem occurs.

## Return Value

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

## Discussion

Discussion You use this function to create the vImage_ARGBToYpCbCr conversion information necessary for all RGB-to-YUV conversion functions. The following example shows how to prepare for the conversion of ARGB8888 to a YUV format with ITU 601 video range:  vImage_Error err = kvImageNoError;  vImage_Flags flags = kvImageNoFlags;  vImage_YpCbCrPixelRange pixelRange;  vImage_ARGBToYpCbCr outInfo;     pixelRange.Yp_bias         =   16;     // encoding for Y' = 0.0  pixelRange.CbCr_bias       =  128;     // encoding for CbCr = 0.0  pixelRange.YpRangeMax      =  235;     // encoding for Y'= 1.0  pixelRange.CbCrRangeMax    =  240;     // encoding for CbCr = 0.5  pixelRange.YpMax           =  255;     // a clamping limit above which the value is not allowed to go. 255 is fastest. Use pixelRange.YpRangeMax if you don't want Y' > 1.  pixelRange.YpMin           =    0;     // a clamping limit below which the value is not allowed to go. 0 is fastest. Use pixelRange.Yp_bias if you don't want Y' < 0.  pixelRange.CbCrMax         =  255;     // a clamping limit above which the value is not allowed to go. 255 is fastest.  Use pixelRange.CbCrRangeMax, if you don't want CbCr > 0.5  pixelRange.CbCrMin         =    0;     // a clamping limit above which the value is not allowed to go. 0 is fastest.  Use (2*pixelRange.CbCr_bias - pixelRange.CbCrRangeMax), if you don't want CbCr < -0.5    err = vImageConvert_ARGBToYpCbCr_GenerateConversion(kvImage_ARGBToYpCbCrMatrix_ITU_R_601_4, &pixelRange, &outInfo, kvImageARGB8888, kvImage422YpCbYpCr8, flags);

The following example shows how you might define your own conversion coefficients:  vImage_ARGBToYpCbCrMatrix matrix;;  vImage_YpCbCrPixelRange pixelRange;    matrix.R_Yp          =  0.2989f;  matrix.G_Yp          =  0.5866f;  matrix.B_Yp          =  0.1144f;  matrix.R_Cb          = -0.1688f;  matrix.G_Cb          = -0.3312f;  matrix.B_Cb_R_Cr     =  0.5f;  matrix.G_Cr          = -0.4183f;  matrix.B_Cr          = -0.0816f;  pixelRange.Yp_bias         =   16;     // encoding for Y' = 0.0  pixelRange.CbCr_bias       =  128;     // encoding for CbCr = 0.0  pixelRange.YpRangeMax      =  235;     // encoding for Y'= 1.0  pixelRange.CbCrRangeMax    =  240;     // encoding for CbCr = 0.5  pixelRange.YpMax           =  255;     // a clamping limit above which the value is not allowed to go. 255 is fastest. Use pixelRange.YpRangeMax if you don't want Y' > 1.  pixelRange.YpMin           =    0;     // a clamping limit below which the value is not allowed to go. 0 is fastest. Use pixelRange.Yp_bias if you don't want Y' < 0.  pixelRange.CbCrMax         =  255;     // a clamping limit above which the value is not allowed to go. 255 is fastest.  Use pixelRange.CbCrRangeMax, if you don't want CbCr > 0.5  pixelRange.CbCrMin         =    0;     // a clamping limit above which the value is not allowed to go. 0 is fastest.  Use (2*pixelRange.CbCr_bias - pixelRange.CbCrRangeMax), if you don't want CbCr < -0.5    err = vImageConvert_ARGBToYpCbCr_GenerateConversion(&matrix, &pixelRange, &outInfo, kvImageARGB8888, kvImage422YpCbYpCr8, flags)

The vImage_ARGBToYpCbCr structure this function creates can be reused concurrently, multiple times from multiple threads. The conversions that are available are:  |  |  |   |  |  |   |  |  |   |  |  |   |  |  |   |  |  |

## See Also

### Generating conversion information

- [vImageYpCbCrType](accelerate/vimageypcbcrtype.md)
- [vImageARGBType](accelerate/vimageargbtype.md)
- [vImage_ARGBToYpCbCrMatrix](accelerate/vimage_argbtoypcbcrmatrix.md)
- [vImage_ARGBToYpCbCr](accelerate/vimage_argbtoypcbcr.md)
- [vImage_YpCbCrPixelRange](accelerate/vimage_ypcbcrpixelrange.md)
