[net.micro.mac] How does MacDraw use the PICT resource

lsr@apple.UUCP (Larry Rosenstein) (02/25/85)

In article <utcsri.791> mnh@utcsri.UUCP (Mark N. Hume) asks about how
MacDraw interprets PICT resources.

PICT resources are just Quickdraw pictures; MacDraw uses this as its main
Scrap format, because all application can use Quickdraw to read the
picture.  (MacDraw also can save documents in PICT format.  This format
consists of 512 bytes of header followed by a Quickdraw picture.)

To convert a Quickdraw picture into an internal data structure is easy, and
does not require any knowledge of how a picture is represented.  All you do
is replace the standard Quickdraw capture procs with your own special ones,
and then draw the picture in that grafPort.

For example, you would define a MyRect procedure that takes the same
arguments as StdRect, and install it in the grafPort's capture procs.  Then
every time a rectangle appears in the picture, your procedure will be
called.  By examining the arguments you can determine the location of the
rectangle and the kind of graphic operation (fill, paint, ...).  By
examining the grafPort you can determine the fill pattern, pen pattern,
etc.

The same approach applies to the other graphical shapes.  (This is the
technique usd by MacDraw itself.)  You will be able to paste in graphical
data from any application that uses pictures, not just MacDraw.

MacDraw also uses picture comments to embed mre semantics in pictures.  (I
know that these are used in PICT documents, but I am not sure if they are
also used for cutting and pasting.)  An example of where these are used is
rotated text.  MacDraw inserts a bitmap for the rotated text so that any
program that draws the picture gets the rotated text.  It also inserts a
picture comment with the actual text so that if a users un-rotates the text
it can be edited normally.  Comments are NOT used for simple objects, such
as rectangles.

If you try to read in a PICT file, note that it is not necessary to read
the entire file into memory at once.  There is a Quickdraw capture proc for
reading bytes from a picture.  Simple install your own procedure that reads
bytes from the disk instead.

Good luck.

Larry Rosenstein

{nsc, ios, dual, voder}!apple!lsr
lsr@Apple.CSNET