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

Broadly speaking, image masking is a process that controls the coverage of paint to apply when painting an image. Image masking is typically performed using an image mask. The terms image mask, masking image, and mask are interchangeable terms to describe an image whose sample values indicate a percentage of paint to apply but not the color of the paint itself. Such an image is sometimes called a stencil mask because the mask does not itself have any intrinsic color; instead, color "pours" through the stencil. An image mask has only one component value, the coverage value.
An image mask is not the only way in Quartz to accomplish image masking. Colors and images can also serve as masking devices. Each masking device image masks, colors, and images produces its own unique and interesting effect in Quartz.
An image mask can be 1, 2, 4, or 8 bits per sample. A sample value that decodes to 0 allows paint to go through it it's the "hole" in the stencil. A sample value that decodes to 1 doesn't allow paint through it's the solid part of the stencil. A 1-bit mask, by definition, has only "on/off" options 0 or 1. Deeper masks, such as an 8-bit mask, can contain intermediate values ( 0 < x < 1) that specify gradations of paint that get through the mask, with lower values allowing more paint than higher values.
An image, when used as a masking...