draw(_:in:from:)
Renders a region of an image to a rectangle in the context destination.
Declaration
func draw(_ image: CIImage, in inRect: CGRect, from fromRect: CGRect)Parameters
- image:
A Core Image image object.
- inRect:
The rectangle in the context destination to draw into. The image is scaled to fill the destination rectangle.
- fromRect:
The subregion of the image that you want to draw into the context, with the origin and target size defined by the
destparameter. This rectangle is always in pixel dimensions.
Discussion
In iOS, this method draws the CIImage object into a renderbuffer for the OpenGL ES context. Use this method only if the CIContext object is created with contextWithEAGLContext: and if you are rendering to a CAEAGLayer. This method is asynchronous for apps linked against the iOS 6 or later SDK.
In macOS, you need to be aware of whether the CIContext object is created with a CGContextRef or a CGLContext object. If you create the CIContext object with a CGContextRef, the dimensions of the destination rectangle are in points. If you create the CIContext object with a CGLContext object, the dimensions are in pixels.