1. Metadata File.
It is composed of a series of binary records equivalent to calling graphical functions. These records are generally used to draw straight lines, curves, areas, text, and so on.
Ii. "DrawingProgram"Create a bitmap, and" plotting program "Create a Metafile.
The metadata file occupies less space than the bitmap, and is more device-independent than the bitmap file.
Iii. Old Metafile format. The extension is. WMF.
HDC hdcmeta = createmetafile (lpctstr lpszfile // file name );
// Create a Metafile and save it in the file path. The extension is. WMF.
// If the parameter is null, it is created in the memory,
Ellipse (hdcmeta, 100,100,); // then plot with hdcmeta.
Hmetafile hmf = closemetafile (hdcmeta); // close and get the handle
Playmetafile (HDC, hmf); // draw hmf on HDC
Deletemetafile (hmf );
Hmf = getmetafile (filename); // read the Metafile.
Getdevicecaps (hmf, horzsize); // This type of getdevicecaps function can obtain the metadata attributes.
Henhmetafile copyenhmetafile (henhmetafileHemfsrc, LpctstrLpszfile); // CopyLpszfile,Empty to memory
Meta files can be used as user-defined resources: setmetafilebitsex
Iv. Enhanced Metadata File With the extension. EMF
HDC hdcmeta = createenhmetafile (
HDC hdcref, // handle to reference DC
Lptstr lpfilename, // file name
Const rect * lprect, // bounding rectangle
Lptstr lpdescription // description string
);
// Create a Metafile and save it in the file path. The extension is. EMF.
// If the parameter is null, it is created in the memory,
Ellipse (hdcmeta, 100,100,); // then plot with hdcmeta.
Hmetafile hmf = closeenhmetafile (hdcmeta); // close and get the handle
Playenhmetafile (HDC, hmf, & rect); // on HDC, draw the hmf and scale it to the rect range.
Deleteenhmetafile (hmf );
Getmetafile (filename); // read the Metafile.
Meta files can be used as user-defined resources: setmetafilebitsex
The biggest improvement of Enhanced Meta files over older meta files is the addition of file header information.
Obtain the file header information: uint getenhmetafileheader (henhmetafile hemf, // handle to Enhanced Metafile uint cbbuffer, // size of buffer lpenhmetaheader EMH // data buffer );
Cximage = EMH. rclbounds. Right-EMH. rclbounds. Left; // metadata file length
Cyimage = EMH. rclbounds. Bottom-EMH. rclbounds. Top; // Metafile width
Enumerate bool enumenhmetafile (HDC, // handle to DC henhmetafile hemf, // handle to Enhanced Metafile enhmfenumproc lpenhmetafunc, // callback function lpvoid lpdata, // callback-function data const rect * lprect); // bounding rectangle
// Execute the operations in the lpenhmetafunc function for each object in the Metafile.
V. Metadata File data format.
It is the same as a normal file. Hexadecimal: object type, type length, type content.
For the type definition, see msdn: EMR ....