2 * Unit test suite for metafiles
4 * Copyright (C) 2011 Vincent Povirk for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
27 #include <wine/test.h>
32 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
33 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
34 #define expectf(expected, got) expectf_((expected), (got), 0.001)
36 static BOOL save_metafiles
;
37 static BOOL load_metafiles
;
39 typedef struct emfplus_record
44 void (*playback_fn
)(GpMetafile
* metafile
, EmfPlusRecordType record_type
,
45 unsigned int flags
, unsigned int dataSize
, const unsigned char *pStr
);
48 typedef struct emfplus_check_state
52 const struct emfplus_record
*expected
;
54 } emfplus_check_state
;
56 static void check_record(int count
, const char *desc
, const struct emfplus_record
*expected
, const struct emfplus_record
*actual
)
58 todo_wine_if (expected
->todo
)
59 ok(expected
->record_type
== actual
->record_type
,
60 "%s.%i: Expected record type 0x%x, got 0x%x\n", desc
, count
,
61 expected
->record_type
, actual
->record_type
);
64 typedef struct EmfPlusRecordHeader
70 } EmfPlusRecordHeader
;
81 ObjectTypeStringFormat
,
82 ObjectTypeImageAttributes
,
83 ObjectTypeCustomLineCap
,
90 ImageDataTypeMetafile
,
95 EmfPlusRecordHeader Header
;
101 DWORD MetafileDataSize
;
102 BYTE MetafileData
[1];
103 } MetafileImageObject
;
105 static int CALLBACK
enum_emf_proc(HDC hDC
, HANDLETABLE
*lpHTable
, const ENHMETARECORD
*lpEMFR
,
106 int nObj
, LPARAM lpData
)
108 emfplus_check_state
*state
= (emfplus_check_state
*)lpData
;
109 emfplus_record actual
;
111 if (lpEMFR
->iType
== EMR_GDICOMMENT
)
113 const EMRGDICOMMENT
*comment
= (const EMRGDICOMMENT
*)lpEMFR
;
115 if (comment
->cbData
>= 4 && memcmp(comment
->Data
, "EMF+", 4) == 0)
119 while (offset
+ sizeof(EmfPlusRecordHeader
) <= comment
->cbData
)
121 const EmfPlusRecordHeader
*record
= (const EmfPlusRecordHeader
*)&comment
->Data
[offset
];
123 ok(record
->Size
== record
->DataSize
+ sizeof(EmfPlusRecordHeader
),
124 "%s: EMF+ record datasize %u and size %u mismatch\n", state
->desc
, record
->DataSize
, record
->Size
);
126 ok(offset
+ record
->DataSize
<= comment
->cbData
,
127 "%s: EMF+ record truncated\n", state
->desc
);
129 if (offset
+ record
->DataSize
> comment
->cbData
)
132 if (state
->expected
[state
->count
].record_type
)
135 actual
.record_type
= record
->Type
;
137 check_record(state
->count
, state
->desc
, &state
->expected
[state
->count
], &actual
);
140 if (state
->expected
[state
->count
-1].todo
&& state
->expected
[state
->count
-1].record_type
!= actual
.record_type
)
145 ok(0, "%s: Unexpected EMF+ 0x%x record\n", state
->desc
, record
->Type
);
148 if ((record
->Flags
>> 8) == ObjectTypeImage
&& record
->Type
== EmfPlusRecordTypeObject
)
150 const MetafileImageObject
*image
= (const MetafileImageObject
*)record
;
152 if (image
->Type
== ImageDataTypeMetafile
)
154 HENHMETAFILE hemf
= SetEnhMetaFileBits(image
->MetafileDataSize
, image
->MetafileData
);
155 ok(hemf
!= NULL
, "%s: SetEnhMetaFileBits failed\n", state
->desc
);
157 EnumEnhMetaFile(0, hemf
, enum_emf_proc
, state
, NULL
);
158 DeleteEnhMetaFile(hemf
);
162 offset
+= record
->Size
;
165 ok(offset
== comment
->cbData
, "%s: truncated EMF+ record data?\n", state
->desc
);
171 if (state
->expected
[state
->count
].record_type
)
174 actual
.record_type
= lpEMFR
->iType
;
176 check_record(state
->count
, state
->desc
, &state
->expected
[state
->count
], &actual
);
182 ok(0, "%s: Unexpected EMF 0x%x record\n", state
->desc
, lpEMFR
->iType
);
188 static void check_emfplus(HENHMETAFILE hemf
, const emfplus_record
*expected
, const char *desc
)
190 emfplus_check_state state
;
194 state
.expected
= expected
;
196 EnumEnhMetaFile(0, hemf
, enum_emf_proc
, &state
, NULL
);
198 todo_wine_if (expected
[state
.count
].todo
)
199 ok(expected
[state
.count
].record_type
== 0, "%s: Got %i records, expecting more\n", desc
, state
.count
);
202 static BOOL CALLBACK
enum_metafile_proc(EmfPlusRecordType record_type
, unsigned int flags
,
203 unsigned int dataSize
, const unsigned char *pStr
, void *userdata
)
205 emfplus_check_state
*state
= (emfplus_check_state
*)userdata
;
206 emfplus_record actual
;
209 actual
.record_type
= record_type
;
212 ok(pStr
== NULL
, "non-NULL pStr\n");
214 if (state
->expected
[state
->count
].record_type
)
216 check_record(state
->count
, state
->desc
, &state
->expected
[state
->count
], &actual
);
222 ok(0, "%s: Unexpected EMF 0x%x record\n", state
->desc
, record_type
);
228 static void check_metafile(GpMetafile
*metafile
, const emfplus_record
*expected
, const char *desc
,
229 const GpPointF
*dst_points
, const GpRectF
*src_rect
, Unit src_unit
)
233 GpGraphics
*graphics
;
234 emfplus_check_state state
;
238 state
.expected
= expected
;
239 state
.metafile
= metafile
;
241 hdc
= CreateCompatibleDC(0);
243 stat
= GdipCreateFromHDC(hdc
, &graphics
);
246 stat
= GdipEnumerateMetafileSrcRectDestPoints(graphics
, metafile
, dst_points
,
247 3, src_rect
, src_unit
, enum_metafile_proc
, &state
, NULL
);
250 todo_wine_if (expected
[state
.count
].todo
)
251 ok(expected
[state
.count
].record_type
== 0, "%s: Got %i records, expecting more\n", desc
, state
.count
);
253 GdipDeleteGraphics(graphics
);
258 static BOOL CALLBACK
play_metafile_proc(EmfPlusRecordType record_type
, unsigned int flags
,
259 unsigned int dataSize
, const unsigned char *pStr
, void *userdata
)
261 emfplus_check_state
*state
= (emfplus_check_state
*)userdata
;
264 if (state
->expected
[state
->count
].record_type
)
266 BOOL match
= (state
->expected
[state
->count
].record_type
== record_type
);
268 if (match
&& state
->expected
[state
->count
].playback_fn
)
269 state
->expected
[state
->count
].playback_fn(state
->metafile
, record_type
, flags
, dataSize
, pStr
);
272 stat
= GdipPlayMetafileRecord(state
->metafile
, record_type
, flags
, dataSize
, pStr
);
273 todo_wine_if (state
->expected
[state
->count
].playback_todo
)
274 ok(stat
== Ok
, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state
->desc
, state
->count
, stat
);
277 todo_wine_if (state
->expected
[state
->count
].todo
)
278 ok(state
->expected
[state
->count
].record_type
== record_type
,
279 "%s.%i: expected record type 0x%x, got 0x%x\n", state
->desc
, state
->count
,
280 state
->expected
[state
->count
].record_type
, record_type
);
285 todo_wine_if (state
->expected
[state
->count
].playback_todo
)
286 ok(0, "%s: unexpected record 0x%x\n", state
->desc
, record_type
);
294 static void play_metafile(GpMetafile
*metafile
, GpGraphics
*graphics
, const emfplus_record
*expected
,
295 const char *desc
, const GpPointF
*dst_points
, const GpRectF
*src_rect
, Unit src_unit
)
298 emfplus_check_state state
;
302 state
.expected
= expected
;
303 state
.metafile
= metafile
;
305 stat
= GdipEnumerateMetafileSrcRectDestPoints(graphics
, metafile
, dst_points
,
306 3, src_rect
, src_unit
, play_metafile_proc
, &state
, NULL
);
310 /* When 'save' or 'load' is specified on the command line, save or
311 * load the specified filename. */
312 static void sync_metafile(GpMetafile
**metafile
, const char *filename
)
320 stat
= GdipCloneImage((GpImage
*)*metafile
, (GpImage
**)&clone
);
323 stat
= GdipGetHemfFromMetafile(clone
, &hemf
);
326 DeleteEnhMetaFile(CopyEnhMetaFileA(hemf
, filename
));
328 DeleteEnhMetaFile(hemf
);
330 stat
= GdipDisposeImage((GpImage
*)clone
);
333 else if (load_metafiles
)
337 stat
= GdipDisposeImage((GpImage
*)*metafile
);
341 hemf
= GetEnhMetaFileA(filename
);
342 ok(hemf
!= NULL
, "%s could not be opened\n", filename
);
344 stat
= GdipCreateMetafileFromEmf(hemf
, TRUE
, metafile
);
349 static const emfplus_record empty_records
[] = {
351 {0, EmfPlusRecordTypeHeader
},
352 {0, EmfPlusRecordTypeEndOfFile
},
357 static void test_empty(void)
360 GpMetafile
*metafile
;
361 GpGraphics
*graphics
;
366 HENHMETAFILE hemf
, dummy
;
367 MetafileHeader header
;
368 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
369 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
370 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
372 hdc
= CreateCompatibleDC(0);
374 stat
= GdipRecordMetafile(NULL
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
375 expect(InvalidParameter
, stat
);
377 stat
= GdipRecordMetafile(hdc
, MetafileTypeInvalid
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
378 expect(InvalidParameter
, stat
);
380 stat
= GdipRecordMetafile(hdc
, MetafileTypeWmf
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
381 expect(InvalidParameter
, stat
);
383 stat
= GdipRecordMetafile(hdc
, MetafileTypeWmfPlaceable
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
384 expect(InvalidParameter
, stat
);
386 stat
= GdipRecordMetafile(hdc
, MetafileTypeEmfPlusDual
+1, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
387 expect(InvalidParameter
, stat
);
389 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, NULL
);
390 expect(InvalidParameter
, stat
);
392 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
400 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
401 expect(InvalidParameter
, stat
);
403 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
406 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
407 expect(InvalidParameter
, stat
);
409 stat
= GdipDeleteGraphics(graphics
);
412 check_metafile(metafile
, empty_records
, "empty metafile", dst_points
, &frame
, UnitPixel
);
414 sync_metafile(&metafile
, "empty.emf");
416 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
418 expectf(0.0, bounds
.X
);
419 expectf(0.0, bounds
.Y
);
420 expectf_(100.0, bounds
.Width
, 0.05);
421 expectf_(100.0, bounds
.Height
, 0.05);
422 expect(UnitPixel
, unit
);
424 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
427 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
430 memset(&header
, 0xaa, sizeof(header
));
431 stat
= GdipGetMetafileHeaderFromMetafile(metafile
, &header
);
433 expect(MetafileTypeEmfPlusOnly
, header
.Type
);
434 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
435 ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
436 expect(1, header
.EmfPlusFlags
); /* reference device was display, not printer */
437 expectf(xres
, header
.DpiX
);
438 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
439 expectf(yres
, header
.DpiY
);
440 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
443 expect(100, header
.Width
);
444 expect(100, header
.Height
);
445 expect(28, header
.EmfPlusHeaderSize
);
446 expect(96, header
.LogicalDpiX
);
447 expect(96, header
.LogicalDpiX
);
448 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
449 expect(0, U(header
).EmfHeader
.rclBounds
.left
);
450 expect(0, U(header
).EmfHeader
.rclBounds
.top
);
451 expect(-1, U(header
).EmfHeader
.rclBounds
.right
);
452 expect(-1, U(header
).EmfHeader
.rclBounds
.bottom
);
453 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
454 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
455 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
456 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
458 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
461 stat
= GdipGetHemfFromMetafile(metafile
, &dummy
);
462 expect(InvalidParameter
, stat
);
464 stat
= GdipDisposeImage((GpImage
*)metafile
);
467 check_emfplus(hemf
, empty_records
, "empty emf");
469 memset(&header
, 0xaa, sizeof(header
));
470 stat
= GdipGetMetafileHeaderFromEmf(hemf
, &header
);
472 expect(MetafileTypeEmfPlusOnly
, header
.Type
);
473 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
474 ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
475 expect(1, header
.EmfPlusFlags
); /* reference device was display, not printer */
476 expectf(xres
, header
.DpiX
);
477 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
478 expectf(yres
, header
.DpiY
);
479 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
482 expect(100, header
.Width
);
483 expect(100, header
.Height
);
484 expect(28, header
.EmfPlusHeaderSize
);
485 expect(96, header
.LogicalDpiX
);
486 expect(96, header
.LogicalDpiX
);
487 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
488 expect(0, U(header
).EmfHeader
.rclBounds
.left
);
489 expect(0, U(header
).EmfHeader
.rclBounds
.top
);
490 expect(-1, U(header
).EmfHeader
.rclBounds
.right
);
491 expect(-1, U(header
).EmfHeader
.rclBounds
.bottom
);
492 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
493 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
494 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
495 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
497 stat
= GdipCreateMetafileFromEmf(hemf
, TRUE
, &metafile
);
500 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
502 expectf(0.0, bounds
.X
);
503 expectf(0.0, bounds
.Y
);
504 expectf_(100.0, bounds
.Width
, 0.05);
505 expectf_(100.0, bounds
.Height
, 0.05);
506 expect(UnitPixel
, unit
);
508 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
510 expectf(header
.DpiX
, xres
);
512 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
514 expectf(header
.DpiY
, yres
);
516 memset(&header
, 0xaa, sizeof(header
));
517 stat
= GdipGetMetafileHeaderFromMetafile(metafile
, &header
);
519 expect(MetafileTypeEmfPlusOnly
, header
.Type
);
520 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
521 ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
522 expect(1, header
.EmfPlusFlags
); /* reference device was display, not printer */
523 expectf(xres
, header
.DpiX
);
524 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
525 expectf(yres
, header
.DpiY
);
526 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
529 expect(100, header
.Width
);
530 expect(100, header
.Height
);
531 expect(28, header
.EmfPlusHeaderSize
);
532 expect(96, header
.LogicalDpiX
);
533 expect(96, header
.LogicalDpiX
);
534 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
535 expect(0, U(header
).EmfHeader
.rclBounds
.left
);
536 expect(0, U(header
).EmfHeader
.rclBounds
.top
);
537 expect(-1, U(header
).EmfHeader
.rclBounds
.right
);
538 expect(-1, U(header
).EmfHeader
.rclBounds
.bottom
);
539 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
540 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
541 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
542 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
544 stat
= GdipDisposeImage((GpImage
*)metafile
);
548 static const emfplus_record getdc_records
[] = {
550 {0, EmfPlusRecordTypeHeader
},
551 {0, EmfPlusRecordTypeGetDC
},
552 {0, EMR_CREATEBRUSHINDIRECT
},
553 {0, EMR_SELECTOBJECT
},
555 {0, EMR_SELECTOBJECT
},
556 {0, EMR_DELETEOBJECT
},
557 {0, EmfPlusRecordTypeEndOfFile
},
562 static void test_getdc(void)
565 GpMetafile
*metafile
;
566 GpGraphics
*graphics
;
567 HDC hdc
, metafile_dc
;
570 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
571 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
572 static const GpPointF dst_points_half
[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
573 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
574 HBRUSH hbrush
, holdbrush
;
578 hdc
= CreateCompatibleDC(0);
580 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
588 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
589 expect(InvalidParameter
, stat
);
591 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
594 stat
= GdipGetDC(graphics
, &metafile_dc
);
599 GdipDeleteGraphics(graphics
);
600 GdipDisposeImage((GpImage
*)metafile
);
604 hbrush
= CreateSolidBrush(0xff0000);
606 holdbrush
= SelectObject(metafile_dc
, hbrush
);
608 Rectangle(metafile_dc
, 25, 25, 75, 75);
610 SelectObject(metafile_dc
, holdbrush
);
612 DeleteObject(hbrush
);
614 stat
= GdipReleaseDC(graphics
, metafile_dc
);
617 stat
= GdipDeleteGraphics(graphics
);
620 check_metafile(metafile
, getdc_records
, "getdc metafile", dst_points
, &frame
, UnitPixel
);
622 sync_metafile(&metafile
, "getdc.emf");
624 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
627 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
630 play_metafile(metafile
, graphics
, getdc_records
, "getdc playback", dst_points
, &frame
, UnitPixel
);
632 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
636 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
638 expect(0xff0000ff, color
);
640 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
643 play_metafile(metafile
, graphics
, getdc_records
, "getdc playback", dst_points_half
, &frame
, UnitPixel
);
645 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
647 expect(0xff0000ff, color
);
649 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
653 stat
= GdipBitmapSetPixel(bitmap
, 15, 15, 0);
656 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
657 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
660 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
664 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
666 expect(0xff0000ff, color
);
668 stat
= GdipDeleteGraphics(graphics
);
671 stat
= GdipDisposeImage((GpImage
*)bitmap
);
674 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
677 stat
= GdipDisposeImage((GpImage
*)metafile
);
680 check_emfplus(hemf
, getdc_records
, "getdc emf");
682 ret
= DeleteEnhMetaFile(hemf
);
683 ok(ret
!= 0, "Failed to delete enhmetafile %p\n", hemf
);
686 static const emfplus_record emfonly_records
[] = {
688 {0, EMR_CREATEBRUSHINDIRECT
},
689 {0, EMR_SELECTOBJECT
},
691 {0, EMR_SELECTOBJECT
},
692 {0, EMR_DELETEOBJECT
},
697 static const emfplus_record emfonly_draw_records
[] = {
701 {1, EMR_SETMITERLIMIT
},
702 {1, EMR_MODIFYWORLDTRANSFORM
},
703 {1, EMR_EXTCREATEPEN
},
704 {1, EMR_SELECTOBJECT
},
705 {1, EMR_SELECTOBJECT
},
707 {1, EMR_SELECTOBJECT
},
708 {1, EMR_SELECTOBJECT
},
709 {1, EMR_MODIFYWORLDTRANSFORM
},
710 {1, EMR_DELETEOBJECT
},
711 {1, EMR_SETMITERLIMIT
},
717 static void test_emfonly(void)
720 GpMetafile
*metafile
;
722 GpGraphics
*graphics
;
723 HDC hdc
, metafile_dc
;
728 MetafileHeader header
;
729 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
730 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
731 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
732 HBRUSH hbrush
, holdbrush
;
737 hdc
= CreateCompatibleDC(0);
739 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
747 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
748 expect(InvalidParameter
, stat
);
750 memset(&header
, 0xaa, sizeof(header
));
751 stat
= GdipGetMetafileHeaderFromMetafile(metafile
, &header
);
753 expect(MetafileTypeEmf
, header
.Type
);
754 ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
755 /* The rest is zeroed or seemingly random/uninitialized garbage. */
757 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
760 stat
= GdipGetDC(graphics
, &metafile_dc
);
765 GdipDeleteGraphics(graphics
);
766 GdipDisposeImage((GpImage
*)metafile
);
770 hbrush
= CreateSolidBrush(0xff0000);
772 holdbrush
= SelectObject(metafile_dc
, hbrush
);
774 Rectangle(metafile_dc
, 25, 25, 75, 75);
776 SelectObject(metafile_dc
, holdbrush
);
778 DeleteObject(hbrush
);
780 stat
= GdipReleaseDC(graphics
, metafile_dc
);
783 stat
= GdipDeleteGraphics(graphics
);
786 check_metafile(metafile
, emfonly_records
, "emfonly metafile", dst_points
, &frame
, UnitPixel
);
788 sync_metafile(&metafile
, "emfonly.emf");
790 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
792 expectf(0.0, bounds
.X
);
793 expectf(0.0, bounds
.Y
);
794 expectf_(100.0, bounds
.Width
, 0.05);
795 expectf_(100.0, bounds
.Height
, 0.05);
796 expect(UnitPixel
, unit
);
798 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
801 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
804 memset(&header
, 0xaa, sizeof(header
));
805 stat
= GdipGetMetafileHeaderFromMetafile(metafile
, &header
);
807 expect(MetafileTypeEmf
, header
.Type
);
808 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
809 /* For some reason a recoreded EMF Metafile has an EMF+ version. */
810 todo_wine
ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
811 expect(0, header
.EmfPlusFlags
);
812 expectf(xres
, header
.DpiX
);
813 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
814 expectf(yres
, header
.DpiY
);
815 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
818 expect(100, header
.Width
);
819 expect(100, header
.Height
);
820 expect(0, header
.EmfPlusHeaderSize
);
821 expect(0, header
.LogicalDpiX
);
822 expect(0, header
.LogicalDpiX
);
823 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
824 expect(25, U(header
).EmfHeader
.rclBounds
.left
);
825 expect(25, U(header
).EmfHeader
.rclBounds
.top
);
826 expect(74, U(header
).EmfHeader
.rclBounds
.right
);
827 expect(74, U(header
).EmfHeader
.rclBounds
.bottom
);
828 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
829 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
830 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
831 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
833 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
836 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
839 play_metafile(metafile
, graphics
, emfonly_records
, "emfonly playback", dst_points
, &frame
, UnitPixel
);
841 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
845 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
847 expect(0xff0000ff, color
);
849 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
852 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
853 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
856 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
860 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
862 expect(0xff0000ff, color
);
864 stat
= GdipCloneImage((GpImage
*)metafile
, &clone
);
869 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
872 stat
= GdipDrawImagePointsRect(graphics
, clone
, dst_points
, 3,
873 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
876 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
880 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
882 expect(0xff0000ff, color
);
884 GdipDisposeImage(clone
);
887 stat
= GdipDeleteGraphics(graphics
);
890 stat
= GdipDisposeImage((GpImage
*)bitmap
);
893 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
896 stat
= GdipDisposeImage((GpImage
*)metafile
);
899 check_emfplus(hemf
, emfonly_records
, "emfonly emf");
901 memset(&header
, 0xaa, sizeof(header
));
902 stat
= GdipGetMetafileHeaderFromEmf(hemf
, &header
);
904 expect(MetafileTypeEmf
, header
.Type
);
905 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
906 expect(0x10000, header
.Version
);
907 expect(0, header
.EmfPlusFlags
);
908 expectf(xres
, header
.DpiX
);
909 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
910 expectf(yres
, header
.DpiY
);
911 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
914 expect(100, header
.Width
);
915 expect(100, header
.Height
);
916 expect(0, header
.EmfPlusHeaderSize
);
917 expect(0, header
.LogicalDpiX
);
918 expect(0, header
.LogicalDpiX
);
919 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
920 expect(25, U(header
).EmfHeader
.rclBounds
.left
);
921 expect(25, U(header
).EmfHeader
.rclBounds
.top
);
922 expect(74, U(header
).EmfHeader
.rclBounds
.right
);
923 expect(74, U(header
).EmfHeader
.rclBounds
.bottom
);
924 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
925 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
926 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
927 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
929 stat
= GdipCreateMetafileFromEmf(hemf
, TRUE
, &metafile
);
932 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
934 expectf(0.0, bounds
.X
);
935 expectf(0.0, bounds
.Y
);
936 expectf_(100.0, bounds
.Width
, 0.05);
937 expectf_(100.0, bounds
.Height
, 0.05);
938 expect(UnitPixel
, unit
);
940 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
942 expectf(header
.DpiX
, xres
);
944 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
946 expectf(header
.DpiY
, yres
);
948 memset(&header
, 0xaa, sizeof(header
));
949 stat
= GdipGetMetafileHeaderFromMetafile(metafile
, &header
);
951 expect(MetafileTypeEmf
, header
.Type
);
952 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
953 expect(0x10000, header
.Version
);
954 expect(0, header
.EmfPlusFlags
);
955 expectf(xres
, header
.DpiX
);
956 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
957 expectf(yres
, header
.DpiY
);
958 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
961 expect(100, header
.Width
);
962 expect(100, header
.Height
);
963 expect(0, header
.EmfPlusHeaderSize
);
964 expect(0, header
.LogicalDpiX
);
965 expect(0, header
.LogicalDpiX
);
966 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
967 expect(25, U(header
).EmfHeader
.rclBounds
.left
);
968 expect(25, U(header
).EmfHeader
.rclBounds
.top
);
969 expect(74, U(header
).EmfHeader
.rclBounds
.right
);
970 expect(74, U(header
).EmfHeader
.rclBounds
.bottom
);
971 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
972 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
973 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
974 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
976 stat
= GdipDisposeImage((GpImage
*)metafile
);
979 /* test drawing to metafile with gdi+ functions */
980 hdc
= CreateCompatibleDC(0);
982 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
990 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
993 stat
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
995 stat
= GdipDrawLineI(graphics
, pen
, 0, 0, 10, 10);
996 todo_wine
expect(Ok
, stat
);
999 stat
= GdipDeleteGraphics(graphics
);
1002 check_metafile(metafile
, emfonly_draw_records
, "emfonly draw metafile", dst_points
, &frame
, UnitPixel
);
1003 sync_metafile(&metafile
, "emfonly_draw.emf");
1005 stat
= GdipDisposeImage((GpImage
*)metafile
);
1009 static const emfplus_record fillrect_records
[] = {
1011 {0, EmfPlusRecordTypeHeader
},
1012 {0, EmfPlusRecordTypeFillRects
},
1013 {0, EmfPlusRecordTypeEndOfFile
},
1018 static void test_fillrect(void)
1021 GpMetafile
*metafile
;
1022 GpGraphics
*graphics
;
1025 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
1026 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1027 static const GpPointF dst_points_half
[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
1028 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1033 hdc
= CreateCompatibleDC(0);
1035 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
1043 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
1044 expect(InvalidParameter
, stat
);
1046 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1049 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
1052 stat
= GdipFillRectangleI(graphics
, brush
, 25, 25, 75, 75);
1055 stat
= GdipDeleteBrush(brush
);
1058 stat
= GdipDeleteGraphics(graphics
);
1061 check_metafile(metafile
, fillrect_records
, "fillrect metafile", dst_points
, &frame
, UnitPixel
);
1063 sync_metafile(&metafile
, "fillrect.emf");
1065 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
1068 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1071 play_metafile(metafile
, graphics
, fillrect_records
, "fillrect playback", dst_points
, &frame
, UnitPixel
);
1073 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
1077 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
1079 expect(0xff0000ff, color
);
1081 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
1084 play_metafile(metafile
, graphics
, fillrect_records
, "fillrect playback", dst_points_half
, &frame
, UnitPixel
);
1086 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
1088 expect(0xff0000ff, color
);
1090 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
1094 stat
= GdipBitmapSetPixel(bitmap
, 15, 15, 0);
1097 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
1098 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
1101 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
1105 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
1107 expect(0xff0000ff, color
);
1109 stat
= GdipDeleteGraphics(graphics
);
1112 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1115 stat
= GdipDisposeImage((GpImage
*)metafile
);
1119 static const emfplus_record clear_emf_records
[] = {
1121 {0, EmfPlusRecordTypeHeader
},
1122 {0, EmfPlusRecordTypeClear
},
1124 {1, EMR_SETICMMODE
},
1127 {0, EmfPlusRecordTypeEndOfFile
},
1132 static void test_clear(void)
1135 GpMetafile
*metafile
;
1136 GpGraphics
*graphics
;
1139 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
1140 static const GpPointF dst_points
[3] = {{10.0,10.0},{20.0,10.0},{10.0,20.0}};
1141 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1145 hdc
= CreateCompatibleDC(0);
1147 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
1155 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
1156 expect(InvalidParameter
, stat
);
1158 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1161 stat
= GdipGraphicsClear(graphics
, 0xffffff00);
1164 stat
= GdipDeleteGraphics(graphics
);
1167 sync_metafile(&metafile
, "clear.emf");
1169 stat
= GdipCreateBitmapFromScan0(30, 30, 0, PixelFormat32bppRGB
, NULL
, &bitmap
);
1172 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1175 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
1176 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
1179 stat
= GdipBitmapGetPixel(bitmap
, 5, 5, &color
);
1181 expect(0xff000000, color
);
1183 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
1185 expect(0xffffff00, color
);
1187 stat
= GdipBitmapGetPixel(bitmap
, 25, 25, &color
);
1189 expect(0xff000000, color
);
1191 stat
= GdipDeleteGraphics(graphics
);
1194 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1197 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
1200 stat
= GdipDisposeImage((GpImage
*)metafile
);
1203 check_emfplus(hemf
, clear_emf_records
, "clear emf");
1205 DeleteEnhMetaFile(hemf
);
1208 static void test_nullframerect(void) {
1210 GpMetafile
*metafile
;
1211 GpGraphics
*graphics
;
1212 HDC hdc
, metafile_dc
;
1213 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1215 HBRUSH hbrush
, holdbrush
;
1219 hdc
= CreateCompatibleDC(0);
1221 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, NULL
, MetafileFrameUnitPixel
, description
, &metafile
);
1229 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1231 expect(UnitPixel
, unit
);
1232 expectf(0.0, bounds
.X
);
1233 expectf(0.0, bounds
.Y
);
1234 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1235 "expected 1.0, got %f\n", bounds
.Width
);
1236 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1237 "expected 1.0, got %f\n", bounds
.Height
);
1239 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1242 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
1245 stat
= GdipFillRectangleI(graphics
, brush
, 25, 25, 75, 75);
1248 stat
= GdipDeleteBrush(brush
);
1251 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1253 expect(UnitPixel
, unit
);
1254 expectf(0.0, bounds
.X
);
1255 expectf(0.0, bounds
.Y
);
1256 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1257 "expected 1.0, got %f\n", bounds
.Width
);
1258 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1259 "expected 1.0, got %f\n", bounds
.Height
);
1261 stat
= GdipDeleteGraphics(graphics
);
1264 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1266 expect(UnitPixel
, unit
);
1267 expectf_(25.0, bounds
.X
, 0.05);
1268 expectf_(25.0, bounds
.Y
, 0.05);
1269 expectf_(75.0, bounds
.Width
, 0.05);
1270 expectf_(75.0, bounds
.Height
, 0.05);
1272 stat
= GdipDisposeImage((GpImage
*)metafile
);
1275 hdc
= CreateCompatibleDC(0);
1277 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, NULL
, MetafileFrameUnitMillimeter
, description
, &metafile
);
1282 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1285 stat
= GdipGetDC(graphics
, &metafile_dc
);
1290 GdipDeleteGraphics(graphics
);
1291 GdipDisposeImage((GpImage
*)metafile
);
1295 hbrush
= CreateSolidBrush(0xff0000);
1297 holdbrush
= SelectObject(metafile_dc
, hbrush
);
1299 Rectangle(metafile_dc
, 25, 25, 75, 75);
1301 SelectObject(metafile_dc
, holdbrush
);
1303 DeleteObject(hbrush
);
1305 stat
= GdipReleaseDC(graphics
, metafile_dc
);
1308 stat
= GdipDeleteGraphics(graphics
);
1311 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1313 expect(UnitPixel
, unit
);
1314 expectf_(25.0, bounds
.X
, 0.05);
1315 expectf_(25.0, bounds
.Y
, 0.05);
1316 todo_wine
expectf_(50.0, bounds
.Width
, 0.05);
1317 todo_wine
expectf_(50.0, bounds
.Height
, 0.05);
1319 stat
= GdipDisposeImage((GpImage
*)metafile
);
1323 static const emfplus_record pagetransform_records
[] = {
1325 {0, EmfPlusRecordTypeHeader
},
1326 {0, EmfPlusRecordTypeFillRects
},
1327 {0, EmfPlusRecordTypeSetPageTransform
},
1328 {0, EmfPlusRecordTypeFillRects
},
1329 {0, EmfPlusRecordTypeSetPageTransform
},
1330 {0, EmfPlusRecordTypeFillRects
},
1331 {0, EmfPlusRecordTypeSetPageTransform
},
1332 {0, EmfPlusRecordTypeFillRects
},
1333 {0, EmfPlusRecordTypeSetPageTransform
},
1334 {0, EmfPlusRecordTypeFillRects
},
1335 {0, EmfPlusRecordTypeEndOfFile
},
1340 static void test_pagetransform(void)
1343 GpMetafile
*metafile
;
1344 GpGraphics
*graphics
;
1346 static const GpRectF frame
= {0.0, 0.0, 5.0, 5.0};
1347 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1348 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1353 REAL scale
, dpix
, dpiy
;
1356 hdc
= CreateCompatibleDC(0);
1358 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitInch
, description
, &metafile
);
1366 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &dpix
);
1367 todo_wine
expect(InvalidParameter
, stat
);
1369 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &dpiy
);
1370 todo_wine
expect(InvalidParameter
, stat
);
1372 stat
= GdipGetImageWidth((GpImage
*)metafile
, &width
);
1373 todo_wine
expect(InvalidParameter
, stat
);
1375 stat
= GdipGetImageHeight((GpImage
*)metafile
, &height
);
1376 todo_wine
expect(InvalidParameter
, stat
);
1378 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1382 stat
= GdipGetPageUnit(graphics
, &unit
);
1384 expect(UnitDisplay
, unit
);
1386 stat
= GdipGetPageScale(graphics
, &scale
);
1388 expectf(1.0, scale
);
1390 stat
= GdipGetDpiX(graphics
, &dpix
);
1392 expectf(96.0, dpix
);
1394 stat
= GdipGetDpiY(graphics
, &dpiy
);
1396 expectf(96.0, dpiy
);
1398 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
1401 stat
= GdipFillRectangleI(graphics
, brush
, 1, 2, 1, 1);
1404 stat
= GdipDeleteBrush(brush
);
1407 /* page unit = pixels */
1408 stat
= GdipSetPageUnit(graphics
, UnitPixel
);
1411 stat
= GdipGetPageUnit(graphics
, &unit
);
1413 expect(UnitPixel
, unit
);
1415 stat
= GdipCreateSolidFill((ARGB
)0xff00ff00, (GpSolidFill
**)&brush
);
1418 stat
= GdipFillRectangleI(graphics
, brush
, 0, 1, 1, 1);
1421 stat
= GdipDeleteBrush(brush
);
1424 /* page scale = 3, unit = pixels */
1425 stat
= GdipSetPageScale(graphics
, 3.0);
1428 stat
= GdipGetPageScale(graphics
, &scale
);
1430 expectf(3.0, scale
);
1432 stat
= GdipCreateSolidFill((ARGB
)0xff00ffff, (GpSolidFill
**)&brush
);
1435 stat
= GdipFillRectangleI(graphics
, brush
, 0, 1, 2, 2);
1438 stat
= GdipDeleteBrush(brush
);
1441 /* page scale = 3, unit = inches */
1442 stat
= GdipSetPageUnit(graphics
, UnitInch
);
1445 stat
= GdipGetPageUnit(graphics
, &unit
);
1447 expect(UnitInch
, unit
);
1449 stat
= GdipCreateSolidFill((ARGB
)0xffff0000, (GpSolidFill
**)&brush
);
1452 stat
= GdipFillRectangle(graphics
, brush
, 1.0/96.0, 0, 1, 1);
1455 stat
= GdipDeleteBrush(brush
);
1458 /* page scale = 3, unit = display */
1459 stat
= GdipSetPageUnit(graphics
, UnitDisplay
);
1462 stat
= GdipGetPageUnit(graphics
, &unit
);
1464 expect(UnitDisplay
, unit
);
1466 stat
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
1469 stat
= GdipFillRectangle(graphics
, brush
, 3, 3, 2, 2);
1472 stat
= GdipDeleteBrush(brush
);
1475 stat
= GdipDeleteGraphics(graphics
);
1478 check_metafile(metafile
, pagetransform_records
, "pagetransform metafile", dst_points
, &frame
, UnitPixel
);
1480 sync_metafile(&metafile
, "pagetransform.emf");
1482 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
1485 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1488 play_metafile(metafile
, graphics
, pagetransform_records
, "pagetransform playback", dst_points
, &frame
, UnitPixel
);
1490 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
1494 stat
= GdipBitmapGetPixel(bitmap
, 30, 50, &color
);
1496 expect(0xff0000ff, color
);
1498 stat
= GdipBitmapGetPixel(bitmap
, 10, 30, &color
);
1500 expect(0xff00ff00, color
);
1502 stat
= GdipBitmapGetPixel(bitmap
, 20, 80, &color
);
1504 expect(0xff00ffff, color
);
1506 stat
= GdipBitmapGetPixel(bitmap
, 80, 20, &color
);
1508 expect(0xffff0000, color
);
1510 stat
= GdipBitmapGetPixel(bitmap
, 80, 80, &color
);
1512 expect(0xffff00ff, color
);
1514 stat
= GdipDeleteGraphics(graphics
);
1517 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1520 stat
= GdipDisposeImage((GpImage
*)metafile
);
1524 static const emfplus_record worldtransform_records
[] = {
1526 {0, EmfPlusRecordTypeHeader
},
1527 {0, EmfPlusRecordTypeFillRects
},
1528 {0, EmfPlusRecordTypeScaleWorldTransform
},
1529 {0, EmfPlusRecordTypeFillRects
},
1530 {0, EmfPlusRecordTypeResetWorldTransform
},
1531 {0, EmfPlusRecordTypeFillRects
},
1532 {0, EmfPlusRecordTypeMultiplyWorldTransform
},
1533 {0, EmfPlusRecordTypeFillRects
},
1534 {0, EmfPlusRecordTypeRotateWorldTransform
},
1535 {0, EmfPlusRecordTypeFillRects
},
1536 {0, EmfPlusRecordTypeSetWorldTransform
},
1537 {0, EmfPlusRecordTypeFillRects
},
1538 {0, EmfPlusRecordTypeTranslateWorldTransform
},
1539 {0, EmfPlusRecordTypeFillRects
},
1540 {0, EmfPlusRecordTypeEndOfFile
},
1545 static void test_worldtransform(void)
1548 GpMetafile
*metafile
;
1549 GpGraphics
*graphics
;
1551 static const GpRectF frame
= {0.0, 0.0, 5.0, 5.0};
1552 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1553 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1557 GpMatrix
*transform
;
1561 hdc
= CreateCompatibleDC(0);
1563 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
1571 stat
= GdipCreateMatrix(&transform
);
1574 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1577 /* initial transform */
1578 stat
= GdipGetWorldTransform(graphics
, transform
);
1581 stat
= GdipIsMatrixIdentity(transform
, &identity
);
1583 expect(TRUE
, identity
);
1585 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
1588 stat
= GdipFillRectangleI(graphics
, brush
, 0, 0, 1, 1);
1591 stat
= GdipDeleteBrush(brush
);
1594 /* scale transform */
1595 stat
= GdipScaleWorldTransform(graphics
, 2.0, 4.0, MatrixOrderPrepend
);
1598 stat
= GdipGetWorldTransform(graphics
, transform
);
1601 stat
= GdipGetMatrixElements(transform
, elements
);
1603 expectf(2.0, elements
[0]);
1604 expectf(0.0, elements
[1]);
1605 expectf(0.0, elements
[2]);
1606 expectf(4.0, elements
[3]);
1607 expectf(0.0, elements
[4]);
1608 expectf(0.0, elements
[5]);
1610 stat
= GdipCreateSolidFill((ARGB
)0xff00ff00, (GpSolidFill
**)&brush
);
1613 stat
= GdipFillRectangle(graphics
, brush
, 0.5, 0.5, 0.5, 0.25);
1616 stat
= GdipDeleteBrush(brush
);
1619 /* reset transform */
1620 stat
= GdipResetWorldTransform(graphics
);
1623 stat
= GdipGetWorldTransform(graphics
, transform
);
1626 stat
= GdipIsMatrixIdentity(transform
, &identity
);
1628 expect(TRUE
, identity
);
1630 stat
= GdipCreateSolidFill((ARGB
)0xff00ffff, (GpSolidFill
**)&brush
);
1633 stat
= GdipFillRectangle(graphics
, brush
, 1.0, 0.0, 1.0, 1.0);
1636 stat
= GdipDeleteBrush(brush
);
1639 /* multiply transform */
1640 stat
= GdipSetMatrixElements(transform
, 2.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1643 stat
= GdipMultiplyWorldTransform(graphics
, transform
, MatrixOrderPrepend
);
1646 stat
= GdipGetWorldTransform(graphics
, transform
);
1649 stat
= GdipGetMatrixElements(transform
, elements
);
1651 expectf(2.0, elements
[0]);
1652 expectf(0.0, elements
[1]);
1653 expectf(0.0, elements
[2]);
1654 expectf(1.0, elements
[3]);
1655 expectf(0.0, elements
[4]);
1656 expectf(0.0, elements
[5]);
1658 stat
= GdipCreateSolidFill((ARGB
)0xffff0000, (GpSolidFill
**)&brush
);
1661 stat
= GdipFillRectangle(graphics
, brush
, 1.0, 1.0, 0.5, 1.0);
1664 stat
= GdipDeleteBrush(brush
);
1667 /* rotate transform */
1668 stat
= GdipRotateWorldTransform(graphics
, 90.0, MatrixOrderAppend
);
1671 stat
= GdipGetWorldTransform(graphics
, transform
);
1674 stat
= GdipGetMatrixElements(transform
, elements
);
1676 expectf(0.0, elements
[0]);
1677 expectf(2.0, elements
[1]);
1678 expectf(-1.0, elements
[2]);
1679 expectf(0.0, elements
[3]);
1680 expectf(0.0, elements
[4]);
1681 expectf(0.0, elements
[5]);
1683 stat
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
1686 stat
= GdipFillRectangle(graphics
, brush
, 1.0, -1.0, 0.5, 1.0);
1689 stat
= GdipDeleteBrush(brush
);
1693 stat
= GdipSetMatrixElements(transform
, 1.0, 0.0, 0.0, 3.0, 0.0, 0.0);
1696 stat
= GdipSetWorldTransform(graphics
, transform
);
1699 stat
= GdipGetWorldTransform(graphics
, transform
);
1702 stat
= GdipGetMatrixElements(transform
, elements
);
1704 expectf(1.0, elements
[0]);
1705 expectf(0.0, elements
[1]);
1706 expectf(0.0, elements
[2]);
1707 expectf(3.0, elements
[3]);
1708 expectf(0.0, elements
[4]);
1709 expectf(0.0, elements
[5]);
1711 stat
= GdipCreateSolidFill((ARGB
)0xffffff00, (GpSolidFill
**)&brush
);
1714 stat
= GdipFillRectangle(graphics
, brush
, 1.0, 1.0, 1.0, 1.0);
1717 stat
= GdipDeleteBrush(brush
);
1720 /* translate transform */
1721 stat
= GdipTranslateWorldTransform(graphics
, -1.0, 0.0, MatrixOrderAppend
);
1724 stat
= GdipGetWorldTransform(graphics
, transform
);
1727 stat
= GdipGetMatrixElements(transform
, elements
);
1729 expectf(1.0, elements
[0]);
1730 expectf(0.0, elements
[1]);
1731 expectf(0.0, elements
[2]);
1732 expectf(3.0, elements
[3]);
1733 expectf(-1.0, elements
[4]);
1734 expectf(0.0, elements
[5]);
1736 stat
= GdipCreateSolidFill((ARGB
)0xffffffff, (GpSolidFill
**)&brush
);
1739 stat
= GdipFillRectangle(graphics
, brush
, 1.0, 1.0, 1.0, 1.0);
1742 stat
= GdipDeleteBrush(brush
);
1745 stat
= GdipDeleteMatrix(transform
);
1748 stat
= GdipDeleteGraphics(graphics
);
1751 check_metafile(metafile
, worldtransform_records
, "worldtransform metafile", dst_points
, &frame
, UnitPixel
);
1753 sync_metafile(&metafile
, "worldtransform.emf");
1755 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
1758 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1761 play_metafile(metafile
, graphics
, worldtransform_records
, "worldtransform playback", dst_points
, &frame
, UnitPixel
);
1763 stat
= GdipBitmapGetPixel(bitmap
, 80, 80, &color
);
1767 stat
= GdipBitmapGetPixel(bitmap
, 10, 10, &color
);
1769 expect(0xff0000ff, color
);
1771 stat
= GdipBitmapGetPixel(bitmap
, 30, 50, &color
);
1773 expect(0xff00ff00, color
);
1775 stat
= GdipBitmapGetPixel(bitmap
, 30, 10, &color
);
1777 expect(0xff00ffff, color
);
1779 stat
= GdipBitmapGetPixel(bitmap
, 50, 30, &color
);
1781 expect(0xffff0000, color
);
1783 stat
= GdipBitmapGetPixel(bitmap
, 10, 50, &color
);
1785 expect(0xffff00ff, color
);
1787 stat
= GdipBitmapGetPixel(bitmap
, 30, 90, &color
);
1789 expect(0xffffff00, color
);
1791 stat
= GdipBitmapGetPixel(bitmap
, 10, 90, &color
);
1793 expect(0xffffffff, color
);
1795 stat
= GdipDeleteGraphics(graphics
);
1798 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1801 stat
= GdipDisposeImage((GpImage
*)metafile
);
1805 static void test_converttoemfplus(void)
1807 GpStatus (WINAPI
*pGdipConvertToEmfPlus
)( const GpGraphics
*graphics
, GpMetafile
*metafile
, BOOL
*succ
,
1808 EmfType emfType
, const WCHAR
*description
, GpMetafile
**outmetafile
);
1809 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
1810 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1812 GpMetafile
*metafile
, *metafile2
= NULL
, *emhmeta
;
1813 GpGraphics
*graphics
;
1816 HMODULE mod
= GetModuleHandleA("gdiplus.dll");
1818 pGdipConvertToEmfPlus
= (void*)GetProcAddress( mod
, "GdipConvertToEmfPlus");
1819 if(!pGdipConvertToEmfPlus
)
1821 /* GdipConvertToEmfPlus was introduced in Windows Vista. */
1822 win_skip("GDIPlus version 1.1 not available\n");
1826 hdc
= CreateCompatibleDC(0);
1828 stat
= GdipRecordMetafile(hdc
, MetafileTypeEmf
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
1831 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &emhmeta
);
1839 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1842 /* Invalid Parameters */
1843 stat
= pGdipConvertToEmfPlus(NULL
, metafile
, &succ
, EmfTypeEmfPlusOnly
, description
, &metafile2
);
1844 expect(InvalidParameter
, stat
);
1846 stat
= pGdipConvertToEmfPlus(graphics
, NULL
, &succ
, EmfTypeEmfPlusOnly
, description
, &metafile2
);
1847 expect(InvalidParameter
, stat
);
1849 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, &succ
, EmfTypeEmfPlusOnly
, description
, NULL
);
1850 expect(InvalidParameter
, stat
);
1852 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, NULL
, MetafileTypeInvalid
, NULL
, &metafile2
);
1853 expect(InvalidParameter
, stat
);
1855 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, NULL
, MetafileTypeEmfPlusDual
+1, NULL
, &metafile2
);
1856 expect(InvalidParameter
, stat
);
1858 /* If we are already an Enhanced Metafile then the conversion fails. */
1859 stat
= pGdipConvertToEmfPlus(graphics
, emhmeta
, NULL
, EmfTypeEmfPlusOnly
, NULL
, &metafile2
);
1860 todo_wine
expect(InvalidParameter
, stat
);
1862 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, NULL
, EmfTypeEmfPlusOnly
, NULL
, &metafile2
);
1863 todo_wine
expect(Ok
, stat
);
1865 GdipDisposeImage((GpImage
*)metafile2
);
1868 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, &succ
, EmfTypeEmfPlusOnly
, NULL
, &metafile2
);
1869 todo_wine
expect(Ok
, stat
);
1871 GdipDisposeImage((GpImage
*)metafile2
);
1873 stat
= GdipDeleteGraphics(graphics
);
1876 stat
= GdipDisposeImage((GpImage
*)metafile
);
1879 stat
= GdipDisposeImage((GpImage
*)emhmeta
);
1883 static void test_frameunit(void)
1886 GpMetafile
*metafile
;
1887 GpGraphics
*graphics
;
1889 static const GpRectF frame
= {0.0, 0.0, 5.0, 5.0};
1890 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1895 hdc
= CreateCompatibleDC(0);
1897 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitInch
, description
, &metafile
);
1905 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1907 expect(UnitPixel
, unit
);
1908 expectf(0.0, bounds
.X
);
1909 expectf(0.0, bounds
.Y
);
1910 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1911 "expected 1.0, got %f\n", bounds
.Width
);
1912 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1913 "expected 1.0, got %f\n", bounds
.Height
);
1915 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1918 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1920 expect(UnitPixel
, unit
);
1921 expectf(0.0, bounds
.X
);
1922 expectf(0.0, bounds
.Y
);
1923 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1924 "expected 1.0, got %f\n", bounds
.Width
);
1925 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1926 "expected 1.0, got %f\n", bounds
.Height
);
1928 stat
= GdipDeleteGraphics(graphics
);
1931 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &dpix
);
1934 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &dpiy
);
1937 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1939 expect(UnitPixel
, unit
);
1940 expectf(0.0, bounds
.X
);
1941 expectf(0.0, bounds
.Y
);
1942 expectf_(5.0 * dpix
, bounds
.Width
, 1.0);
1943 expectf_(5.0 * dpiy
, bounds
.Height
, 1.0);
1945 stat
= GdipDisposeImage((GpImage
*)metafile
);
1949 static const emfplus_record container_records
[] = {
1951 {0, EmfPlusRecordTypeHeader
},
1952 {0, EmfPlusRecordTypeBeginContainerNoParams
},
1953 {0, EmfPlusRecordTypeScaleWorldTransform
},
1954 {0, EmfPlusRecordTypeFillRects
},
1955 {0, EmfPlusRecordTypeEndContainer
},
1956 {0, EmfPlusRecordTypeScaleWorldTransform
},
1957 {0, EmfPlusRecordTypeFillRects
},
1958 {0, EmfPlusRecordTypeSave
},
1959 {0, EmfPlusRecordTypeRestore
},
1960 {0, EmfPlusRecordTypeScaleWorldTransform
},
1961 {0, EmfPlusRecordTypeBeginContainerNoParams
},
1962 {0, EmfPlusRecordTypeScaleWorldTransform
},
1963 {0, EmfPlusRecordTypeBeginContainerNoParams
},
1964 {0, EmfPlusRecordTypeEndContainer
},
1965 {0, EmfPlusRecordTypeFillRects
},
1966 {0, EmfPlusRecordTypeBeginContainer
},
1967 {0, EmfPlusRecordTypeFillRects
},
1968 {0, EmfPlusRecordTypeEndContainer
},
1969 {0, EmfPlusRecordTypeBeginContainerNoParams
},
1970 {0, EmfPlusRecordTypeEndOfFile
},
1975 static void test_containers(void)
1978 GpMetafile
*metafile
;
1979 GpGraphics
*graphics
;
1984 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
1985 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1986 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1987 GraphicsContainer state1
, state2
;
1988 GpRectF srcrect
, dstrect
;
1991 hdc
= CreateCompatibleDC(0);
1993 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2001 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2005 stat
= GdipBeginContainer2(graphics
, &state1
);
2008 stat
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
2011 stat
= GdipCreateSolidFill((ARGB
)0xff000000, (GpSolidFill
**)&brush
);
2014 stat
= GdipFillRectangle(graphics
, brush
, 5.0, 5.0, 5.0, 5.0);
2017 stat
= GdipDeleteBrush(brush
);
2020 stat
= GdipEndContainer(graphics
, state1
);
2023 stat
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
2026 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
2029 stat
= GdipFillRectangle(graphics
, brush
, 5.0, 5.0, 5.0, 5.0);
2032 stat
= GdipDeleteBrush(brush
);
2035 stat
= GdipSaveGraphics(graphics
, &state1
);
2038 stat
= GdipRestoreGraphics(graphics
, state1
);
2041 /* Popping two states at once */
2042 stat
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
2045 stat
= GdipBeginContainer2(graphics
, &state1
);
2048 stat
= GdipScaleWorldTransform(graphics
, 4.0, 4.0, MatrixOrderPrepend
);
2051 stat
= GdipBeginContainer2(graphics
, &state2
);
2054 stat
= GdipEndContainer(graphics
, state1
);
2057 stat
= GdipCreateSolidFill((ARGB
)0xff00ff00, (GpSolidFill
**)&brush
);
2060 stat
= GdipFillRectangle(graphics
, brush
, 20.0, 20.0, 5.0, 5.0);
2063 stat
= GdipDeleteBrush(brush
);
2066 /* With transform applied */
2067 stat
= GdipGetDpiX(graphics
, &dpix
);
2070 stat
= GdipGetDpiY(graphics
, &dpiy
);
2075 srcrect
.Width
= 1.0;
2076 srcrect
.Height
= 1.0;
2080 dstrect
.Width
= 5.0;
2081 dstrect
.Height
= 5.0;
2083 stat
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state1
);
2086 stat
= GdipCreateSolidFill((ARGB
)0xff00ffff, (GpSolidFill
**)&brush
);
2089 stat
= GdipFillRectangle(graphics
, brush
, 0.0, 0.0, dpix
, dpiy
);
2092 stat
= GdipDeleteBrush(brush
);
2095 stat
= GdipEndContainer(graphics
, state1
);
2098 /* Restoring an invalid state seems to break the graphics object? */
2100 stat
= GdipEndContainer(graphics
, state1
);
2104 /* Ending metafile with a state open */
2105 stat
= GdipBeginContainer2(graphics
, &state1
);
2108 stat
= GdipDeleteGraphics(graphics
);
2111 check_metafile(metafile
, container_records
, "container metafile", dst_points
, &frame
, UnitPixel
);
2113 sync_metafile(&metafile
, "container.emf");
2115 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
2118 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2121 play_metafile(metafile
, graphics
, container_records
, "container playback", dst_points
, &frame
, UnitPixel
);
2123 stat
= GdipBitmapGetPixel(bitmap
, 80, 80, &color
);
2127 stat
= GdipBitmapGetPixel(bitmap
, 12, 12, &color
);
2129 expect(0xff000000, color
);
2131 stat
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
2133 expect(0xff0000ff, color
);
2135 stat
= GdipBitmapGetPixel(bitmap
, 42, 42, &color
);
2137 expect(0xff00ff00, color
);
2139 stat
= GdipBitmapGetPixel(bitmap
, 55, 5, &color
);
2141 expect(0xff00ffff, color
);
2143 stat
= GdipDeleteGraphics(graphics
);
2146 stat
= GdipDisposeImage((GpImage
*)bitmap
);
2149 stat
= GdipDisposeImage((GpImage
*)metafile
);
2153 static const emfplus_record clipping_records
[] = {
2155 {0, EmfPlusRecordTypeHeader
},
2156 {0, EmfPlusRecordTypeSave
},
2157 {0, EmfPlusRecordTypeSetClipRect
},
2158 {0, EmfPlusRecordTypeFillRects
},
2159 {0, EmfPlusRecordTypeRestore
},
2160 {0, EmfPlusRecordTypeSetClipRect
},
2161 {0, EmfPlusRecordTypeFillRects
},
2162 {0, EmfPlusRecordTypeObject
, 1},
2163 {0, EmfPlusRecordTypeSetClipRegion
, 1},
2164 {0, EmfPlusRecordTypeEndOfFile
},
2169 static void test_clipping(void)
2172 GpMetafile
*metafile
;
2173 GpGraphics
*graphics
;
2180 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
2181 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
2182 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
2183 GraphicsState state
;
2185 hdc
= CreateCompatibleDC(0);
2187 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2195 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2198 stat
= GdipSaveGraphics(graphics
, &state
);
2201 stat
= GdipGetVisibleClipBounds(graphics
, &rect
);
2203 ok(rect
.X
== -0x400000, "rect.X = %f\n", rect
.X
);
2204 ok(rect
.Y
== -0x400000, "rect.Y = %f\n", rect
.Y
);
2205 ok(rect
.Width
== 0x800000, "rect.Width = %f\n", rect
.Width
);
2206 ok(rect
.Height
== 0x800000, "rect.Height = %f\n", rect
.Height
);
2208 stat
= GdipSetClipRect(graphics
, 30, 30, 10, 10, CombineModeReplace
);
2211 stat
= GdipGetVisibleClipBounds(graphics
, &rect
);
2213 ok(rect
.X
== 30, "rect.X = %f\n", rect
.X
);
2214 ok(rect
.Y
== 30, "rect.Y = %f\n", rect
.Y
);
2215 ok(rect
.Width
== 10, "rect.Width = %f\n", rect
.Width
);
2216 ok(rect
.Height
== 10, "rect.Height = %f\n", rect
.Height
);
2218 stat
= GdipCreateSolidFill((ARGB
)0xff000000, (GpSolidFill
**)&brush
);
2221 stat
= GdipFillRectangle(graphics
, brush
, 0, 0, 100, 100);
2224 stat
= GdipDeleteBrush(brush
);
2227 stat
= GdipRestoreGraphics(graphics
, state
);
2230 stat
= GdipSetClipRect(graphics
, 30, 30, 10, 10, CombineModeXor
);
2233 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
2236 stat
= GdipFillRectangle(graphics
, brush
, 30, 30, 20, 10);
2239 stat
= GdipDeleteBrush(brush
);
2242 stat
= GdipCreateRegionRect(&rect
, ®ion
);
2245 stat
= GdipSetClipRegion(graphics
, region
, CombineModeIntersect
);
2248 stat
= GdipDeleteRegion(region
);
2251 stat
= GdipDeleteGraphics(graphics
);
2254 check_metafile(metafile
, clipping_records
, "clipping metafile", dst_points
, &frame
, UnitPixel
);
2256 sync_metafile(&metafile
, "clipping.emf");
2258 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
2261 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2264 play_metafile(metafile
, graphics
, clipping_records
, "clipping playback", dst_points
, &frame
, UnitPixel
);
2266 stat
= GdipBitmapGetPixel(bitmap
, 80, 80, &color
);
2270 stat
= GdipBitmapGetPixel(bitmap
, 35, 35, &color
);
2272 expect(0xff000000, color
);
2274 stat
= GdipBitmapGetPixel(bitmap
, 45, 35, &color
);
2276 expect(0xff0000ff, color
);
2278 stat
= GdipDeleteGraphics(graphics
);
2281 stat
= GdipDisposeImage((GpImage
*)bitmap
);
2284 stat
= GdipDisposeImage((GpImage
*)metafile
);
2288 static void test_gditransform_cb(GpMetafile
* metafile
, EmfPlusRecordType record_type
,
2289 unsigned int flags
, unsigned int dataSize
, const unsigned char *pStr
)
2291 static const XFORM xform
= {0.5, 0, 0, 0.5, 0, 0};
2292 static const RECTL rectangle
= {0,0,100,100};
2295 stat
= GdipPlayMetafileRecord(metafile
, EMR_SETWORLDTRANSFORM
, 0, sizeof(xform
), (void*)&xform
);
2298 stat
= GdipPlayMetafileRecord(metafile
, EMR_RECTANGLE
, 0, sizeof(rectangle
), (void*)&rectangle
);
2302 static const emfplus_record gditransform_records
[] = {
2304 {0, EMR_CREATEBRUSHINDIRECT
},
2305 {0, EMR_SELECTOBJECT
},
2306 {0, EMR_GDICOMMENT
, 0, test_gditransform_cb
},
2307 {0, EMR_SELECTOBJECT
},
2308 {0, EMR_DELETEOBJECT
},
2313 static void test_gditransform(void)
2316 GpMetafile
*metafile
;
2317 GpGraphics
*graphics
;
2318 HDC hdc
, metafile_dc
;
2320 MetafileHeader header
;
2321 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
2322 static const GpPointF dst_points
[3] = {{0.0,0.0},{40.0,0.0},{0.0,40.0}};
2323 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
2324 HBRUSH hbrush
, holdbrush
;
2328 hdc
= CreateCompatibleDC(0);
2330 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2338 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
2339 expect(InvalidParameter
, stat
);
2341 memset(&header
, 0xaa, sizeof(header
));
2342 stat
= GdipGetMetafileHeaderFromMetafile(metafile
, &header
);
2344 expect(MetafileTypeEmf
, header
.Type
);
2345 ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
2347 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2350 stat
= GdipGetDC(graphics
, &metafile_dc
);
2355 GdipDeleteGraphics(graphics
);
2356 GdipDisposeImage((GpImage
*)metafile
);
2360 hbrush
= CreateSolidBrush(0xff);
2362 holdbrush
= SelectObject(metafile_dc
, hbrush
);
2364 GdiComment(metafile_dc
, 8, (const BYTE
*)"winetest");
2366 SelectObject(metafile_dc
, holdbrush
);
2368 DeleteObject(hbrush
);
2370 stat
= GdipReleaseDC(graphics
, metafile_dc
);
2373 stat
= GdipDeleteGraphics(graphics
);
2376 check_metafile(metafile
, gditransform_records
, "gditransform metafile", dst_points
, &frame
, UnitPixel
);
2378 sync_metafile(&metafile
, "gditransform.emf");
2380 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
2383 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2386 play_metafile(metafile
, graphics
, gditransform_records
, "gditransform playback", dst_points
, &frame
, UnitPixel
);
2388 stat
= GdipBitmapGetPixel(bitmap
, 10, 10, &color
);
2390 expect(0xffff0000, color
);
2392 stat
= GdipBitmapGetPixel(bitmap
, 30, 30, &color
);
2394 expect(0x00000000, color
);
2396 stat
= GdipDeleteGraphics(graphics
);
2399 stat
= GdipDisposeImage((GpImage
*)bitmap
);
2402 stat
= GdipDisposeImage((GpImage
*)metafile
);
2406 static const emfplus_record draw_image_bitmap_records
[] = {
2408 {0, EmfPlusRecordTypeHeader
},
2409 {0, EmfPlusRecordTypeObject
},
2410 {0, EmfPlusRecordTypeObject
},
2411 {0, EmfPlusRecordTypeDrawImagePoints
},
2413 {1, EMR_SETICMMODE
},
2416 {0, EmfPlusRecordTypeEndOfFile
},
2421 static const emfplus_record draw_image_metafile_records
[] = {
2423 {0, EmfPlusRecordTypeHeader
},
2424 {0, EmfPlusRecordTypeObject
},
2425 /* metafile object */
2427 {0, EmfPlusRecordTypeHeader
},
2428 {0, EmfPlusRecordTypeObject
},
2429 {0, EmfPlusRecordTypeObject
},
2430 {0, EmfPlusRecordTypeDrawImagePoints
},
2432 {1, EMR_SETICMMODE
},
2435 {0, EmfPlusRecordTypeEndOfFile
},
2437 /* end of metafile object */
2438 {0, EmfPlusRecordTypeDrawImagePoints
},
2440 {1, EMR_SETICMMODE
},
2443 {0, EmfPlusRecordTypeEndOfFile
},
2448 static void test_drawimage(void)
2450 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
2451 static const GpPointF dst_points
[3] = {{10.0,10.0},{85.0,15.0},{10.0,80.0}};
2452 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
2453 const ColorMatrix double_red
= {{
2454 {2.0,0.0,0.0,0.0,0.0},
2455 {0.0,1.0,0.0,0.0,0.0},
2456 {0.0,0.0,1.0,0.0,0.0},
2457 {0.0,0.0,0.0,1.0,0.0},
2458 {0.0,0.0,0.0,0.0,1.0}}};
2460 GpImageAttributes
*imageattr
;
2461 GpMetafile
*metafile
;
2462 GpGraphics
*graphics
;
2470 hdc
= CreateCompatibleDC(0);
2471 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2474 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2477 memset(&info
, 0, sizeof(info
));
2478 info
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
2479 info
.bmiHeader
.biWidth
= 10;
2480 info
.bmiHeader
.biHeight
= 10;
2481 info
.bmiHeader
.biPlanes
= 1;
2482 info
.bmiHeader
.biBitCount
= 32;
2483 info
.bmiHeader
.biCompression
= BI_RGB
;
2484 memset(buff
, 0x80, sizeof(buff
));
2485 stat
= GdipCreateBitmapFromGdiDib(&info
, buff
, (GpBitmap
**)&image
);
2488 stat
= GdipCreateImageAttributes(&imageattr
);
2491 stat
= GdipSetImageAttributesColorMatrix(imageattr
, ColorAdjustTypeDefault
,
2492 TRUE
, &double_red
, NULL
, ColorMatrixFlagsDefault
);
2495 stat
= GdipDrawImagePointsRect(graphics
, image
, dst_points
, 3,
2496 0.0, 0.0, 10.0, 10.0, UnitPixel
, imageattr
, NULL
, NULL
);
2497 GdipDisposeImageAttributes(imageattr
);
2500 GdipDisposeImage(image
);
2502 stat
= GdipDeleteGraphics(graphics
);
2504 sync_metafile(&metafile
, "draw_image_bitmap.emf");
2506 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
2509 check_emfplus(hemf
, draw_image_bitmap_records
, "draw image bitmap");
2511 /* test drawing metafile */
2512 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2515 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2518 stat
= GdipCreateMetafileFromEmf(hemf
, TRUE
, (GpMetafile
**)&image
);
2521 stat
= GdipDrawImagePointsRect(graphics
, image
, dst_points
, 3,
2522 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
2525 GdipDisposeImage(image
);
2527 stat
= GdipDeleteGraphics(graphics
);
2529 sync_metafile(&metafile
, "draw_image_metafile.emf");
2531 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
2534 if (GetProcAddress(GetModuleHandleA("gdiplus.dll"), "GdipConvertToEmfPlus"))
2536 check_emfplus(hemf
, draw_image_metafile_records
, "draw image metafile");
2540 win_skip("draw image metafile records tests skipped\n");
2542 DeleteEnhMetaFile(hemf
);
2545 stat
= GdipDisposeImage((GpImage
*)metafile
);
2549 static const emfplus_record properties_records
[] = {
2551 {0, EmfPlusRecordTypeHeader
},
2552 {0, EmfPlusRecordTypeSetTextRenderingHint
},
2553 {0, EmfPlusRecordTypeSetPixelOffsetMode
},
2554 {0, EmfPlusRecordTypeSetAntiAliasMode
},
2555 {0, EmfPlusRecordTypeSetCompositingMode
},
2556 {0, EmfPlusRecordTypeSetCompositingQuality
},
2557 {0, EmfPlusRecordTypeSetInterpolationMode
},
2558 {0, EmfPlusRecordTypeEndOfFile
},
2563 static void test_properties(void)
2565 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
2566 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
2568 GpMetafile
*metafile
;
2569 GpGraphics
*graphics
;
2574 hdc
= CreateCompatibleDC(0);
2575 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2579 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2582 stat
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
2584 stat
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAlias
);
2587 stat
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHighQuality
);
2589 stat
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHighQuality
);
2592 stat
= GdipSetSmoothingMode(graphics
, SmoothingModeAntiAlias
);
2594 stat
= GdipSetSmoothingMode(graphics
, SmoothingModeAntiAlias
);
2597 stat
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
2599 stat
= GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
2602 stat
= GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
2604 stat
= GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
2607 stat
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
2609 stat
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
2612 stat
= GdipDeleteGraphics(graphics
);
2614 sync_metafile(&metafile
, "properties.emf");
2616 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
2619 check_emfplus(hemf
, properties_records
, "properties");
2620 DeleteEnhMetaFile(hemf
);
2622 stat
= GdipDisposeImage((GpImage
*)metafile
);
2626 static const emfplus_record draw_path_records
[] = {
2628 {0, EmfPlusRecordTypeHeader
},
2629 {0, EmfPlusRecordTypeObject
},
2630 {0, EmfPlusRecordTypeObject
},
2631 {0, EmfPlusRecordTypeDrawPath
},
2633 {1, EMR_SETICMMODE
},
2636 {0, EmfPlusRecordTypeEndOfFile
},
2641 static void test_drawpath(void)
2643 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
2644 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
2646 GpMetafile
*metafile
;
2647 GpGraphics
*graphics
;
2654 hdc
= CreateCompatibleDC(0);
2655 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2659 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2662 stat
= GdipCreatePath(FillModeAlternate
, &path
);
2664 stat
= GdipAddPathLine(path
, 5, 5, 30, 30);
2667 stat
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
2670 stat
= GdipDrawPath(graphics
, pen
, path
);
2673 stat
= GdipDeletePen(pen
);
2675 stat
= GdipDeletePath(path
);
2678 stat
= GdipDeleteGraphics(graphics
);
2680 sync_metafile(&metafile
, "draw_path.emf");
2682 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
2685 check_emfplus(hemf
, draw_path_records
, "draw path");
2686 DeleteEnhMetaFile(hemf
);
2688 stat
= GdipDisposeImage((GpImage
*)metafile
);
2692 static const emfplus_record fill_path_records
[] = {
2694 {0, EmfPlusRecordTypeHeader
},
2695 {0, EmfPlusRecordTypeObject
},
2696 {0, EmfPlusRecordTypeFillPath
},
2698 {1, EMR_SETICMMODE
},
2701 {0, EmfPlusRecordTypeEndOfFile
},
2706 static void test_fillpath(void)
2708 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
2709 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
2710 static const WCHAR winetestemfW
[] = {'w','i','n','e','t','e','s','t','.','e','m','f',0};
2712 GpMetafile
*metafile
;
2713 GpGraphics
*graphics
;
2720 hdc
= CreateCompatibleDC(0);
2721 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
2725 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
2728 stat
= GdipCreatePath(FillModeAlternate
, &path
);
2730 stat
= GdipAddPathLine(path
, 5, 5, 30, 30);
2732 stat
= GdipAddPathLine(path
, 30, 30, 5, 30);
2735 stat
= GdipCreateSolidFill(0xffaabbcc, &brush
);
2738 stat
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
2741 stat
= GdipDeleteBrush((GpBrush
*)brush
);
2743 stat
= GdipDeletePath(path
);
2746 stat
= GdipDeleteGraphics(graphics
);
2748 sync_metafile(&metafile
, "fill_path.emf");
2750 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
2753 check_emfplus(hemf
, fill_path_records
, "fill path");
2756 DeleteEnhMetaFile(CopyEnhMetaFileW(hemf
, winetestemfW
));
2758 DeleteEnhMetaFile(hemf
);
2760 stat
= GdipDisposeImage((GpImage
*)metafile
);
2763 /* should succeed when given path to an EMF */
2764 stat
= GdipCreateMetafileFromWmfFile(winetestemfW
, NULL
, &metafile
);
2767 stat
= GdipDisposeImage((GpImage
*)metafile
);
2770 DeleteFileW(winetestemfW
);
2772 stat
= GdipCreateMetafileFromWmfFile(winetestemfW
, NULL
, &metafile
);
2773 expect(GenericError
, stat
);
2776 START_TEST(metafile
)
2778 struct GdiplusStartupInput gdiplusStartupInput
;
2779 ULONG_PTR gdiplusToken
;
2783 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
2785 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
2786 hmsvcrt
= LoadLibraryA("msvcrt");
2787 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
2788 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
2790 gdiplusStartupInput
.GdiplusVersion
= 1;
2791 gdiplusStartupInput
.DebugEventCallback
= NULL
;
2792 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
2793 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2795 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2797 myARGC
= winetest_get_mainargs( &myARGV
);
2801 if (!strcmp(myARGV
[2], "save"))
2802 save_metafiles
= TRUE
;
2803 else if (!strcmp(myARGV
[2], "load"))
2804 load_metafiles
= TRUE
;
2812 test_nullframerect();
2813 test_pagetransform();
2814 test_worldtransform();
2815 test_converttoemfplus();
2819 test_gditransform();
2825 GdiplusShutdown(gdiplusToken
);