![]() ![]() |
IntroductionMost applications support Quickdraw pictures to some degree. They will allow you to import or export picture files, as well as using the PICT resource format on the clipboard to support Cut & Paste with other applications. Unfortunately, there are some problems that occur with pictures at print time, and that's what I want to cover here. You PICT When?One of the problems that comes up at print time is the use of picture comments. Some applications store their data in a native format, and only create pictures at print time to enable the use of picture comments. For each page of the document, they open a new picture, record the Quickdraw calls that described the document, along with any picture comments they want to use, and finally close the picture. When this is done, they call DrawPicture to print the picture, and then start the whole process over again for the next page. This method is supported and fully compatible with future system software, but is not required. The Printing Manager spools each page of a document into a Quickdraw picture. Since the Printing Manager already has a picture open, it is totally legal to send a picture comment (via the PicComment call) in between calls to PrOpenPage and PrClosePage without having them recorded in a picture. The Printing Manager has already replaced the StdComment procedure with its own anyway, so the PicComment call will be intercepted and supported correctly by the Printing Manager. If the only reason you are recording into pictures is so that you can use PicComments, you can avoid the overhead at print time by simply sending the comments directly. Feeling PICT On?Even if you aren't sending picture comments, you may still need to create a picture at print time. In general, you should try to create any pictures you need prior to calling PrOpen. This is because there is no way to predict how much memory a particular printer driver will require. Instead, you need to make as much memory available as possible. If you are creating pictures with the Printing Manager open, the chances are good that you are using memory you can't afford to waste.
If you need to create a picture with the Printing Manager open, and memory is
not a problem, you should still be aware of some potential problems. First of
all, keep in mind the Printing Manager receives data from the application by
replacing the Quickdraw GrafProcs stored in the If you do create a picture at print time, you may experience a syndrome we call "floating picture comments." That is, calls made by your application to the PicComment routine will be recorded in a different order than you made them. This will usually cause them to effect the wrong part of the picture, and lead to endless confusion. The best solution to this problem is to create any pictures that your application will need before opening the Printing Manager. Scaling Pictures - Mountains from Mole Hills
Another problem is a basic problem with pictures that seems to show up more at
print time. The problem concerns the scaling of pictures using the destination
rectangle passed to There can also be problems when using certain picture comments or imbedded PostScript. In the case of the TextCenter picture comment, you specify an offset to the center of rotation. This offset is usually based on the metrics of the font being used. If you scale the picture, Quickdraw decides to use a different font, and the offset you originally specified will be incorrect.
The easiest way to solve these problems is to scale the picture yourself.
Especially if you are trying to scale by a large amount. For example, some
applications create a picture at 72 dpi (ie. dots per inch), and then scale it
to 288 dpi for printing by simply increasing the destination rectangle by 4x.
This is asking a lot of the system, and will result in the text problems
described above. Instead, you should either draw the picture into its original
frame, and let the Printing Manager handle scaling it to the resolution of the
device, or handle the scaling yourself by parsing the picture and playing it
back opcode by opcode instead of calling One last thing to watch for when scaling pictures is integer overflows. It's usually pretty rare that you will overflow a coordinate when creating a Quickdraw picture, but it is not so hard to do when scaling a picture. For example, some applications will draw something offscreen to make sure the Printing Manager has configured the clip region and other related structures. They usually do this by moving the cursor to (-32767,-32767), and then draw a pixel. This works fine to initialize the Printing Manager, and the pixel isn't actually seen on the output. The problem occurs when you try to scale this picture. If you try to make it bigger, Quickdraw will adjust to coordinate (-32767,-32767) which will end up overflowing. The only way to solve these problems is to look for these kinds of operations in the picture before trying to scale it with DrawPicture. Pictures Within Pictures-Is Nesting the Best Thing?
One cool feature of Quickdraw pictures is the ability to nest them easily.
Basically, you can call
In most cases, you can simply call On the other hand, if you have a begin comment, and want to insert a picture before inserting the appropriate end comment, you must parse the picture to be inserted to make sure it is not using the same comment pair. If it is, and you insert it, you will have problems. So make sure that all your begins and ends are matched, and don't try to insert other pictures between begin/end pairs of comments. If you find that you have to insert a picture between a pair of begin/end comments, you must parse the picture to be inserted to make sure that it does not use the same comments. Penalty for Quickdraw - Clipping
Here's a subtle fact about Quickdraw pictures. If you call D' Resolution
If you've read Technical Note #275, Features of 32-Bit Quickdraw 1.2, you
probably noticed the new font and resolution information. Basically, fonts are
now stored in pictures by name, not by ID. This means that fonts stored in
pictures will be displayed correctly on any Macintosh without fonts remapping
to other faces. The other new addition to the picture format is horizontal and
vertical resolution information. Applications that create pictures using the
new ConclusionQuickdraw pictures can be used successfully at print time, if you avoid the problems described above. Although there is a little overhead required by some of the workarounds, most are very simple to implement, and will help you avoid future compatibility problems. ReferencesPostScript Language Reference Manual, Adobe Systems Inc. LaserWriter Reference Manual, Addison-Wesley PostScript is a registered trademark of Adobe Systems Incorporated. Downloadables
|
Developer Documentation | Technical Q&As | Development Kits | Sample Code |