2 * Dump an Enhanced Meta File
4 * Copyright 2005 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
39 static unsigned int read_int(const unsigned char *buffer)
47 #define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break
49 static unsigned offset = 0;
51 static int dump_emfrecord(void)
53 const unsigned char* ptr;
54 unsigned int type, length, i;
60 length = read_int(ptr + 4);
65 EMRCASE(EMR_POLYBEZIER);
67 EMRCASE(EMR_POLYLINE);
68 EMRCASE(EMR_POLYBEZIERTO);
69 EMRCASE(EMR_POLYLINETO);
70 EMRCASE(EMR_POLYPOLYLINE);
71 EMRCASE(EMR_POLYPOLYGON);
72 EMRCASE(EMR_SETWINDOWEXTEX);
73 EMRCASE(EMR_SETWINDOWORGEX);
74 EMRCASE(EMR_SETVIEWPORTEXTEX);
75 EMRCASE(EMR_SETVIEWPORTORGEX);
76 EMRCASE(EMR_SETBRUSHORGEX);
78 EMRCASE(EMR_SETPIXELV);
79 EMRCASE(EMR_SETMAPPERFLAGS);
80 EMRCASE(EMR_SETMAPMODE);
81 EMRCASE(EMR_SETBKMODE);
82 EMRCASE(EMR_SETPOLYFILLMODE);
84 EMRCASE(EMR_SETSTRETCHBLTMODE);
85 EMRCASE(EMR_SETTEXTALIGN);
86 EMRCASE(EMR_SETCOLORADJUSTMENT);
87 EMRCASE(EMR_SETTEXTCOLOR);
88 EMRCASE(EMR_SETBKCOLOR);
89 EMRCASE(EMR_OFFSETCLIPRGN);
90 EMRCASE(EMR_MOVETOEX);
91 EMRCASE(EMR_SETMETARGN);
92 EMRCASE(EMR_EXCLUDECLIPRECT);
93 EMRCASE(EMR_INTERSECTCLIPRECT);
94 EMRCASE(EMR_SCALEVIEWPORTEXTEX);
95 EMRCASE(EMR_SCALEWINDOWEXTEX);
97 EMRCASE(EMR_RESTOREDC);
98 EMRCASE(EMR_SETWORLDTRANSFORM);
99 EMRCASE(EMR_MODIFYWORLDTRANSFORM);
100 EMRCASE(EMR_SELECTOBJECT);
101 EMRCASE(EMR_CREATEPEN);
102 EMRCASE(EMR_CREATEBRUSHINDIRECT);
103 EMRCASE(EMR_DELETEOBJECT);
104 EMRCASE(EMR_ANGLEARC);
105 EMRCASE(EMR_ELLIPSE);
106 EMRCASE(EMR_RECTANGLE);
107 EMRCASE(EMR_ROUNDRECT);
111 EMRCASE(EMR_SELECTPALETTE);
112 EMRCASE(EMR_CREATEPALETTE);
113 EMRCASE(EMR_SETPALETTEENTRIES);
114 EMRCASE(EMR_RESIZEPALETTE);
115 EMRCASE(EMR_REALIZEPALETTE);
116 EMRCASE(EMR_EXTFLOODFILL);
119 EMRCASE(EMR_POLYDRAW);
120 EMRCASE(EMR_SETARCDIRECTION);
121 EMRCASE(EMR_SETMITERLIMIT);
122 EMRCASE(EMR_BEGINPATH);
123 EMRCASE(EMR_ENDPATH);
124 EMRCASE(EMR_CLOSEFIGURE);
125 EMRCASE(EMR_FILLPATH);
126 EMRCASE(EMR_STROKEANDFILLPATH);
127 EMRCASE(EMR_STROKEPATH);
128 EMRCASE(EMR_FLATTENPATH);
129 EMRCASE(EMR_WIDENPATH);
130 EMRCASE(EMR_SELECTCLIPPATH);
131 EMRCASE(EMR_ABORTPATH);
132 EMRCASE(EMR_GDICOMMENT);
133 EMRCASE(EMR_FILLRGN);
134 EMRCASE(EMR_FRAMERGN);
135 EMRCASE(EMR_INVERTRGN);
136 EMRCASE(EMR_PAINTRGN);
137 EMRCASE(EMR_EXTSELECTCLIPRGN);
139 EMRCASE(EMR_STRETCHBLT);
140 EMRCASE(EMR_MASKBLT);
142 EMRCASE(EMR_SETDIBITSTODEVICE);
143 EMRCASE(EMR_STRETCHDIBITS);
144 EMRCASE(EMR_EXTCREATEFONTINDIRECTW);
145 EMRCASE(EMR_EXTTEXTOUTA);
146 EMRCASE(EMR_EXTTEXTOUTW);
147 EMRCASE(EMR_POLYBEZIER16);
148 EMRCASE(EMR_POLYGON16);
149 EMRCASE(EMR_POLYLINE16);
150 EMRCASE(EMR_POLYBEZIERTO16);
151 EMRCASE(EMR_POLYLINETO16);
152 EMRCASE(EMR_POLYPOLYLINE16);
153 EMRCASE(EMR_POLYPOLYGON16);
154 EMRCASE(EMR_POLYDRAW16);
155 EMRCASE(EMR_CREATEMONOBRUSH);
156 EMRCASE(EMR_CREATEDIBPATTERNBRUSHPT);
157 EMRCASE(EMR_EXTCREATEPEN);
158 EMRCASE(EMR_POLYTEXTOUTA);
159 EMRCASE(EMR_POLYTEXTOUTW);
160 EMRCASE(EMR_SETICMMODE);
161 EMRCASE(EMR_CREATECOLORSPACE);
162 EMRCASE(EMR_SETCOLORSPACE);
163 EMRCASE(EMR_DELETECOLORSPACE);
164 EMRCASE(EMR_GLSRECORD);
165 EMRCASE(EMR_GLSBOUNDEDRECORD);
166 EMRCASE(EMR_PIXELFORMAT);
167 EMRCASE(EMR_DRAWESCAPE);
168 EMRCASE(EMR_EXTESCAPE);
169 EMRCASE(EMR_STARTDOC);
170 EMRCASE(EMR_SMALLTEXTOUT);
171 EMRCASE(EMR_FORCEUFIMAPPING);
172 EMRCASE(EMR_NAMEDESCAPE);
173 EMRCASE(EMR_COLORCORRECTPALETTE);
174 EMRCASE(EMR_SETICMPROFILEA);
175 EMRCASE(EMR_SETICMPROFILEW);
176 EMRCASE(EMR_ALPHABLEND);
177 EMRCASE(EMR_SETLAYOUT);
178 EMRCASE(EMR_TRANSPARENTBLT);
179 EMRCASE(EMR_RESERVED_117);
180 EMRCASE(EMR_GRADIENTFILL);
181 EMRCASE(EMR_SETLINKEDUFI);
182 EMRCASE(EMR_SETTEXTJUSTIFICATION);
183 EMRCASE(EMR_COLORMATCHTOTARGETW);
184 EMRCASE(EMR_CREATECOLORSPACEW);
187 printf("%u %08x\n", type, length);
191 if ( (length < 8) || (length % 4) )
198 for(i=0; i<length; i+=4)
202 if (!(ptr = PRD(offset, 4))) return -1;
204 printf("%08x ", read_int(ptr));
205 if ( (i % 16 == 12) || (i + 4 == length))
212 enum FileSig get_kind_emf(void)
214 const ENHMETAHEADER* hdr;
216 hdr = PRD(0, sizeof(*hdr));
217 if (hdr && hdr->iType == EMR_HEADER && hdr->dSignature == ENHMETA_SIGNATURE)
225 while (!dump_emfrecord());