n8541751@unicorn.WWU.EDU (Where there is darkness, light) (08/29/90)
Does anyone have format documentation for MacPaint images, or know where it can be FTP'd? I looked and didn't see it anywhere. Thanks in advance. Kris Bruland -- Kriston M. Bruland | . . . . . . . . . . n8541751@unicorn.wwu.edu | . . . . . . . . . 8541751@nessie.wwu.edu | . . . . . .
keeshu@nikhefk.UUCP (Kees Huyser) (08/29/90)
In article <1443@unicorn.WWU.EDU> n8541751@unicorn.WWU.EDU (Where there is darkness, light) writes:
#Does anyone have format documentation for MacPaint images, or know where it
#can be FTP'd?
#Kris Bruland
This comes from TechNote 086, try to get your hands on this one for more info.
===================
MacPaint documents have a file type of PNTG, and since they use only the data
fork, you can ignore the resource fork. The data fork contains a 512Pbyte
header followed by compressed data which represents a single bitmap (576 pixels
wide by 720 pixels tall). At a resolution of 72 pixels per inch, this bitmap
occupies the full 8 inch by 10 inch printable area of a standard ImageWriter
printer page.
Header
The first 512 bytes of the document form a header of the following format:
% 4Pbyte version number (default = 2)
% 38*8 = 304 bytes of patterns
% 204 unused bytes (reserved for future expansion)
As a Pascal record, the document format could look like the following:
MPHeader = RECORD
Version: LONGINT;
PatArray: ARRAY [1..38] of Pattern;
Future: PACKED ARRAY [1..204] of SignedByte;
END;
If the version number is zero, the document uses default patterns, so you can
ignore the rest of the header block, and if your program generates MacPaint
documents, you can write 512 bytes of zero for the document header. Most
programs which read MacPaint documents can skip the header when reading.
Bitmap
Following the header are 720 compressed scan lines of data which form the 576
pixel wide by 720 pixel tall bitmap. Without compression, this bitmap would
occupy 51,840 bytes and chew up disk space pretty fast; typical MacPaint
documents compress to about 10K using the _PackBits procedure to compress runs
of equal bytes within each scan line. The bitmap part of a MacPaint document
is simply the output of _PackBits called 720 times, with 72 bytes of input each
time.
To determine the maximum size of a MacPaint file, it is worth noting what
Inside Macintosh says about _PackBits:
The worst case would be when _PackBits adds one byte to the row
of bytes when packing.
If we include an extra 512 bytes for the file header information to the size of
an uncompressed bitmap (51,840), then the total number of bytes would be
52,352. If we take into account the extra 720 potential bytes (one for each
row) to the previous total, the maximum size of a MacPaint file becomes 53,072
bytes.
=========================
/* -------------------------------------------------------------------------- */
/* keeshu@nikhefk.uucp or {..!uunet.uu.net}!mcsun!hp4nl!nikhefk!keeshu */
/* The National Institute for Nuclear Physics and High-Energy Physics */
/* P.O.Box 4395, 1009 AJ Amsterdam, The Netherlands, phone:+31205920124 */
/* -------------------------------------------------------------------------- */
/* Disregarding the metaphysical aspects of Schrodinger's cats, I must protest*/
/* at the use of (possibly live) animals for experiments such as these. I urge*/
/* readers to boycott whatever product this research is leading to. */
/* -------------------------------------------------------------------------- */