<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 8.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImageConverter_CreateForCGToCVImageFormat(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@vImageConverter_CreateForCGToCVImageFormat"
  },
  "title" : "vImageConverter_CreateForCGToCVImageFormat(_:_:_:_:_:)"
}
-->

# vImageConverter_CreateForCGToCVImageFormat(_:_:_:_:_:)

Creates a vImage converter that converts a Core Graphics-formatted image to a Core Video-formatted image.

```
func vImageConverter_CreateForCGToCVImageFormat(_ srcFormat: UnsafePointer<vImage_CGImageFormat>, _ destFormat: vImageCVImageFormat, _ backgroundColor: UnsafePointer<CGFloat>!, _ flags: vImage_Flags, _ error: UnsafeMutablePointer<vImage_Error>!) -> Unmanaged<vImageConverter>!
```

## Parameters

`srcFormat`

The [`vImage_CGImageFormat`](/documentation/Accelerate/vImage_CGImageFormat) structure that describes the pixel format associated with the source buffers.

`destFormat`

The [`vImageCVImageFormat`](/documentation/Accelerate/vImageCVImageFormat) structure that describes the pixel format associated with the destination image buffers.

`backgroundColor`

In cases where the source format has an alpha channel and the destination doesn’t (or is <doc://com.apple.documentation/documentation/CoreGraphics/CGImageAlphaInfo/noneSkipFirst> or <doc://com.apple.documentation/documentation/CoreGraphics/CGImageAlphaInfo/noneSkipLast>) the conversion removes the alpha channel by flattening it against an opaque background color. The background color is specified as three <doc://com.apple.documentation/documentation/CoreFoundation/CGFloat-swift.struct> values corresponding to red, green, and blue in sRGB.

`flags`

The options to use when performing this operation. The following flags are supported:
    
    |Name                                                                                    |Description                                                                                                                                                                                      |
    |----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    |``doc://com.apple.accelerate/documentation/Accelerate/kvImagePrintDiagnosticsToConsole``|Prints a debug message if the operation fails.                                                                                                                                                   |
    |``doc://com.apple.accelerate/documentation/Accelerate/kvImageHighQualityResampling``    |Instructs the converter to spend extra time to achieve better image quality in cases where chroma is upsampled or downsampled as part of the conversion.                                         |
    |``doc://com.apple.accelerate/documentation/Accelerate/kvImageDoNotTile``                |Operates as if ``doc://com.apple.accelerate/documentation/Accelerate/kvImageDoNotTile`` was passed to ``doc://com.apple.accelerate/documentation/Accelerate/vImageConvert_AnyToAny(_:_:_:_:_:)``.|

## Return Value

[`kvImageNoError`](/documentation/Accelerate/kvImageNoError); otherwise, one of the error codes that <doc://com.apple.documentation/documentation/Accelerate/data-types-and-constants> describes.

## Discussion

This function creates a [`vImageConverter`](/documentation/Accelerate/vImageConverter) instance that’s used with [`vImageConvert_AnyToAny(_:_:_:_:_:)`](/documentation/Accelerate/vImageConvert_AnyToAny(_:_:_:_:_:)) to convert a Core Graphics formatted image, described by [`vImage_CGImageFormat`](/documentation/Accelerate/vImage_CGImageFormat), to Core Video image data, described by [`vImageCVImageFormat`](/documentation/Accelerate/vImageCVImageFormat).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)