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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/port.h"
28 #ifdef HAVE_SYS_TYPES_H
29 # include <sys/types.h>
38 static unsigned int read_int(unsigned char *buffer)
46 #define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break
48 static int dump_emfrecord(int fd)
50 unsigned char buffer[8];
52 unsigned int type, length, i;
54 r = read(fd, buffer, 8);
58 type = read_int(buffer);
59 length = read_int(buffer+4);
65 EMRCASE(EMR_POLYLINE);
66 EMRCASE(EMR_SETWINDOWEXTEX);
67 EMRCASE(EMR_SETWINDOWORGEX);
68 EMRCASE(EMR_SETVIEWPORTEXTEX);
70 EMRCASE(EMR_SETMAPMODE);
71 EMRCASE(EMR_SETPOLYFILLMODE);
73 EMRCASE(EMR_SCALEWINDOWEXTEX);
75 EMRCASE(EMR_SELECTOBJECT);
76 EMRCASE(EMR_CREATEPEN);
77 EMRCASE(EMR_CREATEBRUSHINDIRECT);
78 EMRCASE(EMR_DELETEOBJECT);
79 EMRCASE(EMR_RECTANGLE);
80 EMRCASE(EMR_SELECTPALETTE);
81 EMRCASE(EMR_GDICOMMENT);
82 EMRCASE(EMR_EXTSELECTCLIPRGN);
83 EMRCASE(EMR_EXTCREATEFONTINDIRECTW);
84 EMRCASE(EMR_EXTTEXTOUTW);
85 EMRCASE(EMR_POLYGON16);
86 EMRCASE(EMR_POLYLINE16);
89 printf("%08x %08x\n",type,length);
93 if ( (length < 8) || (length % 4) )
98 for(i=0; i<length; i+=4)
102 memset(buffer,0,sizeof buffer);
103 r = read(fd,buffer,4);
106 printf("%08x ", read_int(buffer));
107 if ( (i%16 == 12) || ((i+4)==length) )
114 static int dump_emf_records(int fd)
116 while(!dump_emfrecord(fd))
121 int dump_emf(const char *emf)
125 fd = open(emf,O_RDONLY);
127 dump_emf_records(fd);