widl: Add support for structures.
[wine.git] / tools / winedump / emf.c
blob253e7c658c23b42c1923113e667dcbd773d17bf7
1 /*
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
21 #include "config.h"
23 #include <stdio.h>
24 #include <fcntl.h>
25 #include <stdarg.h>
27 #include "winedump.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "gdiplusenums.h"
33 typedef struct
35 WORD Type;
36 WORD Flags;
37 DWORD Size;
38 DWORD DataSize;
39 } EmfPlusRecordHeader;
41 static const char *debugstr_wn(const WCHAR *wstr, unsigned int n)
43 static char buf[80];
44 char *p;
45 unsigned int i;
47 if (!wstr) return "(null)";
49 i = 0;
50 p = buf;
51 *p++ = '\"';
52 while (i < n && i < sizeof(buf) - 3 && wstr[i])
54 if (wstr[i] < 127) *p++ = wstr[i];
55 else *p++ = '.';
56 i++;
58 *p++ = '\"';
59 *p = 0;
60 return buf;
63 static const char *debugstr_rect(const RECTL *rect)
65 return strmake( "%d,%d - %d,%d",
66 (UINT)rect->left, (UINT)rect->top, (UINT)rect->right, (UINT)rect->bottom );
69 static unsigned int read_int(const unsigned char *buffer)
71 return buffer[0]
72 + (buffer[1]<<8)
73 + (buffer[2]<<16)
74 + (buffer[3]<<24);
77 #define EMRCASE(x) case x: printf("%s%-20s %08x\n", pfx, #x, length); break
78 #define EMRPLUSCASE(x) case x: printf("%s %-20s %04x %08x %08x\n", pfx, #x, \
79 (UINT)header->Flags, (UINT)header->Size, (UINT)header->DataSize); break
81 unsigned long dump_emfrecord(const char *pfx, unsigned long offset)
83 const unsigned char* ptr;
84 unsigned int type, length, i;
86 ptr = PRD(offset, 8);
87 if (!ptr) return 0;
89 type = read_int(ptr);
90 length = read_int(ptr + 4);
92 switch(type)
94 case EMR_HEADER:
96 const ENHMETAHEADER *header = PRD(offset, sizeof(*header));
98 printf("%s%-20s %08x\n", pfx, "EMR_HEADER", length);
99 printf("%sbounds (%s) frame (%s) signature %#x version %#x bytes %#x records %#x\n"
100 "%shandles %#x reserved %#x palette entries %#x px %dx%d mm %dx%d μm %dx%d opengl %d description %s\n",
101 pfx, debugstr_rect( &header->rclBounds ), debugstr_rect( &header->rclFrame ),
102 (UINT)header->dSignature, (UINT)header->nVersion, (UINT)header->nBytes,
103 (UINT)header->nRecords, pfx, (UINT)header->nHandles, header->sReserved, (UINT)header->nPalEntries,
104 (UINT)header->szlDevice.cx, (UINT)header->szlDevice.cy,
105 (UINT)header->szlMillimeters.cx, (UINT)header->szlMillimeters.cy,
106 (UINT)header->szlMicrometers.cx, (UINT)header->szlMicrometers.cy,
107 (UINT)header->bOpenGL,
108 debugstr_wn((LPCWSTR)((const BYTE *)header + header->offDescription), header->nDescription));
109 break;
112 EMRCASE(EMR_POLYBEZIER);
113 EMRCASE(EMR_POLYGON);
114 EMRCASE(EMR_POLYLINE);
115 EMRCASE(EMR_POLYBEZIERTO);
116 EMRCASE(EMR_POLYLINETO);
117 EMRCASE(EMR_POLYPOLYLINE);
118 EMRCASE(EMR_POLYPOLYGON);
119 EMRCASE(EMR_SETWINDOWEXTEX);
120 EMRCASE(EMR_SETWINDOWORGEX);
121 EMRCASE(EMR_SETVIEWPORTEXTEX);
122 EMRCASE(EMR_SETVIEWPORTORGEX);
123 EMRCASE(EMR_SETBRUSHORGEX);
124 EMRCASE(EMR_EOF);
125 EMRCASE(EMR_SETPIXELV);
126 EMRCASE(EMR_SETMAPPERFLAGS);
127 EMRCASE(EMR_SETMAPMODE);
128 EMRCASE(EMR_SETBKMODE);
129 EMRCASE(EMR_SETPOLYFILLMODE);
130 EMRCASE(EMR_SETROP2);
131 EMRCASE(EMR_SETSTRETCHBLTMODE);
132 EMRCASE(EMR_SETTEXTALIGN);
133 EMRCASE(EMR_SETCOLORADJUSTMENT);
134 EMRCASE(EMR_SETTEXTCOLOR);
135 EMRCASE(EMR_SETBKCOLOR);
136 EMRCASE(EMR_OFFSETCLIPRGN);
137 EMRCASE(EMR_MOVETOEX);
138 EMRCASE(EMR_SETMETARGN);
139 EMRCASE(EMR_EXCLUDECLIPRECT);
141 case EMR_INTERSECTCLIPRECT:
143 const EMRINTERSECTCLIPRECT *clip = PRD(offset, sizeof(*clip));
145 printf("%s%-20s %08x\n", pfx, "EMR_INTERSECTCLIPRECT", length);
146 printf("%srect %s\n", pfx, debugstr_rect( &clip->rclClip ));
147 break;
150 EMRCASE(EMR_SCALEVIEWPORTEXTEX);
151 EMRCASE(EMR_SCALEWINDOWEXTEX);
152 EMRCASE(EMR_SAVEDC);
153 EMRCASE(EMR_RESTOREDC);
154 EMRCASE(EMR_SETWORLDTRANSFORM);
155 EMRCASE(EMR_MODIFYWORLDTRANSFORM);
156 EMRCASE(EMR_SELECTOBJECT);
157 EMRCASE(EMR_CREATEPEN);
158 EMRCASE(EMR_CREATEBRUSHINDIRECT);
159 EMRCASE(EMR_DELETEOBJECT);
160 EMRCASE(EMR_ANGLEARC);
161 EMRCASE(EMR_ELLIPSE);
162 EMRCASE(EMR_RECTANGLE);
163 EMRCASE(EMR_ROUNDRECT);
164 EMRCASE(EMR_ARC);
165 EMRCASE(EMR_CHORD);
166 EMRCASE(EMR_PIE);
167 EMRCASE(EMR_SELECTPALETTE);
168 EMRCASE(EMR_CREATEPALETTE);
169 EMRCASE(EMR_SETPALETTEENTRIES);
170 EMRCASE(EMR_RESIZEPALETTE);
171 EMRCASE(EMR_REALIZEPALETTE);
172 EMRCASE(EMR_EXTFLOODFILL);
173 EMRCASE(EMR_LINETO);
174 EMRCASE(EMR_ARCTO);
175 EMRCASE(EMR_POLYDRAW);
176 EMRCASE(EMR_SETARCDIRECTION);
177 EMRCASE(EMR_BEGINPATH);
178 EMRCASE(EMR_ENDPATH);
179 EMRCASE(EMR_CLOSEFIGURE);
180 EMRCASE(EMR_FILLPATH);
181 EMRCASE(EMR_STROKEANDFILLPATH);
182 EMRCASE(EMR_STROKEPATH);
183 EMRCASE(EMR_FLATTENPATH);
184 EMRCASE(EMR_WIDENPATH);
185 EMRCASE(EMR_SELECTCLIPPATH);
186 EMRCASE(EMR_ABORTPATH);
188 case EMR_SETMITERLIMIT:
190 const EMRSETMITERLIMIT *record = PRD(offset, sizeof(*record));
192 printf("%s%-20s %08x\n", pfx, "EMR_SETMITERLIMIT", length);
193 printf("%s miter limit %u\n", pfx, *(unsigned int *)&record->eMiterLimit);
194 break;
197 case EMR_GDICOMMENT:
199 printf("%s%-20s %08x\n", pfx, "EMR_GDICOMMENT", length);
201 /* Handle EMF+ records */
202 if (length >= 16 && !memcmp((char*)PRD(offset + 12, sizeof(unsigned int)), "EMF+", 4))
204 const EmfPlusRecordHeader *header;
205 const unsigned int *data_size;
207 offset += 8;
208 length -= 8;
209 data_size = PRD(offset, sizeof(*data_size));
210 printf("%sdata size = %x\n", pfx, *data_size);
211 offset += 8;
212 length -= 8;
214 while (length >= sizeof(*header))
216 header = PRD(offset, sizeof(*header));
217 switch(header->Type)
219 EMRPLUSCASE(EmfPlusRecordTypeInvalid);
220 EMRPLUSCASE(EmfPlusRecordTypeHeader);
221 EMRPLUSCASE(EmfPlusRecordTypeEndOfFile);
222 EMRPLUSCASE(EmfPlusRecordTypeComment);
223 EMRPLUSCASE(EmfPlusRecordTypeGetDC);
224 EMRPLUSCASE(EmfPlusRecordTypeMultiFormatStart);
225 EMRPLUSCASE(EmfPlusRecordTypeMultiFormatSection);
226 EMRPLUSCASE(EmfPlusRecordTypeMultiFormatEnd);
227 EMRPLUSCASE(EmfPlusRecordTypeObject);
228 EMRPLUSCASE(EmfPlusRecordTypeClear);
229 EMRPLUSCASE(EmfPlusRecordTypeFillRects);
230 EMRPLUSCASE(EmfPlusRecordTypeDrawRects);
231 EMRPLUSCASE(EmfPlusRecordTypeFillPolygon);
232 EMRPLUSCASE(EmfPlusRecordTypeDrawLines);
233 EMRPLUSCASE(EmfPlusRecordTypeFillEllipse);
234 EMRPLUSCASE(EmfPlusRecordTypeDrawEllipse);
235 EMRPLUSCASE(EmfPlusRecordTypeFillPie);
236 EMRPLUSCASE(EmfPlusRecordTypeDrawPie);
237 EMRPLUSCASE(EmfPlusRecordTypeDrawArc);
238 EMRPLUSCASE(EmfPlusRecordTypeFillRegion);
239 EMRPLUSCASE(EmfPlusRecordTypeFillPath);
240 EMRPLUSCASE(EmfPlusRecordTypeDrawPath);
241 EMRPLUSCASE(EmfPlusRecordTypeFillClosedCurve);
242 EMRPLUSCASE(EmfPlusRecordTypeDrawClosedCurve);
243 EMRPLUSCASE(EmfPlusRecordTypeDrawCurve);
244 EMRPLUSCASE(EmfPlusRecordTypeDrawBeziers);
245 EMRPLUSCASE(EmfPlusRecordTypeDrawImage);
246 EMRPLUSCASE(EmfPlusRecordTypeDrawImagePoints);
247 EMRPLUSCASE(EmfPlusRecordTypeDrawString);
248 EMRPLUSCASE(EmfPlusRecordTypeSetRenderingOrigin);
249 EMRPLUSCASE(EmfPlusRecordTypeSetAntiAliasMode);
250 EMRPLUSCASE(EmfPlusRecordTypeSetTextRenderingHint);
251 EMRPLUSCASE(EmfPlusRecordTypeSetTextContrast);
252 EMRPLUSCASE(EmfPlusRecordTypeSetInterpolationMode);
253 EMRPLUSCASE(EmfPlusRecordTypeSetPixelOffsetMode);
254 EMRPLUSCASE(EmfPlusRecordTypeSetCompositingMode);
255 EMRPLUSCASE(EmfPlusRecordTypeSetCompositingQuality);
256 EMRPLUSCASE(EmfPlusRecordTypeSave);
257 EMRPLUSCASE(EmfPlusRecordTypeRestore);
258 EMRPLUSCASE(EmfPlusRecordTypeBeginContainer);
259 EMRPLUSCASE(EmfPlusRecordTypeBeginContainerNoParams);
260 EMRPLUSCASE(EmfPlusRecordTypeEndContainer);
261 EMRPLUSCASE(EmfPlusRecordTypeSetWorldTransform);
262 EMRPLUSCASE(EmfPlusRecordTypeResetWorldTransform);
263 EMRPLUSCASE(EmfPlusRecordTypeMultiplyWorldTransform);
264 EMRPLUSCASE(EmfPlusRecordTypeTranslateWorldTransform);
265 EMRPLUSCASE(EmfPlusRecordTypeScaleWorldTransform);
266 EMRPLUSCASE(EmfPlusRecordTypeRotateWorldTransform);
267 EMRPLUSCASE(EmfPlusRecordTypeSetPageTransform);
268 EMRPLUSCASE(EmfPlusRecordTypeResetClip);
269 EMRPLUSCASE(EmfPlusRecordTypeSetClipRect);
270 EMRPLUSCASE(EmfPlusRecordTypeSetClipPath);
271 EMRPLUSCASE(EmfPlusRecordTypeSetClipRegion);
272 EMRPLUSCASE(EmfPlusRecordTypeOffsetClip);
273 EMRPLUSCASE(EmfPlusRecordTypeDrawDriverString);
274 EMRPLUSCASE(EmfPlusRecordTypeStrokeFillPath);
275 EMRPLUSCASE(EmfPlusRecordTypeSerializableObject);
276 EMRPLUSCASE(EmfPlusRecordTypeSetTSGraphics);
277 EMRPLUSCASE(EmfPlusRecordTypeSetTSClip);
278 EMRPLUSCASE(EmfPlusRecordTotal);
280 default:
281 printf("%s unknown EMF+ record %x %04x %08x\n",
282 pfx, (UINT)header->Type, (UINT)header->Flags, (UINT)header->Size);
283 break;
286 if (length<sizeof(*header) || header->Size%4)
287 return 0;
289 length -= sizeof(*header);
290 offset += sizeof(*header);
292 for (i=0; i<header->Size-sizeof(*header); i+=4)
294 if (i%16 == 0)
295 printf("%s ", pfx);
296 if (!(ptr = PRD(offset, 4))) return 0;
297 length -= 4;
298 offset += 4;
299 printf("%08x ", read_int(ptr));
300 if ((i % 16 == 12) || (i + 4 == header->Size - sizeof(*header)))
301 printf("\n");
305 return offset;
308 break;
311 EMRCASE(EMR_FILLRGN);
312 EMRCASE(EMR_FRAMERGN);
313 EMRCASE(EMR_INVERTRGN);
314 EMRCASE(EMR_PAINTRGN);
316 case EMR_EXTSELECTCLIPRGN:
318 const EMREXTSELECTCLIPRGN *clip = PRD(offset, sizeof(*clip));
319 const RGNDATA *data = (const RGNDATA *)clip->RgnData;
320 UINT i, rc_count = 0;
321 const RECTL *rc;
323 if (length >= sizeof(*clip) + sizeof(*data))
324 rc_count = data->rdh.nCount;
326 printf("%s%-20s %08x\n", pfx, "EMR_EXTSELECTCLIPRGN", length);
327 printf("%smode %d, rects %d\n", pfx, (UINT)clip->iMode, rc_count);
328 for (i = 0, rc = (const RECTL *)data->Buffer; i < rc_count; i++)
329 printf("%s (%s)", pfx, debugstr_rect( &rc[i] ));
330 if (rc_count != 0) printf("\n");
331 break;
334 EMRCASE(EMR_BITBLT);
336 case EMR_STRETCHBLT:
338 const EMRSTRETCHBLT *blt = PRD(offset, sizeof(*blt));
339 const BITMAPINFOHEADER *bmih = (const BITMAPINFOHEADER *)((const unsigned char *)blt + blt->offBmiSrc);
341 printf("%s%-20s %08x\n", pfx, "EMR_STRETCHBLT", length);
342 printf("%sbounds (%s) dst %d,%d %dx%d src %d,%d %dx%d rop %#x xform (%f, %f, %f, %f, %f, %f)\n"
343 "%sbk_color %#x usage %#x bmi_offset %#x bmi_size %#x bits_offset %#x bits_size %#x\n",
344 pfx, debugstr_rect( &blt->rclBounds ), (UINT)blt->xDest, (UINT)blt->yDest, (UINT)blt->cxDest, (UINT)blt->cyDest,
345 (UINT)blt->xSrc, (UINT)blt->ySrc, (UINT)blt->cxSrc, (UINT)blt->cySrc, (UINT)blt->dwRop,
346 blt->xformSrc.eM11, blt->xformSrc.eM12, blt->xformSrc.eM21,
347 blt->xformSrc.eM22, blt->xformSrc.eDx, blt->xformSrc.eDy,
348 pfx, (UINT)blt->crBkColorSrc, (UINT)blt->iUsageSrc, (UINT)blt->offBmiSrc, (UINT)blt->cbBmiSrc,
349 (UINT)blt->offBitsSrc, (UINT)blt->cbBitsSrc);
350 printf("%sBITMAPINFOHEADER biSize %#x biWidth %d biHeight %d biPlanes %d biBitCount %d biCompression %#x\n"
351 "%sbiSizeImage %#x biXPelsPerMeter %d biYPelsPerMeter %d biClrUsed %#x biClrImportant %#x\n",
352 pfx, (UINT)bmih->biSize, (UINT)bmih->biWidth, (UINT)bmih->biHeight, (UINT)bmih->biPlanes,
353 (UINT)bmih->biBitCount, (UINT)bmih->biCompression, pfx, (UINT)bmih->biSizeImage,
354 (UINT)bmih->biXPelsPerMeter, (UINT)bmih->biYPelsPerMeter, (UINT)bmih->biClrUsed,
355 (UINT)bmih->biClrImportant);
356 break;
359 EMRCASE(EMR_MASKBLT);
360 EMRCASE(EMR_PLGBLT);
361 EMRCASE(EMR_SETDIBITSTODEVICE);
362 EMRCASE(EMR_STRETCHDIBITS);
364 case EMR_EXTCREATEFONTINDIRECTW:
366 const EMREXTCREATEFONTINDIRECTW *pf = PRD(offset, sizeof(*pf));
367 const LOGFONTW *plf = &pf->elfw.elfLogFont;
369 printf("%s%-20s %08x\n", pfx, "EMR_EXTCREATEFONTINDIRECTW", length);
370 printf("%s(%d %d %d %d %x out %d clip %x quality %d charset %d) %s %s %s %s\n",
371 pfx, (UINT)plf->lfHeight, (UINT)plf->lfWidth, (UINT)plf->lfEscapement, (UINT)plf->lfOrientation,
372 (UINT)plf->lfPitchAndFamily, (UINT)plf->lfOutPrecision, (UINT)plf->lfClipPrecision,
373 plf->lfQuality, plf->lfCharSet,
374 debugstr_wn(plf->lfFaceName, LF_FACESIZE),
375 plf->lfWeight > 400 ? "Bold" : "",
376 plf->lfItalic ? "Italic" : "",
377 plf->lfUnderline ? "Underline" : "");
378 break;
381 EMRCASE(EMR_EXTTEXTOUTA);
383 case EMR_EXTTEXTOUTW:
385 const EMREXTTEXTOUTW *etoW = PRD(offset, sizeof(*etoW));
386 const int *dx = (const int *)((const BYTE *)etoW + etoW->emrtext.offDx);
387 int dx_size;
389 printf("%s%-20s %08x\n", pfx, "EMR_EXTTEXTOUTW", length);
390 printf("%sbounds (%s) mode %#x x_scale %f y_scale %f pt (%d,%d) rect (%s) flags %#x, %s\n",
391 pfx, debugstr_rect( &etoW->rclBounds ), (UINT)etoW->iGraphicsMode, etoW->exScale, etoW->eyScale,
392 (UINT)etoW->emrtext.ptlReference.x, (UINT)etoW->emrtext.ptlReference.y,
393 debugstr_rect( &etoW->emrtext.rcl ), (UINT)etoW->emrtext.fOptions,
394 debugstr_wn((LPCWSTR)((const BYTE *)etoW + etoW->emrtext.offString), etoW->emrtext.nChars));
395 printf("%sdx_offset %u {", pfx, (UINT)etoW->emrtext.offDx);
396 dx_size = etoW->emrtext.nChars;
397 if (etoW->emrtext.fOptions & ETO_PDY)
398 dx_size *= 2;
399 for (i = 0; i < dx_size; ++i)
401 printf("%d", dx[i]);
402 if (i != dx_size - 1)
403 putchar(',');
405 printf("}\n");
406 break;
409 EMRCASE(EMR_POLYBEZIER16);
410 EMRCASE(EMR_POLYGON16);
411 EMRCASE(EMR_POLYLINE16);
412 EMRCASE(EMR_POLYBEZIERTO16);
413 EMRCASE(EMR_POLYLINETO16);
414 EMRCASE(EMR_POLYPOLYLINE16);
415 EMRCASE(EMR_POLYPOLYGON16);
416 EMRCASE(EMR_POLYDRAW16);
417 EMRCASE(EMR_CREATEMONOBRUSH);
418 EMRCASE(EMR_CREATEDIBPATTERNBRUSHPT);
419 EMRCASE(EMR_EXTCREATEPEN);
420 EMRCASE(EMR_POLYTEXTOUTA);
421 EMRCASE(EMR_POLYTEXTOUTW);
422 EMRCASE(EMR_SETICMMODE);
423 EMRCASE(EMR_CREATECOLORSPACE);
424 EMRCASE(EMR_SETCOLORSPACE);
425 EMRCASE(EMR_DELETECOLORSPACE);
426 EMRCASE(EMR_GLSRECORD);
427 EMRCASE(EMR_GLSBOUNDEDRECORD);
428 EMRCASE(EMR_PIXELFORMAT);
429 EMRCASE(EMR_DRAWESCAPE);
430 EMRCASE(EMR_EXTESCAPE);
431 EMRCASE(EMR_STARTDOC);
432 EMRCASE(EMR_SMALLTEXTOUT);
433 EMRCASE(EMR_FORCEUFIMAPPING);
434 EMRCASE(EMR_NAMEDESCAPE);
435 EMRCASE(EMR_COLORCORRECTPALETTE);
436 EMRCASE(EMR_SETICMPROFILEA);
437 EMRCASE(EMR_SETICMPROFILEW);
439 case EMR_ALPHABLEND:
441 const EMRALPHABLEND *blend = PRD(offset, sizeof(*blend));
442 const BITMAPINFOHEADER *bmih = (const BITMAPINFOHEADER *)((const unsigned char *)blend + blend->offBmiSrc);
444 printf("%s%-20s %08x\n", pfx, "EMR_ALPHABLEND", length);
445 printf("%sbounds (%s) dst %d,%d %dx%d src %d,%d %dx%d rop %#x xform (%f, %f, %f, %f, %f, %f)\n"
446 "%sbk_color %#x usage %#x bmi_offset %#x bmi_size %#x bits_offset %#x bits_size %#x\n",
447 pfx, debugstr_rect( &blend->rclBounds ), (UINT)blend->xDest, (UINT)blend->yDest, (UINT)blend->cxDest, (UINT)blend->cyDest,
448 (UINT)blend->xSrc, (UINT)blend->ySrc, (UINT)blend->cxSrc, (UINT)blend->cySrc,
449 (UINT)blend->dwRop, blend->xformSrc.eM11, blend->xformSrc.eM12, blend->xformSrc.eM21,
450 blend->xformSrc.eM22, blend->xformSrc.eDx, blend->xformSrc.eDy,
451 pfx, (UINT)blend->crBkColorSrc, (UINT)blend->iUsageSrc, (UINT)blend->offBmiSrc,
452 (UINT)blend->cbBmiSrc, (UINT)blend->offBitsSrc, (UINT)blend->cbBitsSrc);
453 printf("%sBITMAPINFOHEADER biSize %#x biWidth %d biHeight %d biPlanes %d biBitCount %d biCompression %#x\n"
454 "%sbiSizeImage %#x biXPelsPerMeter %d biYPelsPerMeter %d biClrUsed %#x biClrImportant %#x\n",
455 pfx, (UINT)bmih->biSize, (UINT)bmih->biWidth, (UINT)bmih->biHeight, (UINT)bmih->biPlanes,
456 (UINT)bmih->biBitCount, (UINT)bmih->biCompression, pfx, (UINT)bmih->biSizeImage,
457 (UINT)bmih->biXPelsPerMeter, (UINT)bmih->biYPelsPerMeter, (UINT)bmih->biClrUsed,
458 (UINT)bmih->biClrImportant);
459 break;
462 EMRCASE(EMR_SETLAYOUT);
463 EMRCASE(EMR_TRANSPARENTBLT);
464 EMRCASE(EMR_RESERVED_117);
465 EMRCASE(EMR_GRADIENTFILL);
466 EMRCASE(EMR_SETLINKEDUFI);
467 EMRCASE(EMR_SETTEXTJUSTIFICATION);
468 EMRCASE(EMR_COLORMATCHTOTARGETW);
469 EMRCASE(EMR_CREATECOLORSPACEW);
471 default:
472 printf("%s%u %08x\n", pfx, type, length);
473 break;
476 if ( (length < 8) || (length % 4) )
477 return 0;
479 length -= 8;
481 offset += 8;
483 for(i=0; i<length; i+=4)
485 if (i%16 == 0)
486 printf("%s ", pfx);
487 if (!(ptr = PRD(offset, 4))) return 0;
488 offset += 4;
489 printf("%08x ", read_int(ptr));
490 if ( (i % 16 == 12) || (i + 4 == length))
491 printf("\n");
494 return offset;
497 enum FileSig get_kind_emf(void)
499 const ENHMETAHEADER* hdr;
501 hdr = PRD(0, sizeof(*hdr));
502 if (hdr && hdr->iType == EMR_HEADER && hdr->dSignature == ENHMETA_SIGNATURE)
503 return SIG_EMF;
504 return SIG_UNKNOWN;
507 void emf_dump(void)
509 unsigned long offset = 0;
510 while ((offset = dump_emfrecord("", offset)));