Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Appendix B - Using Picture Comments for Printing


Maintaining Device Independence

Whenever printing, you should use both QuickDraw and non-QuickDraw representations of an image, so that the current printer driver can render the best possible picture. If you send an image described with picture comments to a QuickDraw printer driver that does not support those picture comments, the driver ignores the comments and subsequently does not print your image; if you send only a QuickDraw image to a printer driver that supports picture comments, the driver may not render its best possible image.

Printer drivers that support TextBegin, TextCenter, and TextEnd are expected to ignore calls to the CopyBits, CopyMask, and CopyDeepMask procedures that fall between the TextBegin and TextEnd picture comments. Between the TextBegin and TextEnd picture comments, you can use CopyBits to draw a bitmap representation of rotated text on QuickDraw printers; this bitmap is not used if the TextBegin and TextEnd picture comments are supported, but it is used if TextBegin and TextEnd are not supported. This is illustrated in Listing B-4 on page B-23.

When your application draws polygons on a PostScript printer, you can use PolyBegin, PolySmooth, and PolyEnd picture comments to draw smoothed polygons; QuickDraw printer drivers ignore these comments. To make a PostScript printer driver ignore your QuickDraw representation of the polygons, you can use the PolyIgnore picture comment, as illustrated in Listing B-6 on page B-29.

A technique for maintaining two sets of drawing codes, described in "Rotating Graphics" beginning on page B-31 and "Drawing Dashed Lines" beginning on page B-34, makes use of a "magic pen" visible only to PostScript drivers. Graphics comments for drawing dashed lines and for rotating graphics require the use of the PenMode procedure to set the pattern mode to a value of 23. Normally this value is undefined, but it is handled specially by PostScript printer drivers (all QuickDraw drivers ignore it). Your application can use this pattern mode to draw objects in a picture, and if the picture is printed on a QuickDraw printer, these objects are not visible.

To maintain device independence when you send routines to a PostScript printer driver, you can "hide" QuickDraw routines between the PostScriptBegin and PostScriptEnd picture comments. The PostScriptBegin comment is recognized only by PostScript printer drivers. When a PostScript driver receives the PostScriptBegin comment, it tells the PostScript printer to save the current state of the printer and to disable all low-level standard QuickDraw drawing procedures. Thus, the QuickDraw representation of the graphic is ignored by PostScript printer drivers.

Table B-2 lists the QuickDraw low-level procedures and the affected high-level drawing routines that are disabled by the PostScriptBegin picture comment.

Table B-2: Low-level QuickDraw routines disabled by the PostScriptBegin comment
Low-level routineExamples of affected high-level QuickDraw routines
StdTextQuickDraw text-drawing routines (as described in the chapter "QuickDraw Text" in Inside Macintosh: Text)
StdLineMoveTo, Move, LineTo, Line
StdRectFrameRect, PaintRect, FillRect, EraseRect, InvertRect
StdRRectFrameRoundRect, PaintRoundRect, FillRoundRect, EraseRoundRect, InvertRoundRect
StdOvalFrameOval, PaintOval, FillOval, EraseOval, InvertOval
StdArcFrameArc, PaintArc, FillArc, EraseArc, InvertArc
StdPolyFramePoly, PaintPoly, FillPoly, ErasePoly, InvertPoly
StdRgnFrameRgn, PaintRgn
StdBitsCopyBits, CopyMask, CopyDeepMask

To mark the end of a sequence of hidden QuickDraw drawing routines and to reenable QuickDraw drawing routines, you can use the picture comment PostScriptEnd. The PostScriptEnd comment is recognized only by PostScript printer drivers. When a PostScript driver receives the PostScriptEnd comment, it tells the PostScript printer driver to restore the previous state of the printer driver and to enable QuickDraw drawing operations.

For a LaserWriter PostScript printer driver, QuickDraw routines that draw text, lines, and shapes and copy bitmaps or pixel maps have no effect when placed between the PostScriptBegin and PostScriptEnd picture comments. Instead, the driver expects to receive imaging instructions in subsequent picture comments. On the other hand, a QuickDraw printer driver ignores the PostScriptBegin and PostScriptEnd picture comments.

Only PostScript printer drivers should support the DashedLine, DashedStop, RotateBegin, RotateCenter, and RotateEnd picture comments. Therefore, you can use the PostScriptBegin and PostScriptEnd picture comments to hide your QuickDraw implementations of these comments from the printer driver. Listing B-7 on page B-32 illustrates how to use PostScriptBegin and PostScriptEnd when rotating graphics on PostScript printers; Listing B-9 on page B-35 illustrates how to use PostScriptBegin and PostScriptEnd when drawing dashed lines on PostScript printers.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996