2.3.4.2 EMR_HEADER Record Types

The EMR_HEADER record is the starting point of an EMF metafile. It specifies properties of the device on which the image in the metafile was recorded; this information in the header record makes it possible for EMF metafiles to be independent of any specific output device.

The following are the EMR_HEADER record types.

Name

Section

Description

EmfMetafileHeader

2.3.4.2.1

The original EMF header record.

EmfMetafileHeaderExtension1

2.3.4.2.2

The header record defined in the first extension to EMF, which added support for OpenGL records and an optional internal pixel format descriptor.<62>

EmfMetafileHeaderExtension2

2.3.4.2.3

The header record defined in the second extension to EMF, which added the capability of measuring display dimensions in micrometers.<63>

EMF metafiles SHOULD be created with an EmfMetafileHeaderExtension2 header record.

The generic structure of EMR_HEADER records is specified as follows.

Fields not specified in this section are specified in section 2.3.4.


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

Type

Size

EmfHeader (80 bytes)

...

...

...

EmfHeaderRecordBuffer (variable, optional)

...

Type (4 bytes): An unsigned integer that identifies this record type as EMR_HEADER. This value is 0x00000001.

EmfHeader (80 bytes): A Header object (section 2.2.9), which contains information about the content and structure of the metafile.

EmfHeaderRecordBuffer (variable, optional): An array of bytes that contains the remainder of the EMF header record.


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

EmfHeaderRecordParm (variable)

...

AlignmentPadding (variable, optional)

...

EmfHeaderRecordParm (variable): An array of bytes that contains additional parameters for the EMF header record.

AlignmentPadding (variable, optional): An array of up to 3 bytes that pads the record so that its total size is a multiple of 4 bytes. This field MUST be ignored.

The value of the Size field can be used to distinguish between the different EMR_HEADER record types listed earlier in this section. There are three possible headers:

  • The EmfMetafileHeader record. The fixed-size part of this header is 88 bytes, and it contains a Header object (section 2.2.9).

  • The EmfMetafileHeaderExtension1 record. The fixed-size part of this header is 100 bytes, and it contains a Header object and a HeaderExtension1 object (section 2.2.10).

  • The EmfMetafileHeaderExtension2 record. The fixed-size part of this header is 108 bytes, and it contains a Header object, a HeaderExtension1 object, and a HeaderExtension2 object (section 2.2.11).

There are one or two optional, variable-length fields that are possible in each header: a description string and a pixel format field. In all three types of headers, the fixed-size part comes first, followed by the variable-length fields.

The algorithm shown in the following figure computes a non-negative integer variable called HeaderSize from the offsets and lengths of the variable-length data. The type of header is determined from that value.

Header type determination algorithm

Figure 3: Header type determination algorithm

After applying the algorithm, consider the value of HeaderSize field:

  •  If HeaderSize >= 108, the record type is EmfMetafileHeaderExtension2.

  •  If HeaderSize >= 100, the record type is EmfMetafileHeaderExtension1.

  •  Otherwise, the record type is EmfMetafileHeader.

 See section 2.3.4 for more control record types.