<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGDisplayGetDrawingContext(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGDisplayGetDrawingContext"
  },
  "title" : "CGDisplayGetDrawingContext(_:)"
}
-->

# CGDisplayGetDrawingContext(_:)

Returns a graphics context suitable for drawing to a captured display.

```
func CGDisplayGetDrawingContext(_ display: CGDirectDisplayID) -> CGContext?
```

## Parameters

`display`

The identifier of the display to be accessed.

## Return Value

A Quartz graphics context suitable for drawing to a captured display, or `NULL` if the display has not been captured. The context is owned by the system and you should not release it.

## Discussion

After capturing a display or changing the configuration of a captured display, you can use this function to obtain the current graphics context for the display. The graphics context remains valid while the display is captured and the display configuration is unchanged. Releasing the captured display or reconfiguring the display invalidates the context. To determine when the display configuration is changing, you can use the function [`CGDisplayRegisterReconfigurationCallback(_:_:)`](/documentation/CoreGraphics/CGDisplayRegisterReconfigurationCallback(_:_:)) to register a display reconfiguration callback.

---

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)