Pictures

An RTF file can include pictures created with other applications. These pictures can be in hexadecimal (the default) or binary format. Pictures are destinations, and begin with the \pict control word. The \pict keyword is preceded by \*\shppict destination control keyword as described in the following example. A picture destination has the following syntax:

<pict> '{' \pict (<brdr>? & <shading>? & <picttype> & <pictsize> & <metafileinfo>?) <data> '}'
<picttype> | \emfblip | \pngblip | \jpegblip | \macpict | \pmmetafile | \wmetafile | \dibitmap <bitmapinfo> | \wbitmap <bitmapinfo>
<bitmapinfo> \wbmbitspixel & \wbmplanes & \wbmwidthbytes
<pictsize> (\picw & \pich) \picwgoal? & \pichgoal? \picscalex? & \picscaley? & \picscaled? & \piccropt? & \piccropb? & \piccropr? & \piccropl?
<metafileinfo> \picbmp & \picbpp
<data> (\bin #BDATA) | #SDATA

These control words are described in the following table. Some measurements in this table are in twips; a twip is one-twentieth of a point.

Control Word Meaning
\emfblip Source of the picture is an EMF (enhanced metafile).
\pngblip Source of the picture is a PNG.
\jpegblip Source of the picture is a JPEG.
\shppict Specifies a Word 97 picture. This is a destination control word.
\nonshppict Specifies that Word 97 has written a {\pict destination that it will not read on input. This keyword is for compatibility with other readers.
\macpict Source of the picture is QuickDraw.
\pmmetafileN Source of the picture is an OS/2 metafile. The N argument identifies the metafile type. The N values are described on page 43 of this Application Note.
\wmetafileN Source of the picture is a Windows metafile. The N argument identifies the metafile type (the default is 1).
\dibitmapN Source of the picture is a Windows device-independent bitmap. The N argument identifies the bitmap type (must equal 0).

The information to be included in RTF from a Windows device-independent bitmap is the concatenation of the BITMAPINFO structure followed by the actual pixel data.

\wbitmapN Source of the picture is a Windows device-dependent bitmap. The N argument identifies the bitmap type (must equal 0).

The information to be included in RTF from a Windows device-dependent bitmap is the result of the GetBitmapBits function.


Example:

{\*\shppict {\pict \emfblip ….. }}{\nonshppict {\pict ….}}

For more information on the GetDIBits and GetBitmapBits functions and the structure of Windows device-independent and device-dependent bitmaps, see Volume 1 and Volume 2 of the Programmer's Reference in the Microsoft Windows 3.1 Software Development Kit. For best device-independence and interoperability with Microsoft products, however, use of the \wbitmap and \dibitmap control words is discouraged. Rather, bitmaps should be embedded within Windows metafiles and the \wmetafile control word used. For more information on embedding bitmaps within metafiles, see Volume 1 and Volume 2 of the Programmer's Reference in the Microsoft Windows 3.1 Software Development Kit.

Control word Meaning
Bitmap Information
\wbmbitspixelN Number of adjacent color bits on each plane needed to define a pixel (the default is 1). Possible values are 1 (monochrome), 4 (16 colors), 8 (256 colors) and 24 (RGB).
\wbmplanesN Number of bitmap color planes (must equal 1).
\wbmwidthbytesN Specifies the number of bytes in each raster line. This value must be an even number because the Windows graphics device interface (GDI) assumes that the bit values of a bitmap form an array of integer (two-byte) values. In other words, \wbmwidthbytes times 8 must be the next multiple of 16 greater than or equal to the \picw (bitmap width in pixels) value.
Picture Size, Scaling, and Cropping
\picwN xExt field if the picture is a Windows metafile; picture width in pixels if the picture is a bitmap or from QuickDraw. The N argument is a long integer.
\pichN yExt field if the picture is a Windows metafile; picture height in pixels if the picture is a bitmap or from QuickDraw. The N argument is a long integer.
\picwgoalN Desired width of the picture in twips. The N argument is a long integer.
\pichgoalN Desired height of the picture in twips. The N argument is a long integer.
\picscalexN Horizontal scaling value. The N argument is a value representing a percentage (the default is 100).
\picscaleyN Vertical scaling value. The N argument is a value representing a percentage (the default is 100).
\picscaled Scales the picture to fit within the specified frame. Used only with \macpict pictures.
\picprop Indicates there are shape properties applied to an inline picture. This is a destination control word.
\piccroptN Top cropping value in twips. A positive value crops toward the center of the picture; a negative value crops away from the center, adding a space border around picture (the default is 0).
\piccropbN Bottom cropping value in twips. A positive value crops toward the center of the picture; a negative value crops away from the center, adding a space border around picture (the default is 0).
\piccroplN Left cropping value in twips. A positive value crops toward the center of the picture; a negative value crops away from the center, adding a space border around picture (the default is 0).
\piccroprN Right cropping value in twips. A positive value crops toward the center of the picture; a negative value crops away from the center, adding a space border around picture (the default is 0).
Metafile Information
\picbmp Specifies whether a metafile contains a bitmap.
\picbppN Specifies the bits per pixel in a metafile bitmap. The valid range is 1–32, with 1, 4, 8, and 24 being recognized.
Picture Data
\binN The picture is in binary format. The numeric parameter N is the number of bytes that follow. Unlike all other controls, this control word takes a 32-bit parameter.
\blipupiN N represents units per inch on a picture (only certain image types need or output this)
\blipuid XXXXX Used as: {\*\blipuid XXXXX} where XXXX is a 16-byte identification number for the image.
\bliptagN A mostly unique identifier for a picture, where N is a long integer value.

The \wbitmap control word is optional. If no other picture type is specified, the picture is assumed to be a Windows bitmap. If \wmetafile is specified, the N argument can be one of the following types.

Type N argument
MM_TEXT 1
MM_LOMETRIC 2
MM_HIMETRIC 3
MM_LOENGLISH 4
MM_HIENGLISH 5
MM_TWIPS 6
MM_ISOTROPIC 7
MM_ANISOTROPIC 8

For more information about these types, see volume 1 of the Programmer’s Reference in the Microsoft Windows 3.1 Software Development Kit.

If \pmmetafile is specified, the N argument can be one of the following types.

Type N argument
PU_ARBITRARY 0x0004
PU_PELS 0x0008
PU_LOMETRIC 0x000C
PU_HIMETRIC 0x0010
PU_LOENGLISH 0x0014
PU_HIENGLISH 0x0018
PU_TWIPS 0x001C

For more information about these types, see volume 2 of the OS/2 Programmer’s Reference.

Be careful with spaces following control words when dealing with pictures in binary format. When reading files, RTF considers the first space after a control word the delimiter and subsequent spaces part of the document text. Therefore, any extra spaces are attached to the picture, with unpredictable results.

RTF writers should not use the carriage-return/linefeed (CR/LF) combination to break up pictures in binary format. If they do, the CR/LF combination is treated as literal text and considered part of the picture data.

The picture in hexadecimal or binary format follows the picture-destination control words. The following example illustrates the destination format:

{\pict\wbitmap0\picw170\pich77\wbmbitspixel1\wbmplanes1\wbmwidthbytes22
\picwgoal505
\pichgoal221
\picscalex172
\picscaley172
49f2000000000273023d1101a030
3901000a000000000273023d98
0048000200000275
02040000200010275023e000000000
273023d000002b90002b90002
b90002b90002b9
0002b90002b90002b90002b90002b90002
b92222b90002b90002b90
002b90002b9
0002b90002b90002b90002b9000