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

# vImageConverter_CreateWithCGImageFormat(_:_:_:_:_:)

Creates a vImage converter that converts from one vImage Core Graphics image format to another.

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

## Parameters

`srcFormat`

A pointer to a populated [`vImage_CGImageFormat`](/documentation/Accelerate/vImage_CGImageFormat) structure describing the image format of the source image. If the <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpace> value is `NULL`, sRGB is used as the default value. The <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpace> reference is retained by this function and is released when the [`vImageConverter`](/documentation/Accelerate/vImageConverter) is destroyed.

`destFormat`

A pointer to a populated [`vImage_CGImageFormat`](/documentation/Accelerate/vImage_CGImageFormat) structure describing the image format of the destination image. If the <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpace> value is `NULL`, sRGB is used as the default value. The <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpace> reference is retained by this function and is released when the [`vImageConverter`](/documentation/Accelerate/vImageConverter) is destroyed.

`backgroundColor`

An array of floats to be used as a background color if one is needed. The `backgroundColor` range is assumed to be [0,1]. The channel ordering and number of color channels must match the natural order of the destination colorspace (for example, RGB or CMYK). The `backgroundColor` value may be `NULL` if no background color is needed.

`flags`

The options to use when performing this operation. The following flags are supported:
    
    |``doc://com.apple.accelerate/documentation/Accelerate/kvImagePrintDiagnosticsToConsole``|Prints a debug message if the operation fails.                                                                                                                                                   |
    |----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    |``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 to convert between image formats described by [`vImage_CGImageFormat`](/documentation/Accelerate/vImage_CGImageFormat).  The [`vImageConverter`](/documentation/Accelerate/vImageConverter) is intended to be used and reused with [`vImageConvert_AnyToAny(_:_:_:_:_:)`](/documentation/Accelerate/vImageConvert_AnyToAny(_:_:_:_:_:)) to convert images from one format to another.

---

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)