Programming with Quartz: 2D and PDF Graphics in Mac OS X

A bitmap image is a rectangular array of image samples (also called pixels), with each sample representing a single color value at a particular location in the image. There are a wide variety of sources of images. Digital cameras produce bitmap photographic images directly. Digital scanners can produce images from a wide variety of source material. Quartz produces bitmap image data when it renders to a bitmap context. Pixel painting programs produce images through human interaction. Images can be produced synthetically, such as with specialpurpose rendering software to algorithmically produce a rendered scene. Figure 9.1 illustrates a few different image sources.
Quartz uses the opaque data type CGImageRef to represent an image, regardless of the format of the image data, the type of image, or how you supply the image data to Quartz. Quartz provides a number of different functions that can create a CGImage object ( CGImageRef) from bitmap images. The data itself can be in one of a wide variety of image pixel formats and data layouts, including image samples that are represented by floating-point values. Image samples can contain per-sample alpha data in one of several different formats.
Quartz supports images that have intrinsic color as well as images that are used as a mask or stencil. An image with intrinsic color contains pixel values in a specific color space and an optional alpha value for...