Returns an image containing the contents of a portion of the specified display.


func CGDisplayCreateImage(_ display: CGDirectDisplayID, rect: CGRect) -> CGImage?



The identifier of the display to be accessed.


The rectangle, specified in display space, for the portion of the display being copied into the image.

Return Value

An image containing the contents of the specified rectangle. If the display ID is invalid, the return value is NULL. The caller is responsible for releasing the image created by calling CGImageRelease.


The actual rectangle used is the rectangle returned by integral with rect as a parameter.

See Also

Creating Images from the Display

func CGDisplayCreateImage(CGDirectDisplayID) -> CGImage?

Returns an image containing the contents of the specified display.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software