lsr@apple.UUCP (Larry Rosenstein) (07/30/85)
In article <639@gatech.CSNET> klute@gatech.CSNET (Gregory Kenley) writes: > > >I am looking for a way to convert Macdraw documents into Macpaint >documents. First, MacDraw. It is relatively easy to read MacDraw documents that are saved as PICT files. These documents consist of a 512-byte header, followed by a standard Quickdraw picture. To read the file you simply ignore the header, get the picture, and call DrawPicture. (If you were to generate a PICT document, simply make the header all zeros.) There are two fancy things you can do. One is to avoid reading the whole picture into memory at once, by setting up Quickdraw capture procs that read the picture byte codes directly from disk. The second involves picture comments. Drawing the picture always gives you a visual reprensentation of the drawing. In addition, MacDraw generates a number of picture comments to give the picture some higher level semantics. For example, rotated text is drawn in the picture as a bitmap, but there are also comments that tell you what the actual text was (in case you rotate it back to a normal orientation). I don't have the memo with the comment codes at hand, but if all you want to do is go into MacPaint then you don't need them. Now, MacPaint. MacPaint files consist of a 512-byte header followed by a compressed bitmap. The first LONGINT is a version number. If this is 2 or greater, then the next part of the header is the 38 patterns used in that document. The rest of the header was unused according to the information I have (version 2 of the file format), but this may change in future versions. If you are generating a MacPaint file, simply make the header be all zeros. The compressed bitmap is read/written using the PackBits/UnpackBits Toobox calls. (I don't know the details of the packing algorithm, but maybe someone else does.) The document is 720 pixels high, and is un/packed one row at a time. The magic value for srcBytes in PackBits (dstBytes in UnpackBits) is 72, because the document is 72 bytes wide. Putting this all together, you can easily write a program that read a MacDraw PICT file and generates a MacPaint document. On a 512k machine, you can read the picture into memory, draw it into an off-screen bitmap and pack the bitmap as you write it out. With a little extra effort, you can get this to run on a 128K machine by reading the picture directly from the disk, and generating the bitmap form a band at a time. Another enhancement would be to allow the user to select only a certain part of the MacDraw image and position it within the MacPaint document. -- Larry Rosenstein Apple Computer UUCP: {nsc, dual, voder, ios, mtxinu}!apple!lsr CSNET: lsr@Apple.CSNET