<!--
{
  "documentType" : "article",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/creating-a-core-graphics-image-from-a-vimage-buffer",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Creating a Core Graphics Image from a vImage Buffer"
}
-->

# Creating a Core Graphics Image from a vImage Buffer

Create displayable representations of vImage buffers.

## Discussion

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 <doc://com.apple.documentation/documentation/UIKit/UIImage> instance from that. The [`createCGImage(format:flags:)`](/documentation/Accelerate/vImage_Buffer/createCGImage(format:flags:)) function returns a <doc://com.apple.documentation/documentation/CoreGraphics/CGImage> instance based on the supplied Core Graphics image format (for more information, see <doc://com.apple.documentation/documentation/Accelerate/converting-bitmap-data-between-core-graphics-images-and-vimage-buffers>).

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

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

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

---

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)