⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmf.htm

📁 各种文件格式说明及程序描述
💻 HTM
字号:
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>new page 8</title>
<meta name="generator" content="microsoft frontpage 3.0">
</head>

<body background="../jpg/di1.JPG">

<p align="center"><font size="6" color="#0000ff">.wmf metafile format</font></p>
<div align="center"><center>

<table border="0" width="88%">
<tr>
<td width="100%"><br>
a metafile for the microsoft windows operating system consists of a collection of graphics
device interface (gdi) functions that describe an image. because metafiles take up less
space and are more device-independent than bitmaps, they provide convenient storage for
images that appear repeatedly in an application or need to be moved from one application
to another. to generate a metafile, a windows application creates a special device context
that sends gdi commands to a file or memory for storage. the application can later play
back the metafile and display the image. during playback, windows breaks the metafile down
into records and identifies each object with an index to a handle table. when a
meta_deleteobject record is encountered during playback, the associated object is deleted
from the handle table. the entry is then reused by the next object that the metafile
creates. to ensure compatibility, an application that explicitly manipulates records or
builds its own metafile should manage the handle table in the same way. for more
information on the format of the handle table, see the handletable structure. <br>
<br>
in some cases, there are two variants of a metafile record, one representing the record
created by windows versions before 3.0 and the second representing the record created by
windows versions 3.0 and later. windows versions 3.0 and later play all metafile versions
but store only 3.0 and later versions. windows versions earlier than 3.0 do not play
metafiles recorded by windows versions 3.0 and later. <br>
a metafile consists of two parts: a header and a list of records. the header and records
are described in the remainder of this topic. for a list of function-specific records, see
metafile records. <br>
<br>
metafile header<br>
<br>
the metafile header contains a description of the size of the metafile and the number of
drawing objects it uses. the drawing objects can be pens, brushes, bitmaps, or fonts. <br>
the metafile header has the following form: <br>
<br>
<br>
<br>
typedef struct tagmetaheader {<br>
word mttype;<br>
word mtheadersize;<br>
word mtversion;<br>
dword mtsize;<br>
word mtnoobjects;<br>
dword mtmaxrecord;<br>
word mtnoparameters;<br>
} metaheader;<br>
<br>
following are the members in the metafile header: <br>
<br>
mttype&nbsp;&nbsp;&nbsp; specifies whether the metafile is stored in memory or recorded in
a file. this member has one of the following values: <br>
<br>
value&nbsp;&nbsp;&nbsp; meaning<br>
<br>
0&nbsp;&nbsp;&nbsp; metafile is in memory. <br>
1&nbsp;&nbsp;&nbsp; metafile is in a file. <br>
<br>
mtheadersize&nbsp;&nbsp;&nbsp; specifies the size, in words, of the metafile header. <br>
mtversion&nbsp;&nbsp;&nbsp; specifies the windows version number. the version number for
windows version 3.0 and later is 0x300. <br>
mtsize&nbsp;&nbsp;&nbsp; specifies the size, in words, of the file. <br>
mtnoobjects&nbsp;&nbsp;&nbsp; specifies the maximum number of objects that can exist in
the metafile at the same time. <br>
mtmaxrecord&nbsp;&nbsp;&nbsp; specifies the size, in words, of the largest record in the
metafile. <br>
mtnoparameters&nbsp;&nbsp;&nbsp; not used. <br>
<br>
typical metafile record<br>
<br>
the graphics device interface stores most of the gdi functions that an application can use
to create metafiles in typical records. <br>
a typical metafile record has the following form: <br>
<br>
<br>
<br>
struct {<br>
dword rdsize;<br>
word rdfunction;<br>
word rdparm[];<br>
}<br>
<br>
following are the members in a typical metafile record: <br>
<br>
rdsize&nbsp;&nbsp;&nbsp; specifies the size, in words, of the record. <br>
rdfunction&nbsp;&nbsp;&nbsp; specifies the function number. this value may be the number
of any function in the table at the end of this section. <br>
rdparm&nbsp;&nbsp;&nbsp; identifies an array of words containing the function parameters
(listed in the reverse order in which they are <br>
passed to the function). <br>
<br>
following are the gdi functions found in typical records, along with their hexadecimal
values: <br>
<br>
gdi function&nbsp;&nbsp;&nbsp; value<br>
<br>
arc&nbsp;&nbsp;&nbsp; 0x0817 <br>
chord&nbsp;&nbsp;&nbsp; 0x0830 <br>
ellipse&nbsp;&nbsp;&nbsp; 0x0418 <br>
excludecliprect&nbsp;&nbsp;&nbsp; 0x0415 <br>
floodfill&nbsp;&nbsp;&nbsp; 0x0419 <br>
intersectcliprect&nbsp;&nbsp;&nbsp; 0x0416 <br>
lineto&nbsp;&nbsp;&nbsp; 0x0213 <br>
moveto&nbsp;&nbsp;&nbsp; 0x0214 <br>
offsetcliprgn&nbsp;&nbsp;&nbsp; 0x0220 <br>
offsetviewportorg&nbsp;&nbsp;&nbsp; 0x0211 <br>
offsetwindoworg&nbsp;&nbsp;&nbsp; 0x020f <br>
patblt&nbsp;&nbsp;&nbsp; 0x061d <br>
pie&nbsp;&nbsp;&nbsp; 0x081a <br>
realizepalette (3.0 and later)&nbsp;&nbsp;&nbsp; 0x0035 <br>
<br>
rectangle&nbsp;&nbsp;&nbsp; 0x041b <br>
resizepalette (3.0 and later)&nbsp;&nbsp;&nbsp; 0x0139 <br>
restoredc&nbsp;&nbsp;&nbsp; 0x0127 <br>
roundrect&nbsp;&nbsp;&nbsp; 0x061c <br>
savedc&nbsp;&nbsp;&nbsp; 0x001e <br>
scaleviewportext&nbsp;&nbsp;&nbsp; 0x0412 <br>
scalewindowext&nbsp;&nbsp;&nbsp; 0x0400 <br>
setbkcolor&nbsp;&nbsp;&nbsp; 0x0201 <br>
setbkmode&nbsp;&nbsp;&nbsp; 0x0102 <br>
setmapmode&nbsp;&nbsp;&nbsp; 0x0103 <br>
setmapperflags&nbsp;&nbsp;&nbsp; 0x0231 <br>
setpixel&nbsp;&nbsp;&nbsp; 0x041f <br>
setpolyfillmode&nbsp;&nbsp;&nbsp; 0x0106 <br>
setrop2&nbsp;&nbsp;&nbsp; 0x0104 <br>
<br>
setstretchbltmode&nbsp;&nbsp;&nbsp; 0x0107 <br>
settextalign&nbsp;&nbsp;&nbsp; 0x012e <br>
settextcharacterextra&nbsp;&nbsp;&nbsp; 0x0108 <br>
settextcolor&nbsp;&nbsp;&nbsp; 0x0209 <br>
settextjustification&nbsp;&nbsp;&nbsp; 0x020a <br>
setviewportext&nbsp;&nbsp;&nbsp; 0x020e <br>
setviewportorg&nbsp;&nbsp;&nbsp; 0x020d <br>
setwindowext&nbsp;&nbsp;&nbsp; 0x020c <br>
setwindoworg&nbsp;&nbsp;&nbsp; 0x020b <br>
<br>
placeable windows metafiles<br>
<br>
a placeable windows metafile is a standard windows metafile that has an additional 22-byte
header. the header contains information about the aspect ratio and original size of the
metafile, permitting applications to display the metafile in its intended form. <br>
the header for a placeable windows metafile has the following form: <br>
<br>
<br>
<br>
typedef struct {<br>
dword key;<br>
handle hmf;<br>
rect bbox;<br>
word inch;<br>
dword reserved;<br>
word checksum;<br>
} metafileheader;<br>
<br>
following are the members of a placeable metafile header: <br>
<br>
key&nbsp;&nbsp;&nbsp; specifies the binary key that uniquely identifies this file type.
this member must be set to 0x9ac6cdd7l. <br>
hmf&nbsp;&nbsp;&nbsp; unused; must be zero. <br>
bbox&nbsp;&nbsp;&nbsp; specifies the coordinates of the smallest rectangle that encloses
the picture. the coordinates are in metafile units <br>
as defined by the inch member. <br>
inch&nbsp;&nbsp;&nbsp; specifies the number of metafile units to the inch. to avoid
numeric overflow, this value should be less than 1440. <br>
most applications use 576 or 1000. <br>
reserved&nbsp;&nbsp;&nbsp; unused; must be zero. <br>
checksum&nbsp;&nbsp;&nbsp; specifies the checksum. it is the sum (using the xor operator)
of the first 10 words of the header. <br>
<br>
the actual content of the windows metafile immediately follows the header. the format for
this content is identical to that for standard windows metafiles. for some applications, a
placeable windows metafile must not exceed 64k. <br>
<br>
note:&nbsp;&nbsp;&nbsp; placeable windows metafiles are not compatible with the
getmetafile function. applications that intend to use the metafile functions to read and
play placeable windows metafiles must read the file by using an input function (such as
_lread), strip the 22-byte header, and create a standard windows metafile by using the
remaining bytes and the setmetafilebits function. <br>
<br>
guidelines for windows metafiles<br>
<br>
to ensure that metafiles can be transported between different computers and applications,
any application that creates a metafile should make sure the metafile is
device-independent and sizable. <br>
the following guidelines ensure that every metafile can be accepted and manipulated by
other applications: <br>
<br>
&nbsp;&nbsp;&nbsp; set a mapping mode as one of the first records. many applications,
including ole applications, only accept metafiles that are in mm_anisotropic mode. <br>
<br>
&nbsp;&nbsp;&nbsp; call the setwindoworg and setwindowext functions. do not call the
setviewportext or setviewportorg functions if the user will be able to resize or change
the dimensions of the object. <br>
<br>
&nbsp;&nbsp;&nbsp; use the mfcomment printer escape to add comments to the metafile. <br>
<br>
&nbsp;&nbsp;&nbsp; rely primarily on the functions listed in typical metafile record.
observe the following limitations on the functions you use: <br>
<br>
&nbsp;&nbsp;&nbsp; do not use functions that retrieve data (for example, getactivewindow
or enumfontfamilies). <br>
<br>
&nbsp;&nbsp;&nbsp; do not use any of the region functions (because they are device
dependent). <br>
<br>
&nbsp;&nbsp;&nbsp; use stretchblt or stretchdib instead of bitblt. <br>
<br>
sample of metafile program output<br>
<br>
this section describes a sample program and the metafile that it creates. the sample
program creates a small metafile that draws a purple rectangle with a green border and
writes the words &quot;hello people&quot; in the rectangle. <br>
<br>
<br>
<br>
makeametafile(hdc)<br>
hdc hdc;<br>
{<br>
hpen hmetagreenpen;<br>
hbrush hmetavioletbrush;<br>
hdc hdcmeta;<br>
handle hmeta;<br>
<br>
/* create the metafile with output going to the disk. */<br>
<br>
hdcmeta = createmetafile( (lpstr) &quot;sample.met&quot;);<br>
<br>
hmetagreenpen = createpen(0, 0, (dword) 0x0000ff00);<br>
selectobject(hdcmeta, hmetagreenpen);<br>
<br>
hmetavioletbrush = createsolidbrush((dword) 0x00ff00ff);<br>
selectobject(hdcmeta, hmetavioletbrush);<br>
<br>
rectangle(hdcmeta, 0, 0, 150, 70);<br>
<br>
textout(hdcmeta, 10, 10, (lpstr) &quot;hello people&quot;, 12);<br>
<br>
<br>
/* we are done with the metafile. */<br>
<br>
hmeta = closemetafile(hdcmeta);<br>
<br>
/* play the metafile that we just created. */<br>
<br>
playmetafile(hdc, hmeta);<br>
}<br>
<br>
the resulting metafile, sample.met, consists of a metafile header and six records. it has
the following binary form: <br>
<br>
<br>
<br>
0001 mttype... disk metafile<br>
0009 mtsize...<br>
0300 mtversion<br>
0000 0036 mtsize<br>
0002 mtnoobjects<br>
0000 000c mtmaxrecord<br>
0000 mtnoparameters<br>
<br>
0000 0008 rdsize<br>
02fa rdfunction (createpenindirect function)<br>
0000 0000 0000 0000 ff00 rdparm (logpen structure defining pen)<br>
<br>
0000 0004 rdsize<br>
012d rdfunction (selectobject)<br>
0000 rdparm (index to object #0... the above pen)<br>
<br>
0000 0007 rdsize<br>
02fc rdfunction (createbrushindirect)<br>
<br>
0000 00ff 00ff 0000 rdparm (logbrush structure defining the brush)<br>
<br>
0000 0004 rdsize<br>
012d rdfunction (selectobject)<br>
0001 rdparm (index to object #1... the brush)<br>
<br>
0000 0007 rdsize<br>
041b rdfunction (rectangle)<br>
0046 0096 0000 0000 rdparm (parameters sent to rectangle...<br>
in reverse order)<br>
<br>
0000 000c rdsize<br>
0521 rdfunction (textout)<br>
rdparm<br>
000c count<br>
string<br>
48 65 6c 6c 6f 20 50 65 6f 70 6c 65 &quot;hello people&quot;<br>
000a y-value<br>
<br>
000a x-value&#26;</td>
</tr>
</table>
</center></div>

<p align="center"><a href="../index.htm">返回</a></p>
<p align="center"><a href="../index.htm">返回</a></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -