Quartz 2d programming guide pdf download






















You can find out more about how to use these functions by reading the PDF specification. The PDF content stream contains operators that signify parts of a PDF content stream that may be of interest to your application. An operator either marks a single point or a sequence. An operator is specified as a tag that has a property list or an object associated with it. A tag specifies what the point or content sequence represents.

A property list is a dictionary that contains key-value pairs specified by the PDF content creator. Write Callbacks for Operators. You need to write callbacks only for the operators you want to handle. Create and Set Up the Operator Table. Open the PDF Document. Scan the Content Stream for Each Page. The following sections show how to parse a content stream to find marked-content operators see Table Signals the start of a marked-content sequence begin marked content and is paired with the EMC marker that signals the end of the sequence.

Has a tag associated with it. Signals the start of a marked-content sequence and is paired with the EMC marker that signals the end of the sequence. Has a tag and a property list or object associated with it.

This operator does not have a tag associated with it. Typically, your callback retrieves any items associated with the operator. If the code in the listing successfully retrieves the name from the scanner stack, it prints the name. Quartz has an assortment of CGPDFScannerPop functions for retrieving objects, Boolean values, names, numbers, strings, arrays, dictionaries, and streams.

Each function returns a Boolean value to indicate whether the item was retrieved successfully. Listing A callback for the MP operator. You pass the table, the string that specifies the PDF operator, and a pointer to a callback function you write to handle that operator. The code in Listing sets a callback for each of the marked-content operators listed in Table See QuickTime Framework Reference for details.

The paint on the page can be modified by overlaying more paint through additional drawing operations. An object drawn on the page cannot be modified except by overlaying more paint. This model allows you to construct extremely sophisticated images from a small number of powerful primitives. To get the image in the top part of the figure, the shape on the left was drawn first followed by the solid shape.

The solid shape overlays the first shape, obscuring all but the perimeter of the first shape. The shapes are drawn in the opposite order in the bottom of the figure, with the solid shape drawn first. The page may be a real sheet of paper if the output device is a printer ; it may be a virtual sheet of paper if the output device is a PDF file ; it may even be a bitmap image. The exact nature of the page depends on the particular graphics context you use. A graphics context is an opaque data type CGContextRef that encapsulates the information Quartz uses to draw images to an output device, such as a PDF file, a bitmap, or a window on a display.

The information inside a graphics context includes graphics drawing parameters and a device-specific representation of the paint on the page. All objects in Quartz are drawn to, or contained by, a graphics context. You can think of a graphics context as a drawing destination, as shown in Figure When you draw with Quartz, all device-specific characteristics are contained within the specific type of graphics context you use.

In other words, you can draw the same image to a different device simply by providing a different graphics context to the same sequence of Quartz drawing routines. You do not need to perform any device-specific calculations; Quartz does it for you.

A bitmap is a rectangular array or raster of pixels, each pixel representing a point in an image. Bitmap images are also called sampled images.

See Creating a Bitmap Graphics Context. In a PDF file, your drawing is preserved as a sequence of commands. There are some significant differences between PDF files and bitmaps:. When you draw a page from a PDF file on a different device, the resulting image is optimized for the display characteristics of that device. PDF files are resolution independent by nature—the size at which they are drawn can be increased or decreased infinitely without sacrificing image detail. The user-perceived quality of a bitmap image is tied to the resolution at which the bitmap is intended to be viewed.

A window graphics context is a graphics context that you can use to draw into a window. Note that because Quartz 2D is a graphics engine and not a window management system, you use one of the application frameworks to obtain a graphics context for a window.

A layer context CGLayerRef is an offscreen drawing destination associated with another graphics context. It is designed for optimal performance when drawing the layer to the graphics context that created it.

A layer context can be a much better choice for offscreen drawing than a bitmap graphics context. See Core Graphics Layer Drawing. When you want to print in Mac OS X, you send your content to a PostScript graphics context that is managed by the printing framework. See Obtaining a Graphics Context for Printing for more information. Quartz 2D creates objects from opaque data types that your application operates on to achieve a particular drawing output.

Figure shows the sorts of results you can achieve when you apply drawing operations to three of the objects provided by Quartz 2D. For example:. You can rotate and display a PDF page by creating a PDF page object, applying a rotation operation to the graphics context, and asking Quartz 2D to draw the page to a graphics context.

You can draw a pattern by creating a pattern object, defining the shape that makes up the pattern, and setting up Quartz 2D to use the pattern as paint when it draws to a graphics context. You can fill an area with an axial or radial shading by creating a shading object, providing a function that determines the color at each point in the shading, and then asking Quartz 2D to use the shading as a fill color.

CGPathRef , used for vector graphics to create paths that you fill or stroke. See Paths. CGImageRef , used to represent bitmap images and bitmap image masks based on sample data that you supply. See Bitmap Images and Image Masks. If you are writing an application that needs precise control over how text is displayed, see Core Text Programming Guide. In particular, UIKit provides classes that implement common tasks, making it easy to add text to your application:. Cocoa provides full Unicode support, text input and editing, precise text layout and typesetting, font management, and many other advanced text-handling capabilities.

All Rights Reserved. Terms of Use Privacy Policy Updated: To submit a product bug or enhancement request, please visit the Bug Reporter page.



0コメント

  • 1000 / 1000