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

Just about all the examples in the book so far create content using Quartz line art drawing routines to draw to a graphics context. But what if an application needs to draw from other sources JPEG, GIF, PDF, and so forth or write content to such destinations as the hard disk, the Clipboard, a location on the Web, or a block of memory? Quartz provides two opaque data types CGDataProviderRef and CGDataConsumerRef that abstract the data access process, making it easy to obtain data from a variety of sources as well as to write data to various destinations. Data providers ( CGDataProviderRef) read data from a source, while data consumers ( CGDataConsumerRef) write data to a destination, as Figure 8.1 depicts.
Data providers and data consumers aren't the only data types Quartz provides for reading and writing data, but they are the most versatile. They can access PDF, PostScript, and bitmap image data and they have been part of Quartz since its beginning, making them backward-compatible. The next chapter, "Drawing Images" (page 203), uses data providers to access image data. Later in that chapter, you'll learn additional ways to access data sources and destinations.
Data providers retrieve and package data so that the data can be used by Quartz for such tasks as drawing images and PDF documents and supplying PostScript data to a PostScript-to-PDF converter. Quartz uses the opaque data type CGDataProviderRef to represent...