~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/tools/winedump/emf.c

Version: ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  *  Dump an Enhanced Meta File
  3  *
  4  *  Copyright 2005 Mike McCormack
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include "config.h"
 22 #include "wine/port.h"
 23 #include "winedump.h"
 24 
 25 #include <stdio.h>
 26 #ifdef HAVE_UNISTD_H
 27 # include <unistd.h>
 28 #endif
 29 #ifdef HAVE_SYS_TYPES_H
 30 # include <sys/types.h>
 31 #endif
 32 #include <fcntl.h>
 33 #include <stdarg.h>
 34 
 35 #include "windef.h"
 36 #include "winbase.h"
 37 #include "wingdi.h"
 38 
 39 static const char *debugstr_wn(const WCHAR *wstr, int n)
 40 {
 41     static char buf[80];
 42     char *p;
 43     int i;
 44 
 45     if (!wstr) return "(null)";
 46 
 47     i = 0;
 48     p = buf;
 49     *p++ = '\"';
 50     while (i < n && i < sizeof(buf) - 2 && wstr[i])
 51     {
 52         if (wstr[i] < 127) *p++ = wstr[i];
 53         else *p++ = '.';
 54         i++;
 55     }
 56     *p++ = '\"';
 57     *p = 0;
 58     return buf;
 59 }
 60 
 61 static unsigned int read_int(const unsigned char *buffer)
 62 {
 63     return buffer[0]
 64      + (buffer[1]<<8)
 65      + (buffer[2]<<16)
 66      + (buffer[3]<<24);
 67 }
 68 
 69 #define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break
 70 
 71 static unsigned offset = 0;
 72 
 73 static int dump_emfrecord(void)
 74 {
 75     const unsigned char*        ptr;
 76     unsigned int type, length, i;
 77 
 78     ptr = PRD(offset, 8);
 79     if (!ptr) return -1;
 80 
 81     type = read_int(ptr);
 82     length = read_int(ptr + 4);
 83 
 84     switch(type)
 85     {
 86     EMRCASE(EMR_HEADER);
 87     EMRCASE(EMR_POLYBEZIER);
 88     EMRCASE(EMR_POLYGON);
 89     EMRCASE(EMR_POLYLINE);
 90     EMRCASE(EMR_POLYBEZIERTO);
 91     EMRCASE(EMR_POLYLINETO);
 92     EMRCASE(EMR_POLYPOLYLINE);
 93     EMRCASE(EMR_POLYPOLYGON);
 94     EMRCASE(EMR_SETWINDOWEXTEX);
 95     EMRCASE(EMR_SETWINDOWORGEX);
 96     EMRCASE(EMR_SETVIEWPORTEXTEX);
 97     EMRCASE(EMR_SETVIEWPORTORGEX);
 98     EMRCASE(EMR_SETBRUSHORGEX);
 99     EMRCASE(EMR_EOF);
100     EMRCASE(EMR_SETPIXELV);
101     EMRCASE(EMR_SETMAPPERFLAGS);
102     EMRCASE(EMR_SETMAPMODE);
103     EMRCASE(EMR_SETBKMODE);
104     EMRCASE(EMR_SETPOLYFILLMODE);
105     EMRCASE(EMR_SETROP2);
106     EMRCASE(EMR_SETSTRETCHBLTMODE);
107     EMRCASE(EMR_SETTEXTALIGN);
108     EMRCASE(EMR_SETCOLORADJUSTMENT);
109     EMRCASE(EMR_SETTEXTCOLOR);
110     EMRCASE(EMR_SETBKCOLOR);
111     EMRCASE(EMR_OFFSETCLIPRGN);
112     EMRCASE(EMR_MOVETOEX);
113     EMRCASE(EMR_SETMETARGN);
114     EMRCASE(EMR_EXCLUDECLIPRECT);
115 
116     case EMR_INTERSECTCLIPRECT:
117     {
118         const EMRINTERSECTCLIPRECT *clip = (const EMRINTERSECTCLIPRECT *)PRD(offset, sizeof(*clip));
119 
120         printf("%-20s %08x\n", "EMR_INTERSECTCLIPRECT", length);
121         printf("rect %d,%d - %d, %d\n",
122                clip->rclClip.left, clip->rclClip.top,
123                clip->rclClip.right, clip->rclClip.bottom);
124         break;
125     }
126 
127     EMRCASE(EMR_SCALEVIEWPORTEXTEX);
128     EMRCASE(EMR_SCALEWINDOWEXTEX);
129     EMRCASE(EMR_SAVEDC);
130     EMRCASE(EMR_RESTOREDC);
131     EMRCASE(EMR_SETWORLDTRANSFORM);
132     EMRCASE(EMR_MODIFYWORLDTRANSFORM);
133     EMRCASE(EMR_SELECTOBJECT);
134     EMRCASE(EMR_CREATEPEN);
135     EMRCASE(EMR_CREATEBRUSHINDIRECT);
136     EMRCASE(EMR_DELETEOBJECT);
137     EMRCASE(EMR_ANGLEARC);
138     EMRCASE(EMR_ELLIPSE);
139     EMRCASE(EMR_RECTANGLE);
140     EMRCASE(EMR_ROUNDRECT);
141     EMRCASE(EMR_ARC);
142     EMRCASE(EMR_CHORD);
143     EMRCASE(EMR_PIE);
144     EMRCASE(EMR_SELECTPALETTE);
145     EMRCASE(EMR_CREATEPALETTE);
146     EMRCASE(EMR_SETPALETTEENTRIES);
147     EMRCASE(EMR_RESIZEPALETTE);
148     EMRCASE(EMR_REALIZEPALETTE);
149     EMRCASE(EMR_EXTFLOODFILL);
150     EMRCASE(EMR_LINETO);
151     EMRCASE(EMR_ARCTO);
152     EMRCASE(EMR_POLYDRAW);
153     EMRCASE(EMR_SETARCDIRECTION);
154     EMRCASE(EMR_SETMITERLIMIT);
155     EMRCASE(EMR_BEGINPATH);
156     EMRCASE(EMR_ENDPATH);
157     EMRCASE(EMR_CLOSEFIGURE);
158     EMRCASE(EMR_FILLPATH);
159     EMRCASE(EMR_STROKEANDFILLPATH);
160     EMRCASE(EMR_STROKEPATH);
161     EMRCASE(EMR_FLATTENPATH);
162     EMRCASE(EMR_WIDENPATH);
163     EMRCASE(EMR_SELECTCLIPPATH);
164     EMRCASE(EMR_ABORTPATH);
165     EMRCASE(EMR_GDICOMMENT);
166     EMRCASE(EMR_FILLRGN);
167     EMRCASE(EMR_FRAMERGN);
168     EMRCASE(EMR_INVERTRGN);
169     EMRCASE(EMR_PAINTRGN);
170 
171     case EMR_EXTSELECTCLIPRGN:
172     {
173         const EMREXTSELECTCLIPRGN *clip = (const EMREXTSELECTCLIPRGN *)PRD(offset, sizeof(*clip));
174         const RGNDATA *data = (RGNDATA *)clip->RgnData;
175         DWORD i, rc_count = 0;
176         RECT *rc;
177 
178         if (length >= sizeof(*clip) + sizeof(*data))
179             rc_count = data->rdh.nCount;
180 
181         printf("%-20s %08x\n", "EMREXTSELECTCLIPRGN", length);
182         printf("mode %d, rects %d\n", clip->iMode, rc_count);
183         for (i = 0, rc = (RECT *)data->Buffer; i < rc_count; i++, rc++)
184             printf(" (%d,%d)-(%d,%d)", rc->left, rc->top, rc->right, rc->bottom);
185         if (rc_count != 0) printf("\n");
186         break;
187     }
188 
189     EMRCASE(EMR_BITBLT);
190     EMRCASE(EMR_STRETCHBLT);
191     EMRCASE(EMR_MASKBLT);
192     EMRCASE(EMR_PLGBLT);
193     EMRCASE(EMR_SETDIBITSTODEVICE);
194     EMRCASE(EMR_STRETCHDIBITS);
195 
196     case EMR_EXTCREATEFONTINDIRECTW:
197     {
198         const EMREXTCREATEFONTINDIRECTW *pf = (const EMREXTCREATEFONTINDIRECTW *)PRD(offset, sizeof(*pf));
199         const LOGFONTW *plf = &pf->elfw.elfLogFont;
200 
201         printf("%-20s %08x\n", "EMR_EXTCREATEFONTINDIRECTW", length);
202         printf("(%d %d %d %d %x out %d clip %x quality %d charset %d) %s %s %s %s\n",
203                plf->lfHeight, plf->lfWidth,
204                plf->lfEscapement, plf->lfOrientation,
205                plf->lfPitchAndFamily,
206                plf->lfOutPrecision, plf->lfClipPrecision,
207                plf->lfQuality, plf->lfCharSet,
208                debugstr_wn(plf->lfFaceName, LF_FACESIZE),
209                plf->lfWeight > 400 ? "Bold" : "",
210                plf->lfItalic ? "Italic" : "",
211                plf->lfUnderline ? "Underline" : "");
212         break;
213     }
214 
215     EMRCASE(EMR_EXTTEXTOUTA);
216 
217     case EMR_EXTTEXTOUTW:
218     {
219         const EMREXTTEXTOUTW *etoW = (const EMREXTTEXTOUTW *)PRD(offset, sizeof(*etoW));
220 
221         printf("%-20s %08x\n", "EMR_EXTTEXTOUTW", length);
222         printf("pt (%d,%d) rect (%d,%d - %d,%d) flags %#x, %s\n",
223                etoW->emrtext.ptlReference.x, etoW->emrtext.ptlReference.y,
224                etoW->emrtext.rcl.left, etoW->emrtext.rcl.top,
225                etoW->emrtext.rcl.right, etoW->emrtext.rcl.bottom,
226                etoW->emrtext.fOptions,
227                debugstr_wn((LPCWSTR)((const BYTE *)etoW + etoW->emrtext.offString), etoW->emrtext.nChars));
228         break;
229     }
230 
231     EMRCASE(EMR_POLYBEZIER16);
232     EMRCASE(EMR_POLYGON16);
233     EMRCASE(EMR_POLYLINE16);
234     EMRCASE(EMR_POLYBEZIERTO16);
235     EMRCASE(EMR_POLYLINETO16);
236     EMRCASE(EMR_POLYPOLYLINE16);
237     EMRCASE(EMR_POLYPOLYGON16);
238     EMRCASE(EMR_POLYDRAW16);
239     EMRCASE(EMR_CREATEMONOBRUSH);
240     EMRCASE(EMR_CREATEDIBPATTERNBRUSHPT);
241     EMRCASE(EMR_EXTCREATEPEN);
242     EMRCASE(EMR_POLYTEXTOUTA);
243     EMRCASE(EMR_POLYTEXTOUTW);
244     EMRCASE(EMR_SETICMMODE);
245     EMRCASE(EMR_CREATECOLORSPACE);
246     EMRCASE(EMR_SETCOLORSPACE);
247     EMRCASE(EMR_DELETECOLORSPACE);
248     EMRCASE(EMR_GLSRECORD);
249     EMRCASE(EMR_GLSBOUNDEDRECORD);
250     EMRCASE(EMR_PIXELFORMAT);
251     EMRCASE(EMR_DRAWESCAPE);
252     EMRCASE(EMR_EXTESCAPE);
253     EMRCASE(EMR_STARTDOC);
254     EMRCASE(EMR_SMALLTEXTOUT);
255     EMRCASE(EMR_FORCEUFIMAPPING);
256     EMRCASE(EMR_NAMEDESCAPE);
257     EMRCASE(EMR_COLORCORRECTPALETTE);
258     EMRCASE(EMR_SETICMPROFILEA);
259     EMRCASE(EMR_SETICMPROFILEW);
260     EMRCASE(EMR_ALPHABLEND);
261     EMRCASE(EMR_SETLAYOUT);
262     EMRCASE(EMR_TRANSPARENTBLT);
263     EMRCASE(EMR_RESERVED_117);
264     EMRCASE(EMR_GRADIENTFILL);
265     EMRCASE(EMR_SETLINKEDUFI);
266     EMRCASE(EMR_SETTEXTJUSTIFICATION);
267     EMRCASE(EMR_COLORMATCHTOTARGETW);
268     EMRCASE(EMR_CREATECOLORSPACEW);
269 
270     default:
271         printf("%u %08x\n", type, length);
272         break;
273     }
274 
275     if ( (length < 8) || (length % 4) )
276         return -1;
277 
278     length -= 8;
279 
280     offset += 8;
281 
282     for(i=0; i<length; i+=4)
283     {
284          if (i%16 == 0)
285              printf("   ");
286          if (!(ptr = PRD(offset, 4))) return -1;
287          offset += 4;
288          printf("%08x ", read_int(ptr));
289          if ( (i % 16 == 12) || (i + 4 == length))
290              printf("\n");
291     }
292 
293     return 0;
294 }
295 
296 enum FileSig get_kind_emf(void)
297 {
298     const ENHMETAHEADER*        hdr;
299 
300     hdr = PRD(0, sizeof(*hdr));
301     if (hdr && hdr->iType == EMR_HEADER && hdr->dSignature == ENHMETA_SIGNATURE)
302         return SIG_EMF;
303     return SIG_UNKNOWN;
304 }
305 
306 void emf_dump(void)
307 {
308     offset = 0;
309     while (!dump_emfrecord());
310 }
311 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.