Creates a bitmap graphics context.
- iOS 2.0+
- macOS 10.0+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
- Core Graphics
A pointer to the destination in memory where the drawing is to be rendered. The size of this memory block should be at least
NULLif you want this function to allocate memory for the bitmap. This frees you from managing your own memory, which reduces memory leak issues.
The width, in pixels, of the required bitmap.
The height, in pixels, of the required bitmap.
The number of bits to use for each component of a pixel in memory. For example, for a 32-bit pixel format and an RGB color space, you would specify a value of 8 bits per component. For the list of supported pixel formats, see “Supported Pixel Formats” in the Graphics Contexts chapter of Quartz 2D Programming Guide.
The number of bytes of memory to use per row of the bitmap. If the
NULL, passing a value of
0causes the value to be calculated automatically.
The color space to use for the bitmap context. Note that indexed color spaces are not supported for bitmap graphics contexts.
Constants that specify whether the bitmap should contain an alpha channel, the alpha channel’s relative location in a pixel, and information about whether the pixel components are floating-point or integer values. The constants for specifying the alpha channel information are declared with the
CGImagetype but can be passed to this parameter safely. You can also pass the other constants associated with the
For an example of how to specify the color space, bits per pixel, bits per pixel component, and bitmap information, see Graphics Contexts.
A new bitmap context, or
NULL if a context could not be created. You are responsible for releasing this object using
When you draw into this context, Core Graphics renders your drawing as bitmapped data in the specified block of memory.
The pixel format for a new bitmap context is determined by three parameters—the number of bits per component, the color space, and an alpha option (expressed as a
CGBitmap constant). The alpha value determines the opacity of a pixel when it is drawn.