3.2 WMF Metafile Example

This section provides an example of a metafile which, when processed, renders the following image.

Figure 2: WMF metafile example

The contents of this metafile example are shown in the following in hexadecimal bytes. The far-left column is the byte count; the far-right characters are the interpretation of the bytes in the Latin-1 ANSI Character Set, as specified in [ISO/IEC-8859-1]. The sections that follow describe the packets that convey this series of bytes.

 
00000000: 01 00 09 00 00 03 36 00 00 00 02 00 0C 00 00 00 …...6......... 
00000010: 00 00 08 00 00 00 FA 02 04 00 00 00 00 00 00 00 ......ú......... 
00000020: FF 00 04 00 00 00 2D 01 00 00 07 00 00 00 FC 02 ÿ.....-.......ü. 
00000030: 02 00 00 FF 00 FF 04 00 04 00 00 00 2C 01 01 00 ...ÿ.ÿ......,... 
00000040: 07 00 00 00 1B 04 46 00 96 00 00 00 00 00 0C 00 ......F.–....... 
00000050: 00 00 21 05 0C 00 48 65 6C 6C 6F 20 50 65 6F 70 ..!...Hello Peop 
00000060: 6C 65 0A 00 0A 00 03 00 00 00 00 00             le.......... 
 

Note When a WMF metafile is processed, the order in which graphics are rendered corresponds to the order of records in the metafile. This can create challenges for devices that have layers. For example, Printer Command Language (PCL) defines a graphics layer and a text layer. The text layer in PCL is always drawn on top of the graphics layer. Thus, when converting from metafile format to PCL, the converter, to generate the correct output, either detects text/graphic overlaps and sends the text down as graphics, or always sends the text as graphics. The sections that follow provide definitions of the WMF header and records that correspond to this metafile. The WMF Object Table (section 3.1.4.1) refers to an indexed table of WMF Object that are defined in the metafile.

3.2.1 META_HEADER Example

This section provides an example of a META_HEADER (section 2.3.2.2) record, which is always the first record in the metafile.

 
00000000: 01 00 09 00 00 03 36 00 00 00 02 00 0C 00 00 00 
00000010: 00 00 


Figure 3: META_HEADER record example

Type: 0x0001 specifies the type of metafile from the MetafileType Enumeration (section 2.1.1.18) to be a metafile stored in memory.

HeaderSize: 0x0009 specifies the number of WORDs in this record, which is equivalent to 18 (0x0012) bytes.

Version: 0x0300 specifies the metafile version from the MetafileVersion Enumeration (section 2.1.1.19) to be a WMF metafile that supports DIBs.

Size: 0x00000036 specifies the number of WORDs in the entire metafile, which is equivalent to 108 (0x0000006C) bytes.

NumberOfObjects: 0x0002 specifies the number of graphics objects that are defined in the metafile.

MaxRecord: 0x0000000C specifies the size in WORDs of the largest record in the metafile, which is equivalent to 24 (0x00000018) bytes.

NumberOfMembers: 0x0000 is not used.

Note Based on the value of the NumberOfObjects field, a WMF Object Table (section 3.1.4.1) can be created that is large enough for 2 objects.

3.2.2 META_CREATEPENINDIRECT Example

This section provides an example of a META_CREATEPENDIRECT record.

 
00000010:       08 00 00 00 FA 02 04 00 00 00 00 00 00 00 
00000020: FF 00 


Figure 4: META_CREATEPENINDIRECT record example

RecordSize: 0x00000008 specifies the number of WORDs in this record, which is equivalent to 16 (0x00000010) bytes.

RecordFunction: 0x02FA specifies a META_CREATEPENINDIRECT record from the RecordType Enumeration (section 2.1.1.1).

Pen Object: A Pen Object that defines the pen to create.


Figure 5: Pen Object example

PenStyle: 0x0004 specifies the PS_DASHDOTDOT style from the PenStyle Enumeration (section 2.1.1.23).

PointS Object: A PointS Object that specifies the width of the pen.


Figure 6: PointS Object example

x: 0x0000 specifies the width of the pen to be the default, which is 1 pixel.

y: 0x0000 is not used.

ColorRef Object: A ColorRef Object that specifies a green pen color.


Figure 7: ColorRef Object example

Reserved: 0x00 is not used.

Blue: 0x00 specifies no blue.

Green: 0xFF specifies full intensity of green.

Red: 0x00 specifies no red.

Note The Pen Object created by processing this record is assigned index 0 in the WMF Object Table (section 3.1.4.1).

3.2.3 META_SELECTOBJECT Example 1

This section provides an example of a META_SELECTOBJECT record.

 
00000020:       04 00 00 00 2D 01 00 00


Figure 8: META_SELECTOBJECT record example

RecordSize: 0x00000004 specifies the number of WORDs in this record, which is equivalent to 8 (0x00000008) bytes.

RecordFunction: 0x012D specifies the type of this record from the RecordType Enumeration (section 2.1.1.1) to be META_SELECTOBJECT.

ObjectIndex: 0x0000 specifies the index in the WMF Object Table (section 3.1.4.1) of the object being selected, which is the Pen Object created in the previous record.

3.2.4 META_CREATEBRUSHINDIRECT Example

This section provides an example of a META_CREATEBRUSHINDIRECT record.

 
00000020:                               07 00 00 00 FC 02 
00000030: 02 00 00 FF 00 FF 04 00


Figure 9: META_CREATEBRUSHINDIRECT record example

RecordSize: 0x00000007 specifies the number of WORDs in this record, which is equivalent to 14 (0x0000000E) bytes.

RecordFunction: 0x02FC specifies a META_CREATEBRUSHINDIRECT record from the RecordType Enumeration (section 2.1.1.1).

LogBrush Object: A LogBrush Object that defines the brush to create.


Figure 10: LogBrush Object example

BrushStyle: 0x0002 specifies the BS_HATCHED style from the BrushStyle Enumeration (section 2.1.1.4).

ColorRef Object: A ColorRef Object that specifies a magenta brush color.


Figure 11: ColorRef Object example

Reserved: 0x00 is not used.

Blue: 0xFF specifies full intensity blue.

Green: 0x00 specifies no green.

Red: 0xFF specifies full intensity red.

BrushHatch: 0x0004 specifies the hatch style from the HatchStyle Enumeration (section 2.1.1.12), a horizontal and vertical cross-hatch.

Note The Brush Object created by processing this record is assigned index 1 in the WMF Object Table (section 3.1.4.1).

3.2.5 META_SELECTOBJECT Example 2

This section provides an example of a META_SELECTOBJECT record.

 
00000030:                         04 00 00 00 2D 01 01 00  


Figure 12: META_SELECTOBJECT record example

RecordSize: 0x00000004 specifies the number of WORDs in this record, which is equivalent to 8 (0x00000008) bytes.

RecordFunction: 0x012D specifies the type of this record from the RecordType Enumeration (section 2.1.1.1) to be META_SELECTOBJECT.

ObjectIndex: 0x0001 specifies the index in the WMF Object Table (section 3.1.4.1) of the object being selected, which is the Brush Object created in the previous record.

3.2.6 META_RECTANGLE Example

This section provides an example of a META_RECTANGLE record.

 
00000040: 07 00 00 00 1B 04 46 00 96 00 00 00 00 00 


Figure 13: META_RECTANGLE Record Example

RecordSize: 0x0000007 specifies the number of WORDs in this record, which is equivalent to 14 (0x0000000E) bytes.

RecordFunction: 0x041B defines the type of this record from the RecordType Enumeration (section 2.1.1.1) to be META_RECTANGLE.

BottomRect: 0x0046 defines the y-coordinate, in logical units, of the lower-right corner of the rectangle.

RightRect: 0x0096 defines the x-coordinate, in logical units, of the lower-right corner of the rectangle.

TopRect: 0x0000 defines the y-coordinate, in logical units, of the upper-left corner of the rectangle.

LeftRect: 0x0000 defines the x-coordinate, in logical units, of the upper-left corner of the rectangle.

3.2.7 META_TEXTOUT Example

This section provides an example of a META_TEXTOUT record.

 
0000004E:                                           0C 00 
00000050: 00 00 21 05 0C 00 48 65 6C 6C 6F 20 50 65 6F 70 
00000060: 6C 65 0A 00 0A 00 


Figure 14: META_TEXTOUT record example

RecordSize: 0x0000000C specifies the number of WORDs in this record, which is equivalent to 24 (0x00000018) bytes.

RecordFunction: 0x0521 specifies the META_TEXTOUT record from the RecordType Enumeration (section 2.1.1.1).

StringLength: 0x000C specifies the length of the string in bytes.

String: "Hello People" specifies the text to be drawn.

YStart: 0x000A specifies the vertical (y-axis) coordinate, in logical units, of the point where drawing is to start.

XStart: 0x000A specifies the horizontal (x-axis) coordinate, in logical units, of the point where drawing is to start.

3.2.8 META_EOF Example

This section provides an example of a META_EOF record, which is always the last record in the metafile.

 
00000060:                   03 00 00 00 00 00 


Figure 15: META_EOF record example

RecordSize: 0x00000003 specifies the number of WORDs in this record, which is equivalent to 6 (0x00000006) bytes.

RecordFunction: 0x0000 specifies the type of this record from the RecordType Enumeration