Creating a Core Graphics Image from a vImage Buffer

Create displayable representations of vImage buffers.


vImage provides a function for creating Core Graphics images from vImage buffers. This function allows you to display the results of a vImage operation to your user.

Create the Image

You create a Core Graphics image from the buffer, and initialize a UIImage instance from that. The createCGImage(format:flags:) function returns a CGImageRef instance based on the supplied Core Graphics image format (for more information, see Creating a Core Graphics Image Format).

The following example shows how to create a Core Graphics image from a vImage buffer:

let result = try? destinationBuffer.createCGImage(format: format)

if let result = result {
    // Assumes `imageView` is a `UIImageView`
    imageView.image = UIImage(cgImage: result)

See Also

Image Processing Essentials

Creating a Core Graphics Image Format

Provide descriptions of Core Graphics image formats for conversions to and from vImage.

Creating and Populating Buffers from Core Graphics Images

Initialize vImage buffers from Core Graphics images.

Applying vImage Operations to Regions of Interest

Limit the effect of vImage operations to rectangular regions of interest.

Optimizing Image Processing Performance

Improve your app's performance by converting image buffer formats from interleaved to planar.


Manipulate large images using the CPU’s vector processor.