Creates a bitmap-based graphics context with the specified options.
- iOS 4.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The size (measured in points) of the new bitmap context. This represents the size of the image returned by the
UIGraphicsfunction. To get the size of the bitmap in pixels, you must multiply the width and height values by the value in the
Get Image From Current Image Context()
A Boolean flag indicating whether the bitmap is opaque. If you know the bitmap is fully opaque, specify
trueto ignore the alpha channel and optimize the bitmap’s storage. Specifying
falsemeans that the bitmap must include an alpha channel to handle any partially transparent pixels.
The scale factor to apply to the bitmap. If you specify a value of
0, the scale factor is set to the scale factor of the device’s main screen.
You use this function to configure the drawing environment for rendering into a bitmap. The format for the bitmap is a ARGB 32-bit integer pixel format using host-byte order. If the opaque parameter is
true, the alpha channel is ignored and the bitmap is treated as fully opaque (
k). Otherwise, each pixel uses a premultipled ARGB format (
The environment also uses the default coordinate system for UIKit views, where the origin is in the upper-left corner and the positive axes extend down and to the right of the origin. The supplied scale factor is also applied to the coordinate system and resulting images. The drawing environment is pushed onto the graphics context stack immediately.
While the context created by this function is the current context, you can call the
UIGraphics function to retrieve an image object based on the current contents of the context. When you are done modifying the context, you must call the
UIGraphics function to clean up the bitmap drawing environment and remove the graphics context from the top of the context stack. You should not use the
UIGraphics function to remove this type of context from the stack.
In most other respects, the graphics context created by this function behaves like any other graphics context. You can change the context by pushing and popping other graphics contexts. You can also get the bitmap context using the
This function may be called from any thread of your app.