Retry sending a WM_PAINT in update_now after we sent an erase
[wine/wine-kai.git] / tools / winedump / emf.c
bloba418ae830d8741b0b4335a21740e1600933e3192
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdio.h>
25 #ifdef HAVE_UNISTD_H
26 # include <unistd.h>
27 #endif
28 #ifdef HAVE_SYS_TYPES_H
29 # include <sys/types.h>
30 #endif
31 #include <fcntl.h>
32 #include <stdarg.h>
34 #include "windef.h"
35 #include "winbase.h"
36 #include "wingdi.h"
38 static unsigned int read_int(unsigned char *buffer)
40 return buffer[0]
41 + (buffer[1]<<8)
42 + (buffer[2]<<16)
43 + (buffer[3]<<24);
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];
51 int r;
52 unsigned int type, length, i;
54 r = read(fd, buffer, 8);
55 if(r!=8)
56 return -1;
58 type = read_int(buffer);
59 length = read_int(buffer+4);
61 switch(type)
63 EMRCASE(EMR_HEADER);
64 EMRCASE(EMR_POLYGON);
65 EMRCASE(EMR_POLYLINE);
66 EMRCASE(EMR_SETWINDOWEXTEX);
67 EMRCASE(EMR_SETWINDOWORGEX);
68 EMRCASE(EMR_SETVIEWPORTEXTEX);
69 EMRCASE(EMR_EOF);
70 EMRCASE(EMR_SETMAPMODE);
71 EMRCASE(EMR_SETPOLYFILLMODE);
72 EMRCASE(EMR_SETROP2);
73 EMRCASE(EMR_SCALEWINDOWEXTEX);
74 EMRCASE(EMR_SAVEDC);
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);
88 default:
89 printf("%08x %08x\n",type,length);
90 break;
93 if ( (length < 8) || (length % 4) )
94 return -1;
96 length -= 8;
98 for(i=0; i<length; i+=4)
100 if (i%16 == 0)
101 printf(" ");
102 memset(buffer,0,sizeof buffer);
103 r = read(fd,buffer,4);
104 if(r!=4)
105 return -1;
106 printf("%08x ", read_int(buffer));
107 if ( (i%16 == 12) || ((i+4)==length) )
108 printf("\n");
111 return 0;
114 static int dump_emf_records(int fd)
116 while(!dump_emfrecord(fd))
118 return 0;
121 int dump_emf(const char *emf)
123 int fd;
125 fd = open(emf,O_RDONLY);
126 if (fd<0) return -1;
127 dump_emf_records(fd);
128 close(fd);
129 return 0;