Appendix A - Reading a Macintosh PICT Graphic
As described under "picture" in the Definition section of this document, some pictures in Word documents are stored as Macintosh PICT graphics, particularly in files created by Word for the Macintosh. All pictures, including these, are stored as a block of binary data attached to a special chPic character in the text stream. This block always begins with a PIC structure. (Please see the "picture" definition mentioned above for more information on general picture-reading.)
Normal graphics follow the PIC structure with a single Office shape, Windows metafile, bitmap, or TIFF representation, as described in the "picture" definition section. Macintosh PICT graphics have a standard, unchanging Windows metafile after the PIC which always depicts an "x", followed by the actual Macintosh PICT picture. This is for backward-compatibility with older readers, which expect to find a Windows metafile after the PIC structure. These readers will simply display the fixed "x" image. In the Macintosh PICT case, the PIC structure's lcb field represents the size of the entire picture data block, including the PIC itself, the "x" metafile and the Macintosh PICT data. (see the description of the PIC structure in the Structure Definitions section of this document.)
To distinguish between normal and Macintosh PICT graphics, a reader needs to detect the presence of the special "x" metafile. The bytes below are in an early portion of the "x" metafile.
unsigned char rgbWmfXBegin[] =
{
'\x14', '\x00', '\x00', '\x00', '\x26', '\x06', '\x0F', '\x00', '\x1E', '\x00',
'\xFF', '\xFF', '\xFF', '\xFF', '\x04', '\x00', '\x14', '\x00', '\x00', '\x00',
'\x57', '\x6F', '\x72', '\x64', '\x0E', '\x00', '\x4D', '\x69', '\x63', '\x72',
'\x6F', '\x73', '\x6F', '\x66', '\x74', '\x20', '\x57', '\x6F', '\x72', '\x64',
'\x0E', '\x00', '\x00', '\x00', '\x26', '\x06', '\x0F', '\x00', '\x12', '\x00',
'\x57', '\x6F', '\x72', '\x64', '\xFF', '\xFF', '\x08', '\x00', '\x00', '\x00'
/* "x" wmf and PICT data sizes immediately follow as 2 four-byte longs */
};
#define cbMETAHDR 18 // size of a standard Windows metafile header
#define cbWmfXBegin 60 // length of this beginning section of the x metafile
After reading the PIC structure from the picture data block, the reader should skip cbMETAHDR bytes (the size of a standard Windows metafile header). It should then compare the next cbWmfXBegin bytes in the picture data block against the bytes in the rgbWmfXBegin array above. If they do not match, the picture is a normal picture—Windows metafile, bitmap or TIFF.
If they do match, then the reader should read the next 8 bytes in the picture data block as two 4-byte "long"s (Intel 80x86 byte order). These numbers are the sizes (in bytes) of the "x" metafile and the Macintosh PICT data, respectively. The size of the "x" metafile is measured from its start immediately after the PIC structure. It is possible for the PICT's size to be zero. In this case, there is no PICT data, and the reader may use the "x" Windows metafile as the picture's representation.