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.
Declaration
func createCGImage(_ image: CIImage, from fromRect: CGRect, format: CIFormat, colorSpace: CGColorSpace?, deferred: Bool) -> CGImage?Parameters
- image:
A Ciimage image instance for which to create a
CGImage. - fromRect:
The
CGRectregion of theimageto use. This region relative to the cartesean coordinate system ofimage. This region will be intersected with integralized and intersected withimage.extent. - format:
A Ciformat to specify the pixel format of the created
CGImage. For example, ifkCIFormatRGBX16is specified, then the createdCGImagewill be 16 bits-per-component and opaque. - colorSpace:
The
CGColorSpacefor the output image. This color space must have eitherCGColorSpaceModel.rgborCGColorSpaceModel.monochromeand be compatible with the specified pixel format. - deferred:
Controls when Core Image renders
image.True: rendering of
imageis deferred until the createdCGImagerendered.False: the
imageis 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.