8.2.2 Pictures

Pictures (including OLE objects) are stored as a sequence of bytes in the text stream. These bytes can be identified as picture information by examining their paragraph formatting. One picture is exactly one paragraph. Paragraphs that are pictures have a special bit set in their paragraph property (PAP) structure. For more information on the PAP structure, see Section 8.3, “Formatting.”

Each picture consists of a descriptive header followed by the data that makes up the picture. The header for OLE objects is different from the one used for pictures. The picture header has the following form:

Byte Name Description

0–7 mfp Windows METAFILEPICT structure (hMF member undefined)
8–9 dxaOffset Offset of picture from left margin, in twips (1/1440 inch)
10–11 dxaSize Horizontal size, in twips
12–13 dyaSize Vertical size, in twips
14–15 cbOldSize Number of following bytes (actual metafile or bitmap bits); set to zero
16–29 bm Additional information for bitmaps only
30–31 cbHeader Number of bytes in this header
32–35 cbSize Number of following bytes (actual metafile or bitmap bits), replacing cbOldSize for new files
36–37 mx Scaling factor (x)
38–39 my Scaling factor (y)
40–? cbHeader Picture contents, through cbHeader+cbSize–1

The mm member (bytes 0–1) of the METAFILEPICT structure specifies the mapping mode used to draw the picture. The last set of bytes will be bitmap bits if the value of the mm member is 0xE3. This is a special value used only in Write. Otherwise, the bytes will be metafile contents.

If the picture has never been rescaled with the Size Picture command in Write, the scaling factors in each direction will be 1000 (decimal). If the picture has been resized, the scaling factor will be the percentage of the original size that the picture is now, relative to 1000 (100 per cent).

For information about the METAFILEPICT structure and bitmaps, see the Microsoft Windows Guide to Programming and the Microsoft Windows Programmer's Reference, Volumes 1 and 3.

The descriptive header for OLE objects is similar to the one used for pictures. The OLE object header has the following form:

Byte Name Description

0–1 mm Must be 0xE4
2–5   Not used
6–7 objectType Type: 1=static, 2=embedded, 3=link
8–9 dxaOffset Offset of picture from left margin, in twips (1/1440 inch)
10–11 dxaSize Horizontal size, in twips
12–13 dyaSize Vertical size, in twips
14–15   Not used
16–19 dwDataSize Number of bytes in the object data that follows the header
20–23   Not used
24–27 dwObjNum Hexadecimal number that, when converted to an 8-digit string, represents the object's unique name
28–29   Not used
30–31 cbHeader Number of bytes in this header
32–35   Not used
36–37 mx Scaling factor (x)
38–39 my Scaling factor (y)
40–? cbHeader Object contents, through cbHeader+dwDataSize–1

The scaling factors for OLE objects work the same way as they do with pictures.