<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/init(cgContext:options:)-6p78w",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(cm)contextWithCGContext:options:"
  },
  "title" : "init(cgContext:options:)"
}
-->

# init(cgContext:options:)

Creates a Core Image context from a Quartz context, using the specified options.

```
init(cgContext cgctx: CGContext, options: [CIContextOption : Any]? = nil)
```

## Parameters

`cgctx`

A Quartz graphics context.

`options`

A dictionary that contains color space information. You can pass any of the keys defined in [`CIContextOption`](/documentation/CoreImage/CIContextOption) along with the appropriate value.

## Discussion

After calling this method, Core Image draws content to the specified Quartz graphics context.

When you create a [`CIContext`](/documentation/CoreImage/CIContext) object using a Quartz graphics context, any transformations that are already set on the Quartz graphics context affect drawing to that context.

> Note:
> To obtain a Core Image context for the current AppKit drawing context in macOS, use the <doc://com.apple.documentation/documentation/AppKit/NSGraphicsContext> <doc://com.apple.documentation/documentation/AppKit/NSGraphicsContext/ciContext> property.

---

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)