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(unsigned char *buffer)
47 #define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break
49 static int dump_emfrecord(int fd)
51 unsigned char buffer[8];
53 unsigned int type, length, i;
55 r = read(fd, buffer, 8);
59 type = read_int(buffer);
60 length = read_int(buffer+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) )
99 for(i=0; i<length; i+=4)
103 memset(buffer,0,sizeof buffer);
104 r = read(fd,buffer,4);
107 printf("%08x ", read_int(buffer));
108 if ( (i%16 == 12) || ((i+4)==length) )
115 static int dump_emf_records(int fd)
117 while(!dump_emfrecord(fd))
122 int dump_emf(const char *emf)
126 fd = open(emf,O_RDONLY);
128 dump_emf_records(fd);