| Derived from | |
| Framework | ApplicationServices/ApplicationServices.h |
| Companion guide | |
| Declared in | CGBitmapContext.h |
The CGBitmapContext header file defines functions that create and operate on a Quartz bitmap graphics context. A bitmap graphics context is a type of CGContextRef that you can use for drawing bits to memory. The functions in this reference operate only on Quartz bitmap graphics contexts created using the functionCGBitmapContextCreate.
The number of components for each pixel in a bitmap graphics context is specified by a color space (defined by a CGColorSpaceRef, which includes RGB, grayscale, and CMYK, and which also may specify a destination color profile). The bitmap graphics context specifies whether the bitmap should contain an alpha channel, and how the bitmap is generated.
These functions return the values of attributes specified when a bitmap context is created.
CGBitmapContextGetBitmapInfo
CGBitmapContextGetAlphaInfo
CGBitmapContextGetBitsPerComponent
CGBitmapContextGetBitsPerPixel
CGBitmapContextGetBytesPerRow
CGBitmapContextGetColorSpace
CGBitmapContextGetData
CGBitmapContextGetHeight
CGBitmapContextGetWidth
Creates a bitmap graphics context.
CGContextRef CGBitmapContextCreate ( void *data, size_t width, size_t height, size_t bitsPerComponent, size_t bytesPerRow, CGColorSpaceRef colorspace, CGBitmapInfo bitmapInfo );
A pointer to the destination in memory where the drawing is to be rendered. The size of this memory block should be at least (bytesPerRow*height) bytes.
Starting in Mac OS X v10.3, you can pass NULL if you don’t care where the data is stored. This frees you from managing your own memory, which reduces memory leak issues. Quartz has more flexibility when it manages data storage for you. For example, it’s possible for Quartz to use OpenGL for rendering if it takes care of the memory.
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 more information about supported pixel formats, see Quartz 2D Programming Guide.
The number of bytes of memory to use per row of the bitmap.
The color space to use for the bitmap context. Note that indexed color spaces are not supported for bitmap graphics contexts.
A CGBitmapInfo constant that specifies whether the bitmap should contain an alpha channel and its relative location in a pixel, along with whether the components are floating-point or integer values. (See CGImage Reference for a description CGBitmapInfo constants.) In Quartz 2D Programming Guide, see “Creating a Bitmap Graphics Context” (in the Graphics Contexts chapter) for the color space, bits per pixel, bits per pixel component, and bitmap information constant combinations that you can use when creating a bitmap context with CGBitmapContextCreate.
A new bitmap context, or NULL if a context could not be created. You are responsible for releasing this object using CGContextRelease.
When you call this function, Quartz creates a bitmap drawing environment—that is, a bitmap context—to your specifications. When you draw into this context, Quartz 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 CGBitmapInfo constant). The alpha value determines the opacity of a pixel when it is drawn.
CGBitmapContext.h
Creates and returns a Quartz image from the pixel data in a bitmap graphics context.
CGImageRef CGBitmapContextCreateImage ( CGContextRef c );
A bitmap graphics context.
A CGImage object that contains a snapshot of the bitmap graphics context or NULL if the image is not created.
The CGImage object returned by this function is created by a copy operation. Subsequent changes to the bitmap graphics context do not affect the contents of the returned image. In some cases the copy operation actually follows copy-on-write semantics, so that the actual physical copy of the bits occur only if the underlying data in the bitmap graphics context is modified. As a consequence, you may want to use the resulting image and release it before you perform additional drawing into the bitmap graphics context. In this way, you can avoid the actual physical copy of the data.
CGBitmapContext.hReturns the alpha information associated with the context, which indicates how a bitmap context handles the alpha component.
CGImageAlphaInfo CGBitmapContextGetAlphaInfo ( CGContextRef c );
A bitmap context.
A bitmap information constant. If the specified context is not a bitmap context, kCGImageAlphaNone is returned. See CGImageAlphaInfo (renamed to CGBitmapInfo in Mac OS X v10.4) for more information about values.
Every bitmap context contains an attribute that specifies whether the bitmap contains an alpha component, and how it is generated. The alpha component determines the opacity of a pixel when it is drawn.
CGBitmapContext.h
Obtains the bitmap information associated with a bitmap graphics context.
CGBitmapInfo CGBitmapContextGetBitmapInfo ( CGContextRef c );
A bitmap graphics context.
The bitmap info of the bitmap graphics context or 0 if c is not a bitmap graphics context. See CGImage Reference for a description of the CGBitmapInfo constants that can be returned.
The CGBitmapInfo data returned by the function specifies whether the bitmap contains an alpha channel and how the alpha channel is generated, along with whether the components are floating-point or integer.
CGBitmapContext.hReturns the bits per component of a bitmap context.
size_t CGBitmapContextGetBitsPerComponent ( CGContextRef c );
The bitmap context to examine.
The number of bits per component in the specified context, or 0 if the context is not a bitmap context.
CGBitmapContext.hReturns the bits per pixel of a bitmap context.
size_t CGBitmapContextGetBitsPerPixel ( CGContextRef c );
The bitmap context to examine.
The number of bits per pixel in the specified context, or 0 if the context is not a bitmap context.
CGBitmapContext.hReturns the bytes per row of a bitmap context.
size_t CGBitmapContextGetBytesPerRow ( CGContextRef c );
The bitmap context to examine.
The number of bytes per row of the specified context, or 0 if the context is not a bitmap context.
CGBitmapContext.hReturns the color space of a bitmap context.
CGColorSpaceRef CGBitmapContextGetColorSpace ( CGContextRef c );
The bitmap context to examine.
The color space of the specified context, or NULL if the context is not a bitmap context. You are responsible for retaining and releasing this object as necessary.
CGBitmapContext.hReturns a pointer to the image data associated with a bitmap context.
void * CGBitmapContextGetData ( CGContextRef c );
The bitmap context to examine.
A pointer to the specified bitmap context’s image data, or NULL if the context is not a bitmap context.
CGBitmapContext.hReturns the height in pixels of a bitmap context.
size_t CGBitmapContextGetHeight ( CGContextRef c );
The bitmap context to examine.
The height in pixels of the specified context, or 0 if the context is not a bitmap context.
CGBitmapContext.hReturns the width in pixels of a bitmap context.
size_t CGBitmapContextGetWidth ( CGContextRef c );
The bitmap context to examine.
The width in pixels of the specified context, or 0 if the context is not a bitmap context.
CGBitmapContext.h
© 2003, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-06-28)