Windows program design Reading Notes-metafiles

Source: Internet
Author: User

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 ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.