createCGImage(_:from:format:colorSpace:deferred:calculateHDRStats:)
Creates a Core Graphics image from a region of a Core Image image instance with an option for calculating HDR statistics.
Declaration
func createCGImage(_ image: CIImage, from fromRect: CGRect, format: CIFormat, colorSpace: CGColorSpace?, deferred: Bool, calculateHDRStats: 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.
- calculateHDRStats:
Controls if Core Image calculates HDR statistics.
True: Core Image will immediately render
image, calculate the HDR statistics and create aCGImagethat has the calculated values.False: the created
CGImagewill not have any HDR statistics.
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.