---
title: UIGraphicsGetImageFromCurrentImageContext()
framework: uikit
role: symbol
role_heading: Function
path: uikit/uigraphicsgetimagefromcurrentimagecontext()
---

# UIGraphicsGetImageFromCurrentImageContext()

Returns an image from the contents of the current bitmap-based graphics context.

## Declaration

```swift
func UIGraphicsGetImageFromCurrentImageContext() -> UIImage?
```

## Return Value

Return Value A image object containing the contents of the current bitmap graphics context.

## Discussion

Discussion You should call this function only when a bitmap-based graphics context is the current graphics context. If the current context is nil or was not created by a call to UIGraphicsBeginImageContext(_:), this function returns nil. This function may be called from any thread of your app.

## See Also

### Image creation

- [Supporting HDR images in your app](uikit/supporting-hdr-images-in-your-app.md)
- [jpegData(compressionQuality:)](uikit/uiimage/jpegdata(compressionquality:).md)
- [pngData()](uikit/uiimage/pngdata().md)
- [UIGraphicsBeginImageContext(_:)](uikit/uigraphicsbeginimagecontext(_:).md)
- [UIGraphicsEndImageContext()](uikit/uigraphicsendimagecontext().md)
