Function

vImageConverter_CreateWithColorSyncCodeFragment(_:_:_:_:_:_:)

Creates a vImage converter to convert from one vImage Core Graphics image format to another, using custom ColorSync transform.

Declaration

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

Parameters

codeFragment

A code fragment created with ColorSyncTransformCopyProperty(_:_:_:).

srcFormat

A pointer to a populated vImage_CGImageFormat structure describing the image format of the source image. If the CGColorSpace value is NULL, sRGB is used as the default value. The CGColorSpace value is retained by this function and is released when the vImageConverter is destroyed.

destFormat

A pointer to a populated vImage_CGImageFormat structure describing the image format of the destination image. If the CGColorSpace value is NULL, sRGB is used as the default value. The CGColorSpace value is retained by this function and is released when the 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:

kvImagePrintDiagnosticsToConsole

Prints a debug message if the operation fails.

kvImageDoNotTile

Operates as if kvImageDoNotTile was passed to vImageConvert_AnyToAny(_:_:_:_:_:).

Return Value

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

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.

If codeFragment is NULL, no colorspace conversion or correction is done. In this case, behavior is undefined if the colorspaces don't have the same channel order, if they have a different number of channels, or if the colorspaces aren't from the same family.

kColorSyncTransformFullConversionData is required for black point compensation.

See Also

Converting Any-to-Any

Building a Basic Conversion Workflow

Learn the fundamentals of the convert-any-to-any function by converting a CMYK image to an RGB image.

class vImageConverter

A description of a conversion from one image format to another.

func vImageConverter_GetSourceBufferOrder(vImageConverter) -> UnsafePointer<vImageBufferTypeCode>!

Returns a list of vImage source buffer channel names, specifying the order of planes.

func vImageConverter_GetDestinationBufferOrder(vImageConverter) -> UnsafePointer<vImageBufferTypeCode>!

Returns a list of vImage destination buffer channel names, specifying the order of planes.

vImage Buffer Type Codes

Constants that specify the contents of vImage buffers.

func vImageConverter_GetNumberOfSourceBuffers(vImageConverter) -> UInt

Returns the number of source buffers consumed by the converter.

func vImageConverter_GetNumberOfDestinationBuffers(vImageConverter) -> UInt

Returns the number of destination buffers written to by the converter.