blob: 7df34b61eca4f2e0688c807a72ee8b40bd500794 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% EEEEE M M FFFFF %
7% E MM MM F %
8% EEE M M M FFF %
9% E M M F %
10% EEEEE M M F %
11% %
12% %
13% Read Windows Enahanced Metafile Format %
14% %
15% Software Design %
16% Bill Radcliffe %
17% 2001 %
18% %
cristy7e41fe82010-12-04 23:12:08 +000019% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000020% dedicated to making software imaging solutions freely available. %
21% %
22% You may not use this file except in compliance with the License. You may %
23% obtain a copy of the License at %
24% %
25% http://www.imagemagick.org/script/license.php %
26% %
27% Unless required by applicable law or agreed to in writing, software %
28% distributed under the License is distributed on an "AS IS" BASIS, %
29% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
30% See the License for the specific language governing permissions and %
31% limitations under the License. %
32% %
33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34*/
35
36/*
37 * Include declarations.
38 */
39
cristy4c08aed2011-07-01 19:47:50 +000040#include "MagickCore/studio.h"
cristy3ed852e2009-09-05 21:47:34 +000041#if defined(MAGICKCORE_WINGDI32_DELEGATE)
42# if defined(__CYGWIN__)
43# include <windows.h>
44# else
cristy3ed852e2009-09-05 21:47:34 +000045# include <wingdi.h>
46# endif
47#endif
48
cristy4c08aed2011-07-01 19:47:50 +000049#include "MagickCore/blob.h"
50#include "MagickCore/blob-private.h"
51#include "MagickCore/cache.h"
52#include "MagickCore/exception.h"
53#include "MagickCore/exception-private.h"
54#include "MagickCore/geometry.h"
55#include "MagickCore/image.h"
56#include "MagickCore/image-private.h"
57#include "MagickCore/list.h"
58#include "MagickCore/magick.h"
59#include "MagickCore/memory_.h"
60#include "MagickCore/pixel.h"
61#include "MagickCore/quantum-private.h"
62#include "MagickCore/static.h"
63#include "MagickCore/string_.h"
64#include "MagickCore/module.h"
cristy3ed852e2009-09-05 21:47:34 +000065
66/*
67%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68% %
69% %
70% %
71% I s E F M %
72% %
73% %
74% %
75%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76%
77% IsEMF() returns MagickTrue if the image format type, identified by the
78% magick string, is a Microsoft Windows Enhanced MetaFile (EMF) file.
79%
80% The format of the ReadEMFImage method is:
81%
82% MagickBooleanType IsEMF(const unsigned char *magick,const size_t length)
83%
84% A description of each parameter follows:
85%
86% o magick: compare image format pattern against these bytes.
87%
88% o length: Specifies the length of the magick string.
89%
90*/
91static MagickBooleanType IsEMF(const unsigned char *magick,const size_t length)
92{
93 if (length < 48)
94 return(MagickFalse);
95 if (memcmp(magick+40,"\040\105\115\106\000\000\001\000",8) == 0)
96 return(MagickTrue);
97 return(MagickFalse);
98}
99
100/*
101%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102% %
103% %
104% %
105% I s W M F %
106% %
107% %
108% %
109%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110%
111% IsWMF() returns MagickTrue if the image format type, identified by the
112% magick string, is a Windows MetaFile (WMF) file.
113%
114% The format of the ReadEMFImage method is:
115%
116% MagickBooleanType IsEMF(const unsigned char *magick,const size_t length)
117%
118% A description of each parameter follows:
119%
120% o magick: compare image format pattern against these bytes.
121%
122% o length: Specifies the length of the magick string.
123%
124*/
125static MagickBooleanType IsWMF(const unsigned char *magick,const size_t length)
126{
127 if (length < 4)
128 return(MagickFalse);
129 if (memcmp(magick,"\327\315\306\232",4) == 0)
130 return(MagickTrue);
131 if (memcmp(magick,"\001\000\011\000",4) == 0)
132 return(MagickTrue);
133 return(MagickFalse);
134}
135
136/*
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138% %
139% %
140% %
141% R e a d E M F I m a g e %
142% %
143% %
144% %
145%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146%
147% ReadEMFImage() reads an Microsoft Windows Enhanced MetaFile (EMF) or
148% Windows MetaFile (WMF) file using the Windows API and returns it. It
149% allocates the memory necessary for the new Image structure and returns a
150% pointer to the new image.
151%
152% The format of the ReadEMFImage method is:
153%
154% Image *ReadEMFImage(const ImageInfo *image_info,
155% ExceptionInfo *exception)
156%
157% A description of each parameter follows:
158%
159% o image_info: the image info..
160%
161% o exception: return any errors or warnings in this structure.
162%
163*/
164
165#if defined(MAGICKCORE_HAVE__WFOPEN)
166static size_t UTF8ToUTF16(const unsigned char *utf8,wchar_t *utf16)
167{
168 register const unsigned char
169 *p;
170
171 if (utf16 != (wchar_t *) NULL)
172 {
173 register wchar_t
174 *q;
175
176 wchar_t
177 c;
178
179 /*
180 Convert UTF-8 to UTF-16.
181 */
182 q=utf16;
183 for (p=utf8; *p != '\0'; p++)
184 {
185 if ((*p & 0x80) == 0)
186 *q=(*p);
187 else
188 if ((*p & 0xE0) == 0xC0)
189 {
190 c=(*p);
191 *q=(c & 0x1F) << 6;
192 p++;
193 if ((*p & 0xC0) != 0x80)
194 return(0);
195 *q|=(*p & 0x3F);
196 }
197 else
198 if ((*p & 0xF0) == 0xE0)
199 {
200 c=(*p);
201 *q=c << 12;
202 p++;
203 if ((*p & 0xC0) != 0x80)
204 return(0);
205 c=(*p);
206 *q|=(c & 0x3F) << 6;
207 p++;
208 if ((*p & 0xC0) != 0x80)
209 return(0);
210 *q|=(*p & 0x3F);
211 }
212 else
213 return(0);
214 q++;
215 }
216 *q++='\0';
217 return(q-utf16);
218 }
219 /*
220 Compute UTF-16 string length.
221 */
222 for (p=utf8; *p != '\0'; p++)
223 {
224 if ((*p & 0x80) == 0)
225 ;
226 else
227 if ((*p & 0xE0) == 0xC0)
228 {
229 p++;
230 if ((*p & 0xC0) != 0x80)
231 return(0);
232 }
233 else
234 if ((*p & 0xF0) == 0xE0)
235 {
236 p++;
237 if ((*p & 0xC0) != 0x80)
238 return(0);
239 p++;
240 if ((*p & 0xC0) != 0x80)
241 return(0);
242 }
243 else
244 return(0);
245 }
246 return(p-utf8);
247}
248
249static wchar_t *ConvertUTF8ToUTF16(const unsigned char *source)
250{
251 size_t
252 length;
253
254 wchar_t
255 *utf16;
256
257 length=UTF8ToUTF16(source,(wchar_t *) NULL);
258 if (length == 0)
259 {
cristybb503372010-05-27 20:51:26 +0000260 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000261 i;
262
263 /*
264 Not UTF-8, just copy.
265 */
cristye7e40552010-04-24 21:34:22 +0000266 length=strlen((char *) source);
cristy3ed852e2009-09-05 21:47:34 +0000267 utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
268 if (utf16 == (wchar_t *) NULL)
269 return((wchar_t *) NULL);
cristybb503372010-05-27 20:51:26 +0000270 for (i=0; i <= (ssize_t) length; i++)
cristy3ed852e2009-09-05 21:47:34 +0000271 utf16[i]=source[i];
272 return(utf16);
273 }
274 utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
275 if (utf16 == (wchar_t *) NULL)
276 return((wchar_t *) NULL);
277 length=UTF8ToUTF16(source,utf16);
278 return(utf16);
279}
280#endif
281
282/*
283 This method reads either an enhanced metafile, a regular 16bit Windows
284 metafile, or an Aldus Placeable metafile and converts it into an enhanced
285 metafile. Width and height are returned in .01mm units.
286*/
287#if defined(MAGICKCORE_WINGDI32_DELEGATE)
cristybb503372010-05-27 20:51:26 +0000288static HENHMETAFILE ReadEnhMetaFile(const char *path,ssize_t *width,
289 ssize_t *height)
cristy3ed852e2009-09-05 21:47:34 +0000290{
cristy1f9e1ed2009-11-18 04:09:38 +0000291#pragma pack( push, 2 )
cristy3ed852e2009-09-05 21:47:34 +0000292 typedef struct
293 {
294 DWORD dwKey;
295 WORD hmf;
296 SMALL_RECT bbox;
297 WORD wInch;
298 DWORD dwReserved;
299 WORD wCheckSum;
300 } APMHEADER, *PAPMHEADER;
301#pragma pack( pop )
302
303 DWORD
304 dwSize;
305
306 ENHMETAHEADER
307 emfh;
308
309 HANDLE
310 hFile;
311
312 HDC
313 hDC;
314
315 HENHMETAFILE
316 hTemp;
317
318 LPBYTE
319 pBits;
320
321 METAFILEPICT
322 mp;
323
324 HMETAFILE
325 hOld;
326
327 *width=512;
328 *height=512;
329 hTemp=GetEnhMetaFile(path);
330#if defined(MAGICKCORE_HAVE__WFOPEN)
331 if (hTemp == (HENHMETAFILE) NULL)
332 {
333 wchar_t
334 *unicode_path;
335
cristye7e40552010-04-24 21:34:22 +0000336 unicode_path=ConvertUTF8ToUTF16((const unsigned char *) path);
cristy3ed852e2009-09-05 21:47:34 +0000337 if (unicode_path != (wchar_t *) NULL)
338 {
339 hTemp=GetEnhMetaFileW(unicode_path);
340 unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path);
341 }
342 }
343#endif
344 if (hTemp != (HENHMETAFILE) NULL)
345 {
346 /*
347 Enhanced metafile.
348 */
349 GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh);
350 *width=emfh.rclFrame.right-emfh.rclFrame.left;
351 *height=emfh.rclFrame.bottom-emfh.rclFrame.top;
352 return(hTemp);
353 }
354 hOld=GetMetaFile(path);
355 if (hOld != (HMETAFILE) NULL)
356 {
357 /*
358 16bit windows metafile.
359 */
360 dwSize=GetMetaFileBitsEx(hOld,0,NULL);
361 if (dwSize == 0)
362 {
363 DeleteMetaFile(hOld);
364 return((HENHMETAFILE) NULL);
365 }
366 pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits));
367 if (pBits == (LPBYTE) NULL)
368 {
369 DeleteMetaFile(hOld);
370 return((HENHMETAFILE) NULL);
371 }
372 if (GetMetaFileBitsEx(hOld,dwSize,pBits) == 0)
373 {
374 pBits=(BYTE *) DestroyString((char *) pBits);
375 DeleteMetaFile(hOld);
376 return((HENHMETAFILE) NULL);
377 }
378 /*
379 Make an enhanced metafile from the windows metafile.
380 */
381 mp.mm=MM_ANISOTROPIC;
382 mp.xExt=1000;
383 mp.yExt=1000;
384 mp.hMF=NULL;
385 hDC=GetDC(NULL);
386 hTemp=SetWinMetaFileBits(dwSize,pBits,hDC,&mp);
387 ReleaseDC(NULL,hDC);
388 DeleteMetaFile(hOld);
389 pBits=(BYTE *) DestroyString((char *) pBits);
390 GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh);
391 *width=emfh.rclFrame.right-emfh.rclFrame.left;
392 *height=emfh.rclFrame.bottom-emfh.rclFrame.top;
393 return(hTemp);
394 }
395 /*
396 Aldus Placeable metafile.
397 */
398 hFile=CreateFile(path,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,
399 NULL);
400 if (hFile == INVALID_HANDLE_VALUE)
401 return(NULL);
402 dwSize=GetFileSize(hFile,NULL);
403 pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits));
404 ReadFile(hFile,pBits,dwSize,&dwSize,NULL);
405 CloseHandle(hFile);
406 if (((PAPMHEADER) pBits)->dwKey != 0x9ac6cdd7l)
407 {
408 pBits=(BYTE *) DestroyString((char *) pBits);
409 return((HENHMETAFILE) NULL);
410 }
411 /*
412 Make an enhanced metafile from the placable metafile.
413 */
414 mp.mm=MM_ANISOTROPIC;
415 mp.xExt=((PAPMHEADER) pBits)->bbox.Right-((PAPMHEADER) pBits)->bbox.Left;
416 *width=mp.xExt;
417 mp.xExt=(mp.xExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch);
418 mp.yExt=((PAPMHEADER)pBits)->bbox.Bottom-((PAPMHEADER) pBits)->bbox.Top;
419 *height=mp.yExt;
420 mp.yExt=(mp.yExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch);
421 mp.hMF=NULL;
422 hDC=GetDC(NULL);
423 hTemp=SetWinMetaFileBits(dwSize,&(pBits[sizeof(APMHEADER)]),hDC,&mp);
424 ReleaseDC(NULL,hDC);
425 pBits=(BYTE *) DestroyString((char *) pBits);
426 return(hTemp);
427}
428
429#define CENTIMETERS_INCH 2.54
430
431static Image *ReadEMFImage(const ImageInfo *image_info,
432 ExceptionInfo *exception)
433{
434 BITMAPINFO
435 DIBinfo;
436
437 HBITMAP
438 hBitmap,
439 hOldBitmap;
440
441 HDC
442 hDC;
443
444 HENHMETAFILE
445 hemf;
446
447 Image
448 *image;
449
cristy3ed852e2009-09-05 21:47:34 +0000450 RECT
451 rect;
452
cristybb503372010-05-27 20:51:26 +0000453 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000454 x;
455
cristy4c08aed2011-07-01 19:47:50 +0000456 register Quantum
cristy3ed852e2009-09-05 21:47:34 +0000457 *q;
458
459 RGBQUAD
460 *pBits,
461 *ppBits;
462
cristy202de442011-04-24 18:19:07 +0000463 ssize_t
464 height,
465 width,
466 y;
467
cristy3ed852e2009-09-05 21:47:34 +0000468 image=AcquireImage(image_info);
469 hemf=ReadEnhMetaFile(image_info->filename,&width,&height);
470 if (hemf == (HENHMETAFILE) NULL)
471 ThrowReaderException(CorruptImageError,"ImproperImageHeader");
472 if ((image->columns == 0) || (image->rows == 0))
473 {
474 double
475 y_resolution,
476 x_resolution;
477
478 y_resolution=DefaultResolution;
479 x_resolution=DefaultResolution;
480 if (image->y_resolution > 0)
481 {
482 y_resolution=image->y_resolution;
483 if (image->units == PixelsPerCentimeterResolution)
484 y_resolution*=CENTIMETERS_INCH;
485 }
486 if (image->x_resolution > 0)
487 {
488 x_resolution=image->x_resolution;
489 if (image->units == PixelsPerCentimeterResolution)
490 x_resolution*=CENTIMETERS_INCH;
491 }
cristy202de442011-04-24 18:19:07 +0000492 image->rows=(size_t) ((height/1000.0/CENTIMETERS_INCH)*y_resolution+0.5);
cristybb503372010-05-27 20:51:26 +0000493 image->columns=(size_t) ((width/1000.0/CENTIMETERS_INCH)*
cristy3ed852e2009-09-05 21:47:34 +0000494 x_resolution+0.5);
495 }
496 if (image_info->size != (char *) NULL)
497 {
cristybb503372010-05-27 20:51:26 +0000498 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000499 x;
500
501 image->columns=width;
502 image->rows=height;
503 x=0;
504 y=0;
505 (void) GetGeometry(image_info->size,&x,&y,&image->columns,&image->rows);
506 }
507 if (image_info->page != (char *) NULL)
508 {
509 char
510 *geometry;
511
cristy3ed852e2009-09-05 21:47:34 +0000512 register char
513 *p;
514
515 MagickStatusType
516 flags;
517
cristy202de442011-04-24 18:19:07 +0000518 ssize_t
519 sans;
520
cristy3ed852e2009-09-05 21:47:34 +0000521 geometry=GetPageGeometry(image_info->page);
522 p=strchr(geometry,'>');
523 if (p == (char *) NULL)
524 {
525 flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
526 &image->rows);
527 if (image->x_resolution != 0.0)
cristy202de442011-04-24 18:19:07 +0000528 image->columns=(size_t) floor((image->columns*image->x_resolution)+
cristy06609ee2010-03-17 20:21:27 +0000529 0.5);
cristy202de442011-04-24 18:19:07 +0000530 if (image->y_resolution != 0.0)
531 image->rows=(size_t) floor((image->rows*image->y_resolution)+0.5);
cristy3ed852e2009-09-05 21:47:34 +0000532 }
533 else
534 {
535 *p='\0';
536 flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
537 &image->rows);
538 if (image->x_resolution != 0.0)
cristy202de442011-04-24 18:19:07 +0000539 image->columns=(size_t) floor(((image->columns*image->x_resolution)/
540 DefaultResolution)+0.5);
cristy3ed852e2009-09-05 21:47:34 +0000541 if (image->y_resolution != 0.0)
cristy202de442011-04-24 18:19:07 +0000542 image->rows=(size_t) floor(((image->rows*image->y_resolution)/
543 DefaultResolution)+0.5);
cristy3ed852e2009-09-05 21:47:34 +0000544 }
545 geometry=DestroyString(geometry);
546 }
547 hDC=GetDC(NULL);
548 if (hDC == (HDC) NULL)
549 {
550 DeleteEnhMetaFile(hemf);
551 ThrowReaderException(ResourceLimitError,"UnableToCreateADC");
552 }
553 /*
554 Initialize the bitmap header info.
555 */
556 (void) ResetMagickMemory(&DIBinfo,0,sizeof(BITMAPINFO));
557 DIBinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
cristyeaedf062010-05-29 22:36:02 +0000558 DIBinfo.bmiHeader.biWidth=(LONG) image->columns;
559 DIBinfo.bmiHeader.biHeight=(-1)*(LONG) image->rows;
cristy3ed852e2009-09-05 21:47:34 +0000560 DIBinfo.bmiHeader.biPlanes=1;
561 DIBinfo.bmiHeader.biBitCount=32;
562 DIBinfo.bmiHeader.biCompression=BI_RGB;
cristy202de442011-04-24 18:19:07 +0000563 hBitmap=CreateDIBSection(hDC,&DIBinfo,DIB_RGB_COLORS,(void **) &ppBits,NULL,
564 0);
cristy3ed852e2009-09-05 21:47:34 +0000565 ReleaseDC(NULL,hDC);
566 if (hBitmap == (HBITMAP) NULL)
567 {
568 DeleteEnhMetaFile(hemf);
569 ThrowReaderException(ResourceLimitError,"UnableToCreateBitmap");
570 }
571 hDC=CreateCompatibleDC(NULL);
572 if (hDC == (HDC) NULL)
573 {
574 DeleteEnhMetaFile(hemf);
575 DeleteObject(hBitmap);
576 ThrowReaderException(ResourceLimitError,"UnableToCreateADC");
577 }
578 hOldBitmap=(HBITMAP) SelectObject(hDC,hBitmap);
579 if (hOldBitmap == (HBITMAP) NULL)
580 {
581 DeleteEnhMetaFile(hemf);
582 DeleteDC(hDC);
583 DeleteObject(hBitmap);
584 ThrowReaderException(ResourceLimitError,"UnableToCreateBitmap");
585 }
586 /*
587 Initialize the bitmap to the image background color.
588 */
589 pBits=ppBits;
cristybb503372010-05-27 20:51:26 +0000590 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000591 {
cristybb503372010-05-27 20:51:26 +0000592 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000593 {
594 pBits->rgbRed=ScaleQuantumToChar(image->background_color.red);
595 pBits->rgbGreen=ScaleQuantumToChar(image->background_color.green);
596 pBits->rgbBlue=ScaleQuantumToChar(image->background_color.blue);
597 pBits++;
598 }
599 }
600 rect.top=0;
601 rect.left=0;
cristyeaedf062010-05-29 22:36:02 +0000602 rect.right=(LONG) image->columns;
603 rect.bottom=(LONG) image->rows;
cristy3ed852e2009-09-05 21:47:34 +0000604 /*
605 Convert metafile pixels.
606 */
607 PlayEnhMetaFile(hDC,hemf,&rect);
608 pBits=ppBits;
cristybb503372010-05-27 20:51:26 +0000609 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000610 {
611 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000612 if (q == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000613 break;
cristybb503372010-05-27 20:51:26 +0000614 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000615 {
cristy4c08aed2011-07-01 19:47:50 +0000616 SetPixelRed(image,ScaleCharToQuantum(pBits->rgbRed),q);
617 SetPixelGreen(image,ScaleCharToQuantum(pBits->rgbGreen),q);
618 SetPixelBlue(image,ScaleCharToQuantum(pBits->rgbBlue),q);
619 SetPixelAlpha(image,OpaqueAlpha,q);
cristy3ed852e2009-09-05 21:47:34 +0000620 pBits++;
cristyed231572011-07-14 02:18:59 +0000621 q+=GetPixelChannels(image);
cristy3ed852e2009-09-05 21:47:34 +0000622 }
623 if (SyncAuthenticPixels(image,exception) == MagickFalse)
624 break;
625 }
626 DeleteEnhMetaFile(hemf);
627 SelectObject(hDC,hOldBitmap);
628 DeleteDC(hDC);
629 DeleteObject(hBitmap);
630 return(GetFirstImageInList(image));
631}
632#endif /* MAGICKCORE_WINGDI32_DELEGATE */
633
634/*
635%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
636% %
637% %
638% %
639% R e g i s t e r E M F I m a g e %
640% %
641% %
642% %
643%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644%
645% RegisterEMFImage() adds attributes for the EMF image format to
646% the list of supported formats. The attributes include the image format
647% tag, a method to read and/or write the format, whether the format
648% supports the saving of more than one frame to the same file or blob,
649% whether the format supports native in-memory I/O, and a brief
650% description of the format.
651%
652% The format of the RegisterEMFImage method is:
653%
cristybb503372010-05-27 20:51:26 +0000654% size_t RegisterEMFImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000655%
656*/
cristybb503372010-05-27 20:51:26 +0000657ModuleExport size_t RegisterEMFImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000658{
659 MagickInfo
660 *entry;
661
662 entry=SetMagickInfo("EMF");
663#if defined(MAGICKCORE_WINGDI32_DELEGATE)
664 entry->decoder=ReadEMFImage;
665#endif
666 entry->description=ConstantString(
667 "Windows WIN32 API rendered Enhanced Meta File");
668 entry->magick=(IsImageFormatHandler *) IsEMF;
669 entry->blob_support=MagickFalse;
670 entry->module=ConstantString("WMF");
671 (void) RegisterMagickInfo(entry);
672 entry=SetMagickInfo("WMFWIN32");
673#if defined(MAGICKCORE_WINGDI32_DELEGATE)
674 entry->decoder=ReadEMFImage;
675#endif
676 entry->description=ConstantString("Windows WIN32 API rendered Meta File");
677 entry->magick=(IsImageFormatHandler *) IsWMF;
678 entry->blob_support=MagickFalse;
679 entry->module=ConstantString("WMFWIN32");
680 (void) RegisterMagickInfo(entry);
681 return(MagickImageCoderSignature);
682}
683
684/*
685%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
686% %
687% %
688% %
689% U n r e g i s t e r E M F I m a g e %
690% %
691% %
692% %
693%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
694%
695% UnregisterEMFImage() removes format registrations made by the
696% EMF module from the list of supported formats.
697%
698% The format of the UnregisterEMFImage method is:
699%
700% UnregisterEMFImage(void)
701%
702*/
703ModuleExport void UnregisterEMFImage(void)
704{
705 (void) UnregisterMagickInfo("EMF");
706 (void) UnregisterMagickInfo("WMFWIN32");
707}