viraf@seas.gwu.edu (Viraf Bankwalla) (05/05/90)
Hi,
I'm writing a program which can load in various PICT files. My problem
lies in determining the characteristics of the source. There are three
types of PICT files (or so I think)
versionOne // BitImage. Old style PICT
versionTwo // PixMap. Support for color.
Chunky // CLUT - supports {1, 2, 4, 8} bits per pixel
RGBDirect // Direct - supports {16, 32} bits per pixel.
OK. So I open up the 'PICT' file, and look at the header
int picSize; // low word of picture size
Rect picFrame; // picture frame in 72dpi
switch (version) {
case versionOne: // opcodes are one byte long
opVersion = 0x11 // version opcode
0x01 // DATA - version number
OPCODE - BYTE // OPCODES followed by DATA
DATA
OPCODE - BYTE
DATA
::::
::::
::::
opEndPic = 0xFF // End of picture opcode
case versionTwo: // opcodes are one word long
opVersion = 0x0011 // version opcode
0x02FF // DATA - version number
HeaderOp = 0x0C00 // Version2 PICT have a header
// before playback defination
DATA - 24 bytes
:::::::
:::::::
opPicEnd = 0x00ff // End of picture
}
The 24 bytes of data is defined as
longint Version2 = -1
unsigned hex longint // Fixed point bounding box
unsigned hex longint
unsigned hex longint
unsigned hex longint
longint Version2 = -1 // RESERVED
Distinguishing between versionOne and versionTwo is easy.
If versionOne I allocate memory for a BitMap. I need to distinguish
between a RGBDirect and Chunky PICT so that I may create and
appropiate GDevice, and allocate memory for the PixMap. It would
be nice to be able to get the pixMap struct, and intrepret it.
Any suggestions ??? I thought of replacing StdBits as it provides the
source pixMap (dest = current port), but then I'd have to spool in the
PICT twice - once to gather info and then to actually draw it. Is there
a better way ?? What should one do if the destination is composed from
two sources which have different resolutions ??
Apple strongly recommends letting QuickDraw parse the picture, and
thus I dont want to sit down putting YACC to work.
Any help would be greatly appreciated.
Thanks once again.
viraf bankwalla
viraf@seas.gwu.edu
uunet!gwusun!viraf