An EMF file is a list of records. Each one starts with its Type (u32) and
Size (u32, in bytes, a multiple of 4), and the fields listed below follow.
The header is the first record and
EMR_EOF the last. The numbers come from the MS-EMF
RecordType enumeration; fields come from the C structures in
wingdi.h. Where no fields are listed here, see the MS-EMF section for that
record.
Drawing records
| Value | Name | Fields after Size | Meaning |
|---|---|---|---|
| 0x02 | EMR_POLYBEZIER | Bounds RectL, count u32, PointL[count] | Bezier curves. |
| 0x03 | EMR_POLYGON | Bounds RectL, count u32, PointL[count] | Closed polygon. |
| 0x04 | EMR_POLYLINE | Bounds RectL, count u32, PointL[count] | Connected lines. |
| 0x05 | EMR_POLYBEZIERTO | Bounds RectL, count u32, PointL[count] | Beziers from the current position. |
| 0x06 | EMR_POLYLINETO | Bounds RectL, count u32, PointL[count] | Lines from the current position. |
| 0x07 | EMR_POLYPOLYLINE | Bounds RectL, nPolys u32, total u32, nPolys u32 counts, PointL points | Several polylines. |
| 0x08 | EMR_POLYPOLYGON | Same layout as EMR_POLYPOLYLINE | Several polygons. |
| 0x0F | EMR_SETPIXELV | Pixel PointL, ColorRef | Set one pixel. |
| 0x29 | EMR_ANGLEARC | Center PointL, radius u32, start float, sweep float | Arc on a circle. |
| 0x2A | EMR_ELLIPSE | Box RectL | Ellipse. |
| 0x2B | EMR_RECTANGLE | Box RectL | Rectangle. |
| 0x2C | EMR_ROUNDRECT | Box RectL, corner SizeL | Rectangle with rounded corners. |
| 0x2D | EMR_ARC | Box RectL, start PointL, end PointL | Elliptical arc. |
| 0x2E | EMR_CHORD | Box RectL, start PointL, end PointL | Chord. |
| 0x2F | EMR_PIE | Box RectL, start PointL, end PointL | Pie wedge. |
| 0x35 | EMR_EXTFLOODFILL | Point, colour, mode | Flood fill. |
| 0x36 | EMR_LINETO | PointL | Line to a point. |
| 0x37 | EMR_ARCTO | Box RectL, start PointL, end PointL | Arc that moves the current position. |
| 0x38 | EMR_POLYDRAW | Bounds, count, points, a type byte per point | Lines and Beziers. |
| 0x47 | EMR_FILLRGN | Fill a region with a brush. | |
| 0x48 | EMR_FRAMERGN | Border around a region. | |
| 0x49 | EMR_INVERTRGN | Invert a region. | |
| 0x4A | EMR_PAINTRGN | Paint a region with the current brush. | |
| 0x53 | EMR_EXTTEXTOUTA | Same layout as EMR_EXTTEXTOUTW | ASCII text. |
| 0x54 | EMR_EXTTEXTOUTW | Bounds RectL, iGraphicsMode u32, exScale float, eyScale float, EmrText | Unicode text. |
| 0x55 | EMR_POLYBEZIER16 | Bounds RectL, count u32, PointS[count] | 16-bit form. |
| 0x56 | EMR_POLYGON16 | Bounds RectL, count u32, PointS[count] | 16-bit form. |
| 0x57 | EMR_POLYLINE16 | Bounds RectL, count u32, PointS[count] | 16-bit form. |
| 0x58 | EMR_POLYBEZIERTO16 | Bounds RectL, count u32, PointS[count] | 16-bit form. |
| 0x59 | EMR_POLYLINETO16 | Bounds RectL, count u32, PointS[count] | 16-bit form. |
| 0x5A | EMR_POLYPOLYLINE16 | Bounds, nPolys, total, counts, PointS | 16-bit form. |
| 0x5B | EMR_POLYPOLYGON16 | Bounds, nPolys, total, counts, PointS | 16-bit form. |
| 0x5C | EMR_POLYDRAW16 | Bounds, count, PointS, type bytes | 16-bit form. |
| 0x60 | EMR_POLYTEXTOUTA | Several ASCII strings. | |
| 0x61 | EMR_POLYTEXTOUTW | Several Unicode strings. | |
| 0x6C | EMR_SMALLTEXTOUT | A compact text record. | |
| 0x76 | EMR_GRADIENTFILL | Bounds, nVer, nTri, ulMode, TriVertex[nVer], then rectangles or triangles | Gradient fill. |
EmrText holds the reference point, character count, string offset, options,
clip rectangle and spacing offset: ptlReference (PointL),
nChars, offString, fOptions, rcl
(RectL), offDx.
Path records
| Value | Name | Fields | Meaning |
|---|---|---|---|
| 0x3B | EMR_BEGINPATH | None | Open a path. |
| 0x3C | EMR_ENDPATH | None | Close the path and select it. |
| 0x3D | EMR_CLOSEFIGURE | None | Close the open figure. |
| 0x3E | EMR_FILLPATH | Bounds RectL | Fill the path. |
| 0x3F | EMR_STROKEANDFILLPATH | Bounds RectL | Stroke and fill. |
| 0x40 | EMR_STROKEPATH | Bounds RectL | Stroke. |
| 0x41 | EMR_FLATTENPATH | None | Turn curves into lines. |
| 0x42 | EMR_WIDENPATH | None | Widen the path to the pen. |
| 0x43 | EMR_SELECTCLIPPATH | RegionMode | Use the path as clip region. |
| 0x44 | EMR_ABORTPATH | None | Discard the path. |
Bitmap records
| Value | Name | Fields after Size | Meaning |
|---|---|---|---|
| 0x4C | EMR_BITBLT | Bounds RectL, xDest, yDest, cxDest, cyDest (s32), dwRop u32, xSrc, ySrc s32, xformSrc XForm, crBkColorSrc, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc (u32) | Block transfer. |
| 0x4D | EMR_STRETCHBLT | Same as EMR_BITBLT, then cxSrc, cySrc (s32) | With stretching. |
| 0x4E | EMR_MASKBLT | Block transfer with a mask. | |
| 0x4F | EMR_PLGBLT | Transfer to a parallelogram. | |
| 0x50 | EMR_SETDIBITSTODEVICE | Pixels from DIB scan lines. | |
| 0x51 | EMR_STRETCHDIBITS | Bounds RectL, xDest, yDest, xSrc, ySrc, cxSrc, cySrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, iUsageSrc, dwRop, cxDest, cyDest | Stretch a DIB. |
| 0x72 | EMR_ALPHABLEND | Same layout as EMR_STRETCHBLT | Copy with alpha. |
| 0x74 | EMR_TRANSPARENTBLT | Copy with one colour transparent. |
Bitmap headers and pixels are stored inside the record at
offBmiSrc and offBitsSrc and use the same formats as a
BMP DIB.
Object records
| Value | Name | Fields after Size | Meaning |
|---|---|---|---|
| 0x25 | EMR_SELECTOBJECT | ihObject u32 | Select an object, or a stock object if the top bit is set. |
| 0x26 | EMR_CREATEPEN | ihPen u32, LogPen | Create a pen. |
| 0x27 | EMR_CREATEBRUSHINDIRECT | ihBrush u32, LogBrush | Create a brush. |
| 0x28 | EMR_DELETEOBJECT | ihObject u32 | Delete an object. |
| 0x30 | EMR_SELECTPALETTE | ihPal u32 | Select a palette. |
| 0x31 | EMR_CREATEPALETTE | ihPal u32, LogPalette | Create a palette. |
| 0x32 | EMR_SETPALETTEENTRIES | Set colours in a palette. | |
| 0x33 | EMR_RESIZEPALETTE | Resize a palette. | |
| 0x34 | EMR_REALIZEPALETTE | Map to the system palette. | |
| 0x52 | EMR_EXTCREATEFONTINDIRECTW | ihFont u32, ExtLogFontW | Create a font. |
| 0x5D | EMR_CREATEMONOBRUSH | Brush from a bitmap. | |
| 0x5E | EMR_CREATEDIBPATTERNBRUSHPT | Brush from a DIB. | |
| 0x5F | EMR_EXTCREATEPEN | ihPen u32, offBmi, cbBmi, offBits, cbBits u32, ExtLogPen32 | Extended pen. |
| 0x63 | EMR_CREATECOLORSPACE | Colour space, ASCII profile name. | |
| 0x64 | EMR_SETCOLORSPACE | Select a colour space. | |
| 0x65 | EMR_DELETECOLORSPACE | Delete a colour space. | |
| 0x6F | EMR_COLORCORRECTPALETTE | Correct palette entries. | |
| 0x7A | EMR_CREATECOLORSPACEW | Colour space, Unicode profile name. |
State records
| Value | Name | Fields | Meaning |
|---|---|---|---|
| 0x09 | EMR_SETWINDOWEXTEX | SizeL | Window extent. |
| 0x0A | EMR_SETWINDOWORGEX | PointL | Window origin. |
| 0x0B | EMR_SETVIEWPORTEXTEX | SizeL | Viewport extent. |
| 0x0C | EMR_SETVIEWPORTORGEX | PointL | Viewport origin. |
| 0x0D | EMR_SETBRUSHORGEX | PointL | Brush origin. |
| 0x10 | EMR_SETMAPPERFLAGS | u32 | Font mapper flags. |
| 0x11 | EMR_SETMAPMODE | iMode u32 | Map mode. |
| 0x12 | EMR_SETBKMODE | iMode u32 | Background mode. |
| 0x13 | EMR_SETPOLYFILLMODE | iMode u32 | Polygon fill mode. |
| 0x14 | EMR_SETROP2 | iMode u32 | Foreground mix. |
| 0x15 | EMR_SETSTRETCHBLTMODE | iMode u32 | Stretch mode. |
| 0x16 | EMR_SETTEXTALIGN | u32 | Text alignment. |
| 0x17 | EMR_SETCOLORADJUSTMENT | Colour adjustment. | |
| 0x18 | EMR_SETTEXTCOLOR | ColorRef | Text colour. |
| 0x19 | EMR_SETBKCOLOR | ColorRef | Background colour. |
| 0x1A | EMR_OFFSETCLIPRGN | PointL | Move the clip region. |
| 0x1B | EMR_MOVETOEX | PointL | Current position. |
| 0x1C | EMR_SETMETARGN | None | Combine clip region into the metaregion. |
| 0x1D | EMR_EXCLUDECLIPRECT | RectL | Remove a rectangle from the clip. |
| 0x1E | EMR_INTERSECTCLIPRECT | RectL | Intersect the clip. |
| 0x1F | EMR_SCALEVIEWPORTEXTEX | Ratios | Scale the viewport. |
| 0x20 | EMR_SCALEWINDOWEXTEX | Ratios | Scale the window. |
| 0x21 | EMR_SAVEDC | None | Save the state. |
| 0x22 | EMR_RESTOREDC | iRelative s32 | Restore a saved state. |
| 0x23 | EMR_SETWORLDTRANSFORM | XForm | World transform. |
| 0x24 | EMR_MODIFYWORLDTRANSFORM | XForm, iMode u32 | Modify the transform. |
| 0x39 | EMR_SETARCDIRECTION | u32 | Arc direction. |
| 0x3A | EMR_SETMITERLIMIT | float | Miter limit. |
| 0x4B | EMR_EXTSELECTCLIPRGN | Combine with the clip region. | |
| 0x62 | EMR_SETICMMODE | u32 | Colour management mode. |
| 0x68 | EMR_PIXELFORMAT | Pixel format. | |
| 0x6D | EMR_FORCEUFIMAPPING | Font mapping by id. | |
| 0x70 | EMR_SETICMPROFILEA | Colour profile, ASCII name. | |
| 0x71 | EMR_SETICMPROFILEW | Colour profile, Unicode name. | |
| 0x73 | EMR_SETLAYOUT | u32 | Text and graphics order. |
| 0x77 | EMR_SETLINKEDUFIS | Linked fonts. | |
| 0x78 | EMR_SETTEXTJUSTIFICATION | Extra space on break characters. | |
| 0x79 | EMR_COLORMATCHTOTARGETW | Colour matching to a target. |
Other records
| Value | Name | Meaning |
|---|---|---|
| 0x01 | EMR_HEADER | See Header. |
| 0x0E | EMR_EOF | End of file. Fields: nPalEntries, offPalEntries, optional palette, SizeLast (the record’s size again, last in the file). |
| 0x46 | EMR_COMMENT | Comment. Fields: DataSize, then the data. |
| 0x66 | EMR_GLSRECORD | OpenGL function. |
| 0x67 | EMR_GLSBOUNDEDRECORD | OpenGL function with bounds. |
| 0x69 | EMR_DRAWESCAPE | Data for the driver, intended to draw. |
| 0x6A | EMR_EXTESCAPE | Data for the driver, not drawing. |
| 0x6E | EMR_NAMEDESCAPE | Data for a named driver. |
Values not listed, such as 0x45, 0x6B and 0x75, have no named record type in the MS-EMF list.
Comments and EMF+
A comment record holds DataSize and then the data. If the data starts with
one of the identifiers below, it is one of the defined comment types. Any other start
means private application data.
| Value | Name | Meaning |
|---|---|---|
0x00000000 | EMR_COMMENT_EMFSPOOL | Holds EMFSPOOL records (MS-EMFSPOOL). |
0x2B464D45 | EMR_COMMENT_EMFPLUS | Bytes EMF+. Holds EMF+ records (MS-EMFPLUS). |
0x43494447 | EMR_COMMENT_PUBLIC | Bytes GDIC. Extension comments. |
A public comment identifies its type next:
| Value | Name | Meaning |
|---|---|---|
0x80000001 | EMR_COMMENT_WINDOWS_METAFILE | Holds a WMF image. |
0x00000002 | EMR_COMMENT_BEGINGROUP | Starts a group of drawing records. |
0x00000003 | EMR_COMMENT_ENDGROUP | Ends a group. |
0x40000004 | EMR_COMMENT_MULTIFORMATS | Several definitions of the same image, for example EPS and EMF. |
0x00000040 | EMR_COMMENT_UNICODE_STRING | Reserved, must not be used. |
0x00000080 | EMR_COMMENT_UNICODE_END | Reserved, must not be used. |
In EMR_COMMENT_MULTIFORMATS, each format starts with a signature:
0x464D4520 “ EMF” for EMF data or 0x46535045 “EPSF” for
PostScript. EMF+ is a separate format, specified in
[MS-EMFPLUS].
Its own record set is not listed on this site; a program that only knows plain EMF
plays the plain records that normally accompany it.
Stock objects
An object index with the top bit set is a stock object.
| Value | Name | Value | Name |
|---|---|---|---|
0x80000000 | WHITE_BRUSH | 0x80000001 | LTGRAY_BRUSH |
0x80000002 | GRAY_BRUSH | 0x80000003 | DKGRAY_BRUSH |
0x80000004 | BLACK_BRUSH | 0x80000005 | NULL_BRUSH |
0x80000006 | WHITE_PEN | 0x80000007 | BLACK_PEN |
0x80000008 | NULL_PEN | 0x8000000A | OEM_FIXED_FONT |
0x8000000B | ANSI_FIXED_FONT | 0x8000000C | ANSI_VAR_FONT |
0x8000000D | SYSTEM_FONT | 0x8000000E | DEVICE_DEFAULT_FONT |
0x8000000F | DEFAULT_PALETTE | 0x80000010 | SYSTEM_FIXED_FONT |
0x80000011 | DEFAULT_GUI_FONT | 0x80000012 | DC_BRUSH |
0x80000013 | DC_PEN |
Code values
| Field | Values |
|---|---|
| Graphics mode | 1 GM_COMPATIBLE, 2 GM_ADVANCED |
| Arc direction | 1 AD_COUNTERCLOCKWISE, 2 AD_CLOCKWISE |
| World transform mode | 1 MWT_IDENTITY, 2 MWT_LEFTMULTIPLY, 3 MWT_RIGHTMULTIPLY |
| Region mode | 1 RGN_AND, 2 RGN_OR, 3 RGN_XOR, 4 RGN_DIFF, 5 RGN_COPY |
| Point type | PT_CLOSEFIGURE 1, PT_LINETO 2, PT_BEZIERTO 4, PT_MOVETO 6 |
| Map mode, ROP2, brush, pen, stretch and fill modes | As in WMF; the pen style also has PS_GEOMETRIC 0x10000. |