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
;
38 typedef struct emfplus_record
45 typedef struct emfplus_check_state
49 const struct emfplus_record
*expected
;
51 } emfplus_check_state
;
53 static void check_record(int count
, const char *desc
, const struct emfplus_record
*expected
, const struct emfplus_record
*actual
)
55 todo_wine_if (expected
->todo
)
56 ok(expected
->record_type
== actual
->record_type
,
57 "%s.%i: Expected record type 0x%x, got 0x%x\n", desc
, count
,
58 expected
->record_type
, actual
->record_type
);
61 typedef struct EmfPlusRecordHeader
67 } EmfPlusRecordHeader
;
69 static int CALLBACK
enum_emf_proc(HDC hDC
, HANDLETABLE
*lpHTable
, const ENHMETARECORD
*lpEMFR
,
70 int nObj
, LPARAM lpData
)
72 emfplus_check_state
*state
= (emfplus_check_state
*)lpData
;
73 emfplus_record actual
;
75 if (lpEMFR
->iType
== EMR_GDICOMMENT
)
77 const EMRGDICOMMENT
*comment
= (const EMRGDICOMMENT
*)lpEMFR
;
79 if (comment
->cbData
>= 4 && memcmp(comment
->Data
, "EMF+", 4) == 0)
83 while (offset
+ sizeof(EmfPlusRecordHeader
) <= comment
->cbData
)
85 const EmfPlusRecordHeader
*record
= (const EmfPlusRecordHeader
*)&comment
->Data
[offset
];
87 ok(record
->Size
== record
->DataSize
+ sizeof(EmfPlusRecordHeader
),
88 "%s: EMF+ record datasize %u and size %u mismatch\n", state
->desc
, record
->DataSize
, record
->Size
);
90 ok(offset
+ record
->DataSize
<= comment
->cbData
,
91 "%s: EMF+ record truncated\n", state
->desc
);
93 if (offset
+ record
->DataSize
> comment
->cbData
)
96 if (state
->expected
[state
->count
].record_type
)
99 actual
.record_type
= record
->Type
;
101 check_record(state
->count
, state
->desc
, &state
->expected
[state
->count
], &actual
);
107 ok(0, "%s: Unexpected EMF+ 0x%x record\n", state
->desc
, record
->Type
);
110 offset
+= record
->Size
;
113 ok(offset
== comment
->cbData
, "%s: truncated EMF+ record data?\n", state
->desc
);
119 if (state
->expected
[state
->count
].record_type
)
122 actual
.record_type
= lpEMFR
->iType
;
124 check_record(state
->count
, state
->desc
, &state
->expected
[state
->count
], &actual
);
130 ok(0, "%s: Unexpected EMF 0x%x record\n", state
->desc
, lpEMFR
->iType
);
136 static void check_emfplus(HENHMETAFILE hemf
, const emfplus_record
*expected
, const char *desc
)
138 emfplus_check_state state
;
142 state
.expected
= expected
;
144 EnumEnhMetaFile(0, hemf
, enum_emf_proc
, &state
, NULL
);
146 todo_wine_if (expected
[state
.count
].todo
)
147 ok(expected
[state
.count
].record_type
== 0, "%s: Got %i records, expecting more\n", desc
, state
.count
);
150 static BOOL CALLBACK
enum_metafile_proc(EmfPlusRecordType record_type
, unsigned int flags
,
151 unsigned int dataSize
, const unsigned char *pStr
, void *userdata
)
153 emfplus_check_state
*state
= (emfplus_check_state
*)userdata
;
154 emfplus_record actual
;
157 actual
.record_type
= record_type
;
160 ok(pStr
== NULL
, "non-NULL pStr\n");
162 if (state
->expected
[state
->count
].record_type
)
164 check_record(state
->count
, state
->desc
, &state
->expected
[state
->count
], &actual
);
170 ok(0, "%s: Unexpected EMF 0x%x record\n", state
->desc
, record_type
);
176 static void check_metafile(GpMetafile
*metafile
, const emfplus_record
*expected
, const char *desc
,
177 const GpPointF
*dst_points
, const GpRectF
*src_rect
, Unit src_unit
)
181 GpGraphics
*graphics
;
182 emfplus_check_state state
;
186 state
.expected
= expected
;
187 state
.metafile
= metafile
;
189 hdc
= CreateCompatibleDC(0);
191 stat
= GdipCreateFromHDC(hdc
, &graphics
);
194 stat
= GdipEnumerateMetafileSrcRectDestPoints(graphics
, metafile
, dst_points
,
195 3, src_rect
, src_unit
, enum_metafile_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
);
201 GdipDeleteGraphics(graphics
);
206 static BOOL CALLBACK
play_metafile_proc(EmfPlusRecordType record_type
, unsigned int flags
,
207 unsigned int dataSize
, const unsigned char *pStr
, void *userdata
)
209 emfplus_check_state
*state
= (emfplus_check_state
*)userdata
;
212 stat
= GdipPlayMetafileRecord(state
->metafile
, record_type
, flags
, dataSize
, pStr
);
214 if (state
->expected
[state
->count
].record_type
)
216 todo_wine_if (state
->expected
[state
->count
].playback_todo
)
217 ok(stat
== Ok
, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state
->desc
, state
->count
, stat
);
222 todo_wine_if (state
->expected
[state
->count
].playback_todo
)
223 ok(0, "%s: too many records\n", state
->desc
);
231 static void play_metafile(GpMetafile
*metafile
, GpGraphics
*graphics
, const emfplus_record
*expected
,
232 const char *desc
, const GpPointF
*dst_points
, const GpRectF
*src_rect
, Unit src_unit
)
235 emfplus_check_state state
;
239 state
.expected
= expected
;
240 state
.metafile
= metafile
;
242 stat
= GdipEnumerateMetafileSrcRectDestPoints(graphics
, metafile
, dst_points
,
243 3, src_rect
, src_unit
, play_metafile_proc
, &state
, NULL
);
247 static void save_metafile(GpMetafile
*metafile
, const char *filename
)
255 stat
= GdipCloneImage((GpImage
*)metafile
, (GpImage
**)&clone
);
258 stat
= GdipGetHemfFromMetafile(clone
, &hemf
);
261 DeleteEnhMetaFile(CopyEnhMetaFileA(hemf
, filename
));
263 DeleteEnhMetaFile(hemf
);
265 stat
= GdipDisposeImage((GpImage
*)clone
);
270 static const emfplus_record empty_records
[] = {
272 {0, EmfPlusRecordTypeHeader
},
273 {0, EmfPlusRecordTypeEndOfFile
},
278 static void test_empty(void)
281 GpMetafile
*metafile
;
282 GpGraphics
*graphics
;
287 HENHMETAFILE hemf
, dummy
;
288 MetafileHeader header
;
289 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
290 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
291 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
293 hdc
= CreateCompatibleDC(0);
295 stat
= GdipRecordMetafile(NULL
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
296 expect(InvalidParameter
, stat
);
298 stat
= GdipRecordMetafile(hdc
, MetafileTypeInvalid
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
299 expect(InvalidParameter
, stat
);
301 stat
= GdipRecordMetafile(hdc
, MetafileTypeWmf
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
302 expect(InvalidParameter
, stat
);
304 stat
= GdipRecordMetafile(hdc
, MetafileTypeWmfPlaceable
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
305 expect(InvalidParameter
, stat
);
307 stat
= GdipRecordMetafile(hdc
, MetafileTypeEmfPlusDual
+1, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
308 expect(InvalidParameter
, stat
);
310 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, NULL
);
311 expect(InvalidParameter
, stat
);
313 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
321 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
322 expect(InvalidParameter
, stat
);
324 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
327 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
328 expect(InvalidParameter
, stat
);
330 stat
= GdipDeleteGraphics(graphics
);
333 check_metafile(metafile
, empty_records
, "empty metafile", dst_points
, &frame
, UnitPixel
);
335 save_metafile(metafile
, "empty.emf");
337 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
339 expectf(0.0, bounds
.X
);
340 expectf(0.0, bounds
.Y
);
341 expectf_(100.0, bounds
.Width
, 0.05);
342 expectf_(100.0, bounds
.Height
, 0.05);
343 expect(UnitPixel
, unit
);
345 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
348 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
351 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
354 stat
= GdipGetHemfFromMetafile(metafile
, &dummy
);
355 expect(InvalidParameter
, stat
);
357 stat
= GdipDisposeImage((GpImage
*)metafile
);
360 check_emfplus(hemf
, empty_records
, "empty emf");
362 memset(&header
, 0xaa, sizeof(header
));
363 stat
= GdipGetMetafileHeaderFromEmf(hemf
, &header
);
365 expect(MetafileTypeEmfPlusOnly
, header
.Type
);
366 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
367 ok(header
.Version
== 0xdbc01001 || header
.Version
== 0xdbc01002, "Unexpected version %x\n", header
.Version
);
368 expect(1, header
.EmfPlusFlags
); /* reference device was display, not printer */
369 expectf(xres
, header
.DpiX
);
370 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
371 expectf(yres
, header
.DpiY
);
372 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
375 expect(100, header
.Width
);
376 expect(100, header
.Height
);
377 expect(28, header
.EmfPlusHeaderSize
);
378 expect(96, header
.LogicalDpiX
);
379 expect(96, header
.LogicalDpiX
);
380 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
381 expect(0, U(header
).EmfHeader
.rclBounds
.left
);
382 expect(0, U(header
).EmfHeader
.rclBounds
.top
);
383 expect(-1, U(header
).EmfHeader
.rclBounds
.right
);
384 expect(-1, U(header
).EmfHeader
.rclBounds
.bottom
);
385 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
386 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
387 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
388 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
390 stat
= GdipCreateMetafileFromEmf(hemf
, TRUE
, &metafile
);
393 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
395 expectf(0.0, bounds
.X
);
396 expectf(0.0, bounds
.Y
);
397 expectf_(100.0, bounds
.Width
, 0.05);
398 expectf_(100.0, bounds
.Height
, 0.05);
399 expect(UnitPixel
, unit
);
401 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
403 expectf(header
.DpiX
, xres
);
405 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
407 expectf(header
.DpiY
, yres
);
409 stat
= GdipDisposeImage((GpImage
*)metafile
);
413 static const emfplus_record getdc_records
[] = {
415 {0, EmfPlusRecordTypeHeader
},
416 {0, EmfPlusRecordTypeGetDC
},
417 {0, EMR_CREATEBRUSHINDIRECT
},
418 {0, EMR_SELECTOBJECT
},
420 {0, EMR_SELECTOBJECT
},
421 {0, EMR_DELETEOBJECT
},
422 {0, EmfPlusRecordTypeEndOfFile
},
427 static void test_getdc(void)
430 GpMetafile
*metafile
;
431 GpGraphics
*graphics
;
432 HDC hdc
, metafile_dc
;
435 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
436 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
437 static const GpPointF dst_points_half
[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
438 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
439 HBRUSH hbrush
, holdbrush
;
443 hdc
= CreateCompatibleDC(0);
445 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
453 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
454 expect(InvalidParameter
, stat
);
456 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
459 stat
= GdipGetDC(graphics
, &metafile_dc
);
464 GdipDeleteGraphics(graphics
);
465 GdipDisposeImage((GpImage
*)metafile
);
469 hbrush
= CreateSolidBrush(0xff0000);
471 holdbrush
= SelectObject(metafile_dc
, hbrush
);
473 Rectangle(metafile_dc
, 25, 25, 75, 75);
475 SelectObject(metafile_dc
, holdbrush
);
477 DeleteObject(hbrush
);
479 stat
= GdipReleaseDC(graphics
, metafile_dc
);
482 stat
= GdipDeleteGraphics(graphics
);
485 check_metafile(metafile
, getdc_records
, "getdc metafile", dst_points
, &frame
, UnitPixel
);
487 save_metafile(metafile
, "getdc.emf");
489 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
492 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
495 play_metafile(metafile
, graphics
, getdc_records
, "getdc playback", dst_points
, &frame
, UnitPixel
);
497 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
501 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
503 expect(0xff0000ff, color
);
505 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
508 play_metafile(metafile
, graphics
, getdc_records
, "getdc playback", dst_points_half
, &frame
, UnitPixel
);
510 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
512 expect(0xff0000ff, color
);
514 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
518 stat
= GdipBitmapSetPixel(bitmap
, 15, 15, 0);
521 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
522 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
525 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
529 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
531 expect(0xff0000ff, color
);
533 stat
= GdipDeleteGraphics(graphics
);
536 stat
= GdipDisposeImage((GpImage
*)bitmap
);
539 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
542 stat
= GdipDisposeImage((GpImage
*)metafile
);
545 check_emfplus(hemf
, getdc_records
, "getdc emf");
547 ret
= DeleteEnhMetaFile(hemf
);
548 ok(ret
!= 0, "Failed to delete enhmetafile %p\n", hemf
);
551 static const emfplus_record emfonly_records
[] = {
553 {0, EMR_CREATEBRUSHINDIRECT
},
554 {0, EMR_SELECTOBJECT
},
556 {0, EMR_SELECTOBJECT
},
557 {0, EMR_DELETEOBJECT
},
562 static void test_emfonly(void)
565 GpMetafile
*metafile
;
567 GpGraphics
*graphics
;
568 HDC hdc
, metafile_dc
;
573 MetafileHeader header
;
574 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
575 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
576 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
577 HBRUSH hbrush
, holdbrush
;
581 hdc
= CreateCompatibleDC(0);
583 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
591 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
592 expect(InvalidParameter
, stat
);
594 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
597 stat
= GdipGetDC(graphics
, &metafile_dc
);
602 GdipDeleteGraphics(graphics
);
603 GdipDisposeImage((GpImage
*)metafile
);
607 hbrush
= CreateSolidBrush(0xff0000);
609 holdbrush
= SelectObject(metafile_dc
, hbrush
);
611 Rectangle(metafile_dc
, 25, 25, 75, 75);
613 SelectObject(metafile_dc
, holdbrush
);
615 DeleteObject(hbrush
);
617 stat
= GdipReleaseDC(graphics
, metafile_dc
);
620 stat
= GdipDeleteGraphics(graphics
);
623 check_metafile(metafile
, emfonly_records
, "emfonly metafile", dst_points
, &frame
, UnitPixel
);
625 save_metafile(metafile
, "emfonly.emf");
627 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
629 expectf(0.0, bounds
.X
);
630 expectf(0.0, bounds
.Y
);
631 expectf_(100.0, bounds
.Width
, 0.05);
632 expectf_(100.0, bounds
.Height
, 0.05);
633 expect(UnitPixel
, unit
);
635 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
638 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
641 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
644 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
647 play_metafile(metafile
, graphics
, emfonly_records
, "emfonly playback", dst_points
, &frame
, UnitPixel
);
649 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
653 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
655 expect(0xff0000ff, color
);
657 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
660 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
661 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
664 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
668 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
670 expect(0xff0000ff, color
);
672 stat
= GdipCloneImage((GpImage
*)metafile
, &clone
);
677 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
680 stat
= GdipDrawImagePointsRect(graphics
, clone
, dst_points
, 3,
681 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
684 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
688 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
690 expect(0xff0000ff, color
);
692 GdipDisposeImage(clone
);
695 stat
= GdipDeleteGraphics(graphics
);
698 stat
= GdipDisposeImage((GpImage
*)bitmap
);
701 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
704 stat
= GdipDisposeImage((GpImage
*)metafile
);
707 check_emfplus(hemf
, emfonly_records
, "emfonly emf");
709 memset(&header
, 0xaa, sizeof(header
));
710 stat
= GdipGetMetafileHeaderFromEmf(hemf
, &header
);
712 expect(MetafileTypeEmf
, header
.Type
);
713 expect(U(header
).EmfHeader
.nBytes
, header
.Size
);
714 expect(0x10000, header
.Version
);
715 expect(0, header
.EmfPlusFlags
);
716 expectf(xres
, header
.DpiX
);
717 expectf(xres
, U(header
).EmfHeader
.szlDevice
.cx
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cx
* 25.4);
718 expectf(yres
, header
.DpiY
);
719 expectf(yres
, U(header
).EmfHeader
.szlDevice
.cy
/ (REAL
)U(header
).EmfHeader
.szlMillimeters
.cy
* 25.4);
722 expect(100, header
.Width
);
723 expect(100, header
.Height
);
724 expect(0, header
.EmfPlusHeaderSize
);
725 expect(0, header
.LogicalDpiX
);
726 expect(0, header
.LogicalDpiX
);
727 expect(EMR_HEADER
, U(header
).EmfHeader
.iType
);
728 expect(25, U(header
).EmfHeader
.rclBounds
.left
);
729 expect(25, U(header
).EmfHeader
.rclBounds
.top
);
730 expect(74, U(header
).EmfHeader
.rclBounds
.right
);
731 expect(74, U(header
).EmfHeader
.rclBounds
.bottom
);
732 expect(0, U(header
).EmfHeader
.rclFrame
.left
);
733 expect(0, U(header
).EmfHeader
.rclFrame
.top
);
734 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.right
* xres
/ 2540.0, 2.0);
735 expectf_(100.0, U(header
).EmfHeader
.rclFrame
.bottom
* yres
/ 2540.0, 2.0);
737 stat
= GdipCreateMetafileFromEmf(hemf
, TRUE
, &metafile
);
740 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
742 expectf(0.0, bounds
.X
);
743 expectf(0.0, bounds
.Y
);
744 expectf_(100.0, bounds
.Width
, 0.05);
745 expectf_(100.0, bounds
.Height
, 0.05);
746 expect(UnitPixel
, unit
);
748 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &xres
);
750 expectf(header
.DpiX
, xres
);
752 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &yres
);
754 expectf(header
.DpiY
, yres
);
756 stat
= GdipDisposeImage((GpImage
*)metafile
);
760 static const emfplus_record fillrect_records
[] = {
762 {0, EmfPlusRecordTypeHeader
},
763 {0, EmfPlusRecordTypeFillRects
},
764 {0, EmfPlusRecordTypeEndOfFile
},
769 static void test_fillrect(void)
772 GpMetafile
*metafile
;
773 GpGraphics
*graphics
;
776 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
777 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
778 static const GpPointF dst_points_half
[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
779 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
784 hdc
= CreateCompatibleDC(0);
786 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
794 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
795 expect(InvalidParameter
, stat
);
797 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
800 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
803 stat
= GdipFillRectangleI(graphics
, brush
, 25, 25, 75, 75);
806 stat
= GdipDeleteBrush(brush
);
809 stat
= GdipDeleteGraphics(graphics
);
812 check_metafile(metafile
, fillrect_records
, "fillrect metafile", dst_points
, &frame
, UnitPixel
);
814 save_metafile(metafile
, "fillrect.emf");
816 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
819 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
822 play_metafile(metafile
, graphics
, fillrect_records
, "fillrect playback", dst_points
, &frame
, UnitPixel
);
824 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
828 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
830 expect(0xff0000ff, color
);
832 stat
= GdipBitmapSetPixel(bitmap
, 50, 50, 0);
835 play_metafile(metafile
, graphics
, fillrect_records
, "fillrect playback", dst_points_half
, &frame
, UnitPixel
);
837 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
839 expect(0xff0000ff, color
);
841 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
845 stat
= GdipBitmapSetPixel(bitmap
, 15, 15, 0);
848 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
849 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
852 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
856 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
858 expect(0xff0000ff, color
);
860 stat
= GdipDeleteGraphics(graphics
);
863 stat
= GdipDisposeImage((GpImage
*)bitmap
);
866 stat
= GdipDisposeImage((GpImage
*)metafile
);
870 static const emfplus_record clear_emf_records
[] = {
872 {0, EmfPlusRecordTypeHeader
},
873 {0, EmfPlusRecordTypeClear
},
878 {0, EmfPlusRecordTypeEndOfFile
},
883 static void test_clear(void)
886 GpMetafile
*metafile
;
887 GpGraphics
*graphics
;
890 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
891 static const GpPointF dst_points
[3] = {{10.0,10.0},{20.0,10.0},{10.0,20.0}};
892 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
896 hdc
= CreateCompatibleDC(0);
898 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
906 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
907 expect(InvalidParameter
, stat
);
909 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
912 stat
= GdipGraphicsClear(graphics
, 0xffffff00);
915 stat
= GdipDeleteGraphics(graphics
);
918 save_metafile(metafile
, "clear.emf");
920 stat
= GdipCreateBitmapFromScan0(30, 30, 0, PixelFormat32bppRGB
, NULL
, &bitmap
);
923 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
926 stat
= GdipDrawImagePointsRect(graphics
, (GpImage
*)metafile
, dst_points
, 3,
927 0.0, 0.0, 100.0, 100.0, UnitPixel
, NULL
, NULL
, NULL
);
930 stat
= GdipBitmapGetPixel(bitmap
, 5, 5, &color
);
932 expect(0xff000000, color
);
934 stat
= GdipBitmapGetPixel(bitmap
, 15, 15, &color
);
936 expect(0xffffff00, color
);
938 stat
= GdipBitmapGetPixel(bitmap
, 25, 25, &color
);
940 expect(0xff000000, color
);
942 stat
= GdipDeleteGraphics(graphics
);
945 stat
= GdipDisposeImage((GpImage
*)bitmap
);
948 stat
= GdipGetHemfFromMetafile(metafile
, &hemf
);
951 stat
= GdipDisposeImage((GpImage
*)metafile
);
954 check_emfplus(hemf
, clear_emf_records
, "clear emf");
956 DeleteEnhMetaFile(hemf
);
959 static void test_nullframerect(void) {
961 GpMetafile
*metafile
;
962 GpGraphics
*graphics
;
963 HDC hdc
, metafile_dc
;
964 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
966 HBRUSH hbrush
, holdbrush
;
970 hdc
= CreateCompatibleDC(0);
972 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, NULL
, MetafileFrameUnitPixel
, description
, &metafile
);
980 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
982 expect(UnitPixel
, unit
);
983 expectf(0.0, bounds
.X
);
984 expectf(0.0, bounds
.Y
);
985 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
986 "expected 1.0, got %f\n", bounds
.Width
);
987 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
988 "expected 1.0, got %f\n", bounds
.Height
);
990 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
993 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
996 stat
= GdipFillRectangleI(graphics
, brush
, 25, 25, 75, 75);
999 stat
= GdipDeleteBrush(brush
);
1002 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1004 expect(UnitPixel
, unit
);
1005 expectf(0.0, bounds
.X
);
1006 expectf(0.0, bounds
.Y
);
1007 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1008 "expected 1.0, got %f\n", bounds
.Width
);
1009 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1010 "expected 1.0, got %f\n", bounds
.Height
);
1012 stat
= GdipDeleteGraphics(graphics
);
1015 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1017 expect(UnitPixel
, unit
);
1018 expectf_(25.0, bounds
.X
, 0.05);
1019 expectf_(25.0, bounds
.Y
, 0.05);
1020 expectf_(75.0, bounds
.Width
, 0.05);
1021 expectf_(75.0, bounds
.Height
, 0.05);
1023 stat
= GdipDisposeImage((GpImage
*)metafile
);
1026 hdc
= CreateCompatibleDC(0);
1028 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, NULL
, MetafileFrameUnitMillimeter
, description
, &metafile
);
1033 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1036 stat
= GdipGetDC(graphics
, &metafile_dc
);
1041 GdipDeleteGraphics(graphics
);
1042 GdipDisposeImage((GpImage
*)metafile
);
1046 hbrush
= CreateSolidBrush(0xff0000);
1048 holdbrush
= SelectObject(metafile_dc
, hbrush
);
1050 Rectangle(metafile_dc
, 25, 25, 75, 75);
1052 SelectObject(metafile_dc
, holdbrush
);
1054 DeleteObject(hbrush
);
1056 stat
= GdipReleaseDC(graphics
, metafile_dc
);
1059 stat
= GdipDeleteGraphics(graphics
);
1062 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1064 expect(UnitPixel
, unit
);
1065 expectf_(25.0, bounds
.X
, 0.05);
1066 expectf_(25.0, bounds
.Y
, 0.05);
1067 todo_wine
expectf_(50.0, bounds
.Width
, 0.05);
1068 todo_wine
expectf_(50.0, bounds
.Height
, 0.05);
1070 stat
= GdipDisposeImage((GpImage
*)metafile
);
1074 static const emfplus_record pagetransform_records
[] = {
1076 {0, EmfPlusRecordTypeHeader
},
1077 {0, EmfPlusRecordTypeFillRects
},
1078 {0, EmfPlusRecordTypeSetPageTransform
},
1079 {0, EmfPlusRecordTypeFillRects
},
1080 {0, EmfPlusRecordTypeSetPageTransform
},
1081 {0, EmfPlusRecordTypeFillRects
},
1082 {0, EmfPlusRecordTypeSetPageTransform
},
1083 {0, EmfPlusRecordTypeFillRects
},
1084 {0, EmfPlusRecordTypeSetPageTransform
},
1085 {0, EmfPlusRecordTypeFillRects
},
1086 {0, EmfPlusRecordTypeEndOfFile
},
1091 static void test_pagetransform(void)
1094 GpMetafile
*metafile
;
1095 GpGraphics
*graphics
;
1097 static const GpRectF frame
= {0.0, 0.0, 5.0, 5.0};
1098 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1099 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1104 REAL scale
, dpix
, dpiy
;
1107 hdc
= CreateCompatibleDC(0);
1109 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitInch
, description
, &metafile
);
1117 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &dpix
);
1118 todo_wine
expect(InvalidParameter
, stat
);
1120 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &dpiy
);
1121 todo_wine
expect(InvalidParameter
, stat
);
1123 stat
= GdipGetImageWidth((GpImage
*)metafile
, &width
);
1124 todo_wine
expect(InvalidParameter
, stat
);
1126 stat
= GdipGetImageHeight((GpImage
*)metafile
, &height
);
1127 todo_wine
expect(InvalidParameter
, stat
);
1129 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1133 stat
= GdipGetPageUnit(graphics
, &unit
);
1135 expect(UnitDisplay
, unit
);
1137 stat
= GdipGetPageScale(graphics
, &scale
);
1139 expectf(1.0, scale
);
1141 stat
= GdipGetDpiX(graphics
, &dpix
);
1143 expectf(96.0, dpix
);
1145 stat
= GdipGetDpiY(graphics
, &dpiy
);
1147 expectf(96.0, dpiy
);
1149 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
1152 stat
= GdipFillRectangleI(graphics
, brush
, 1, 2, 1, 1);
1155 stat
= GdipDeleteBrush(brush
);
1158 /* page unit = pixels */
1159 stat
= GdipSetPageUnit(graphics
, UnitPixel
);
1162 stat
= GdipGetPageUnit(graphics
, &unit
);
1164 expect(UnitPixel
, unit
);
1166 stat
= GdipCreateSolidFill((ARGB
)0xff00ff00, (GpSolidFill
**)&brush
);
1169 stat
= GdipFillRectangleI(graphics
, brush
, 0, 1, 1, 1);
1172 stat
= GdipDeleteBrush(brush
);
1175 /* page scale = 3, unit = pixels */
1176 stat
= GdipSetPageScale(graphics
, 3.0);
1179 stat
= GdipGetPageScale(graphics
, &scale
);
1181 expectf(3.0, scale
);
1183 stat
= GdipCreateSolidFill((ARGB
)0xff00ffff, (GpSolidFill
**)&brush
);
1186 stat
= GdipFillRectangleI(graphics
, brush
, 0, 1, 2, 2);
1189 stat
= GdipDeleteBrush(brush
);
1192 /* page scale = 3, unit = inches */
1193 stat
= GdipSetPageUnit(graphics
, UnitInch
);
1196 stat
= GdipGetPageUnit(graphics
, &unit
);
1198 expect(UnitInch
, unit
);
1200 stat
= GdipCreateSolidFill((ARGB
)0xffff0000, (GpSolidFill
**)&brush
);
1203 stat
= GdipFillRectangle(graphics
, brush
, 1.0/96.0, 0, 1, 1);
1206 stat
= GdipDeleteBrush(brush
);
1209 /* page scale = 3, unit = display */
1210 stat
= GdipSetPageUnit(graphics
, UnitDisplay
);
1213 stat
= GdipGetPageUnit(graphics
, &unit
);
1215 expect(UnitDisplay
, unit
);
1217 stat
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
1220 stat
= GdipFillRectangle(graphics
, brush
, 3, 3, 2, 2);
1223 stat
= GdipDeleteBrush(brush
);
1226 stat
= GdipDeleteGraphics(graphics
);
1229 check_metafile(metafile
, pagetransform_records
, "pagetransform metafile", dst_points
, &frame
, UnitPixel
);
1231 save_metafile(metafile
, "pagetransform.emf");
1233 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
1236 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1239 play_metafile(metafile
, graphics
, pagetransform_records
, "pagetransform playback", dst_points
, &frame
, UnitPixel
);
1241 stat
= GdipBitmapGetPixel(bitmap
, 50, 50, &color
);
1245 stat
= GdipBitmapGetPixel(bitmap
, 30, 50, &color
);
1247 expect(0xff0000ff, color
);
1249 stat
= GdipBitmapGetPixel(bitmap
, 10, 30, &color
);
1251 expect(0xff00ff00, color
);
1253 stat
= GdipBitmapGetPixel(bitmap
, 20, 80, &color
);
1255 expect(0xff00ffff, color
);
1257 stat
= GdipBitmapGetPixel(bitmap
, 80, 20, &color
);
1259 expect(0xffff0000, color
);
1261 stat
= GdipBitmapGetPixel(bitmap
, 80, 80, &color
);
1263 expect(0xffff00ff, color
);
1265 stat
= GdipDeleteGraphics(graphics
);
1268 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1271 stat
= GdipDisposeImage((GpImage
*)metafile
);
1275 static const emfplus_record worldtransform_records
[] = {
1277 {0, EmfPlusRecordTypeHeader
},
1278 {0, EmfPlusRecordTypeFillRects
},
1279 {0, EmfPlusRecordTypeScaleWorldTransform
},
1280 {0, EmfPlusRecordTypeFillRects
},
1281 {0, EmfPlusRecordTypeResetWorldTransform
},
1282 {0, EmfPlusRecordTypeFillRects
},
1283 {0, EmfPlusRecordTypeEndOfFile
},
1288 static void test_worldtransform(void)
1291 GpMetafile
*metafile
;
1292 GpGraphics
*graphics
;
1294 static const GpRectF frame
= {0.0, 0.0, 5.0, 5.0};
1295 static const GpPointF dst_points
[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1296 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1300 GpMatrix
*transform
;
1304 hdc
= CreateCompatibleDC(0);
1306 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
1314 stat
= GdipCreateMatrix(&transform
);
1317 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1320 /* initial transform */
1321 stat
= GdipGetWorldTransform(graphics
, transform
);
1324 stat
= GdipIsMatrixIdentity(transform
, &identity
);
1326 expect(TRUE
, identity
);
1328 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
1331 stat
= GdipFillRectangleI(graphics
, brush
, 0, 0, 1, 1);
1334 stat
= GdipDeleteBrush(brush
);
1337 /* scale transform */
1338 stat
= GdipScaleWorldTransform(graphics
, 2.0, 4.0, MatrixOrderPrepend
);
1341 stat
= GdipGetWorldTransform(graphics
, transform
);
1344 stat
= GdipGetMatrixElements(transform
, elements
);
1346 expectf(2.0, elements
[0]);
1347 expectf(0.0, elements
[1]);
1348 expectf(0.0, elements
[2]);
1349 expectf(4.0, elements
[3]);
1350 expectf(0.0, elements
[4]);
1351 expectf(0.0, elements
[5]);
1353 stat
= GdipCreateSolidFill((ARGB
)0xff00ff00, (GpSolidFill
**)&brush
);
1356 stat
= GdipFillRectangle(graphics
, brush
, 0.5, 0.5, 0.5, 0.25);
1359 stat
= GdipDeleteBrush(brush
);
1362 /* reset transform */
1363 stat
= GdipResetWorldTransform(graphics
);
1366 stat
= GdipGetWorldTransform(graphics
, transform
);
1369 stat
= GdipIsMatrixIdentity(transform
, &identity
);
1371 expect(TRUE
, identity
);
1373 stat
= GdipCreateSolidFill((ARGB
)0xff00ffff, (GpSolidFill
**)&brush
);
1376 stat
= GdipFillRectangle(graphics
, brush
, 1.0, 0.0, 1.0, 1.0);
1379 stat
= GdipDeleteBrush(brush
);
1382 stat
= GdipDeleteMatrix(transform
);
1385 stat
= GdipDeleteGraphics(graphics
);
1388 check_metafile(metafile
, worldtransform_records
, "worldtransform metafile", dst_points
, &frame
, UnitPixel
);
1390 save_metafile(metafile
, "worldtransform.emf");
1392 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
1395 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1398 play_metafile(metafile
, graphics
, worldtransform_records
, "worldtransform playback", dst_points
, &frame
, UnitPixel
);
1400 stat
= GdipBitmapGetPixel(bitmap
, 80, 80, &color
);
1404 stat
= GdipBitmapGetPixel(bitmap
, 10, 10, &color
);
1406 expect(0xff0000ff, color
);
1408 stat
= GdipBitmapGetPixel(bitmap
, 30, 50, &color
);
1410 expect(0xff00ff00, color
);
1412 stat
= GdipBitmapGetPixel(bitmap
, 30, 10, &color
);
1414 expect(0xff00ffff, color
);
1416 stat
= GdipDeleteGraphics(graphics
);
1419 stat
= GdipDisposeImage((GpImage
*)bitmap
);
1422 stat
= GdipDisposeImage((GpImage
*)metafile
);
1426 static void test_converttoemfplus(void)
1428 GpStatus (WINAPI
*pGdipConvertToEmfPlus
)( const GpGraphics
*graphics
, GpMetafile
*metafile
, BOOL
*succ
,
1429 EmfType emfType
, const WCHAR
*description
, GpMetafile
**outmetafile
);
1430 static const GpRectF frame
= {0.0, 0.0, 100.0, 100.0};
1431 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1433 GpMetafile
*metafile
, *metafile2
= NULL
, *emhmeta
;
1434 GpGraphics
*graphics
;
1437 HMODULE mod
= GetModuleHandleA("gdiplus.dll");
1439 pGdipConvertToEmfPlus
= (void*)GetProcAddress( mod
, "GdipConvertToEmfPlus");
1440 if(!pGdipConvertToEmfPlus
)
1442 /* GdipConvertToEmfPlus was introduced in Windows Vista. */
1443 win_skip("GDIPlus version 1.1 not available\n");
1447 hdc
= CreateCompatibleDC(0);
1449 stat
= GdipRecordMetafile(hdc
, MetafileTypeEmf
, &frame
, MetafileFrameUnitPixel
, description
, &metafile
);
1452 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitPixel
, description
, &emhmeta
);
1460 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1463 /* Invalid Parameters */
1464 stat
= pGdipConvertToEmfPlus(NULL
, metafile
, &succ
, EmfTypeEmfPlusOnly
, description
, &metafile2
);
1465 expect(InvalidParameter
, stat
);
1467 stat
= pGdipConvertToEmfPlus(graphics
, NULL
, &succ
, EmfTypeEmfPlusOnly
, description
, &metafile2
);
1468 expect(InvalidParameter
, stat
);
1470 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, &succ
, EmfTypeEmfPlusOnly
, description
, NULL
);
1471 expect(InvalidParameter
, stat
);
1473 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, NULL
, MetafileTypeInvalid
, NULL
, &metafile2
);
1474 expect(InvalidParameter
, stat
);
1476 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, NULL
, MetafileTypeEmfPlusDual
+1, NULL
, &metafile2
);
1477 expect(InvalidParameter
, stat
);
1479 /* If we are already an Enhanced Metafile then the conversion fails. */
1480 stat
= pGdipConvertToEmfPlus(graphics
, emhmeta
, NULL
, EmfTypeEmfPlusOnly
, NULL
, &metafile2
);
1481 todo_wine
expect(InvalidParameter
, stat
);
1483 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, NULL
, EmfTypeEmfPlusOnly
, NULL
, &metafile2
);
1484 todo_wine
expect(Ok
, stat
);
1486 GdipDisposeImage((GpImage
*)metafile2
);
1489 stat
= pGdipConvertToEmfPlus(graphics
, metafile
, &succ
, EmfTypeEmfPlusOnly
, NULL
, &metafile2
);
1490 todo_wine
expect(Ok
, stat
);
1492 GdipDisposeImage((GpImage
*)metafile2
);
1494 stat
= GdipDeleteGraphics(graphics
);
1497 stat
= GdipDisposeImage((GpImage
*)metafile
);
1500 stat
= GdipDisposeImage((GpImage
*)emhmeta
);
1504 static void test_frameunit(void)
1507 GpMetafile
*metafile
;
1508 GpGraphics
*graphics
;
1510 static const GpRectF frame
= {0.0, 0.0, 5.0, 5.0};
1511 static const WCHAR description
[] = {'w','i','n','e','t','e','s','t',0};
1516 hdc
= CreateCompatibleDC(0);
1518 stat
= GdipRecordMetafile(hdc
, EmfTypeEmfPlusOnly
, &frame
, MetafileFrameUnitInch
, description
, &metafile
);
1526 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1528 expect(UnitPixel
, unit
);
1529 expectf(0.0, bounds
.X
);
1530 expectf(0.0, bounds
.Y
);
1531 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1532 "expected 1.0, got %f\n", bounds
.Width
);
1533 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1534 "expected 1.0, got %f\n", bounds
.Height
);
1536 stat
= GdipGetImageGraphicsContext((GpImage
*)metafile
, &graphics
);
1539 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1541 expect(UnitPixel
, unit
);
1542 expectf(0.0, bounds
.X
);
1543 expectf(0.0, bounds
.Y
);
1544 ok(bounds
.Width
== 1.0 || broken(bounds
.Width
== 0.0) /* xp sp1 */,
1545 "expected 1.0, got %f\n", bounds
.Width
);
1546 ok(bounds
.Height
== 1.0 || broken(bounds
.Height
== 0.0) /* xp sp1 */,
1547 "expected 1.0, got %f\n", bounds
.Height
);
1549 stat
= GdipDeleteGraphics(graphics
);
1552 stat
= GdipGetImageHorizontalResolution((GpImage
*)metafile
, &dpix
);
1555 stat
= GdipGetImageVerticalResolution((GpImage
*)metafile
, &dpiy
);
1558 stat
= GdipGetImageBounds((GpImage
*)metafile
, &bounds
, &unit
);
1560 expect(UnitPixel
, unit
);
1561 expectf(0.0, bounds
.X
);
1562 expectf(0.0, bounds
.Y
);
1563 expectf_(5.0 * dpix
, bounds
.Width
, 1.0);
1564 expectf_(5.0 * dpiy
, bounds
.Height
, 1.0);
1566 stat
= GdipDisposeImage((GpImage
*)metafile
);
1570 START_TEST(metafile
)
1572 struct GdiplusStartupInput gdiplusStartupInput
;
1573 ULONG_PTR gdiplusToken
;
1577 gdiplusStartupInput
.GdiplusVersion
= 1;
1578 gdiplusStartupInput
.DebugEventCallback
= NULL
;
1579 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
1580 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
1582 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
1584 myARGC
= winetest_get_mainargs( &myARGV
);
1586 if (myARGC
>= 3 && !strcmp(myARGV
[2], "save"))
1587 save_metafiles
= TRUE
;
1594 test_nullframerect();
1595 test_pagetransform();
1596 test_worldtransform();
1597 test_converttoemfplus();
1600 GdiplusShutdown(gdiplusToken
);