---
title: "vImageConverter_CreateWithCGImageFormat(_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageconverter_createwithcgimageformat(_:_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.accelerate/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 doc://com.apple.accelerate/documentation/Accelerate/vImageConverter is destroyed.
- `destFormat`: A pointer to a populated doc://com.apple.accelerate/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 doc://com.apple.accelerate/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: | |

## Mentioned in

Building a basic image conversion workflow

## Return Value

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

## Discussion

Discussion This function creates a vImageConverter instance to convert between image formats described by vImage_CGImageFormat.  The vImageConverter is intended to be used and reused with vImageConvert_AnyToAny(_:_:_:_:_:) to convert images from one format to another.

## See Also

### Creating a converter

- [vImageConverter](accelerate/vimageconverter.md)
- [vImageConverter_CreateWithCGColorConversionInfo(_:_:_:_:_:_:)](accelerate/vimageconverter_createwithcgcolorconversioninfo(_:_:_:_:_:_:).md)
- [vImageConverter_CreateForCGToCVImageFormat(_:_:_:_:_:)](accelerate/vimageconverter_createforcgtocvimageformat(_:_:_:_:_:).md)
- [vImageConverter_CreateForCVToCGImageFormat(_:_:_:_:_:)](accelerate/vimageconverter_createforcvtocgimageformat(_:_:_:_:_:).md)
- [vImageConverter_CreateWithColorSyncCodeFragment(_:_:_:_:_:_:)](accelerate/vimageconverter_createwithcolorsynccodefragment(_:_:_:_:_:_:).md)
