DrawPicture
DrawPicture
Draw a pre- defined picture, scaled to desired size PicHandle thePicture ; handle of picture to draw Rect *destRect ; rectangle defining location and size read from the scrap or a resource. The image is scaled to fit inside a specified
rectangle.
thePicture is the handle of the picture to draw. It leads to a variable- length
destRect is the address of an 8-byte Rect structure, expressed in local coordinates. The picture will be drawn within that rectangle, scaled
to fit, if necessary.
Notes: See OpenPicture for a discussion of how to create a picture definition. Non-text data in the desk scrap is sometimes in the form of a picture (see
GetScrap). Applications typically store predefined pictures into an application resource. To read a picture from a resource, use GetResource if (thePic == 0) { ... an error occurred ... }
To find the original size of the picture, you can read from the picFrame
field of the Picture structure, and then position the resulting rectangle within the local coordinates system; e.g.:
short wide, high;
/* ------------- draw at (0,0), original size */
r = (*thePic)->picFrame;
wide = r.right - r.left; [TOKEN:12074] calculate width and height */
high = r.bottom - r.top;
/* -------- draw at (100,100), twice as wide */
OffsetRect( &r, 100,100 ); /* move into position */ InsetRect( &r, -wide, 0 ); /* make twice as wide */ If you need to store a 'PICT' over 32K, you may not be able to store it in a
'PICT' resource. To see how to work around this, see Large PICTs. Don't replace the DrawPicture routine with your own routine to interpret PICTs, unless you absolutely must. If Apple adds any new opcodes
to QuickDraw, your program may not be able to read 'PICT's anymore.