The functions listed in Table 10-2 move data out of Quartz 2D. All these functions, except for CGPDFContextCreateWithURL, either return an image destination (CGImageDestinationRef) or a data consumer (CGDataConsumerRef). Image destination and data consumers abstract the data-writing task, letting Quartz take care of the details for you. Image destinations are used exclusively for writing image data, but are available only in Mac OS X v10.4 or later. Similar to image sources, an image destination can represent a variety of image data, from a single image to a destination that contains multiple images, thumbnail images, and properties for each image or for the image file.
Data consumers can be used to write image or PDF data, and all, except for CGDataConsumerCreateWithCFData, are available in Mac OS X v10.0 or later. The function CGPDFContextCreateWithURL is a convenience function that writes PDF data to the location specified by a URL.
You can supply a data consumer to:
The PDF context creation function CGPDFContextCreate. This function returns a graphics context that records your drawing as a sequence of PDF drawing commands that are passed to the data consumer object.
The function CGImageDestinationCreateWithDataConsumer to create an image destination from a data consumer.
When you are working with image data and your application runs in Mac OS X v10.4 or later, an image destination is the preferred way to move image data out of Quartz. After you have a CGImageDestinationRef, you can accomplish these tasks:
Add images (CGImageRef) to a destination using the functions CGImageDestinationAddImage or CGImageDestinationAddImageFromSource. A CGImageRef data type represents a single Quartz image.
Set properties using the function CGImageDestinationSetProperties.
Obtain information from an image destination using the functions CGImageDestinationCopyTypeIdentifiers or CGImageDestinationGetTypeID.
For more information on images, see “Bitmap Images and Image Masks.”
Function | When to use this function | Availability |
|---|---|---|
Whenever you can supply a URL that specifies where to write the image or PDF data. | 10.0 | |
To write image or PDF data using callbacks you supply. | 10.0 | |
Whenever you can supply a URL that specifies where to write PDF data. | 10.0 | |
To write image or PDF data to a CFData object. | 10.4 | |
To write image data to a data consumer. | 10.4 | |
To write image data to a CFData object. | 10.4 | |
Whenever you can supply a URL that specifies where to write the image data. | 10.4 |
Last updated: 2007-12-11