blob: 777890584bf649a4e5ae4341b428c6ff32af5211 [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"
cristy6c9c9e82011-08-05 14:27:57 +000061#include "MagickCore/pixel-accessor.h"
cristy4c08aed2011-07-01 19:47:50 +000062#include "MagickCore/quantum-private.h"
63#include "MagickCore/static.h"
64#include "MagickCore/string_.h"
65#include "MagickCore/module.h"
cristy3ed852e2009-09-05 21:47:34 +000066
67/*
68%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69% %
70% %
71% %
72% I s E F M %
73% %
74% %
75% %
76%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77%
78% IsEMF() returns MagickTrue if the image format type, identified by the
79% magick string, is a Microsoft Windows Enhanced MetaFile (EMF) file.
80%
81% The format of the ReadEMFImage method is:
82%
83% MagickBooleanType IsEMF(const unsigned char *magick,const size_t length)
84%
85% A description of each parameter follows:
86%
87% o magick: compare image format pattern against these bytes.
88%
89% o length: Specifies the length of the magick string.
90%
91*/
92static MagickBooleanType IsEMF(const unsigned char *magick,const size_t length)
93{
94 if (length < 48)
95 return(MagickFalse);
96 if (memcmp(magick+40,"\040\105\115\106\000\000\001\000",8) == 0)
97 return(MagickTrue);
98 return(MagickFalse);
99}
100
101/*
102%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103% %
104% %
105% %
106% I s W M F %
107% %
108% %
109% %
110%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111%
112% IsWMF() returns MagickTrue if the image format type, identified by the
113% magick string, is a Windows MetaFile (WMF) file.
114%
115% The format of the ReadEMFImage method is:
116%
117% MagickBooleanType IsEMF(const unsigned char *magick,const size_t length)
118%
119% A description of each parameter follows:
120%
121% o magick: compare image format pattern against these bytes.
122%
123% o length: Specifies the length of the magick string.
124%
125*/
126static MagickBooleanType IsWMF(const unsigned char *magick,const size_t length)
127{
128 if (length < 4)
129 return(MagickFalse);
130 if (memcmp(magick,"\327\315\306\232",4) == 0)
131 return(MagickTrue);
132 if (memcmp(magick,"\001\000\011\000",4) == 0)
133 return(MagickTrue);
134 return(MagickFalse);
135}
136
137/*
138%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139% %
140% %
141% %
142% R e a d E M F I m a g e %
143% %
144% %
145% %
146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147%
148% ReadEMFImage() reads an Microsoft Windows Enhanced MetaFile (EMF) or
149% Windows MetaFile (WMF) file using the Windows API and returns it. It
150% allocates the memory necessary for the new Image structure and returns a
151% pointer to the new image.
152%
153% The format of the ReadEMFImage method is:
154%
155% Image *ReadEMFImage(const ImageInfo *image_info,
156% ExceptionInfo *exception)
157%
158% A description of each parameter follows:
159%
160% o image_info: the image info..
161%
162% o exception: return any errors or warnings in this structure.
163%
164*/
165
cristy0bd2bc52011-08-10 02:47:13 +0000166
167#if defined(MAGICKCORE_HAVE__WFOPEN)
168static size_t UTF8ToUTF16(const unsigned char *utf8,wchar_t *utf16)
169{
170 register const unsigned char
171 *p;
172
173 if (utf16 != (wchar_t *) NULL)
174 {
175 register wchar_t
176 *q;
177
178 wchar_t
179 c;
180
181 /*
182 Convert UTF-8 to UTF-16.
183 */
184 q=utf16;
185 for (p=utf8; *p != '\0'; p++)
186 {
187 if ((*p & 0x80) == 0)
188 *q=(*p);
189 else
190 if ((*p & 0xE0) == 0xC0)
191 {
192 c=(*p);
193 *q=(c & 0x1F) << 6;
194 p++;
195 if ((*p & 0xC0) != 0x80)
196 return(0);
197 *q|=(*p & 0x3F);
198 }
199 else
200 if ((*p & 0xF0) == 0xE0)
201 {
202 c=(*p);
203 *q=c << 12;
204 p++;
205 if ((*p & 0xC0) != 0x80)
206 return(0);
207 c=(*p);
208 *q|=(c & 0x3F) << 6;
209 p++;
210 if ((*p & 0xC0) != 0x80)
211 return(0);
212 *q|=(*p & 0x3F);
213 }
214 else
215 return(0);
216 q++;
217 }
218 *q++='\0';
219 return(q-utf16);
220 }
221 /*
222 Compute UTF-16 string length.
223 */
224 for (p=utf8; *p != '\0'; p++)
225 {
226 if ((*p & 0x80) == 0)
227 ;
228 else
229 if ((*p & 0xE0) == 0xC0)
230 {
231 p++;
232 if ((*p & 0xC0) != 0x80)
233 return(0);
234 }
235 else
236 if ((*p & 0xF0) == 0xE0)
237 {
238 p++;
239 if ((*p & 0xC0) != 0x80)
240 return(0);
241 p++;
242 if ((*p & 0xC0) != 0x80)
243 return(0);
244 }
245 else
246 return(0);
247 }
248 return(p-utf8);
249}
250
251static wchar_t *ConvertUTF8ToUTF16(const unsigned char *source)
252{
253 size_t
254 length;
255
256 wchar_t
257 *utf16;
258
259 length=UTF8ToUTF16(source,(wchar_t *) NULL);
260 if (length == 0)
261 {
262 register ssize_t
263 i;
264
265 /*
266 Not UTF-8, just copy.
267 */
268 length=strlen((char *) source);
269 utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
270 if (utf16 == (wchar_t *) NULL)
271 return((wchar_t *) NULL);
272 for (i=0; i <= (ssize_t) length; i++)
273 utf16[i]=source[i];
274 return(utf16);
275 }
276 utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
277 if (utf16 == (wchar_t *) NULL)
278 return((wchar_t *) NULL);
279 length=UTF8ToUTF16(source,utf16);
280 return(utf16);
281}
282#endif
283
cristy3ed852e2009-09-05 21:47:34 +0000284/*
285 This method reads either an enhanced metafile, a regular 16bit Windows
286 metafile, or an Aldus Placeable metafile and converts it into an enhanced
287 metafile. Width and height are returned in .01mm units.
288*/
289#if defined(MAGICKCORE_WINGDI32_DELEGATE)
cristybb503372010-05-27 20:51:26 +0000290static HENHMETAFILE ReadEnhMetaFile(const char *path,ssize_t *width,
291 ssize_t *height)
cristy3ed852e2009-09-05 21:47:34 +0000292{
cristy1f9e1ed2009-11-18 04:09:38 +0000293#pragma pack( push, 2 )
cristy3ed852e2009-09-05 21:47:34 +0000294 typedef struct
295 {
296 DWORD dwKey;
297 WORD hmf;
298 SMALL_RECT bbox;
299 WORD wInch;
300 DWORD dwReserved;
301 WORD wCheckSum;
302 } APMHEADER, *PAPMHEADER;
303#pragma pack( pop )
304
305 DWORD
306 dwSize;
307
308 ENHMETAHEADER
309 emfh;
310
311 HANDLE
312 hFile;
313
314 HDC
315 hDC;
316
317 HENHMETAFILE
318 hTemp;
319
320 LPBYTE
321 pBits;
322
323 METAFILEPICT
324 mp;
325
326 HMETAFILE
327 hOld;
328
329 *width=512;
330 *height=512;
331 hTemp=GetEnhMetaFile(path);
332#if defined(MAGICKCORE_HAVE__WFOPEN)
333 if (hTemp == (HENHMETAFILE) NULL)
334 {
335 wchar_t
336 *unicode_path;
337
cristy0bd2bc52011-08-10 02:47:13 +0000338 unicode_path=ConvertUTF8ToUTF16((const unsigned char *) path);
cristy3ed852e2009-09-05 21:47:34 +0000339 if (unicode_path != (wchar_t *) NULL)
340 {
341 hTemp=GetEnhMetaFileW(unicode_path);
342 unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path);
343 }
344 }
345#endif
346 if (hTemp != (HENHMETAFILE) NULL)
347 {
348 /*
349 Enhanced metafile.
350 */
351 GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh);
352 *width=emfh.rclFrame.right-emfh.rclFrame.left;
353 *height=emfh.rclFrame.bottom-emfh.rclFrame.top;
354 return(hTemp);
355 }
356 hOld=GetMetaFile(path);
357 if (hOld != (HMETAFILE) NULL)
358 {
359 /*
360 16bit windows metafile.
361 */
362 dwSize=GetMetaFileBitsEx(hOld,0,NULL);
363 if (dwSize == 0)
364 {
365 DeleteMetaFile(hOld);
366 return((HENHMETAFILE) NULL);
367 }
368 pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits));
369 if (pBits == (LPBYTE) NULL)
370 {
371 DeleteMetaFile(hOld);
372 return((HENHMETAFILE) NULL);
373 }
374 if (GetMetaFileBitsEx(hOld,dwSize,pBits) == 0)
375 {
376 pBits=(BYTE *) DestroyString((char *) pBits);
377 DeleteMetaFile(hOld);
378 return((HENHMETAFILE) NULL);
379 }
380 /*
381 Make an enhanced metafile from the windows metafile.
382 */
383 mp.mm=MM_ANISOTROPIC;
384 mp.xExt=1000;
385 mp.yExt=1000;
386 mp.hMF=NULL;
387 hDC=GetDC(NULL);
388 hTemp=SetWinMetaFileBits(dwSize,pBits,hDC,&mp);
389 ReleaseDC(NULL,hDC);
390 DeleteMetaFile(hOld);
391 pBits=(BYTE *) DestroyString((char *) pBits);
392 GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh);
393 *width=emfh.rclFrame.right-emfh.rclFrame.left;
394 *height=emfh.rclFrame.bottom-emfh.rclFrame.top;
395 return(hTemp);
396 }
397 /*
398 Aldus Placeable metafile.
399 */
400 hFile=CreateFile(path,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,
401 NULL);
402 if (hFile == INVALID_HANDLE_VALUE)
403 return(NULL);
404 dwSize=GetFileSize(hFile,NULL);
405 pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits));
406 ReadFile(hFile,pBits,dwSize,&dwSize,NULL);
407 CloseHandle(hFile);
408 if (((PAPMHEADER) pBits)->dwKey != 0x9ac6cdd7l)
409 {
410 pBits=(BYTE *) DestroyString((char *) pBits);
411 return((HENHMETAFILE) NULL);
412 }
413 /*
414 Make an enhanced metafile from the placable metafile.
415 */
416 mp.mm=MM_ANISOTROPIC;
417 mp.xExt=((PAPMHEADER) pBits)->bbox.Right-((PAPMHEADER) pBits)->bbox.Left;
418 *width=mp.xExt;
419 mp.xExt=(mp.xExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch);
420 mp.yExt=((PAPMHEADER)pBits)->bbox.Bottom-((PAPMHEADER) pBits)->bbox.Top;
421 *height=mp.yExt;
422 mp.yExt=(mp.yExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch);
423 mp.hMF=NULL;
424 hDC=GetDC(NULL);
425 hTemp=SetWinMetaFileBits(dwSize,&(pBits[sizeof(APMHEADER)]),hDC,&mp);
426 ReleaseDC(NULL,hDC);
427 pBits=(BYTE *) DestroyString((char *) pBits);
428 return(hTemp);
429}
430
431#define CENTIMETERS_INCH 2.54
432
433static Image *ReadEMFImage(const ImageInfo *image_info,
434 ExceptionInfo *exception)
435{
436 BITMAPINFO
437 DIBinfo;
438
439 HBITMAP
440 hBitmap,
441 hOldBitmap;
442
443 HDC
444 hDC;
445
446 HENHMETAFILE
447 hemf;
448
449 Image
450 *image;
451
cristy3ed852e2009-09-05 21:47:34 +0000452 RECT
453 rect;
454
cristybb503372010-05-27 20:51:26 +0000455 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000456 x;
457
cristy4c08aed2011-07-01 19:47:50 +0000458 register Quantum
cristy3ed852e2009-09-05 21:47:34 +0000459 *q;
460
461 RGBQUAD
462 *pBits,
463 *ppBits;
464
cristy202de442011-04-24 18:19:07 +0000465 ssize_t
466 height,
467 width,
468 y;
469
cristy3ed852e2009-09-05 21:47:34 +0000470 image=AcquireImage(image_info);
471 hemf=ReadEnhMetaFile(image_info->filename,&width,&height);
472 if (hemf == (HENHMETAFILE) NULL)
473 ThrowReaderException(CorruptImageError,"ImproperImageHeader");
474 if ((image->columns == 0) || (image->rows == 0))
475 {
476 double
477 y_resolution,
478 x_resolution;
479
480 y_resolution=DefaultResolution;
481 x_resolution=DefaultResolution;
482 if (image->y_resolution > 0)
483 {
484 y_resolution=image->y_resolution;
485 if (image->units == PixelsPerCentimeterResolution)
486 y_resolution*=CENTIMETERS_INCH;
487 }
488 if (image->x_resolution > 0)
489 {
490 x_resolution=image->x_resolution;
491 if (image->units == PixelsPerCentimeterResolution)
492 x_resolution*=CENTIMETERS_INCH;
493 }
cristy202de442011-04-24 18:19:07 +0000494 image->rows=(size_t) ((height/1000.0/CENTIMETERS_INCH)*y_resolution+0.5);
cristybb503372010-05-27 20:51:26 +0000495 image->columns=(size_t) ((width/1000.0/CENTIMETERS_INCH)*
cristy3ed852e2009-09-05 21:47:34 +0000496 x_resolution+0.5);
497 }
498 if (image_info->size != (char *) NULL)
499 {
cristybb503372010-05-27 20:51:26 +0000500 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000501 x;
502
503 image->columns=width;
504 image->rows=height;
505 x=0;
506 y=0;
507 (void) GetGeometry(image_info->size,&x,&y,&image->columns,&image->rows);
508 }
509 if (image_info->page != (char *) NULL)
510 {
511 char
512 *geometry;
513
cristy3ed852e2009-09-05 21:47:34 +0000514 register char
515 *p;
516
517 MagickStatusType
518 flags;
519
cristy202de442011-04-24 18:19:07 +0000520 ssize_t
521 sans;
522
cristy3ed852e2009-09-05 21:47:34 +0000523 geometry=GetPageGeometry(image_info->page);
524 p=strchr(geometry,'>');
525 if (p == (char *) NULL)
526 {
527 flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
528 &image->rows);
529 if (image->x_resolution != 0.0)
cristy202de442011-04-24 18:19:07 +0000530 image->columns=(size_t) floor((image->columns*image->x_resolution)+
cristy06609ee2010-03-17 20:21:27 +0000531 0.5);
cristy202de442011-04-24 18:19:07 +0000532 if (image->y_resolution != 0.0)
533 image->rows=(size_t) floor((image->rows*image->y_resolution)+0.5);
cristy3ed852e2009-09-05 21:47:34 +0000534 }
535 else
536 {
537 *p='\0';
538 flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
539 &image->rows);
540 if (image->x_resolution != 0.0)
cristy202de442011-04-24 18:19:07 +0000541 image->columns=(size_t) floor(((image->columns*image->x_resolution)/
542 DefaultResolution)+0.5);
cristy3ed852e2009-09-05 21:47:34 +0000543 if (image->y_resolution != 0.0)
cristy202de442011-04-24 18:19:07 +0000544 image->rows=(size_t) floor(((image->rows*image->y_resolution)/
545 DefaultResolution)+0.5);
cristy3ed852e2009-09-05 21:47:34 +0000546 }
547 geometry=DestroyString(geometry);
548 }
549 hDC=GetDC(NULL);
550 if (hDC == (HDC) NULL)
551 {
552 DeleteEnhMetaFile(hemf);
553 ThrowReaderException(ResourceLimitError,"UnableToCreateADC");
554 }
555 /*
556 Initialize the bitmap header info.
557 */
558 (void) ResetMagickMemory(&DIBinfo,0,sizeof(BITMAPINFO));
559 DIBinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
cristyeaedf062010-05-29 22:36:02 +0000560 DIBinfo.bmiHeader.biWidth=(LONG) image->columns;
561 DIBinfo.bmiHeader.biHeight=(-1)*(LONG) image->rows;
cristy3ed852e2009-09-05 21:47:34 +0000562 DIBinfo.bmiHeader.biPlanes=1;
563 DIBinfo.bmiHeader.biBitCount=32;
564 DIBinfo.bmiHeader.biCompression=BI_RGB;
cristy202de442011-04-24 18:19:07 +0000565 hBitmap=CreateDIBSection(hDC,&DIBinfo,DIB_RGB_COLORS,(void **) &ppBits,NULL,
566 0);
cristy3ed852e2009-09-05 21:47:34 +0000567 ReleaseDC(NULL,hDC);
568 if (hBitmap == (HBITMAP) NULL)
569 {
570 DeleteEnhMetaFile(hemf);
571 ThrowReaderException(ResourceLimitError,"UnableToCreateBitmap");
572 }
573 hDC=CreateCompatibleDC(NULL);
574 if (hDC == (HDC) NULL)
575 {
576 DeleteEnhMetaFile(hemf);
577 DeleteObject(hBitmap);
578 ThrowReaderException(ResourceLimitError,"UnableToCreateADC");
579 }
580 hOldBitmap=(HBITMAP) SelectObject(hDC,hBitmap);
581 if (hOldBitmap == (HBITMAP) NULL)
582 {
583 DeleteEnhMetaFile(hemf);
584 DeleteDC(hDC);
585 DeleteObject(hBitmap);
586 ThrowReaderException(ResourceLimitError,"UnableToCreateBitmap");
587 }
588 /*
589 Initialize the bitmap to the image background color.
590 */
591 pBits=ppBits;
cristybb503372010-05-27 20:51:26 +0000592 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000593 {
cristybb503372010-05-27 20:51:26 +0000594 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000595 {
596 pBits->rgbRed=ScaleQuantumToChar(image->background_color.red);
597 pBits->rgbGreen=ScaleQuantumToChar(image->background_color.green);
598 pBits->rgbBlue=ScaleQuantumToChar(image->background_color.blue);
599 pBits++;
600 }
601 }
602 rect.top=0;
603 rect.left=0;
cristyeaedf062010-05-29 22:36:02 +0000604 rect.right=(LONG) image->columns;
605 rect.bottom=(LONG) image->rows;
cristy3ed852e2009-09-05 21:47:34 +0000606 /*
607 Convert metafile pixels.
608 */
609 PlayEnhMetaFile(hDC,hemf,&rect);
610 pBits=ppBits;
cristybb503372010-05-27 20:51:26 +0000611 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000612 {
613 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000614 if (q == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000615 break;
cristybb503372010-05-27 20:51:26 +0000616 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000617 {
cristy4c08aed2011-07-01 19:47:50 +0000618 SetPixelRed(image,ScaleCharToQuantum(pBits->rgbRed),q);
619 SetPixelGreen(image,ScaleCharToQuantum(pBits->rgbGreen),q);
620 SetPixelBlue(image,ScaleCharToQuantum(pBits->rgbBlue),q);
621 SetPixelAlpha(image,OpaqueAlpha,q);
cristy3ed852e2009-09-05 21:47:34 +0000622 pBits++;
cristyed231572011-07-14 02:18:59 +0000623 q+=GetPixelChannels(image);
cristy3ed852e2009-09-05 21:47:34 +0000624 }
625 if (SyncAuthenticPixels(image,exception) == MagickFalse)
626 break;
627 }
628 DeleteEnhMetaFile(hemf);
629 SelectObject(hDC,hOldBitmap);
630 DeleteDC(hDC);
631 DeleteObject(hBitmap);
632 return(GetFirstImageInList(image));
633}
634#endif /* MAGICKCORE_WINGDI32_DELEGATE */
635
636/*
637%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638% %
639% %
640% %
641% R e g i s t e r E M F I m a g e %
642% %
643% %
644% %
645%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
646%
647% RegisterEMFImage() adds attributes for the EMF image format to
648% the list of supported formats. The attributes include the image format
649% tag, a method to read and/or write the format, whether the format
650% supports the saving of more than one frame to the same file or blob,
651% whether the format supports native in-memory I/O, and a brief
652% description of the format.
653%
654% The format of the RegisterEMFImage method is:
655%
cristybb503372010-05-27 20:51:26 +0000656% size_t RegisterEMFImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000657%
658*/
cristybb503372010-05-27 20:51:26 +0000659ModuleExport size_t RegisterEMFImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000660{
661 MagickInfo
662 *entry;
663
664 entry=SetMagickInfo("EMF");
665#if defined(MAGICKCORE_WINGDI32_DELEGATE)
666 entry->decoder=ReadEMFImage;
667#endif
668 entry->description=ConstantString(
669 "Windows WIN32 API rendered Enhanced Meta File");
670 entry->magick=(IsImageFormatHandler *) IsEMF;
671 entry->blob_support=MagickFalse;
672 entry->module=ConstantString("WMF");
673 (void) RegisterMagickInfo(entry);
674 entry=SetMagickInfo("WMFWIN32");
675#if defined(MAGICKCORE_WINGDI32_DELEGATE)
676 entry->decoder=ReadEMFImage;
677#endif
678 entry->description=ConstantString("Windows WIN32 API rendered Meta File");
679 entry->magick=(IsImageFormatHandler *) IsWMF;
680 entry->blob_support=MagickFalse;
681 entry->module=ConstantString("WMFWIN32");
682 (void) RegisterMagickInfo(entry);
683 return(MagickImageCoderSignature);
684}
685
686/*
687%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
688% %
689% %
690% %
691% U n r e g i s t e r E M F I m a g e %
692% %
693% %
694% %
695%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
696%
697% UnregisterEMFImage() removes format registrations made by the
698% EMF module from the list of supported formats.
699%
700% The format of the UnregisterEMFImage method is:
701%
702% UnregisterEMFImage(void)
703%
704*/
705ModuleExport void UnregisterEMFImage(void)
706{
707 (void) UnregisterMagickInfo("EMF");
708 (void) UnregisterMagickInfo("WMFWIN32");
709}