<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/draw(_:in:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)drawImage:inRect:fromRect:"
  },
  "title" : "draw(_:in:from:)"
}
-->

# draw(_:in:from:)

Renders a region of an image to a rectangle in the context destination.

```
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 `dest` parameter. 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`](/documentation/CoreImage/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`](/documentation/CoreImage/CIContext) object is created with a `CGContextRef` or a `CGLContext` object. If you create the [`CIContext`](/documentation/CoreImage/CIContext) object with a `CGContextRef`, the dimensions of the destination rectangle are in points. If you create the [`CIContext`](/documentation/CoreImage/CIContext) object with a `CGLContext` object, the dimensions are in pixels.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)