Windows Metafile

{{Short description|File format for images}}

Windows Metafile (WMF) is an image file format originally designed for Microsoft Windows in the 1990s. The original Windows Metafile format was not device-independent (though could be made more so with placement headers) and may contain both vector graphics and bitmap components. It acts in a similar manner to SVG files. WMF files were later superseded by Enhanced Metafiles (EMF files) which did provide for device-independence. EMF files were then themselves enhanced via EMF+ files.

Essentially, a metafile stores a list of records consisting of drawing commands, property definitions and graphics objects to display an image on screen.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|page=16}} The drawing commands used are closely related to the commands of the Graphics Device Interface (GDI) API used for drawing in Microsoft Windows.

There are three major types of metafiles – a WMF is a 16-bit format introduced in Windows 3.0. It is the native vector format for Microsoft Office applications such as Word, PowerPoint, and Publisher. {{As of|2024|April}}, revision 18 of the Windows Metafile Format specification is available.{{cite web |date=2021-04-26 |title=[MS-WMF]: Windows Metafile Format |url=http://msdn.microsoft.com/en-us/library/cc250370.aspx |access-date=2023-09-13 |publisher=MSDN}} EMF files, which replaced WMF files, work on the same principle only it is a 32-bit file format that also allows for the embedding of private data within "comment" records.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Enhanced Metafile Format|publisher=Microsoft|page=17}} EMF+ is an extension to EMF files and embedded in these comment records, allowing for images and text using commands, objects and properties that are similar to Windows GDI+.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMFPLUS/%5bMS-EMFPLUS%5d.pdf|title=[MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions|publisher=Microsoft|page=19}}

History

The original 16 bit WMF file format was fully specified in volume 4 of the 1992 Windows 3.1 SDK documentationMicrosoft Windows 3.1 Programmers Reference, Volume 4 Resources, Microsoft Press 1992, {{ISBN|1-55615-494-1}}, chapter 3 pp. 21-45 (at least if combined with the descriptions of the individual functions and structures in the other volumes), but that specification was vague about a few details. These manuals were published as printed books available in bookstores with no click through EULA or other unusual licensing restrictions (just a general warning that if purchased as part of a software bundle, the software would be subject to one).

Over time the existence of that historic specification was largely forgotten and some alternative implementations resorted to reverse engineering to figure out the file format from existing WMF files, which was difficult and error prone.{{cite web | url=http://wvware.sourceforge.net/caolan/support.html | title=Window Metafile (wmf) Reference | quote=These opcodes are unimplemented, for the reason that i dont know what they are, no known documentation | author=Caolan McNamara | access-date=2008-06-01}} In September 2006, Microsoft again published the WMF file format specification in a more complete form{{cite web | url=http://msdn.microsoft.com/en-us/library/cc215212.aspx | title=[MS-WMF]: Windows Metafile Format Specification | access-date=2008-06-01 }} in the context of the Microsoft Open Specification Promise, promising to not assert patent rights to file format implementors.{{cite web | url=http://www.microsoft.com/interop/osp/ | title=Microsoft Open Specification Promise | website=Microsoft | access-date=2008-06-01 }}

Microsoft later deprecated WMF files in favour of 32-bit EMF files as WMF files had real issues with device independence, despite the use of a "placeable" file header which provided basic device independence. Microsoft found that developers who use the format were "[embedding] application, location, or scaling comments in the metafiles... Others added headers to the metafile that provided various application-specific information", causing major compatibility issues.{{citation|title=Enhanced Metafiles in Win32|publisher=Microsoft Developer Network Technology Group|date=June 10, 1993|url=http://www.massmind.org/techref/fileext/emf/enh_meta.htm}} Thus, in 1992 with Windows NT 3.1, Microsoft introduced the Enhanced Metafile format (EMF){{cite IETF|title = Windows Image Media Types|rfc = 7903|sectionname = Windows Metafiles|page = 1|last1 = Leonard|first1 = Sean|date = September 2016|publisher = IETF|access-date = February 8, 2020|issn = 2070-1721|doi = 10.17487/RFC7903}} — a format which was based on the Win32 API and with which they built-in device independence.{{citation|url=https://wiki.fileformat.com/image/emf/|title=EMF|work=FileFormat|date=11 October 2019|publisher=Aspose Pty Ltd|access-date=2020-01-20}} — these were also known as NT metafiles.{{citation|title=NT Metafiles and GDI Objects|first=Charles|last=Petzold|author-link=Charles Petzold|work=PC Magazine|date=October 11, 1994|pages=343–347|url=https://books.google.com/books?id=fy_G-xlQbE8C&pg=PA345}} With the release of Windows XP and GDI+, the set of records had to be significantly increased and so Microsoft released EMF+ as an extension to the existing EMF file format.{{cite book|title=Graphics Programming with GDI+ & DirectX|publisher=A-List Publishing|page=68|year=2005|first1=Alex|last1=Polyakov|first2=Vitaly|last2=Brusentsev|isbn=1-931769-39-7|url=https://books.google.com/books?id=MJ_VAwAAQBAJ&pg=PA68}}

Metafile structure

File:Microsoft Metafile comparisons.svg

WMF, EMF and EMF+ files all consist of a series of records that are played back to produce graphical output. Some records define objects which can specify graphical objects used to determine how graphics should be drawn (e.g. pens specify the color and width of lines). Each of these objects are stored in metafiles and are placed into an object table, which tracks the usage of graphic objects while processing the metafile. The object table is an associative array of indexes to graphical object structures defined within the metafile.

WMF and EMF files handle object processing differently to EMF+ records in EMF files. As a WMF and EMF file is being processed, the records are read into an object table once an object is defined. If an object is deleted then the object is released from the table and the identifier can be reused. Notably an object will not be used until it is specifically selected during record playback.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Enhanced Metafile Format|publisher=Microsoft|page=187|section=3.1.4.1 WMF Object Table}}{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Windows Metafile Format Specification|publisher=Microsoft|pages=212–214|section=3.1.1.1 EMF Object Table}} This differs for EMF+ files, which also use an associative array via a hashmap which records the object along with an object identifier. However, unlike WMF and EMF files which can delete an object, when a new object is created that has the same index as an existing object, the entry in the table is replaced with the new object. An EMF file also does not need to specifically select an object before it is used.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMFPLUS/%5bMS-EMFPLUS%5d.pdf|pages=204–205|title=[MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions|publisher=Microsoft}}

=WMF=

{{Infobox file format

| name = Windows Metafile

| icon =

| logo =

| extension = .wmf

| mime = image/wmf

| type code =

| uniform type = com.microsoft.wmf

| magic =

| released =

| latest release version =

| latest release date =

| type = Vector graphics

| container for =

| contained by =

| extended from =

| extended to = EMF

| standard =

| open =

| free =

}}

File:WMF-structure.svg

WMF files were not originally designed to be device independent, meaning that a file could not be played back on output devices that differed from the original device on which the file was recorded. A partial solution to this issue was invented by Aldus Corporation, who added an additional "placeable" header, called the "APM header",{{citation|title=Q66949: INFO: Windows Metafile Functions & Aldus Placeable Metafiles|publisher=Microsoft|url=https://jeffpar.github.io/kbarchive/kb/066/Q66949/|via=KnowledgeBase Archive: An Archive of Early Microsoft KnowledgeBase }} which added a bounding rectangle, a metafile version, metafile size, number of objects in the metafile and the size of the largest single record in the metafile.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|page=17|section=1.3.1 Metafile Structure}}{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|section=2.3.2.3 META_PLACEABLE Record|page=115}} This was later incorporated into the WMF format by Microsoft, starting in Windows 2000.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|page=55|quote=<55> Section 2.3.2.3: Windows NT 3.1, Windows NT 3.5, Windows NT 3.51, and Windows 95: This feature is not supported.}}

WMF files are structured by a series of records, starting with a number of control records: the header record,{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|section=2.3.2.2 MTF_HEADERRECORD Record|page=114}} the aforementioned optional placeable record,{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|section=2.3.2.2 MTF_HEADERRECORD Record|page=114}} and finished by an end of file record.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=Windows Metafile Format|publisher=Microsoft|section=2.3.2.1 MTF_EOF Record|page=114}}

Encapsulated by the control records are the records that make up the image itself. These records work within what is known as the playback device context, which is the collection of properties and objects that make up a device's graphical environment as the metafile is being "played back" onto this output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=1.1 Glossary|page=13|access-date=2020-01-24|publisher=Microsoft}}

Records other than control records can be largely grouped into bitmap records, drawing records, object records, state records and escape records.

{{Clear}}

==Bitmap records==

Bitmap records manage and output bitmap images.

class="wikitable"
valign="bottom"

! Name

! Description

META_BITBLT

| Specifies how to do a bit block transfer. These records can specify a bitmap to use as the source, or a region.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.1.1 META_BITBLT Record|pages=101–103|access-date=2020-01-24 }}

META_DIBBITBLT

| Specifies how to do a bit block transfer of a device-independent bitmap image. These records can specify a bitmap to use as the source, or a region.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.1.2 META_DIBBITBLT Record|pages=103–106|access-date=2020-01-24|publisher=Microsoft}}

META_DIBSTRETCHBITBLT

| Specifies how to do a bit block transfer of a device-independent bitmap image, but allows for expansion or contraction of the image. These records can specify a bitmap to use as the source, or a region.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.1.3 META_DIBSTRETCHBITBLT Record|pages=106–108|access-date=2020-01-24|publisher=Microsoft}}

META_SETDIBTODEV

| Specifies color to set a block of pixels in a device-independent bitmap image. These records can specify a bitmap to use as the source, or a region.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.1.4 META_SETDIBTODEV Record|pages=108–109|access-date=2020-01-24|publisher=Microsoft}}

META_STRETCHBLT

| Specifies how to do a bit block transfer, but allows for expansion or contraction of the image.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.1.5 META_STRETCHBLT Record|pages=109–110|access-date=2020-01-24|publisher=Microsoft}}

META_STRETCHDIB

| Specifies how to do a bit block transfer of a device-independent bitmap image, but allows for expansion or contraction of the image. These records can specify a bitmap to use as the source, or a region.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.1.6 META_STRETCHDIB Record|pages=103–106|access-date=2020-01-24|publisher=Microsoft}}

==Drawing records==

Drawing records produce graphics output.

class="wikitable"
valign="bottom"

! Name

! Description

META_ARC

| Draws an elliptical arc.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.1 META_ARC Record|pages=101–103|access-date=2020-01-24}}

META_CHORD

| Draws a chord.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.2 META_CHORD Record|pages=117–118|access-date=2020-01-24}}

META_ELLIPSE

| Draws an elliptical arc.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.3 META_ELLIPSE Record|page=119|access-date=2020-01-24}}

META_EXTFLOODFILL

| Fills an area with a brush.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.4 META_EXTFLOODFILL Record|pages=119–120|access-date=2020-01-24}}

META_EXTTEXTOUT

| Draw text with font, background color and text color of the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.5 META_EXTTEXTOUT Record|pages=119–120|access-date=2020-01-24}}

META_FILLREGION

| Fills a region with a specified brush.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.6 META_FILLREGION Record|page=121|access-date=2020-01-24}}

META_FLOODFILL

| Fills an area with a brush.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.7 META_FLOODFILL Record|pages=119–120|access-date=2020-01-24}}

META_FRAMEREGION

| Draws a border around a region of the page with a brush.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.8 META_FRAMEREGION Record|pages=122–123|access-date=2020-01-24}}

META_INVERTREGION

| Paints a region of the graphic with inverted colors.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.9 META_INVERTREGION Record|page=123|access-date=2020-01-24}}

META_LINETO

| Draws a half-open line from the drawing position defined in the playback device context to a specified point.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.10 META_LINETO Record|pages=123–124|access-date=2020-01-24}}

META_PAINTREGION

| Paint a region with the current brush specified in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.11 META_PAINTREGION Record|page=124|access-date=2020-01-24}}

META_PATBLT

| Paint a region with the current brush specified in the playback device context and then combine the brush color and surface color(s) using a raster operation.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.12 META_PATBLT Record|pages=124–125|access-date=2020-01-24}}

META_PIE

| Draw a pie-shaped wedge bounded by the intersection of an ellipse and two radials — the line is set via the pen set via the playback device context, and the area bounded by the pie shape is filled in by the current brush of the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.13 META_PIE Record|pages=125–126|access-date=2020-01-24}}

META_POLYLINE

| Draws a series of line segnments by connecting the points in a specified array.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.14 META_POLYLINE Record|page=126|access-date=2020-01-24}}

META_POLYGON

| Paints a polygon consisting of two or more vertices connected by straight lines. The polygon is outlined by using the pen and filled by using the brush and polygon fill mode that are defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.15 META_POLYGON Record|page=127|access-date=2020-01-24}}

META_POLYPOLYGON

| Paints a series of closed polygons, which may overlap. Each polygon is outlined by using the pen and filled by using the brush and polygon fill mode that are defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.16 META_POLYPOLYGON Record|pages=127–128|access-date=2020-01-24}}

META_RECTANGLE

| Paints a rectangle, which is outlined by using the pen and filled by using the brush and is filled by using the brush that is defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.17 META_RECTANGLE Record|pages=127–128|access-date=2020-01-24}}

META_ROUNDRECT

| Paints a rectangle with rounded corners. The rectangle is outlined by using the pen and filled by using the brush and is filled by using the brush that is defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.18 META_ROUNDRECT Record|pages=128–129|access-date=2020-01-24}}

META_SETPIXEL

| Sets the pixel at the specified coordinates to the specified color.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.19 META_SETPIXEL Record|pages=129–130|access-date=2020-01-24}}

META_TEXTOUT

| Outputs a character string at the specified location by using the font, background color, and text color that are defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf | title=[MS-WMF]: Windows Metafile Format Specification | section=2.3.3.20 META_TEXTOUT Record|page=130|access-date=2020-01-24}}

==Object records==

Object records create and manage graphics objects. In WMF files there are two broad categories of objects – graphics objects and structure objects. Structure objects are not explicitly created or deleted in a WMF, they are instead of complex structures. For example, the BitmapCoreHeader contains information about the dimensions and color format of a device-independent bitmap,{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.2.2.2. BitmapCoreHeader Object|page=85|access-date=2020-01-25}} which is itself part of a DeviceIndependentBitmap object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.2.2.9. DeviceIndependentBitmap Object|page=91|access-date=2020-01-25}} A graphics object, however, specifies parameters for graphics output and during playback of the WMF it sets up the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.2.1. Graphics Objects|page=79|access-date=2020-01-25}}

Graphics objects can be brushes (defines the style, color and pattern of a brush which defines how to paint an area of the graphic), fonts (defines properties that affect how text is displayed), palettes (specifies colors as device-independent values, defined by an application), pens (specifies the graphical attributes of a line), and regions (which specify line and curve segments that define a shape).

class="wikitable"
valign="bottom"

! Name

! Description

META_CREATEBRUSHINDIRECT

| Creates a brush object from a LogBrush (logical brush) object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.1 META_CREATEBRUSHINDIRECT Record|pages=131–132|access-date=2020-01-25}}

META_CREATEFONTINDIRECT

| Creates a brush object from a font object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.2 META_CREATEFONTINDIRECT Record|pages=132|access-date=2020-01-25}}

META_CREATEPALETTE

| Creates a palette object.

META_CREATEPATTERNBRUSH{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.4 META_CREATEPATTERNBRUSH Record|pages=133–135|access-date=2020-01-25}}

| Creates a brush object from a LogBrush (logical brush) object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.3 META_CREATEPALETTE Record|pages=132–133|access-date=2020-01-25}}

META_CREATEPENINDIRECT

| Creates a pen object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.5 META_CREATEPENINDIRECT Record|pages=134–135|access-date=2020-01-25}}

META_CREATEREGION

| Creates a region object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.6 META_CREATEREGION Record|page=135|access-date=2020-01-25}}

META_DELETEOBJECT

| Delete an object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.7 META_DELETEOBJECT Record|page=135|access-date=2020-01-25}}

META_CREATEBRUSHINDIRECT

| Creates a brush object from a LogBrush (logical brush) object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.8 META_CREATEBRUSHINDIRECT Record|pages=135–136|access-date=2020-01-25}}

META_DIBCREATEPATTERNBRUSH

| Creates a brush object from a device-independent bitmap.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.9 META_DIBCREATEPATTERNBRUSH Record|pages=136–137|access-date=2020-01-25}}

META_SELECTCLIPREGION

| Specifies the region object that will be the current clipping region.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.10 META_SELECTCLIPREGION Record|page=137|access-date=2020-01-25}}

META_SELECTOBJECT

| Selects the object that will be the current object for the playback device context, which works on all graphics objects except palette objects, which must be set with META_SELECTPALETTE.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.11 META_SELECTOBJECT Record|pages=137–138|access-date=2020-01-25}}

META_SELECTPALETTE

| Selects the logical palette for the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.4.11 META_SELECTPALETTE Record|page=139|access-date=2020-01-25}}

==State records==

State records manage the graphics properties of the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5 State Record Types|pages=138|access-date=2020-01-28}}

class="wikitable"
valign="bottom"

! Name

! Description

META_ANIMATEPALETTE

| Redefines entries in the logical palette that is defined in the playback device context with a specified Palette Object.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.1 META_ANIMATEPALETTE Record|pages=140|access-date=2020-01-28}}

META_EXCLUDECLIPRECT

| Sets the clipping region that is defined in the playback device context to the existing clipping region minus a specified rectangle.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.2 META_EXCLUDECLIPRECT Record|pages=140–141|access-date=2020-01-28}}

META_INTERSECTCLIPRECT

| Sets the clipping region that is defined in the playback device context to the intersection of the existing clipping region and a specified rectangle.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.3 META_INTERSECTCLIPRECT Record|pages=141–142|access-date=2020-01-28}}

META_MOVETO

| Sets the output position in the playback device context to a specified point.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.1 META_MOVETO Record|pages=142|access-date=2020-01-28}}

META_OFFSETCLIPRGN

| Moves the clipping region that is defined in the playback device context by specified offsets.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.4 META_OFFSETCLIPRGN Record|pages=142–143|access-date=2020-01-28}}

META_OFFSETVIEWPORTORG

| Moves the viewport origin in the playback device context by specified horizontal and vertical offsets.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.5 META_OFFSETVIEWPORTORG Record|page=143|access-date=2020-01-28}}

META_OFFSETWINDOWORG

| Moves the output window origin in the playback device context by specified horizontal and vertical offsets.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.6 META_OFFSETWINDOWORG Record|pages=131–132|access-date=2020-01-28}}

META_REALIZEPALETTE

| Maps entries from the logical palette that is defined in the playback device context to the system palette.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.7 META_REALIZEPALETTE Record|pages=143–144|access-date=2020-01-28}}

META_RESIZEPALETTE

| Redefines the size of the logical palette that is defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.8 META_RESIZEPALETTE Record|page=144|access-date=2020-01-28}}

META_RESTOREDC

| Restores the playback device context from a previously saved device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.9 META_RESTOREDC Record|page=145|access-date=2020-01-28}}

META_SAVEDC

| Saves the playback device context for later retrieval.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.10 META_SAVEDC Record|page=145|access-date=2020-01-28}}

META_SCALEVIEWPORTEXT

| Scales the horizontal and vertical extents of the viewport that is defined in the playback device context using the ratios formed by specified multiplicands and divisors.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.11 META_SCALEVIEWPORTEXT Record|pages=145–146|access-date=2020-01-28}}

META_SCALEWINDOWEXT

| Scales the horizontal and vertical extents of the output window that is defined in the playback device context using the ratios formed by specified multiplicands and divisors.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.12 META_SCALEWINDOWEXT Record|pages=146–147|access-date=2020-01-28}}

META_SETBKCOLOR

| Sets the background color in the playback device context to a specified color.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.13 META_SETBKCOLOR Record|page=147|access-date=2020-01-28}}

META_SETBKMODE

| Sets the background mix mode in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.14 META_SETBKMODE Record|pages=147–148|access-date=2020-01-28}}

META_SETLAYOUT

| Defines the layout orientation in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.15 META_SETLAYOUT Record|page=148|access-date=2020-01-28}}

META_SETMAPMODE

| Defines the mapping mode in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.16 META_SETMAPMODE Record|pages=148–149|access-date=2020-01-28}}

META_SETMAPPERFLAGS

| Defines the algorithm that the font mapper uses when it maps logical fonts to physical fonts.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.17 META_SETMAPPERFLAGS Record|pages=131–132|access-date=2020-01-28}}

META_SETPALENTRIES

| Defines RGB color values in a range of entries in the logical palette that is defined in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.18 META_ANIMATEPALETTE Record|page=149|access-date=2020-01-28}}

META_SETPOLYFILLMODE

| Defines polygon fill mode in the playback device context for graphics operations that fill polygons.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.19 META_SETPALENTRIES Record|pages=149–150|access-date=2020-01-28}}

META_SETRELABS

| Unused record.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.20 META_SETRELABS Record|page=150|access-date=2020-01-28}}

META_SETROP2

| Defines the foreground raster operation mixing mode in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.21 META_SETROP2 Record|page=151|access-date=2020-01-28}}

META_SETSTRETCHBLTMODE

| Defines the bitmap stretching mode in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.1 META_SETSTRETCHBLTMODE Record|pages=151–152|access-date=2020-01-28}}

META_SETTEXTALIGN

| Defines text-alignment values in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.22 META_SETTEXTALIGN Record|page=152|access-date=2020-01-28}}

META_SETTEXTCHAREXTRA

| Defines inter-character spacing for text justification in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.1 META_SETTEXTCHAREXTRA Record|pages=152–153|access-date=2020-01-28}}

META_SETTEXTCOLOR

| Defines the text foreground color in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.23 META_SETTEXTCOLOR Record|page=153|access-date=2020-01-28}}

META_SETTEXTJUSTIFICATION

| Defines the amount of space to add to break characters in a string of justified text.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.24 META_SETTEXTJUSTIFICATION Record|pages=153–154|access-date=2020-01-28}}

META_SETVIEWPORTEXT

| Defines the horizontal and vertical extents of the viewport in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.25 META_SETVIEWPORTEXT Record|page=154|access-date=2020-01-28}}

META_SETVIEWPORTORG

| Defines the viewport origin in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.26 META_SETVIEWPORTORG Record|pages=154–155|access-date=2020-01-28}}

META_SETWINDOWEXT

| Defines the horizontal and vertical extents of the output window in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.27 META_SETWINDOWEXT Record|page=155|access-date=2020-01-28}}

META_SETWINDOWORG

| Defines the output window origin in the playback device context.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.5.28 META_SETWINDOWORG Record|page=155|access-date=2020-01-28}}

==Escape records==

File:WMF Escape Record.svg

Escape records are a means to extend metafile functionality via records that are not otherwise defined as a WMF record type. Each escape record contains a record function, an escape function and potentially escape data.

The following escape records make up a WMF file.

class="wikitable"
valign="bottom"

! Name

! Description

ABORTDOC

| Stops processing the current document.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.2. ABORTDOC Record|pages=158–159|access-date=2020-01-28}}

BEGIN_PATH

| Opens a path.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.3. BEGIN_PATH Record|page=159|access-date=2020-01-28}}

CHECK_JPEGFORMAT

| Determines whether it can handle the given JPEG image.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.4. CHECK_JPEGFORMAT Record|pages=159–160|access-date=2020-01-28}}

CHECK_PNGFORMAT

| Determines whether it can handle the given PNG image.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.5. CHECK_PNGFORMAT Record|page=160|access-date=2020-01-28}}

CLIP_TO_PATH

| Applies a function to the current PostScript clipping path.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.6. CLIP_TO_PATH Record|page=160|access-date=2020-01-28}}

CLOSE_CHANNEL

| Same as ENDDOC.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.7. CLOSE_CHANNEL Record|page=162|access-date=2020-01-28}}

DOWNLOAD_FACE

| Sets the font face name on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.8. DOWNLOAD_FACE Record|pages=162–163|access-date=2020-01-28}}

DOWNLOAD_HEADER

| Downloads sets of PostScript procedures.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.9. DOWNLOAD_HEADER Record|pages=158–159|access-date=2020-01-28}}

DRAW_PATTERNRECT

| Draws a rectangle with a defined pattern.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.10. DRAW_PATTERNRECT Record|pages=163–164|access-date=2020-01-28}}

ENCAPSULATED_POSTSCRIPT

| Sends arbitrary encapsulated PostScript (EPS) data directly to the printer driver.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.11. ENCAPSULATED_POSTSCRIPT Record|page=164|access-date=2020-01-28}}

END_PATH

| Ends a path.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.12. END_PATH Record|pages=164–165|access-date=2020-01-28}}

ENDDOC

| Notifies the printer driver that a new print job is ending.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.13. ENDDOC Record|pages=165|access-date=2020-01-28}}

EPS_PRINTING

| Indicates the start and end of EPS printing.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.14. EPS_PRINTING Record|pages=165–166|access-date=2020-01-28}}

EXTTEXTOUT

| Draws text using the currently selected font, background color, and text color.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.15. EXTTEXTOUT Record|pages=166–167|access-date=2020-01-28}}

GET_COLORTABLE

| Gets color table values from the printer driver.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.16. GET_COLORTABLE Record|pages=167–168|access-date=2020-01-28}}

GET_DEVICEUNITS

| Gets the device units currently configured on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.17. GET_DEVICEUNITS Record|page=168|access-date=2020-01-28}}

GET_EXTENDED_TEXTMETRICS

| Gets the extended text metrics that are currently configured on the printer driver.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.18. GET_EXTENDED_TEXTMETRICS Record|pages=168–169|access-date=2020-01-28}}

GET_FACENAME

| Gets the font face name currently configured on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.19. GET_FACENAME Record|page=169|access-date=2020-01-28}}

GET_PAIRKERNTABLE

| Gets the font kern table currently defined on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.20. GET_PAIRKERNTABLE Record|pages=169–170|access-date=2020-01-28}}

GET_PHYSPAGESIZE

| Retrieves the physical page size currently selected on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.21. GET_PHYSPAGESIZE Record|page=170|access-date=2020-01-28}}

GET_PRINTINGOFFSET

| Retrieves the offset from the upper-left corner of the physical page where the actual printing or drawing begins.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.22. GET_PRINTINGOFFSET Record|pages=170–171|access-date=2020-01-28}}

GET_PS_FEATURESETTING

| Queries the printer driver for information about PostScript features supported on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.23. GET_PS_FEATURESETTING Record|page=171|access-date=2020-01-28}}

GET_SCALINGFACTOR

| Retrieves the scaling factors for the x-axis and the y-axis of a printer.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.24. GET_SCALINGFACTOR Record|pages=171–172|access-date=2020-01-28}}

META_ESCAPE_ENHANCED_METAFILE

| Used to embed an EMF metafile within a WMF metafile.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.25. META_ESCAPE_ENHANCED_METAFILE Record|pages=172–173|access-date=2020-01-28}}

METAFILE_DRIVER

| Queries the printer driver about its support for metafiles on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.26. METAFILE_DRIVER Record|pages=173–174|access-date=2020-01-28}}

NEWFRAME

| Notifies the printer driver that the application has finished writing to a page.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.27. NEWFRAME Record|pages=174–175|access-date=2020-01-28}}

NEXTBAND

| Notifies the printer driver that the application has finished writing to a band.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.28. NEXTBAND Record|pages=174–175|access-date=2020-01-28}}

PASSTHROUGH

| Passes through arbitrary data to the printer driver.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.29. PASSTHROUGH Record|page=175|access-date=2020-01-28}}

POSTSCRIPT_DATA

| Sends arbitrary PostScript data to the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.30. POSTSCRIPT_DATA Record|page=176|access-date=2020-01-28}}

POSTSCRIPT_IDENTIFY

| Sets the printer driver to either PostScript-centric or GDI-centric mode.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.31. POSTSCRIPT_IDENTIFY Record|pages=176–177|access-date=2020-01-28}}

POSTSCRIPT_IGNORE

| Notifies the output device to ignore PostScript data.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.32. POSTSCRIPT_IGNORE Record|page=177|access-date=2020-01-28}}

POSTSCRIPT_INJECTION

| Inserts a block of raw data into a PostScript stream.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.33. POSTSCRIPT_INJECTION Record|pages=177–178|access-date=2020-01-28}}

POSTSCRIPT_PASSTHROUGH

| Sends arbitrary data directly to a printer driver, which is expected to process this data only when in PostScript mode.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.34. POSTSCRIPT_PASSTHROUGH Record|page=178|access-date=2020-01-28}}

OPEN_CHANNEL

| Acts the same as STARTDOC, with a NULL document and output filename, and data in raw mode.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.35. OPEN_CHANNEL Record|page=179|access-date=2020-01-28}}

QUERY_DIBSUPPORT

| Queries the printer driver about its support for DIBs on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.36. QUERY_DIBSUPPORT Record|pages=179–180|access-date=2020-01-28}}

QUERY_ESCSUPPORT

| Queries the printer driver to determine whether a specific WMF escape function is supported on the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.37. QUERY_ESCSUPPORT Record|page=180|access-date=2020-01-28}}

SET_COLORTABLE

| Sets color table values.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.38. SET_COLORTABLE Record|pages=180–181|access-date=2020-01-28}}

SET_COPYCOUNT

| Sets the number of copies.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.39. SET_COPYCOUNT Record|page=181|access-date=2020-01-28}}

SET_LINECAP

| Specifies the line-ending mode to use in drawing to the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.40. SET_LINECAP Record|pages=181–182|access-date=2020-01-28}}

SET_LINEJOIN

| Specifies the line-joining mode to use in drawing to the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.41. SET_LINEJOIN Record|pages=182–183|access-date=2020-01-28}}

SET_MITERLIMIT

| Sets the limit for the length of miter joins to use in drawing to the output device.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.42. SET_MITERLIMIT Record|page=183|access-date=2020-01-28}}

SPCLPASSTHROUGH2

| Enables documents to include private procedures and other arbitrary data in documents.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.43. SPCLPASSTHROUGH2 Record|pages=183–184|access-date=2020-01-28}}

STARTDOC

| Notifies the printer driver that a new print job is starting.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/%5bMS-WMF%5d.pdf|title=[MS-WMF]: Windows Metafile Format Specification|section=2.3.6.44. STARTDOC Record|page=184|access-date=2020-01-28}}

There was a major vulnerability found in escape records around the Abort escape record, which stores the abort procedure code within the record itself. This affected Windows systems (see {{CVE|2005-4560}}) and the Wine project (see {{CVE|2006-0106}}). According to Secunia, "The vulnerability is caused due to an error in the handling of Windows Metafile files ('.wmf') containing specially crafted SETABORTPROC 'Escape' records. Such records allow arbitrary user-defined function to be executed when the rendering of a WMF file fails."{{cite web|archive-url=https://web.archive.org/web/20060102123654/http://secunia.com/advisories/18255/|archive-date=January 2, 2006|url=http://secunia.com/advisories/18255/|title=Microsoft Windows WMF "SETABORTPROC" Arbitrary Code Execution|id=Secunia Advisory: SA18255|publisher=Secunia}} According to the Windows 3.1 SDK documentation, the SETABORTPROC escape was obsoleted and replaced by the function of the same name in Windows 3.1, long before the WMF vulnerability was discovered.{{citation|url=https://docs.microsoft.com/en-us/windows-hardware/drivers/print/pscript-supported-escapes|title=Pscript-Supported Escapes|publisher=Microsoft|access-date=2020-01-28}} However the obsoleted escape code was retained for compatibility with 16 bit programs written for (or at least backwards compatible with) Windows 3.0. This change happened at approximately the same time as Microsoft was creating the 32 bit reimplementation of GDI for Windows NT, and it is likely that the vulnerability occurred during this effort.

After Steve Gibson accused Microsoft of deliberately implementing a backdoor into their code,{{cite podcast|url=https://media.grc.com/sn/sn-022.mp3|title=The Windows MetaFile Backdoor?|website=GRC Security Now!|publisher=Gibson Research Corporation|date=January 12, 2006|access-date=2020-01-28}}{{citation|title = Re: You won't want to miss tonight's Security Now!, #22|first=Steve|last=Gibson|author-link=Steve Gibson (computer programmer)|date=January 12, 2006|work=grc.news.feedback|url=https://www.grc.com/x/news.exe?cmd=article&group=grc.news.feedback&item=60006|access-date=2020-01-28}} Mark Russinovich provided a rebuttal, and stated that:

{{blockquote|...things were different when the format was architected. In the Windows 3.1 “large” memory model code is inherently location-independent and Windows was never patched, so both Windows and an application could simply copy an application function into the WMF file and assume it would work when played back by the same application in a later run session. In any case, its not clear that the developers envisioned applications creating on-disk metafiles with abort procedures. Also, as Microsoft’s Stephen Toulouse pointed out in [https://web.archive.org/web/20060116042756/http://blogs.technet.com/msrc/archive/2006/01/13/417431.aspx Microsoft’s rebuttal] to Steve’s claims, the security landscape in the early 1990s was very different than today and all code, including that stored in a WMF file, was inherently trusted.{{citation|url=https://techcommunity.microsoft.com/t5/windows-blog-archive/inside-the-wmf-backdoor/ba-p/723489|first=Mark|last=Russinovich|author-link=Mark Russinovich|title=Inside the WMF Backdoor|publisher=Microsoft|work=TechNet|via=Microsoft Tech Community|date=January 18, 2006}}}}

Peter Ferrie of Symantec Security Response, USA also disagreed with Gibson, noting that:

{{blockquote|Gibson claimed that a thread is created to run the SetAbortProc handler. In fact, no thread is created to run the handler – it is a callback, which is called by the parser, and the parser has to wait until the callback returns, otherwise the whole point of the function (to abort the printing) is lost. By his own admission, Gibson did not read the documentation (in fact, he claimed that he couldn’t find it, although it is freely available on Microsoft’s Web site), and he claimed that the device context is not available to the function handler. Of course the device context is available to the function handler — it is one of the two parameters that is passed to it (see above), and it is required in order to abort the printing. Finally, Gibson claimed that the control flow could not return to Windows. It is simply a matter of the function returning and discarding the parameters that were passed on the stack. If the record is well formed, Windows will continue to parse the file, as before. ... Gibson admits that he was guessing about a number of things. Unfortunately, he guessed poorly. I guess we know better now.{{citation|title=Inside the Windows Meta File Format|publisher=Virus Bulletin|date=February 2, 2006|first=Peter|surname=Ferrie|url=https://www.symantec.com/avcenter/reference/inside.the.windows.meta.file.format.pdf|archive-url=https://web.archive.org/web/20080516052826/http://www.symantec.com/avcenter/reference/inside.the.windows.meta.file.format.pdf|url-status=dead|archive-date=May 16, 2008|via=Symantec|access-date=2020-01-24}}}}

=EMF=

{{Infobox file format

| name = Enhanced Metafile

| icon =

| logo =

| extension = .emf

| mime = image/emf

| type code =

| uniform type = com.microsoft.emf

| magic =

| released =

| latest release version =

| latest release date =

| type = Vector graphics

| container for =

| contained by =

| extended from = WMF

| extended to = EMF+

| standard =

| open =

| free =

}}

File:EMF headers.svg

EMF files have three possible versions of headers. The original headers is just a container for images, the second and third version encapsulates the original header and contains a pixel format record and support for OpenGL records, and the third version encapsulates the second header extension and increases EMF accuracy and scalability of EMFs as it adds the ability to measure distances of device surfaces using the metric system.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Enhanced Metafile Format|publisher=Microsoft|pages=17–18|section=1.3.1. Metafile Structure}}

Each EMF header starts with an EMR_HEADER record, and records the relevant properties of the device on which the metafile image was recorded. The original EMF header has an 80 byte header and an optional variable length description string.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Enhanced Metafile Format|publisher=Microsoft|page=120|section=2.3.4.2.1 EmfMetafileHeader Record}} Other metafiles contain extension fields, which encapsulate the original header. EmfMetafileHeaderExtension1 is a record that is inserted directly after the original EMF header, specifies whether there is a pixel format descriptor and the offset to the descriptor object within the header, as well as a field that specifies if OpenGL records exist in the metafile.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Enhanced Metafile Format|publisher=Microsoft|pages=57–58|section=2.2.10 HeaderExtension1 Object}} The pixel format descriptor specifies the capabilities of the drawing surface and whether a pixel is encoded in RGBA or is an index into a color table.{{citation|url= https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Enhanced Metafile Format|publisher=Microsoft|pages=68–71|section=2.2.22 PixelFormatDescriptor Object}} EmfMetafileHeaderExtension2 is a record that is inserted directly after the EmfMetafileHeaderExtension1 record, and it contains two fields with the X and Y values to measure the device surface in micrometers.{{citation|url=https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-EMF/%5bMS-EMF%5d.pdf|title=[MS-EMF]: Enhanced Metafile Format|publisher=Microsoft|pages=122–124|section=2.3.4.2.3 EmfMetafileHeaderExtension2 Record}}

Like WMF files, records can be classified by function, however there are more record types in EMF files than there are in WMF files. Records can be classified as control, bitmap, clipping, comment, drawing, escape, object creation, object manipulation, OpenGL, path bracket, state and transform records.

=EMF+=

With the release of Windows XP, the Enhanced Metafile Format Plus Extensions (EMF+) format was introduced. EMF+ provides a way to serialize calls to the GDI+ API in the same way that WMF/EMF stores calls to GDI.

There are also compressed versions of Windows Metafiles known as Compressed Windows Metafile (WMZ) and Compressed Windows Enhanced Metafile (EMZ),{{cite web | url=http://support.microsoft.com/kb/895083 | archive-url=https://web.archive.org/web/20140419204933/http://support.microsoft.com/kb/895083 | url-status=dead | archive-date=2014-04-19 | title=You receive a "This file is an unsupported graphic format" error message when you try to insert a picture into a PowerPoint for Mac presentation | publisher=Microsoft | access-date=2014-04-19}} which are basically gzip compressed WMF and EMF files correspondingly.

Implementations

The WMF format was designed to be executed by the Windows GDI layer in order to restore the image, but as the WMF binary files contain the definition of the GDI graphic primitives that constitute this image, it is possible to design alternative libraries that render WMF binary files or convert them into other graphic formats.

See also

References

{{Reflist|30em}}