Important: The information in this document is obsolete and should not be used for new development.
OpenCPicture
To begin defining a picture in extended version 2 format, use theOpenCPicturefunction.
FUNCTION OpenCPicture (newHeader: OpenCPicParams): PicHandle;
newHeader- An
OpenCPicParamsrecord, which is defined as follows (see page 7-28 for a description of theOpenCPicParamsdata type):TYPE OpenCPicParams = RECORD srcRect: Rect; {optimal bounding rectangle } { for displaying picture at } { resolution indicated in } { hRes, vRes fields} hRes: Fixed; {best horizontal resolution; } { $00480000 specifies 72 dpi} vRes: Fixed; {best vertical resolution; } { $00480000 specifies 72 dpi} version: Integer; {set to -2} reserved1: Integer; {reserved; set to 0} reserved2: LongInt; {reserved; set to 0} END;DESCRIPTION
TheOpenCPicturefunction returns a handle to a newPicturerecord (described on page 7-26). Use theOpenCPicturefunction to begin defining a picture;OpenCPicturecollects your subsequent drawing commands in this record. When defining a picture, you can use all other QuickDraw drawing routines described in this book, with the exception ofCopyMask,CopyDeepMask,SeedFill,SeedCFill,CalcMask, andCalcCMask. (Nor can you use thePlotCIconprocedure, described in Inside Macintosh: More Macintosh Toolbox.)You can also use the
PicCommentprocedure (described on page 7-39) to include picture comments in your picture definition.The
OpenCPicturefunction creates pictures in the extended version 2 format. This format permits your application to specify resolutions when creating images.Use the
OpenCPicParamsrecord you pass in thenewHeaderparameter to specify the horizontal and vertical resolution for the picture, and specify an optimal bounding rectangle for displaying the picture at this resolution. When you later call theDrawPictureprocedure (described on page 7-43) to play back the saved picture, you supply a destination rectangle, andDrawPicturescales the picture so that it is completely aligned with the destination rectangle. To display a picture at a resolution other than that at which it was created, your application should compute an appropriate destination rectangle by scaling its width and height by the following factor:scale factor = destination resolution / source resolution
For example, if a picture was created at 300 dpi and you want to display it at 75 dpi, then your application should compute the destination rectangle width and height as 1/4 of those of the picture's bounding rectangle.
The
OpenCPicturefunction calls theHidePenprocedure, so no drawing occurs on the screen while the picture is open (unless you call theShowPenprocedure just afterOpenCPicture, or you calledShowPenpreviously without balancing it by a call toHidePen).Use the handle returned by
OpenCPicturewhen referring to the picture in subsequent routines, such as theDrawPictureprocedure.After defining the picture, close it by using the
ClosePictureprocedure, described on page 7-41. To draw the picture, use theDrawPictureprocedure, described on page 7-43.After creating the picture, your application can use the
GetPictInfofunction (described on page 7-46) to gather information about it. ThePictInforecord (described on page 7-31) returned byGetPictInforeturns the picture's resolution and optimal bounding rectangle.SPECIAL CONSIDERATIONS
When creating a picture, you should generally use theClosePictureprocedure to finish it before you open the Printing Manager with thePrOpenprocedure. There are two main reasons for this. First, you should allow the printing driver to use as much memory as possible. Second, the Printing Manager creates its own type of graphics port--one that replaces the standard QuickDraw drawing operations stored in thegrafProcsfield of aCGrafPortorGrafPortrecord; to avoid unexpected results when creating a picture, you should draw into a graphics port created with QuickDraw instead of drawing into a printing port created by the Printing Manager.After calling
OpenCPicture, be sure to finish your picture definition by callingClosePicturebefore you callOpenCPictureagain. You cannot nest calls toOpenCPicture.Always use the
ClipRectprocedure to specify a clipping region appropriate for your picture before you callOpenCPicture. If you do not useClipRectto specify a clipping region,OpenCPictureuses the clipping region specified in the current graphics port. If the clipping region is very large (as it is when a graphics port is initialized) and you scale the picture when drawing it, the clipping region can become invalid whenDrawPicturescales the clipping region--in which case, your picture will not be drawn. On the other hand, if the graphics port specifies a small clipping region, part of your drawing may be clipped when you draw it. Setting a clipping region equal to the port rectangle of the current graphics port, as shown in Listing 7-1 on page 7-10, always sets a valid clipping region.The
OpenCPicturefunction may move or purge memory.SEE ALSO
ThePrOpenprocedure is described in the chapter "Printing Manager" in this book. TheClipRectprocedure is described in the chapter "Basic QuickDraw" in this book. TheShowPenandHidePenprocedures are described in the chapter "QuickDraw Drawing" in this book.Listing 7-1 on page 7-10 illustrates the use of the
OpenCPicturefunction.