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 theOpenCPicture
function.
FUNCTION OpenCPicture (newHeader: OpenCPicParams): PicHandle;
newHeader
- An
OpenCPicParams
record, which is defined as follows (see page 7-28 for a description of theOpenCPicParams
data 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
TheOpenCPicture
function returns a handle to a newPicture
record (described on page 7-26). Use theOpenCPicture
function to begin defining a picture;OpenCPicture
collects 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 thePlotCIcon
procedure, described in Inside Macintosh: More Macintosh Toolbox.)You can also use the
PicComment
procedure (described on page 7-39) to include picture comments in your picture definition.The
OpenCPicture
function creates pictures in the extended version 2 format. This format permits your application to specify resolutions when creating images.Use the
OpenCPicParams
record you pass in thenewHeader
parameter 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 theDrawPicture
procedure (described on page 7-43) to play back the saved picture, you supply a destination rectangle, andDrawPicture
scales 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
OpenCPicture
function calls theHidePen
procedure, so no drawing occurs on the screen while the picture is open (unless you call theShowPen
procedure just afterOpenCPicture
, or you calledShowPen
previously without balancing it by a call toHidePen
).Use the handle returned by
OpenCPicture
when referring to the picture in subsequent routines, such as theDrawPicture
procedure.After defining the picture, close it by using the
ClosePicture
procedure, described on page 7-41. To draw the picture, use theDrawPicture
procedure, described on page 7-43.After creating the picture, your application can use the
GetPictInfo
function (described on page 7-46) to gather information about it. ThePictInfo
record (described on page 7-31) returned byGetPictInfo
returns the picture's resolution and optimal bounding rectangle.SPECIAL CONSIDERATIONS
When creating a picture, you should generally use theClosePicture
procedure to finish it before you open the Printing Manager with thePrOpen
procedure. 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 thegrafProcs
field of aCGrafPort
orGrafPort
record; 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 callingClosePicture
before you callOpenCPicture
again. You cannot nest calls toOpenCPicture
.Always use the
ClipRect
procedure to specify a clipping region appropriate for your picture before you callOpenCPicture
. If you do not useClipRect
to specify a clipping region,OpenCPicture
uses 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 whenDrawPicture
scales 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
OpenCPicture
function may move or purge memory.SEE ALSO
ThePrOpen
procedure is described in the chapter "Printing Manager" in this book. TheClipRect
procedure is described in the chapter "Basic QuickDraw" in this book. TheShowPen
andHidePen
procedures are described in the chapter "QuickDraw Drawing" in this book.Listing 7-1 on page 7-10 illustrates the use of the
OpenCPicture
function.