---
title: "UIGraphicsBeginImageContext(_:)"
framework: uikit
role: symbol
role_heading: Function
path: "uikit/uigraphicsbeginimagecontext(_:)"
---

# UIGraphicsBeginImageContext(_:)

Creates a bitmap-based graphics context and makes it the current context.

## Declaration

```swift
func UIGraphicsBeginImageContext(_ size: CGSize)
```

## Parameters

- `size`: The size of the new bitmap context. This represents the size of the image returned by the doc://com.apple.uikit/documentation/UIKit/UIGraphicsGetImageFromCurrentImageContext() function.

## Discussion

Discussion This function is equivalent to calling the UIGraphicsBeginImageContextWithOptions(_:_:_:) function with the opaque parameter set to false and a scale factor of 1.0. 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)
- [UIGraphicsGetImageFromCurrentImageContext()](uikit/uigraphicsgetimagefromcurrentimagecontext().md)
- [UIGraphicsEndImageContext()](uikit/uigraphicsendimagecontext().md)
