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);
66 EMRCASE(EMR_POLYLINE);
67 EMRCASE(EMR_SETWINDOWEXTEX);
68 EMRCASE(EMR_SETWINDOWORGEX);
69 EMRCASE(EMR_SETVIEWPORTEXTEX);
71 EMRCASE(EMR_SETMAPMODE);
72 EMRCASE(EMR_SETPOLYFILLMODE);
74 EMRCASE(EMR_SCALEWINDOWEXTEX);
76 EMRCASE(EMR_SELECTOBJECT);
77 EMRCASE(EMR_CREATEPEN);
78 EMRCASE(EMR_CREATEBRUSHINDIRECT);
79 EMRCASE(EMR_DELETEOBJECT);
80 EMRCASE(EMR_RECTANGLE);
81 EMRCASE(EMR_SELECTPALETTE);
82 EMRCASE(EMR_GDICOMMENT);
83 EMRCASE(EMR_EXTSELECTCLIPRGN);
84 EMRCASE(EMR_EXTCREATEFONTINDIRECTW);
85 EMRCASE(EMR_EXTTEXTOUTW);
86 EMRCASE(EMR_POLYGON16);
87 EMRCASE(EMR_POLYLINE16);
90 printf("%08x %08x\n",type,length);
94 if ( (length < 8) || (length % 4) )
101 for(i=0; i<length; i+=4)
105 if (!(ptr = PRD(offset, 4))) return -1;
107 printf("%08x ", read_int(ptr));
108 if ( (i % 16 == 12) || (i + 4 == length))
115 enum FileSig get_kind_emf(void)
117 const ENHMETAHEADER* hdr;
119 hdr = PRD(0, sizeof(*hdr));
120 if (hdr && hdr->iType == EMR_HEADER && hdr->dSignature == ENHMETA_SIGNATURE)
128 while (!dump_emfrecord());