GetWinMetaFileBits function

The GetWinMetaFileBits function converts the enhanced-format records from a metafile into Windows-format records and stores the converted records in the specified buffer.


UINT GetWinMetaFileBits(
  _In_  HENHMETAFILE hemf,
  _In_  UINT         cbBuffer,
  _Out_ LPBYTE       lpbBuffer,
  _In_  INT          fnMapMode,
  _In_  HDC          hdcRef


hemf [in]

A handle to the enhanced metafile.

cbBuffer [in]

The size, in bytes, of the buffer into which the converted records are to be copied.

lpbBuffer [out]

A pointer to the buffer that receives the converted records. If lpbBuffer is NULL, GetWinMetaFileBits returns the number of bytes required to store the converted metafile records.

fnMapMode [in]

The mapping mode to use in the converted metafile.

hdcRef [in]

A handle to the reference device context.

Return value

If the function succeeds and the buffer pointer is NULL, the return value is the number of bytes required to store the converted records; if the function succeeds and the buffer pointer is a valid pointer, the return value is the size of the metafile data in bytes.

If the function fails, the return value is zero.


This function converts an enhanced metafile into a Windows-format metafile so that its picture can be displayed in an application that recognizes the older format.

The system uses the reference device context to determine the resolution of the converted metafile.

The GetWinMetaFileBits function does not invalidate the enhanced metafile handle. An application should call the DeleteEnhMetaFile function to release the handle when it is no longer needed.

To create a scalable Windows-format metafile, specify MM_ANISOTROPIC as the fnMapMode parameter.

The upper-left corner of the metafile picture is always mapped to the origin of the reference device.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Wingdi.h (include Windows.h)





See also

Metafiles Overview
Metafile Functions