<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/createCGImage(_:from:format:colorSpace:deferred:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)createCGImage:fromRect:format:colorSpace:deferred:"
  },
  "title" : "createCGImage(_:from:format:colorSpace:deferred:)"
}
-->

# createCGImage(_:from:format:colorSpace:deferred:)

Creates a Core Graphics image from a region of a Core Image image instance
with an option for controlling when the image is rendered.

```
func createCGImage(_ image: CIImage, from fromRect: CGRect, format: CIFormat, colorSpace: CGColorSpace?, deferred: Bool) -> CGImage?
```

## Parameters

`image`

A [`CIImage`](/documentation/CoreImage/CIImage) image instance for which to create a `CGImage`.

`fromRect`

The `CGRect` region of the `image` to use.
This region relative to the cartesean coordinate system of `image`.
This region will be intersected with integralized and intersected with `image.extent`.

`format`

A [`CIFormat`](/documentation/CoreImage/CIFormat) to specify the pixel format of the created `CGImage`.
For example, if `kCIFormatRGBX16` is specified, then the created `CGImage` will
be 16 bits-per-component and opaque.

`colorSpace`

The `CGColorSpace` for the output image.
This color space must have either `CGColorSpaceModel.rgb` or `CGColorSpaceModel.monochrome`
and be compatible with the specified pixel format.

`deferred`

Controls when Core Image renders `image`.

- True: rendering of `image` is deferred until the created `CGImage` rendered.
- False: the `image` is rendered immediately.

## Return Value


Returns a new `CGImage` instance.
You are responsible for releasing the returned image when you no longer need it.
The returned value will be `null` if the extent is empty or too big.

---

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)