createCGImage(_:from:format:colorSpace:)
Creates a Core Graphics image from a region of a Core Image image instance with an option for controlling the pixel format and color space of the CGImage.
Declaration
func createCGImage(_ image: CIImage, from fromRect: CGRect, format: CIFormat, colorSpace: CGColorSpace?) -> 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.
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.