ReactOS 0.4.17-dev-243-g1369312
metafile.c
Go to the documentation of this file.
1/*
2 * Unit test suite for metafiles
3 *
4 * Copyright (C) 2011 Vincent Povirk for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <math.h>
22
23#include "objbase.h"
24#include "gdiplus.h"
25#include "winspool.h"
26#include "wine/test.h"
27
28#define expect(expected,got) expect_(__LINE__, expected, got)
29static inline void expect_(unsigned line, DWORD expected, DWORD got)
30{
31 ok_(__FILE__, line)(expected == got, "Expected %.8ld, got %.8ld\n", expected, got);
32}
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)
35
38
39static const WCHAR description[] = L"winetest";
40
41typedef struct emfplus_record
42{
44 DWORD flags; /* Used for EMF+ records only. */
48 unsigned int flags, unsigned int dataSize, const unsigned char *pStr);
51
52typedef struct emfplus_check_state
53{
54 const char *desc;
55 int count;
56 const struct emfplus_record *expected;
59
60static void check_record(int count, const char *desc, const struct emfplus_record *expected, const struct emfplus_record *actual)
61{
63 {
65 ok(expected->record_type == actual->record_type && (expected->flags == actual->flags ||
66 broken(expected->broken_flags == actual->flags)),
67 "%s.%i: Expected record type 0x%lx, got 0x%lx. Expected flags %#lx, got %#lx.\n", desc, count,
68 expected->record_type, actual->record_type, expected->flags, actual->flags);
69 }
70 else
71 {
73 ok(expected->record_type == actual->record_type,
74 "%s.%i: Expected record type 0x%lx, got 0x%lx.\n", desc, count,
75 expected->record_type, actual->record_type);
76 }
77}
78
79typedef struct EmfPlusRecordHeader
80{
81 WORD Type;
82 WORD Flags;
83 DWORD Size;
86
87typedef enum
88{
100
101typedef enum
102{
107
108typedef struct
109{
111 /* EmfPlusImage */
114 /* EmfPlusMetafile */
117 BYTE MetafileData[1];
119
120static int CALLBACK enum_emf_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR,
121 int nObj, LPARAM lpData)
122{
124 emfplus_record actual;
125
126 if (lpEMFR->iType == EMR_GDICOMMENT)
127 {
128 const EMRGDICOMMENT *comment = (const EMRGDICOMMENT*)lpEMFR;
129
130 if (comment->cbData >= 4 && memcmp(comment->Data, "EMF+", 4) == 0)
131 {
132 int offset = 4;
133
134 while (offset + sizeof(EmfPlusRecordHeader) <= comment->cbData)
135 {
137
138 ok(record->Size == record->DataSize + sizeof(EmfPlusRecordHeader),
139 "%s: EMF+ record datasize %lu and size %lu mismatch\n", state->desc, record->DataSize, record->Size);
140
141 ok(offset + record->DataSize <= comment->cbData,
142 "%s: EMF+ record truncated\n", state->desc);
143
144 if (offset + record->DataSize > comment->cbData)
145 return 0;
146
147 if (state->expected[state->count].record_type)
148 {
149 actual.todo = FALSE;
150 actual.record_type = record->Type;
151 actual.flags = record->Flags;
152
153 check_record(state->count, state->desc, &state->expected[state->count], &actual);
154 state->count++;
155
156 if (state->expected[state->count-1].todo && state->expected[state->count-1].record_type != actual.record_type)
157 continue;
158 }
159 else
160 {
161 ok(0, "%s: Unexpected EMF+ 0x%x record\n", state->desc, record->Type);
162 }
163
164 if ((record->Flags >> 8) == ObjectTypeImage && record->Type == EmfPlusRecordTypeObject)
165 {
167
168 if (image->Type == ImageDataTypeMetafile)
169 {
170 HENHMETAFILE hemf = SetEnhMetaFileBits(image->MetafileDataSize, image->MetafileData);
171 ok(hemf != NULL, "%s: SetEnhMetaFileBits failed\n", state->desc);
172
174 DeleteEnhMetaFile(hemf);
175 }
176 }
177
178 offset += record->Size;
179 }
180
181 ok(offset == comment->cbData, "%s: truncated EMF+ record data?\n", state->desc);
182
183 return 1;
184 }
185 }
186
187 if (state->expected[state->count].record_type)
188 {
189 actual.todo = FALSE;
190 actual.record_type = lpEMFR->iType;
191 actual.flags = 0;
192
193 check_record(state->count, state->desc, &state->expected[state->count], &actual);
194
195 state->count++;
196 }
197 else
198 {
199 ok(0, "%s: Unexpected EMF 0x%lx record\n", state->desc, lpEMFR->iType);
200 }
201
202 return 1;
203}
204
205static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
206{
208
209 state.desc = desc;
210 state.count = 0;
211 state.expected = expected;
212
214
215 todo_wine_if (expected[state.count].todo)
216 ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
217}
218
219static BOOL CALLBACK enum_metafile_proc(EmfPlusRecordType record_type, unsigned int flags,
220 unsigned int dataSize, const unsigned char *pStr, void *userdata)
221{
223 emfplus_record actual;
224
225 actual.todo = FALSE;
226 actual.record_type = record_type;
227 actual.flags = flags;
228
229 if (dataSize == 0)
230 ok(pStr == NULL, "non-NULL pStr\n");
231
232 if (state->expected[state->count].record_type)
233 {
234 check_record(state->count, state->desc, &state->expected[state->count], &actual);
235
236 state->count++;
237 }
238 else
239 {
240 ok(0, "%s: Unexpected EMF 0x%x record\n", state->desc, record_type);
241 }
242
243 return TRUE;
244}
245
247 const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
248{
250 HDC hdc;
251 GpGraphics *graphics;
253
254 state.desc = desc;
255 state.count = 0;
256 state.expected = expected;
257 state.metafile = metafile;
258
260
261 stat = GdipCreateFromHDC(hdc, &graphics);
262 expect(Ok, stat);
263
265 3, src_rect, src_unit, enum_metafile_proc, &state, NULL);
266 expect(Ok, stat);
267
268 todo_wine_if (expected[state.count].todo)
269 ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
270
271 GdipDeleteGraphics(graphics);
272
273 DeleteDC(hdc);
274}
275
276static BOOL CALLBACK play_metafile_proc(EmfPlusRecordType record_type, unsigned int flags,
277 unsigned int dataSize, const unsigned char *pStr, void *userdata)
278{
281
282 if (state->expected[state->count].record_type)
283 {
284 BOOL match = (state->expected[state->count].record_type == record_type);
285
286 if (match && state->expected[state->count].playback_fn)
287 state->expected[state->count].playback_fn(state->metafile, record_type, flags, dataSize, pStr);
288 else
289 {
290 stat = GdipPlayMetafileRecord(state->metafile, record_type, flags, dataSize, pStr);
291 todo_wine_if (state->expected[state->count].playback_todo)
292 ok(stat == Ok, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state->desc, state->count, stat);
293 }
294
295 todo_wine_if (state->expected[state->count].todo)
296 ok(state->expected[state->count].record_type == record_type,
297 "%s.%i: expected record type 0x%lx, got 0x%x\n", state->desc, state->count,
298 state->expected[state->count].record_type, record_type);
299 state->count++;
300 }
301 else
302 {
303 todo_wine_if (state->expected[state->count].playback_todo)
304 ok(0, "%s: unexpected record 0x%x\n", state->desc, record_type);
305
306 return FALSE;
307 }
308
309 return TRUE;
310}
311
313 const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
314{
317
318 state.desc = desc;
319 state.count = 0;
320 state.expected = expected;
321 state.metafile = metafile;
322
324 3, src_rect, src_unit, play_metafile_proc, &state, NULL);
325 expect(Ok, stat);
326}
327
328/* When 'save' or 'load' is specified on the command line, save or
329 * load the specified filename. */
330static void sync_metafile(GpMetafile **metafile, const char *filename)
331{
333 if (save_metafiles)
334 {
335 GpMetafile *clone;
336 HENHMETAFILE hemf;
337
338 stat = GdipCloneImage((GpImage*)*metafile, (GpImage**)&clone);
339 expect(Ok, stat);
340
341 stat = GdipGetHemfFromMetafile(clone, &hemf);
342 expect(Ok, stat);
343
345
346 DeleteEnhMetaFile(hemf);
347
348 stat = GdipDisposeImage((GpImage*)clone);
349 expect(Ok, stat);
350 }
351 else if (load_metafiles)
352 {
353 HENHMETAFILE hemf;
354
356 expect(Ok, stat);
357 *metafile = NULL;
358
360 ok(hemf != NULL, "%s could not be opened\n", filename);
361
363 expect(Ok, stat);
364 }
365}
366
368 { EMR_HEADER },
371 { EMR_EOF },
372 { 0 }
373};
374
375static void test_empty(void)
376{
379 GpGraphics *graphics;
380 HDC hdc;
381 GpRectF bounds;
382 GpUnit unit;
383 REAL xres, yres;
384 HENHMETAFILE hemf, dummy;
386 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
387 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
388 UINT limit_dpi;
389
391
394
397
400
403
406
409
411 expect(Ok, stat);
412
413 DeleteDC(hdc);
414
415 if (stat != Ok)
416 return;
417
420
423
424 limit_dpi = 0xdeadbeef;
426 expect(Ok, stat);
427 ok(limit_dpi == 96, "limit_dpi was %d\n", limit_dpi);
428
430 expect(Ok, stat);
431
432 limit_dpi = 0xdeadbeef;
434 expect(Ok, stat);
435 ok(limit_dpi == 255, "limit_dpi was %d\n", limit_dpi);
436
438 expect(Ok, stat);
439
440 limit_dpi = 0xdeadbeef;
442 expect(Ok, stat);
443 ok(limit_dpi == 96, "limit_dpi was %d\n", limit_dpi);
444
447
450
452 expect(Ok, stat);
453
456
458 expect(Ok, stat);
459
462
463 stat = GdipDeleteGraphics(graphics);
464 expect(Ok, stat);
465
466 limit_dpi = 0xdeadbeef;
469 expect(0xdeadbeef, limit_dpi);
470
473
474 check_metafile(metafile, empty_records, "empty metafile", dst_points, &frame, UnitPixel);
475
476 sync_metafile(&metafile, "empty.emf");
477
479 expect(Ok, stat);
480 expectf(0.0, bounds.X);
481 expectf(0.0, bounds.Y);
482 expectf_(100.0, bounds.Width, 0.05);
483 expectf_(100.0, bounds.Height, 0.05);
485
487 expect(Ok, stat);
488
490 expect(Ok, stat);
491
492 memset(&header, 0xaa, sizeof(header));
494 expect(Ok, stat);
496 expect(header.EmfHeader.nBytes, header.Size);
497 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
498 expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
499 expectf(xres, header.DpiX);
500 expectf(xres, header.EmfHeader.szlDevice.cx / (REAL)header.EmfHeader.szlMillimeters.cx * 25.4);
501 expectf(yres, header.DpiY);
502 expectf(yres, header.EmfHeader.szlDevice.cy / (REAL)header.EmfHeader.szlMillimeters.cy * 25.4);
503 expect(0, header.X);
504 expect(0, header.Y);
505 expect(100, header.Width);
506 expect(100, header.Height);
507 expect(28, header.EmfPlusHeaderSize);
508 expect(96, header.LogicalDpiX);
509 expect(96, header.LogicalDpiY);
510 expect(EMR_HEADER, header.EmfHeader.iType);
511 expect(0, header.EmfHeader.rclBounds.left);
512 expect(0, header.EmfHeader.rclBounds.top);
513 expect(-1, header.EmfHeader.rclBounds.right);
514 expect(-1, header.EmfHeader.rclBounds.bottom);
515 expect(0, header.EmfHeader.rclFrame.left);
516 expect(0, header.EmfHeader.rclFrame.top);
517 expectf_(100.0, header.EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
518 expectf_(100.0, header.EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
519
521 expect(Ok, stat);
522
525
527 expect(Ok, stat);
528
529 check_emfplus(hemf, empty_records, "empty emf");
530
531 memset(&header, 0xaa, sizeof(header));
533 expect(Ok, stat);
535 expect(header.EmfHeader.nBytes, header.Size);
536 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
537 expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
538 expectf(xres, header.DpiX);
539 expectf(xres, header.EmfHeader.szlDevice.cx / (REAL)header.EmfHeader.szlMillimeters.cx * 25.4);
540 expectf(yres, header.DpiY);
541 expectf(yres, header.EmfHeader.szlDevice.cy / (REAL)header.EmfHeader.szlMillimeters.cy * 25.4);
542 expect(0, header.X);
543 expect(0, header.Y);
544 expect(100, header.Width);
545 expect(100, header.Height);
546 expect(28, header.EmfPlusHeaderSize);
547 expect(96, header.LogicalDpiX);
548 expect(96, header.LogicalDpiY);
549 expect(EMR_HEADER, header.EmfHeader.iType);
550 expect(0, header.EmfHeader.rclBounds.left);
551 expect(0, header.EmfHeader.rclBounds.top);
552 expect(-1, header.EmfHeader.rclBounds.right);
553 expect(-1, header.EmfHeader.rclBounds.bottom);
554 expect(0, header.EmfHeader.rclFrame.left);
555 expect(0, header.EmfHeader.rclFrame.top);
556 expectf_(100.0, header.EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
557 expectf_(100.0, header.EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
558
560 expect(Ok, stat);
561
563 expect(Ok, stat);
564 expectf(0.0, bounds.X);
565 expectf(0.0, bounds.Y);
566 expectf_(100.0, bounds.Width, 0.05);
567 expectf_(100.0, bounds.Height, 0.05);
569
571 expect(Ok, stat);
572 expectf(header.DpiX, xres);
573
575 expect(Ok, stat);
576 expectf(header.DpiY, yres);
577
578 memset(&header, 0xaa, sizeof(header));
580 expect(Ok, stat);
582 expect(header.EmfHeader.nBytes, header.Size);
583 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
584 expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
585 expectf(xres, header.DpiX);
586 expectf(xres, header.EmfHeader.szlDevice.cx / (REAL)header.EmfHeader.szlMillimeters.cx * 25.4);
587 expectf(yres, header.DpiY);
588 expectf(yres, header.EmfHeader.szlDevice.cy / (REAL)header.EmfHeader.szlMillimeters.cy * 25.4);
589 expect(0, header.X);
590 expect(0, header.Y);
591 expect(100, header.Width);
592 expect(100, header.Height);
593 expect(28, header.EmfPlusHeaderSize);
594 expect(96, header.LogicalDpiX);
595 expect(96, header.LogicalDpiY);
596 expect(EMR_HEADER, header.EmfHeader.iType);
597 expect(0, header.EmfHeader.rclBounds.left);
598 expect(0, header.EmfHeader.rclBounds.top);
599 expect(-1, header.EmfHeader.rclBounds.right);
600 expect(-1, header.EmfHeader.rclBounds.bottom);
601 expect(0, header.EmfHeader.rclFrame.left);
602 expect(0, header.EmfHeader.rclFrame.top);
603 expectf_(100.0, header.EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
604 expectf_(100.0, header.EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
605
607 expect(Ok, stat);
608}
609
611 { EMR_HEADER },
616 { EMR_RECTANGLE },
620 { EMR_EOF },
621 { 0 }
622};
623
624static void test_getdc(void)
625{
628 GpGraphics *graphics;
629 HDC hdc, metafile_dc;
630 HENHMETAFILE hemf;
631 BOOL ret;
632 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
633 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
634 static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
635 HBRUSH hbrush, holdbrush;
637 ARGB color;
638
640
642 expect(Ok, stat);
643
644 DeleteDC(hdc);
645
646 if (stat != Ok)
647 return;
648
651
653 expect(Ok, stat);
654
655 stat = GdipGetDC(graphics, &metafile_dc);
656 expect(Ok, stat);
657
658 if (stat != Ok)
659 {
660 GdipDeleteGraphics(graphics);
662 return;
663 }
664
665 hbrush = CreateSolidBrush(0xff0000);
666
667 holdbrush = SelectObject(metafile_dc, hbrush);
668
669 Rectangle(metafile_dc, 25, 25, 75, 75);
670
671 SelectObject(metafile_dc, holdbrush);
672
674
675 stat = GdipReleaseDC(graphics, metafile_dc);
676 expect(Ok, stat);
677
678 stat = GdipDeleteGraphics(graphics);
679 expect(Ok, stat);
680
681 check_metafile(metafile, getdc_records, "getdc metafile", dst_points, &frame, UnitPixel);
682
683 sync_metafile(&metafile, "getdc.emf");
684
686 expect(Ok, stat);
687
689 expect(Ok, stat);
690
691 play_metafile(metafile, graphics, getdc_records, "getdc playback", dst_points, &frame, UnitPixel);
692
693 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
694 expect(Ok, stat);
695 expect(0, color);
696
697 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
698 expect(Ok, stat);
699 expect(0xff0000ff, color);
700
701 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
702 expect(Ok, stat);
703
704 play_metafile(metafile, graphics, getdc_records, "getdc playback", dst_points_half, &frame, UnitPixel);
705
706 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
707 expect(Ok, stat);
708 expect(0xff0000ff, color);
709
710 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
711 expect(Ok, stat);
712 expect(0, color);
713
714 stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
715 expect(Ok, stat);
716
717 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
718 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
719 expect(Ok, stat);
720
721 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
722 expect(Ok, stat);
723 expect(0, color);
724
725 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
726 expect(Ok, stat);
727 expect(0xff0000ff, color);
728
729 stat = GdipDeleteGraphics(graphics);
730 expect(Ok, stat);
731
733 expect(Ok, stat);
734
736 expect(Ok, stat);
737
739 expect(Ok, stat);
740
741 check_emfplus(hemf, getdc_records, "getdc emf");
742
743 ret = DeleteEnhMetaFile(hemf);
744 ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
745}
746
748 { EMR_HEADER },
751 { EMR_RECTANGLE },
754 { EMR_EOF },
755 { 0 }
756};
757
759 { EMR_HEADER },
760 { EMR_SAVEDC, 0, 1 },
761 { EMR_SETICMMODE, 0, 1 },
762 { EMR_SETMITERLIMIT, 0, 1 },
763 { EMR_MODIFYWORLDTRANSFORM, 0, 1 },
764 { EMR_EXTCREATEPEN, 0, 1 },
765 { EMR_SELECTOBJECT, 0, 1 },
766 { EMR_SELECTOBJECT, 0, 1 },
767 { EMR_POLYLINE16, 0, 1 },
768 { EMR_SELECTOBJECT, 0, 1 },
769 { EMR_SELECTOBJECT, 0, 1 },
770 { EMR_MODIFYWORLDTRANSFORM, 0, 1 },
771 { EMR_DELETEOBJECT, 0, 1 },
772 { EMR_SETMITERLIMIT, 0, 1 },
773 { EMR_RESTOREDC, 0, 1 },
774 { EMR_EOF },
775 { 0, 0, 1 }
776};
777
778static void test_emfonly(void)
779{
782 GpImage *clone;
783 GpGraphics *graphics;
784 HDC hdc, metafile_dc;
785 GpRectF bounds;
786 GpUnit unit;
787 REAL xres, yres;
788 HENHMETAFILE hemf;
790 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
791 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
792 HBRUSH hbrush, holdbrush;
794 ARGB color;
795 GpPen *pen;
796
798
800 expect(Ok, stat);
801
802 DeleteDC(hdc);
803
804 if (stat != Ok)
805 return;
806
809
810 memset(&header, 0xaa, sizeof(header));
812 expect(Ok, stat);
814 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
815 /* The rest is zeroed or seemingly random/uninitialized garbage. */
816
818 expect(Ok, stat);
819
820 stat = GdipGetDC(graphics, &metafile_dc);
821 expect(Ok, stat);
822
823 if (stat != Ok)
824 {
825 GdipDeleteGraphics(graphics);
827 return;
828 }
829
830 hbrush = CreateSolidBrush(0xff0000);
831
832 holdbrush = SelectObject(metafile_dc, hbrush);
833
834 Rectangle(metafile_dc, 25, 25, 75, 75);
835
836 SelectObject(metafile_dc, holdbrush);
837
839
840 stat = GdipReleaseDC(graphics, metafile_dc);
841 expect(Ok, stat);
842
843 stat = GdipDeleteGraphics(graphics);
844 expect(Ok, stat);
845
846 check_metafile(metafile, emfonly_records, "emfonly metafile", dst_points, &frame, UnitPixel);
847
848 sync_metafile(&metafile, "emfonly.emf");
849
851 expect(Ok, stat);
852 expectf(0.0, bounds.X);
853 expectf(0.0, bounds.Y);
854 expectf_(100.0, bounds.Width, 0.05);
855 expectf_(100.0, bounds.Height, 0.05);
857
859 expect(Ok, stat);
860
862 expect(Ok, stat);
863
864 memset(&header, 0xaa, sizeof(header));
866 expect(Ok, stat);
868 expect(header.EmfHeader.nBytes, header.Size);
869 /* For some reason a recoreded EMF Metafile has an EMF+ version. */
870 todo_wine ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
871 expect(0, header.EmfPlusFlags);
872 expectf(xres, header.DpiX);
873 expectf(xres, header.EmfHeader.szlDevice.cx / (REAL)header.EmfHeader.szlMillimeters.cx * 25.4);
874 expectf(yres, header.DpiY);
875 expectf(yres, header.EmfHeader.szlDevice.cy / (REAL)header.EmfHeader.szlMillimeters.cy * 25.4);
876 expect(0, header.X);
877 expect(0, header.Y);
878 expect(100, header.Width);
879 expect(100, header.Height);
880 expect(0, header.EmfPlusHeaderSize);
881 expect(0, header.LogicalDpiX);
882 expect(0, header.LogicalDpiY);
883 expect(EMR_HEADER, header.EmfHeader.iType);
884 expect(25, header.EmfHeader.rclBounds.left);
885 expect(25, header.EmfHeader.rclBounds.top);
886 expect(74, header.EmfHeader.rclBounds.right);
887 expect(74, header.EmfHeader.rclBounds.bottom);
888 expect(0, header.EmfHeader.rclFrame.left);
889 expect(0, header.EmfHeader.rclFrame.top);
890 expectf_(100.0, header.EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
891 expectf_(100.0, header.EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
892
894 expect(Ok, stat);
895
897 expect(Ok, stat);
898
899 play_metafile(metafile, graphics, emfonly_records, "emfonly playback", dst_points, &frame, UnitPixel);
900
901 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
902 expect(Ok, stat);
903 expect(0, color);
904
905 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
906 expect(Ok, stat);
907 expect(0xff0000ff, color);
908
909 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
910 expect(Ok, stat);
911
912 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
913 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
914 expect(Ok, stat);
915
916 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
917 expect(Ok, stat);
918 expect(0, color);
919
920 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
921 expect(Ok, stat);
922 expect(0xff0000ff, color);
923
924 stat = GdipCloneImage((GpImage*)metafile, &clone);
925 expect(Ok, stat);
926
927 if (stat == Ok)
928 {
929 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
930 expect(Ok, stat);
931
932 stat = GdipDrawImagePointsRect(graphics, clone, dst_points, 3,
933 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
934 expect(Ok, stat);
935
936 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
937 expect(Ok, stat);
938 expect(0, color);
939
940 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
941 expect(Ok, stat);
942 expect(0xff0000ff, color);
943
944 GdipDisposeImage(clone);
945 }
946
947 stat = GdipDeleteGraphics(graphics);
948 expect(Ok, stat);
949
951 expect(Ok, stat);
952
954 expect(Ok, stat);
955
957 expect(Ok, stat);
958
959 check_emfplus(hemf, emfonly_records, "emfonly emf");
960
961 memset(&header, 0xaa, sizeof(header));
963 expect(Ok, stat);
965 expect(header.EmfHeader.nBytes, header.Size);
966 expect(0x10000, header.Version);
967 expect(0, header.EmfPlusFlags);
968 expectf(xres, header.DpiX);
969 expectf(xres, header.EmfHeader.szlDevice.cx / (REAL)header.EmfHeader.szlMillimeters.cx * 25.4);
970 expectf(yres, header.DpiY);
971 expectf(yres, header.EmfHeader.szlDevice.cy / (REAL)header.EmfHeader.szlMillimeters.cy * 25.4);
972 expect(0, header.X);
973 expect(0, header.Y);
974 expect(100, header.Width);
975 expect(100, header.Height);
976 expect(0, header.EmfPlusHeaderSize);
977 expect(0, header.LogicalDpiX);
978 expect(0, header.LogicalDpiY);
979 expect(EMR_HEADER, header.EmfHeader.iType);
980 expect(25, header.EmfHeader.rclBounds.left);
981 expect(25, header.EmfHeader.rclBounds.top);
982 expect(74, header.EmfHeader.rclBounds.right);
983 expect(74, header.EmfHeader.rclBounds.bottom);
984 expect(0, header.EmfHeader.rclFrame.left);
985 expect(0, header.EmfHeader.rclFrame.top);
986 expectf_(100.0, header.EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
987 expectf_(100.0, header.EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
988
990 expect(Ok, stat);
991
993 expect(Ok, stat);
994 expectf(0.0, bounds.X);
995 expectf(0.0, bounds.Y);
996 expectf_(100.0, bounds.Width, 0.05);
997 expectf_(100.0, bounds.Height, 0.05);
999
1001 expect(Ok, stat);
1002 expectf(header.DpiX, xres);
1003
1005 expect(Ok, stat);
1006 expectf(header.DpiY, yres);
1007
1008 memset(&header, 0xaa, sizeof(header));
1010 expect(Ok, stat);
1012 expect(header.EmfHeader.nBytes, header.Size);
1013 expect(0x10000, header.Version);
1014 expect(0, header.EmfPlusFlags);
1015 expectf(xres, header.DpiX);
1016 expectf(xres, header.EmfHeader.szlDevice.cx / (REAL)header.EmfHeader.szlMillimeters.cx * 25.4);
1017 expectf(yres, header.DpiY);
1018 expectf(yres, header.EmfHeader.szlDevice.cy / (REAL)header.EmfHeader.szlMillimeters.cy * 25.4);
1019 expect(0, header.X);
1020 expect(0, header.Y);
1021 expect(100, header.Width);
1022 expect(100, header.Height);
1023 expect(0, header.EmfPlusHeaderSize);
1024 expect(0, header.LogicalDpiX);
1025 expect(0, header.LogicalDpiY);
1026 expect(EMR_HEADER, header.EmfHeader.iType);
1027 expect(25, header.EmfHeader.rclBounds.left);
1028 expect(25, header.EmfHeader.rclBounds.top);
1029 expect(74, header.EmfHeader.rclBounds.right);
1030 expect(74, header.EmfHeader.rclBounds.bottom);
1031 expect(0, header.EmfHeader.rclFrame.left);
1032 expect(0, header.EmfHeader.rclFrame.top);
1033 expectf_(100.0, header.EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
1034 expectf_(100.0, header.EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
1035
1037 expect(Ok, stat);
1038
1039 /* test drawing to metafile with gdi+ functions */
1041
1043 expect(Ok, stat);
1044
1045 DeleteDC(hdc);
1046
1047 if (stat != Ok)
1048 return;
1049
1051 expect(Ok, stat);
1052
1053 stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1054 expect(Ok, stat);
1055 stat = GdipDrawLineI(graphics, pen, 0, 0, 10, 10);
1057 GdipDeletePen(pen);
1058
1059 stat = GdipDeleteGraphics(graphics);
1060 expect(Ok, stat);
1061
1062 check_metafile(metafile, emfonly_draw_records, "emfonly draw metafile", dst_points, &frame, UnitPixel);
1063 sync_metafile(&metafile, "emfonly_draw.emf");
1064
1066 expect(Ok, stat);
1067}
1068
1070 { EMR_HEADER },
1072 { EmfPlusRecordTypeFillRects, 0xc000 },
1074 { EMR_EOF },
1075 { 0 }
1076};
1077
1078static void test_fillrect(void)
1079{
1080 GpStatus stat;
1082 GpGraphics *graphics;
1083 HDC hdc;
1084 HENHMETAFILE hemf;
1085 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1086 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1087 static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
1089 ARGB color;
1090 GpBrush *brush;
1091
1093
1095 expect(Ok, stat);
1096
1097 DeleteDC(hdc);
1098
1099 if (stat != Ok)
1100 return;
1101
1104
1106 expect(Ok, stat);
1107
1108 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1109 expect(Ok, stat);
1110
1111 stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
1112 expect(Ok, stat);
1113
1114 stat = GdipDeleteBrush(brush);
1115 expect(Ok, stat);
1116
1117 stat = GdipDeleteGraphics(graphics);
1118 expect(Ok, stat);
1119
1120 check_metafile(metafile, fillrect_records, "fillrect metafile", dst_points, &frame, UnitPixel);
1121
1122 sync_metafile(&metafile, "fillrect.emf");
1123
1125 expect(Ok, stat);
1126
1128 expect(Ok, stat);
1129
1130 play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points, &frame, UnitPixel);
1131
1132 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1133 expect(Ok, stat);
1134 expect(0, color);
1135
1136 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1137 expect(Ok, stat);
1138 expect(0xff0000ff, color);
1139
1140 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
1141 expect(Ok, stat);
1142
1143 play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points_half, &frame, UnitPixel);
1144
1145 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1146 expect(Ok, stat);
1147 expect(0xff0000ff, color);
1148
1149 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1150 expect(Ok, stat);
1151 expect(0, color);
1152
1153 stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
1154 expect(Ok, stat);
1155
1156 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
1157 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
1158 expect(Ok, stat);
1159
1160 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1161 expect(Ok, stat);
1162 expect(0, color);
1163
1164 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1165 expect(Ok, stat);
1166 expect(0xff0000ff, color);
1167
1168 stat = GdipDeleteGraphics(graphics);
1169 expect(Ok, stat);
1170
1172 expect(Ok, stat);
1173
1175 expect(Ok, stat);
1176}
1177
1179 { EMR_HEADER },
1182 { EMR_SAVEDC, 0, 1 },
1183 { EMR_SETICMMODE, 0, 1 },
1184 { EMR_BITBLT, 0, 1 },
1185 { EMR_RESTOREDC, 0, 1 },
1187 { EMR_EOF },
1188 { 0 }
1189};
1190
1191static void test_clear(void)
1192{
1193 GpStatus stat;
1195 GpGraphics *graphics;
1196 HDC hdc;
1197 HENHMETAFILE hemf;
1198 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1199 static const GpPointF dst_points[3] = {{10.0,10.0},{20.0,10.0},{10.0,20.0}};
1201 ARGB color;
1202
1204
1206 expect(Ok, stat);
1207
1208 DeleteDC(hdc);
1209
1210 if (stat != Ok)
1211 return;
1212
1215
1217 expect(Ok, stat);
1218
1219 stat = GdipGraphicsClear(graphics, 0xffffff00);
1220 expect(Ok, stat);
1221
1222 stat = GdipDeleteGraphics(graphics);
1223 expect(Ok, stat);
1224
1225 sync_metafile(&metafile, "clear.emf");
1226
1228 expect(Ok, stat);
1229
1231 expect(Ok, stat);
1232
1233 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
1234 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
1235 expect(Ok, stat);
1236
1238 expect(Ok, stat);
1239 expect(0xff000000, color);
1240
1241 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1242 expect(Ok, stat);
1243 expect(0xffffff00, color);
1244
1245 stat = GdipBitmapGetPixel(bitmap, 25, 25, &color);
1246 expect(Ok, stat);
1247 expect(0xff000000, color);
1248
1249 stat = GdipDeleteGraphics(graphics);
1250 expect(Ok, stat);
1251
1253 expect(Ok, stat);
1254
1256 expect(Ok, stat);
1257
1259 expect(Ok, stat);
1260
1261 check_emfplus(hemf, clear_emf_records, "clear emf");
1262
1263 DeleteEnhMetaFile(hemf);
1264}
1265
1266static void test_nullframerect(void) {
1267 GpStatus stat;
1269 GpGraphics *graphics;
1270 HDC hdc, metafile_dc;
1271 GpBrush *brush;
1272 HBRUSH hbrush, holdbrush;
1273 GpRectF bounds;
1274 GpUnit unit;
1275
1277
1279 expect(Ok, stat);
1280
1281 DeleteDC(hdc);
1282
1283 if (stat != Ok)
1284 return;
1285
1287 expect(Ok, stat);
1289 expectf(0.0, bounds.X);
1290 expectf(0.0, bounds.Y);
1291 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
1292 "expected 1.0, got %f\n", bounds.Width);
1293 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
1294 "expected 1.0, got %f\n", bounds.Height);
1295
1297 expect(Ok, stat);
1298
1299 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1300 expect(Ok, stat);
1301
1302 stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
1303 expect(Ok, stat);
1304
1305 stat = GdipDeleteBrush(brush);
1306 expect(Ok, stat);
1307
1309 expect(Ok, stat);
1311 expectf(0.0, bounds.X);
1312 expectf(0.0, bounds.Y);
1313 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
1314 "expected 1.0, got %f\n", bounds.Width);
1315 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
1316 "expected 1.0, got %f\n", bounds.Height);
1317
1318 stat = GdipDeleteGraphics(graphics);
1319 expect(Ok, stat);
1320
1322 expect(Ok, stat);
1324 expectf_(25.0, bounds.X, 0.05);
1325 expectf_(25.0, bounds.Y, 0.05);
1326 expectf_(75.0, bounds.Width, 0.05);
1327 expectf_(75.0, bounds.Height, 0.05);
1328
1330 expect(Ok, stat);
1331
1333
1335 expect(Ok, stat);
1336
1337 DeleteDC(hdc);
1338
1340 expect(Ok, stat);
1341
1342 stat = GdipGetDC(graphics, &metafile_dc);
1343 expect(Ok, stat);
1344
1345 if (stat != Ok)
1346 {
1347 GdipDeleteGraphics(graphics);
1349 return;
1350 }
1351
1352 hbrush = CreateSolidBrush(0xff0000);
1353
1354 holdbrush = SelectObject(metafile_dc, hbrush);
1355
1356 Rectangle(metafile_dc, 25, 25, 75, 75);
1357
1358 SelectObject(metafile_dc, holdbrush);
1359
1361
1362 stat = GdipReleaseDC(graphics, metafile_dc);
1363 expect(Ok, stat);
1364
1365 stat = GdipDeleteGraphics(graphics);
1366 expect(Ok, stat);
1367
1369 expect(Ok, stat);
1371 expectf_(25.0, bounds.X, 0.05);
1372 expectf_(25.0, bounds.Y, 0.05);
1373 todo_wine expectf_(50.0, bounds.Width, 0.05);
1374 todo_wine expectf_(50.0, bounds.Height, 0.05);
1375
1377 expect(Ok, stat);
1378
1380
1383 expect(Ok, stat);
1384
1385 DeleteDC(hdc);
1386
1388 expect(Ok, stat);
1389
1390 stat = GdipGetDC(graphics, &metafile_dc);
1391 expect(Ok, stat);
1392
1393 if (stat != Ok)
1394 {
1395 GdipDeleteGraphics(graphics);
1397 return;
1398 }
1399
1400 hbrush = CreateSolidBrush(0xff0000);
1401
1402 holdbrush = SelectObject(metafile_dc, hbrush);
1403
1404 Rectangle(metafile_dc, 25, 25, 75, 75);
1405
1406 SelectObject(metafile_dc, holdbrush);
1407
1409
1410 stat = GdipReleaseDC(graphics, metafile_dc);
1411 expect(Ok, stat);
1412
1413 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1414 expect(Ok, stat);
1415
1416 stat = GdipFillRectangleI(graphics, brush, 20, 40, 10, 70);
1417 expect(Ok, stat);
1418
1419 stat = GdipDeleteBrush(brush);
1420 expect(Ok, stat);
1421
1422 stat = GdipDeleteGraphics(graphics);
1423 expect(Ok, stat);
1424
1426 expect(Ok, stat);
1428 expectf_(20.0, bounds.X, 0.05);
1429 expectf_(25.0, bounds.Y, 0.05);
1430 expectf_(55.0, bounds.Width, 1.00);
1431 todo_wine expectf_(55.0, bounds.Width, 0.05);
1432 expectf_(85.0, bounds.Height, 0.05);
1433
1435 expect(Ok, stat);
1436}
1437
1439 { EMR_HEADER },
1441 { EmfPlusRecordTypeFillRects, 0xc000 },
1443 { EmfPlusRecordTypeFillRects, 0xc000 },
1445 { EmfPlusRecordTypeFillRects, 0xc000 },
1447 { EmfPlusRecordTypeFillRects, 0x8000 },
1449 { EmfPlusRecordTypeFillRects, 0xc000 },
1451 { EMR_EOF },
1452 { 0 }
1453};
1454
1455static void test_pagetransform(void)
1456{
1457 GpStatus stat;
1459 GpGraphics *graphics;
1460 HDC hdc;
1461 static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
1462 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1464 ARGB color;
1465 GpBrush *brush;
1466 GpUnit unit;
1467 REAL scale, dpix, dpiy;
1468 UINT width, height;
1469
1471
1473 expect(Ok, stat);
1474
1475 DeleteDC(hdc);
1476
1477 if (stat != Ok)
1478 return;
1479
1482
1485
1488
1491
1493 expect(Ok, stat);
1494
1495 /* initial scale */
1496 stat = GdipGetPageUnit(graphics, &unit);
1497 expect(Ok, stat);
1499
1500 stat = GdipGetPageScale(graphics, &scale);
1501 expect(Ok, stat);
1502 expectf(1.0, scale);
1503
1504 stat = GdipGetDpiX(graphics, &dpix);
1505 expect(Ok, stat);
1506 expectf(96.0, dpix);
1507
1508 stat = GdipGetDpiY(graphics, &dpiy);
1509 expect(Ok, stat);
1510 expectf(96.0, dpiy);
1511
1512 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1513 expect(Ok, stat);
1514
1515 stat = GdipFillRectangleI(graphics, brush, 1, 2, 1, 1);
1516 expect(Ok, stat);
1517
1518 stat = GdipDeleteBrush(brush);
1519 expect(Ok, stat);
1520
1521 /* page unit = pixels */
1522 stat = GdipSetPageUnit(graphics, UnitPixel);
1523 expect(Ok, stat);
1524
1525 stat = GdipGetPageUnit(graphics, &unit);
1526 expect(Ok, stat);
1528
1529 stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
1530 expect(Ok, stat);
1531
1532 stat = GdipFillRectangleI(graphics, brush, 0, 1, 1, 1);
1533 expect(Ok, stat);
1534
1535 stat = GdipDeleteBrush(brush);
1536 expect(Ok, stat);
1537
1538 /* page scale = 3, unit = pixels */
1539 stat = GdipSetPageScale(graphics, 3.0);
1540 expect(Ok, stat);
1541
1542 stat = GdipGetPageScale(graphics, &scale);
1543 expect(Ok, stat);
1544 expectf(3.0, scale);
1545
1546 stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
1547 expect(Ok, stat);
1548
1549 stat = GdipFillRectangleI(graphics, brush, 0, 1, 2, 2);
1550 expect(Ok, stat);
1551
1552 stat = GdipDeleteBrush(brush);
1553 expect(Ok, stat);
1554
1555 /* page scale = 3, unit = inches */
1556 stat = GdipSetPageUnit(graphics, UnitInch);
1557 expect(Ok, stat);
1558
1559 stat = GdipGetPageUnit(graphics, &unit);
1560 expect(Ok, stat);
1562
1563 stat = GdipCreateSolidFill((ARGB)0xffff0000, (GpSolidFill**)&brush);
1564 expect(Ok, stat);
1565
1566 stat = GdipFillRectangle(graphics, brush, 1.0/96.0, 0, 1, 1);
1567 expect(Ok, stat);
1568
1569 stat = GdipDeleteBrush(brush);
1570 expect(Ok, stat);
1571
1572 /* page scale = 3, unit = display */
1573 stat = GdipSetPageUnit(graphics, UnitDisplay);
1574 expect(Ok, stat);
1575
1576 stat = GdipGetPageUnit(graphics, &unit);
1577 expect(Ok, stat);
1579
1580 stat = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
1581 expect(Ok, stat);
1582
1583 stat = GdipFillRectangle(graphics, brush, 3, 3, 2, 2);
1584 expect(Ok, stat);
1585
1586 stat = GdipDeleteBrush(brush);
1587 expect(Ok, stat);
1588
1589 stat = GdipDeleteGraphics(graphics);
1590 expect(Ok, stat);
1591
1592 check_metafile(metafile, pagetransform_records, "pagetransform metafile", dst_points, &frame, UnitPixel);
1593
1594 sync_metafile(&metafile, "pagetransform.emf");
1595
1597 expect(Ok, stat);
1598
1600 expect(Ok, stat);
1601
1602 play_metafile(metafile, graphics, pagetransform_records, "pagetransform playback", dst_points, &frame, UnitPixel);
1603
1604 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1605 expect(Ok, stat);
1606 expect(0, color);
1607
1608 stat = GdipBitmapGetPixel(bitmap, 30, 50, &color);
1609 expect(Ok, stat);
1610 expect(0xff0000ff, color);
1611
1612 stat = GdipBitmapGetPixel(bitmap, 10, 30, &color);
1613 expect(Ok, stat);
1614 expect(0xff00ff00, color);
1615
1616 stat = GdipBitmapGetPixel(bitmap, 20, 80, &color);
1617 expect(Ok, stat);
1618 expect(0xff00ffff, color);
1619
1620 stat = GdipBitmapGetPixel(bitmap, 80, 20, &color);
1621 expect(Ok, stat);
1622 expect(0xffff0000, color);
1623
1624 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
1625 expect(Ok, stat);
1626 expect(0xffff00ff, color);
1627
1628 stat = GdipDeleteGraphics(graphics);
1629 expect(Ok, stat);
1630
1632 expect(Ok, stat);
1633
1635 expect(Ok, stat);
1636}
1637
1639 { EMR_HEADER },
1641 { EmfPlusRecordTypeFillRects, 0xc000 },
1643 { EmfPlusRecordTypeFillRects, 0x8000 },
1645 { EmfPlusRecordTypeFillRects, 0xc000 },
1647 { EmfPlusRecordTypeFillRects, 0x8000 },
1649 { EmfPlusRecordTypeFillRects, 0x8000 },
1651 { EmfPlusRecordTypeFillRects, 0xc000 },
1653 { EmfPlusRecordTypeFillRects, 0xc000 },
1655 { EMR_EOF },
1656 { 0 }
1657};
1658
1659static void test_worldtransform(void)
1660{
1661 GpStatus stat;
1663 GpGraphics *graphics;
1664 HDC hdc;
1665 static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
1666 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1668 ARGB color;
1669 GpBrush *brush;
1671 BOOL identity;
1672 REAL elements[6];
1673
1675
1677 expect(Ok, stat);
1678
1679 DeleteDC(hdc);
1680
1681 if (stat != Ok)
1682 return;
1683
1685 expect(Ok, stat);
1686
1688 expect(Ok, stat);
1689
1690 /* initial transform */
1692 expect(Ok, stat);
1693
1695 expect(Ok, stat);
1697
1698 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1699 expect(Ok, stat);
1700
1701 stat = GdipFillRectangleI(graphics, brush, 0, 0, 1, 1);
1702 expect(Ok, stat);
1703
1704 stat = GdipDeleteBrush(brush);
1705 expect(Ok, stat);
1706
1707 /* scale transform */
1708 stat = GdipScaleWorldTransform(graphics, 2.0, 4.0, MatrixOrderPrepend);
1709 expect(Ok, stat);
1710
1712 expect(Ok, stat);
1713
1715 expect(Ok, stat);
1716 expectf(2.0, elements[0]);
1717 expectf(0.0, elements[1]);
1718 expectf(0.0, elements[2]);
1719 expectf(4.0, elements[3]);
1720 expectf(0.0, elements[4]);
1721 expectf(0.0, elements[5]);
1722
1723 stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
1724 expect(Ok, stat);
1725
1726 stat = GdipFillRectangle(graphics, brush, 0.5, 0.5, 0.5, 0.25);
1727 expect(Ok, stat);
1728
1729 stat = GdipDeleteBrush(brush);
1730 expect(Ok, stat);
1731
1732 /* reset transform */
1733 stat = GdipResetWorldTransform(graphics);
1734 expect(Ok, stat);
1735
1737 expect(Ok, stat);
1738
1740 expect(Ok, stat);
1742
1743 stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
1744 expect(Ok, stat);
1745
1746 stat = GdipFillRectangle(graphics, brush, 1.0, 0.0, 1.0, 1.0);
1747 expect(Ok, stat);
1748
1749 stat = GdipDeleteBrush(brush);
1750 expect(Ok, stat);
1751
1752 /* multiply transform */
1753 stat = GdipSetMatrixElements(transform, 2.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1754 expect(Ok, stat);
1755
1757 expect(Ok, stat);
1758
1760 expect(Ok, stat);
1761
1763 expect(Ok, stat);
1764 expectf(2.0, elements[0]);
1765 expectf(0.0, elements[1]);
1766 expectf(0.0, elements[2]);
1767 expectf(1.0, elements[3]);
1768 expectf(0.0, elements[4]);
1769 expectf(0.0, elements[5]);
1770
1771 stat = GdipCreateSolidFill((ARGB)0xffff0000, (GpSolidFill**)&brush);
1772 expect(Ok, stat);
1773
1774 stat = GdipFillRectangle(graphics, brush, 1.0, 1.0, 0.5, 1.0);
1775 expect(Ok, stat);
1776
1777 stat = GdipDeleteBrush(brush);
1778 expect(Ok, stat);
1779
1780 /* rotate transform */
1782 expect(Ok, stat);
1783
1785 expect(Ok, stat);
1786
1788 expect(Ok, stat);
1789 expectf(0.0, elements[0]);
1790 expectf(2.0, elements[1]);
1791 expectf(-1.0, elements[2]);
1792 expectf(0.0, elements[3]);
1793 expectf(0.0, elements[4]);
1794 expectf(0.0, elements[5]);
1795
1796 stat = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
1797 expect(Ok, stat);
1798
1799 stat = GdipFillRectangle(graphics, brush, 1.0, -1.0, 0.5, 1.0);
1800 expect(Ok, stat);
1801
1802 stat = GdipDeleteBrush(brush);
1803 expect(Ok, stat);
1804
1805 /* set transform */
1806 stat = GdipSetMatrixElements(transform, 1.0, 0.0, 0.0, 3.0, 0.0, 0.0);
1807 expect(Ok, stat);
1808
1810 expect(Ok, stat);
1811
1813 expect(Ok, stat);
1814
1816 expect(Ok, stat);
1817 expectf(1.0, elements[0]);
1818 expectf(0.0, elements[1]);
1819 expectf(0.0, elements[2]);
1820 expectf(3.0, elements[3]);
1821 expectf(0.0, elements[4]);
1822 expectf(0.0, elements[5]);
1823
1824 stat = GdipCreateSolidFill((ARGB)0xffffff00, (GpSolidFill**)&brush);
1825 expect(Ok, stat);
1826
1827 stat = GdipFillRectangle(graphics, brush, 1.0, 1.0, 1.0, 1.0);
1828 expect(Ok, stat);
1829
1830 stat = GdipDeleteBrush(brush);
1831 expect(Ok, stat);
1832
1833 /* translate transform */
1834 stat = GdipTranslateWorldTransform(graphics, -1.0, 0.0, MatrixOrderAppend);
1835 expect(Ok, stat);
1836
1838 expect(Ok, stat);
1839
1841 expect(Ok, stat);
1842 expectf(1.0, elements[0]);
1843 expectf(0.0, elements[1]);
1844 expectf(0.0, elements[2]);
1845 expectf(3.0, elements[3]);
1846 expectf(-1.0, elements[4]);
1847 expectf(0.0, elements[5]);
1848
1849 stat = GdipCreateSolidFill((ARGB)0xffffffff, (GpSolidFill**)&brush);
1850 expect(Ok, stat);
1851
1852 stat = GdipFillRectangle(graphics, brush, 1.0, 1.0, 1.0, 1.0);
1853 expect(Ok, stat);
1854
1855 stat = GdipDeleteBrush(brush);
1856 expect(Ok, stat);
1857
1859 expect(Ok, stat);
1860
1861 stat = GdipDeleteGraphics(graphics);
1862 expect(Ok, stat);
1863
1864 check_metafile(metafile, worldtransform_records, "worldtransform metafile", dst_points, &frame, UnitPixel);
1865
1866 sync_metafile(&metafile, "worldtransform.emf");
1867
1869 expect(Ok, stat);
1870
1872 expect(Ok, stat);
1873
1874 play_metafile(metafile, graphics, worldtransform_records, "worldtransform playback", dst_points, &frame, UnitPixel);
1875
1876 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
1877 expect(Ok, stat);
1878 expect(0, color);
1879
1880 stat = GdipBitmapGetPixel(bitmap, 10, 10, &color);
1881 expect(Ok, stat);
1882 expect(0xff0000ff, color);
1883
1884 stat = GdipBitmapGetPixel(bitmap, 30, 50, &color);
1885 expect(Ok, stat);
1886 expect(0xff00ff00, color);
1887
1888 stat = GdipBitmapGetPixel(bitmap, 30, 10, &color);
1889 expect(Ok, stat);
1890 expect(0xff00ffff, color);
1891
1892 stat = GdipBitmapGetPixel(bitmap, 50, 30, &color);
1893 expect(Ok, stat);
1894 expect(0xffff0000, color);
1895
1896 stat = GdipBitmapGetPixel(bitmap, 10, 50, &color);
1897 expect(Ok, stat);
1898 expect(0xffff00ff, color);
1899
1900 stat = GdipBitmapGetPixel(bitmap, 30, 90, &color);
1901 expect(Ok, stat);
1902 expect(0xffffff00, color);
1903
1904 stat = GdipBitmapGetPixel(bitmap, 10, 90, &color);
1905 expect(Ok, stat);
1906 expect(0xffffffff, color);
1907
1908 stat = GdipDeleteGraphics(graphics);
1909 expect(Ok, stat);
1910
1912 expect(Ok, stat);
1913
1915 expect(Ok, stat);
1916}
1917
1918static void test_converttoemfplus(void)
1919{
1920 GpStatus (WINAPI *pGdipConvertToEmfPlus)( const GpGraphics *graphics, GpMetafile *metafile, BOOL *succ,
1921 EmfType emfType, const WCHAR *description, GpMetafile **outmetafile);
1922 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1923 GpStatus stat;
1924 GpMetafile *metafile, *metafile2 = NULL, *emhmeta;
1925 GpGraphics *graphics;
1926 HDC hdc;
1927 BOOL succ;
1928 HMODULE mod = GetModuleHandleA("gdiplus.dll");
1929
1930 pGdipConvertToEmfPlus = (void*)GetProcAddress( mod, "GdipConvertToEmfPlus");
1931 if(!pGdipConvertToEmfPlus)
1932 {
1933 /* GdipConvertToEmfPlus was introduced in Windows Vista. */
1934 win_skip("GDIPlus version 1.1 not available\n");
1935 return;
1936 }
1937
1939
1941 expect(Ok, stat);
1942
1944 expect(Ok, stat);
1945
1946 DeleteDC(hdc);
1947
1948 if (stat != Ok)
1949 return;
1950
1952 expect(Ok, stat);
1953
1954 /* Invalid Parameters */
1955 stat = pGdipConvertToEmfPlus(NULL, metafile, &succ, EmfTypeEmfPlusOnly, description, &metafile2);
1957
1958 stat = pGdipConvertToEmfPlus(graphics, NULL, &succ, EmfTypeEmfPlusOnly, description, &metafile2);
1960
1961 stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, description, NULL);
1963
1964 stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, 0, NULL, &metafile2);
1966
1967 stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, EmfTypeEmfPlusDual+1, NULL, &metafile2);
1969
1970 /* If we are already an Enhanced Metafile then the conversion fails. */
1971 stat = pGdipConvertToEmfPlus(graphics, emhmeta, NULL, EmfTypeEmfPlusOnly, NULL, &metafile2);
1973
1974 stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, EmfTypeEmfPlusOnly, NULL, &metafile2);
1976 if(metafile2)
1977 GdipDisposeImage((GpImage*)metafile2);
1978
1979 succ = FALSE;
1980 stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, NULL, &metafile2);
1982 if(metafile2)
1983 GdipDisposeImage((GpImage*)metafile2);
1984
1985 stat = GdipDeleteGraphics(graphics);
1986 expect(Ok, stat);
1987
1989 expect(Ok, stat);
1990
1991 stat = GdipDisposeImage((GpImage*)emhmeta);
1992 expect(Ok, stat);
1993}
1994
1995static void test_frameunit(void)
1996{
1997 GpStatus stat;
1999 GpGraphics *graphics;
2000 HDC hdc;
2001 static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
2002 GpUnit unit;
2003 REAL dpix, dpiy;
2004 GpRectF bounds;
2005
2007
2009 expect(Ok, stat);
2010
2011 DeleteDC(hdc);
2012
2013 if (stat != Ok)
2014 return;
2015
2017 expect(Ok, stat);
2019 expectf(0.0, bounds.X);
2020 expectf(0.0, bounds.Y);
2021 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
2022 "expected 1.0, got %f\n", bounds.Width);
2023 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
2024 "expected 1.0, got %f\n", bounds.Height);
2025
2027 expect(Ok, stat);
2028
2030 expect(Ok, stat);
2032 expectf(0.0, bounds.X);
2033 expectf(0.0, bounds.Y);
2034 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
2035 "expected 1.0, got %f\n", bounds.Width);
2036 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
2037 "expected 1.0, got %f\n", bounds.Height);
2038
2039 stat = GdipDeleteGraphics(graphics);
2040 expect(Ok, stat);
2041
2043 expect(Ok, stat);
2044
2046 expect(Ok, stat);
2047
2049 expect(Ok, stat);
2051 expectf(0.0, bounds.X);
2052 expectf(0.0, bounds.Y);
2053 expectf_(5.0 * dpix, bounds.Width, 1.0);
2054 expectf_(5.0 * dpiy, bounds.Height, 1.0);
2055
2057 expect(Ok, stat);
2058}
2059
2061 { EMR_HEADER },
2065 { EmfPlusRecordTypeFillRects, 0xc000 },
2068 { EmfPlusRecordTypeFillRects, 0xc000 },
2076 { EmfPlusRecordTypeFillRects, 0xc000 },
2078 { EmfPlusRecordTypeFillRects, 0xc000 },
2082 { EMR_EOF },
2083 { 0 }
2084};
2085
2086static void test_containers(void)
2087{
2088 GpStatus stat;
2090 GpGraphics *graphics;
2092 GpBrush *brush;
2093 ARGB color;
2094 HDC hdc;
2095 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2096 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
2097 GraphicsContainer state1, state2;
2098 GpRectF srcrect, dstrect;
2099 REAL dpix, dpiy;
2100
2102
2104 expect(Ok, stat);
2105
2106 DeleteDC(hdc);
2107
2108 if (stat != Ok)
2109 return;
2110
2112 expect(Ok, stat);
2113
2114 /* Normal usage */
2115 stat = GdipBeginContainer2(graphics, &state1);
2116 expect(Ok, stat);
2117
2118 stat = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
2119 expect(Ok, stat);
2120
2121 stat = GdipCreateSolidFill((ARGB)0xff000000, (GpSolidFill**)&brush);
2122 expect(Ok, stat);
2123
2124 stat = GdipFillRectangle(graphics, brush, 5.0, 5.0, 5.0, 5.0);
2125 expect(Ok, stat);
2126
2127 stat = GdipDeleteBrush(brush);
2128 expect(Ok, stat);
2129
2130 stat = GdipEndContainer(graphics, state1);
2131 expect(Ok, stat);
2132
2133 stat = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
2134 expect(Ok, stat);
2135
2136 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
2137 expect(Ok, stat);
2138
2139 stat = GdipFillRectangle(graphics, brush, 5.0, 5.0, 5.0, 5.0);
2140 expect(Ok, stat);
2141
2142 stat = GdipDeleteBrush(brush);
2143 expect(Ok, stat);
2144
2145 stat = GdipSaveGraphics(graphics, &state1);
2146 expect(Ok, stat);
2147
2148 stat = GdipRestoreGraphics(graphics, state1);
2149 expect(Ok, stat);
2150
2151 /* Popping two states at once */
2152 stat = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
2153 expect(Ok, stat);
2154
2155 stat = GdipBeginContainer2(graphics, &state1);
2156 expect(Ok, stat);
2157
2158 stat = GdipScaleWorldTransform(graphics, 4.0, 4.0, MatrixOrderPrepend);
2159 expect(Ok, stat);
2160
2161 stat = GdipBeginContainer2(graphics, &state2);
2162 expect(Ok, stat);
2163
2164 stat = GdipEndContainer(graphics, state1);
2165 expect(Ok, stat);
2166
2167 stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
2168 expect(Ok, stat);
2169
2170 stat = GdipFillRectangle(graphics, brush, 20.0, 20.0, 5.0, 5.0);
2171 expect(Ok, stat);
2172
2173 stat = GdipDeleteBrush(brush);
2174 expect(Ok, stat);
2175
2176 /* With transform applied */
2177 stat = GdipGetDpiX(graphics, &dpix);
2178 expect(Ok, stat);
2179
2180 stat = GdipGetDpiY(graphics, &dpiy);
2181 expect(Ok, stat);
2182
2183 srcrect.X = 0.0;
2184 srcrect.Y = 0.0;
2185 srcrect.Width = 1.0;
2186 srcrect.Height = 1.0;
2187
2188 dstrect.X = 25.0;
2189 dstrect.Y = 0.0;
2190 dstrect.Width = 5.0;
2191 dstrect.Height = 5.0;
2192
2193 stat = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state1);
2194 expect(Ok, stat);
2195
2196 stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
2197 expect(Ok, stat);
2198
2199 stat = GdipFillRectangle(graphics, brush, 0.0, 0.0, dpix, dpiy);
2200 expect(Ok, stat);
2201
2202 stat = GdipDeleteBrush(brush);
2203 expect(Ok, stat);
2204
2205 stat = GdipEndContainer(graphics, state1);
2206 expect(Ok, stat);
2207
2208 /* Restoring an invalid state seems to break the graphics object? */
2209 if (0) {
2210 stat = GdipEndContainer(graphics, state1);
2211 expect(Ok, stat);
2212 }
2213
2214 /* Ending metafile with a state open */
2215 stat = GdipBeginContainer2(graphics, &state1);
2216 expect(Ok, stat);
2217
2218 stat = GdipDeleteGraphics(graphics);
2219 expect(Ok, stat);
2220
2221 check_metafile(metafile, container_records, "container metafile", dst_points, &frame, UnitPixel);
2222
2223 sync_metafile(&metafile, "container.emf");
2224
2226 expect(Ok, stat);
2227
2229 expect(Ok, stat);
2230
2231 play_metafile(metafile, graphics, container_records, "container playback", dst_points, &frame, UnitPixel);
2232
2233 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
2234 expect(Ok, stat);
2235 expect(0, color);
2236
2237 stat = GdipBitmapGetPixel(bitmap, 12, 12, &color);
2238 expect(Ok, stat);
2239 expect(0xff000000, color);
2240
2242 expect(Ok, stat);
2243 expect(0xff0000ff, color);
2244
2245 stat = GdipBitmapGetPixel(bitmap, 42, 42, &color);
2246 expect(Ok, stat);
2247 expect(0xff00ff00, color);
2248
2249 stat = GdipBitmapGetPixel(bitmap, 55, 5, &color);
2250 expect(Ok, stat);
2251 expect(0xff00ffff, color);
2252
2253 stat = GdipDeleteGraphics(graphics);
2254 expect(Ok, stat);
2255
2257 expect(Ok, stat);
2258
2260 expect(Ok, stat);
2261}
2262
2264 { EMR_HEADER },
2268 { EmfPlusRecordTypeFillRects, 0xc000 },
2271 { EmfPlusRecordTypeFillRects, 0xc000 },
2275 { EMR_EOF },
2276 { 0 }
2277};
2278
2279static void test_clipping(void)
2280{
2281 GpStatus stat;
2283 GpGraphics *graphics;
2285 GpRegion *region;
2286 GpBrush *brush;
2287 GpRectF rect;
2288 ARGB color;
2289 HDC hdc;
2290 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2291 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
2293
2295
2297 expect(Ok, stat);
2298
2299 DeleteDC(hdc);
2300
2301 if (stat != Ok)
2302 return;
2303
2305 expect(Ok, stat);
2306
2307 stat = GdipSaveGraphics(graphics, &state);
2308 expect(Ok, stat);
2309
2310 stat = GdipGetVisibleClipBounds(graphics, &rect);
2311 expect(Ok, stat);
2312 ok(rect.X == -0x400000, "rect.X = %f\n", rect.X);
2313 ok(rect.Y == -0x400000, "rect.Y = %f\n", rect.Y);
2314 ok(rect.Width == 0x800000, "rect.Width = %f\n", rect.Width);
2315 ok(rect.Height == 0x800000, "rect.Height = %f\n", rect.Height);
2316
2317 stat = GdipSetClipRect(graphics, 30, 30, 10, 10, CombineModeReplace);
2318 expect(Ok, stat);
2319
2320 stat = GdipGetVisibleClipBounds(graphics, &rect);
2321 expect(Ok, stat);
2322 ok(rect.X == 30, "rect.X = %f\n", rect.X);
2323 ok(rect.Y == 30, "rect.Y = %f\n", rect.Y);
2324 ok(rect.Width == 10, "rect.Width = %f\n", rect.Width);
2325 ok(rect.Height == 10, "rect.Height = %f\n", rect.Height);
2326
2327 stat = GdipCreateSolidFill((ARGB)0xff000000, (GpSolidFill**)&brush);
2328 expect(Ok, stat);
2329
2330 stat = GdipFillRectangle(graphics, brush, 0, 0, 100, 100);
2331 expect(Ok, stat);
2332
2333 stat = GdipDeleteBrush(brush);
2334 expect(Ok, stat);
2335
2336 stat = GdipRestoreGraphics(graphics, state);
2337 expect(Ok, stat);
2338
2339 stat = GdipSetClipRect(graphics, 30, 30, 10, 10, CombineModeXor);
2340 expect(Ok, stat);
2341
2342 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
2343 expect(Ok, stat);
2344
2345 stat = GdipFillRectangle(graphics, brush, 30, 30, 20, 10);
2346 expect(Ok, stat);
2347
2348 stat = GdipDeleteBrush(brush);
2349 expect(Ok, stat);
2350
2351 stat = GdipCreateRegionRect(&rect, &region);
2352 expect(Ok, stat);
2353
2354 stat = GdipSetClipRegion(graphics, region, CombineModeIntersect);
2355 expect(Ok, stat);
2356
2357 stat = GdipDeleteRegion(region);
2358 expect(Ok, stat);
2359
2360 stat = GdipDeleteGraphics(graphics);
2361 expect(Ok, stat);
2362
2363 check_metafile(metafile, clipping_records, "clipping metafile", dst_points, &frame, UnitPixel);
2364
2365 sync_metafile(&metafile, "clipping.emf");
2366
2368 expect(Ok, stat);
2369
2371 expect(Ok, stat);
2372
2373 play_metafile(metafile, graphics, clipping_records, "clipping playback", dst_points, &frame, UnitPixel);
2374
2375 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
2376 expect(Ok, stat);
2377 expect(0, color);
2378
2379 stat = GdipBitmapGetPixel(bitmap, 35, 35, &color);
2380 expect(Ok, stat);
2381 expect(0xff000000, color);
2382
2383 stat = GdipBitmapGetPixel(bitmap, 45, 35, &color);
2384 expect(Ok, stat);
2385 expect(0xff0000ff, color);
2386
2387 stat = GdipDeleteGraphics(graphics);
2388 expect(Ok, stat);
2389
2391 expect(Ok, stat);
2392
2394 expect(Ok, stat);
2395}
2396
2398 unsigned int flags, unsigned int dataSize, const unsigned char *pStr)
2399{
2400 static const XFORM xform = {0.5, 0, 0, 0.5, 0, 0};
2401 static const RECTL rectangle = {0,0,100,100};
2402 GpStatus stat;
2403
2404 stat = GdipPlayMetafileRecord(metafile, EMR_SETWORLDTRANSFORM, 0, sizeof(xform), (void*)&xform);
2405 expect(Ok, stat);
2406
2407 stat = GdipPlayMetafileRecord(metafile, EMR_RECTANGLE, 0, sizeof(rectangle), (void*)&rectangle);
2408 expect(Ok, stat);
2409}
2410
2412 { EMR_HEADER },
2414 { EMR_SELECTOBJECT },
2416 { EMR_SELECTOBJECT },
2417 { EMR_DELETEOBJECT },
2418 { EMR_EOF },
2419 { 0 }
2420};
2421
2422static void test_gditransform(void)
2423{
2424 GpStatus stat;
2426 GpGraphics *graphics;
2427 HDC hdc, metafile_dc;
2428 HENHMETAFILE hemf;
2430 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2431 static const GpPointF dst_points[3] = {{0.0,0.0},{40.0,0.0},{0.0,40.0}};
2432 HBRUSH hbrush, holdbrush;
2434 ARGB color;
2435
2437
2439 expect(Ok, stat);
2440
2441 DeleteDC(hdc);
2442
2443 if (stat != Ok)
2444 return;
2445
2448
2449 memset(&header, 0xaa, sizeof(header));
2451 expect(Ok, stat);
2453 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
2454
2456 expect(Ok, stat);
2457
2458 stat = GdipGetDC(graphics, &metafile_dc);
2459 expect(Ok, stat);
2460
2461 if (stat != Ok)
2462 {
2463 GdipDeleteGraphics(graphics);
2465 return;
2466 }
2467
2468 hbrush = CreateSolidBrush(0xff);
2469
2470 holdbrush = SelectObject(metafile_dc, hbrush);
2471
2472 GdiComment(metafile_dc, 8, (const BYTE*)"winetest");
2473
2474 SelectObject(metafile_dc, holdbrush);
2475
2477
2478 stat = GdipReleaseDC(graphics, metafile_dc);
2479 expect(Ok, stat);
2480
2481 stat = GdipDeleteGraphics(graphics);
2482 expect(Ok, stat);
2483
2484 check_metafile(metafile, gditransform_records, "gditransform metafile", dst_points, &frame, UnitPixel);
2485
2486 sync_metafile(&metafile, "gditransform.emf");
2487
2489 expect(Ok, stat);
2490
2492 expect(Ok, stat);
2493
2494 play_metafile(metafile, graphics, gditransform_records, "gditransform playback", dst_points, &frame, UnitPixel);
2495
2496 stat = GdipBitmapGetPixel(bitmap, 10, 10, &color);
2497 expect(Ok, stat);
2498 expect(0xffff0000, color);
2499
2500 stat = GdipBitmapGetPixel(bitmap, 30, 30, &color);
2501 expect(Ok, stat);
2502 expect(0x00000000, color);
2503
2504 stat = GdipDeleteGraphics(graphics);
2505 expect(Ok, stat);
2506
2508 expect(Ok, stat);
2509
2511 expect(Ok, stat);
2512}
2513
2515 { EMR_HEADER },
2519 { EmfPlusRecordTypeDrawImagePoints, 0, 0, 0, NULL, 0x4000 },
2520 { EMR_SAVEDC, 0, 1 },
2521 { EMR_SETICMMODE, 0, 1 },
2522 { EMR_BITBLT, 0, 1 },
2523 { EMR_RESTOREDC, 0, 1 },
2525 { EMR_EOF },
2526 { 0 }
2527};
2528
2530 { EMR_HEADER },
2533 /* metafile object */
2534 { EMR_HEADER },
2539 { EMR_SAVEDC, 0, 1 },
2540 { EMR_SETICMMODE, 0, 1 },
2541 { EMR_BITBLT, 0, 1 },
2542 { EMR_RESTOREDC, 0, 1 },
2544 { EMR_EOF },
2545 /* end of metafile object */
2547 { EMR_SAVEDC, 0, 1 },
2548 { EMR_SETICMMODE, 0, 1 },
2549 { EMR_BITBLT, 0, 1 },
2550 { EMR_RESTOREDC, 0, 1 },
2552 { EMR_EOF },
2553 { 0 }
2554};
2555
2556static void test_drawimage(void)
2557{
2558 static const GpPointF dst_points[3] = {{10.0,10.0},{85.0,15.0},{10.0,80.0}};
2559 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2560 const ColorMatrix double_red = {{
2561 {2.0,0.0,0.0,0.0,0.0},
2562 {0.0,1.0,0.0,0.0,0.0},
2563 {0.0,0.0,1.0,0.0,0.0},
2564 {0.0,0.0,0.0,1.0,0.0},
2565 {0.0,0.0,0.0,0.0,1.0}}};
2566
2567 GpImageAttributes *imageattr;
2569 GpGraphics *graphics;
2570 HENHMETAFILE hemf;
2571 GpStatus stat;
2573 BYTE buff[400];
2574 GpImage *image;
2575 HDC hdc;
2576
2579 expect(Ok, stat);
2580
2582 expect(Ok, stat);
2583
2584 memset(&info, 0, sizeof(info));
2585 info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2586 info.bmiHeader.biWidth = 10;
2587 info.bmiHeader.biHeight = 10;
2588 info.bmiHeader.biPlanes = 1;
2589 info.bmiHeader.biBitCount = 32;
2590 info.bmiHeader.biCompression = BI_RGB;
2591 memset(buff, 0x80, sizeof(buff));
2593 expect(Ok, stat);
2594
2595 stat = GdipCreateImageAttributes(&imageattr);
2596 expect(Ok, stat);
2597
2599 TRUE, &double_red, NULL, ColorMatrixFlagsDefault);
2600 expect(Ok, stat);
2601
2602 stat = GdipDrawImagePointsRect(graphics, image, dst_points, 3,
2603 0.0, 0.0, 10.0, 10.0, UnitPixel, imageattr, NULL, NULL);
2604 GdipDisposeImageAttributes(imageattr);
2605 expect(Ok, stat);
2606
2608
2609 stat = GdipDeleteGraphics(graphics);
2610 expect(Ok, stat);
2611 sync_metafile(&metafile, "draw_image_bitmap.emf");
2612
2614 expect(Ok, stat);
2615
2616 check_emfplus(hemf, draw_image_bitmap_records, "draw image bitmap");
2617
2619 expect(Ok, stat);
2620
2621 /* test drawing metafile */
2623 expect(Ok, stat);
2624
2626 expect(Ok, stat);
2627
2629 expect(Ok, stat);
2630
2631 stat = GdipDrawImagePointsRect(graphics, image, dst_points, 3,
2632 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
2633 expect(Ok, stat);
2634
2636
2637 stat = GdipDeleteGraphics(graphics);
2638 expect(Ok, stat);
2639 sync_metafile(&metafile, "draw_image_metafile.emf");
2640
2642 expect(Ok, stat);
2643
2644 if (GetProcAddress(GetModuleHandleA("gdiplus.dll"), "GdipConvertToEmfPlus"))
2645 {
2646 check_emfplus(hemf, draw_image_metafile_records, "draw image metafile");
2647 }
2648 else
2649 {
2650 win_skip("draw image metafile records tests skipped\n");
2651 }
2652 DeleteEnhMetaFile(hemf);
2653
2654 DeleteDC(hdc);
2656 expect(Ok, stat);
2657}
2658
2660 { EMR_HEADER },
2671 { EMR_EOF },
2672 { 0 }
2673};
2674
2675static void test_properties(void)
2676{
2677 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2678
2680 GpGraphics *graphics;
2681 HENHMETAFILE hemf;
2682 GpStatus stat;
2683 HDC hdc;
2684
2687 expect(Ok, stat);
2688 DeleteDC(hdc);
2689
2691 expect(Ok, stat);
2692
2694 expect(Ok, stat);
2696 expect(Ok, stat);
2697
2699 expect(Ok, stat);
2701 expect(Ok, stat);
2702
2704 expect(Ok, stat);
2706 expect(Ok, stat);
2707
2709 expect(Ok, stat);
2711 expect(Ok, stat);
2712
2714 expect(Ok, stat);
2716 expect(Ok, stat);
2717
2719 expect(Ok, stat);
2721 expect(Ok, stat);
2722
2723 stat = GdipSetRenderingOrigin(graphics, 1, 2);
2724 expect(Ok, stat);
2725
2726 stat = GdipSetRenderingOrigin(graphics, 1, 2);
2727 expect(Ok, stat);
2728
2729 stat = GdipSetRenderingOrigin(graphics, 2, 1);
2730 expect(Ok, stat);
2731
2732 stat = GdipDeleteGraphics(graphics);
2733 expect(Ok, stat);
2734 sync_metafile(&metafile, "properties.emf");
2735
2737 expect(Ok, stat);
2738
2739 check_emfplus(hemf, properties_records, "properties");
2740 DeleteEnhMetaFile(hemf);
2741
2743 expect(Ok, stat);
2744}
2745
2747 { EMR_HEADER },
2752 { EMR_SAVEDC, 0, 1 },
2753 { EMR_SETICMMODE, 0, 1 },
2754 { EMR_BITBLT, 0, 1 },
2755 { EMR_RESTOREDC, 0, 1 },
2757 { EMR_EOF },
2758 { 0 }
2759};
2760
2761static void test_drawpath(void)
2762{
2763 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2764
2766 GpGraphics *graphics;
2767 HENHMETAFILE hemf;
2768 GpStatus stat;
2769 GpPath *path;
2770 GpPen *pen;
2771 HDC hdc;
2772
2775 expect(Ok, stat);
2776 DeleteDC(hdc);
2777
2779 expect(Ok, stat);
2780
2782 expect(Ok, stat);
2783 stat = GdipAddPathLine(path, 5, 5, 30, 30);
2784 expect(Ok, stat);
2785
2786 stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
2787 expect(Ok, stat);
2788
2789 stat = GdipDrawPath(graphics, pen, path);
2790 expect(Ok, stat);
2791
2792 stat = GdipDeletePen(pen);
2793 expect(Ok, stat);
2795 expect(Ok, stat);
2796
2797 stat = GdipDeleteGraphics(graphics);
2798 expect(Ok, stat);
2799 sync_metafile(&metafile, "draw_path.emf");
2800
2802 expect(Ok, stat);
2803
2804 check_emfplus(hemf, draw_path_records, "draw path");
2805 DeleteEnhMetaFile(hemf);
2806
2808 expect(Ok, stat);
2809}
2810
2812 { EMR_HEADER },
2815 { EmfPlusRecordTypeFillPath, 0x8000 },
2816 { EMR_SAVEDC, 0, 1 },
2817 { EMR_SETICMMODE, 0, 1 },
2818 { EMR_BITBLT, 0, 1 },
2819 { EMR_RESTOREDC, 0, 1 },
2821 { EMR_EOF },
2822 { 0 }
2823};
2824
2825static void test_fillpath(void)
2826{
2827 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2828
2830 GpGraphics *graphics;
2831 GpSolidFill *brush;
2832 HENHMETAFILE hemf;
2833 GpStatus stat;
2834 GpPath *path;
2835 HDC hdc;
2836
2839 expect(Ok, stat);
2840 DeleteDC(hdc);
2841
2843 expect(Ok, stat);
2844
2846 expect(Ok, stat);
2847 stat = GdipAddPathLine(path, 5, 5, 30, 30);
2848 expect(Ok, stat);
2849 stat = GdipAddPathLine(path, 30, 30, 5, 30);
2850 expect(Ok, stat);
2851
2852 stat = GdipCreateSolidFill(0xffaabbcc, &brush);
2853 expect(Ok, stat);
2854
2855 stat = GdipFillPath(graphics, (GpBrush*)brush, path);
2856 expect(Ok, stat);
2857
2858 stat = GdipDeleteBrush((GpBrush*)brush);
2859 expect(Ok, stat);
2861 expect(Ok, stat);
2862
2863 stat = GdipDeleteGraphics(graphics);
2864 expect(Ok, stat);
2865 sync_metafile(&metafile, "fill_path.emf");
2866
2868 expect(Ok, stat);
2869
2870 check_emfplus(hemf, fill_path_records, "fill path");
2871
2872 /* write to disk */
2873 DeleteEnhMetaFile(CopyEnhMetaFileW(hemf, L"winetest.emf"));
2874
2875 DeleteEnhMetaFile(hemf);
2876
2878 expect(Ok, stat);
2879
2880 /* should succeed when given path to an EMF */
2881 stat = GdipCreateMetafileFromWmfFile(L"winetest.emf", NULL, &metafile);
2882 expect(Ok, stat);
2883
2885 expect(Ok, stat);
2886
2887 DeleteFileW(L"winetest.emf");
2888
2889 stat = GdipCreateMetafileFromWmfFile(L"winetest.emf", NULL, &metafile);
2891}
2892
2894 { EMR_HEADER },
2896 { EMR_SELECTOBJECT },
2897
2898 { EMR_SAVEDC },
2900 { EMR_SAVEDC },
2902 { EMR_SAVEDC },
2904
2905 { EMR_RECTANGLE },
2906
2907 { EMR_RESTOREDC },
2908 { EMR_RECTANGLE },
2909
2910 { EMR_RESTOREDC },
2911 { EMR_RECTANGLE },
2912
2913 { EMR_SELECTOBJECT },
2914 { EMR_DELETEOBJECT },
2915 { EMR_EOF },
2916 { 0 }
2917};
2918
2919static void test_restoredc(void)
2920{
2921 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
2922 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2923
2925 GpGraphics *graphics;
2927 GpStatus stat;
2928 HDC hdc, metafile_dc;
2929 HBRUSH hbrush, holdbrush;
2930 ARGB color;
2931
2933
2935 L"winetest", &metafile);
2936 expect(Ok, stat);
2937
2938 DeleteDC(hdc);
2939
2941 expect(Ok, stat);
2942
2943 stat = GdipGetDC(graphics, &metafile_dc);
2944 expect(Ok, stat);
2945
2946 hbrush = CreateSolidBrush(0xff0000);
2947 holdbrush = SelectObject(metafile_dc, hbrush);
2948
2949 SaveDC(metafile_dc);
2950 SetViewportOrgEx(metafile_dc, 20, 20, NULL);
2951
2952 SaveDC(metafile_dc);
2953 SetViewportOrgEx(metafile_dc, 40, 40, NULL);
2954
2955 SaveDC(metafile_dc);
2956 SetViewportOrgEx(metafile_dc, 60, 60, NULL);
2957
2958 Rectangle(metafile_dc, 0, 0, 3, 3);
2959 RestoreDC(metafile_dc, -2);
2960
2961 Rectangle(metafile_dc, 0, 0, 3, 3);
2962 RestoreDC(metafile_dc, -1);
2963
2964 Rectangle(metafile_dc, 0, 0, 3, 3);
2965
2966 SelectObject(metafile_dc, holdbrush);
2968
2969 stat = GdipReleaseDC(graphics, metafile_dc);
2970 expect(Ok, stat);
2971
2972 stat = GdipDeleteGraphics(graphics);
2973 expect(Ok, stat);
2974
2975 check_metafile(metafile, restoredc_records, "restoredc metafile", dst_points,
2976 &frame, UnitPixel);
2977 sync_metafile(&metafile, "restoredc.emf");
2978
2980 expect(Ok, stat);
2981
2983 expect(Ok, stat);
2984
2985 play_metafile(metafile, graphics, restoredc_records, "restoredc playback", dst_points,
2986 &frame, UnitPixel);
2987
2989 expect(Ok, stat);
2990 expect(0xff0000ff, color);
2991
2992 stat = GdipBitmapGetPixel(bitmap, 21, 21, &color);
2993 expect(Ok, stat);
2994 expect(0xff0000ff, color);
2995
2996 stat = GdipBitmapGetPixel(bitmap, 41, 41, &color);
2997 expect(Ok, stat);
2998 expect(0, color);
2999
3000 stat = GdipBitmapGetPixel(bitmap, 61, 61, &color);
3001 expect(Ok, stat);
3002 expect(0xff0000ff, color);
3003
3004 stat = GdipDeleteGraphics(graphics);
3005 expect(Ok, stat);
3006
3008 expect(Ok, stat);
3009
3011 expect(Ok, stat);
3012}
3013
3015 { EMR_HEADER },
3023 { EMR_EOF },
3024 { 0 }
3025};
3026
3027static void test_drawdriverstring(void)
3028{
3029 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
3030 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
3031 static const PointF solidpos[4] = {{10.0,10.0}, {20.0,10.0}, {30.0,10.0}, {40.0,10.0}};
3032 static const PointF hatchpos = {10.0,30.0};
3033
3035 GpStatus stat;
3036 GpGraphics *graphics;
3037 GpFont *solidfont, *hatchfont;
3038 GpBrush *solidbrush, *hatchbrush;
3039 HDC hdc;
3042 LOGFONTA logfont = { 0 };
3043
3045
3046 strcpy(logfont.lfFaceName, "Times New Roman");
3047 logfont.lfHeight = 12;
3048 logfont.lfCharSet = DEFAULT_CHARSET;
3049
3050 stat = GdipCreateFontFromLogfontA(hdc, &logfont, &solidfont);
3052 {
3053 DeleteDC(hdc);
3054 skip("Times New Roman not installed.\n");
3055 return;
3056 }
3057
3058 stat = GdipCloneFont(solidfont, &hatchfont);
3059 expect(Ok, stat);
3060
3062 L"winetest", &metafile);
3063 expect(Ok, stat);
3064
3065 DeleteDC(hdc);
3066 hdc = NULL;
3067
3069 expect(Ok, stat);
3070
3071 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&solidbrush);
3072 expect(Ok, stat);
3073
3074 stat = GdipCreateHatchBrush(HatchStyleHorizontal, (ARGB)0xff00ff00, (ARGB)0xffff0000,
3075 (GpHatch**)&hatchbrush);
3076 expect(Ok, stat);
3077
3079 expect(Ok, stat);
3080
3081 stat = GdipDrawDriverString(graphics, L"Test", 4, solidfont, solidbrush, solidpos,
3083 expect(Ok, stat);
3084
3085 stat = GdipSetMatrixElements(matrix, 1.5, 0.0, 0.0, 1.5, 0.0, 0.0);
3086 expect(Ok, stat);
3087
3088 stat = GdipDrawDriverString(graphics, L"Test ", 5, hatchfont, hatchbrush, &hatchpos,
3090 expect(Ok, stat);
3091
3092 stat = GdipDeleteGraphics(graphics);
3093 graphics = NULL;
3094
3095 check_metafile(metafile, drawdriverstring_records, "drawdriverstring metafile", dst_points,
3096 &frame, UnitPixel);
3097 sync_metafile(&metafile, "drawdriverstring.emf");
3098
3100 expect(Ok, stat);
3101
3103 expect(Ok, stat);
3104
3105 play_metafile(metafile, graphics, drawdriverstring_records, "drawdriverstring playback",
3106 dst_points, &frame, UnitPixel);
3107
3109 GdipDeleteGraphics(graphics);
3110 GdipDeleteBrush(solidbrush);
3111 GdipDeleteBrush(hatchbrush);
3112 GdipDeleteFont(solidfont);
3113 GdipDeleteFont(hatchfont);
3116}
3117
3119 { EMR_HEADER },
3124 { EMR_EOF },
3125 { 0 }
3126};
3127
3128static void test_unknownfontdecode(void)
3129{
3130 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
3131 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
3132 static const PointF pos = {10.0,30.0};
3133 static const INT testfont0_resnum = 2;
3134
3135 BOOL rval;
3136 DWORD written, ressize;
3138 GpBrush *brush;
3139 GpFont *font;
3140 GpFontCollection *fonts;
3141 GpFontFamily *family;
3142 GpGraphics *graphics;
3144 GpStatus stat;
3145 HANDLE file;
3146 HDC hdc;
3147 HRSRC res;
3148 INT fontscount;
3150 void *buf;
3151
3152 /* Create a custom font from a resource. */
3154 lstrcatW(path, L"wine_testfont0.ttf");
3155
3157 ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %ld\n",
3159
3161 (LPCSTR)RT_RCDATA);
3162 ok(res != 0, "couldn't find resource\n");
3163
3166
3167 WriteFile(file, buf, ressize, &written, NULL);
3168 expect(ressize, written);
3169
3171
3173 expect(Ok, stat);
3174
3176 expect(Ok, stat);
3177
3178 stat = GdipGetFontCollectionFamilyCount(fonts, &fontscount);
3179 expect(Ok, stat);
3180 expect(1, fontscount);
3181
3182 stat = GdipGetFontCollectionFamilyList(fonts, fontscount, &family, &fontscount);
3183 expect(Ok, stat);
3184
3186 expect(Ok, stat);
3187
3188 /* Start metafile recording. */
3191 L"winetest", &metafile);
3192 expect(Ok, stat);
3193 DeleteDC(hdc);
3194 hdc = NULL;
3195
3197 expect(Ok, stat);
3198
3199 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
3200 expect(Ok, stat);
3201
3202 /* Write something with the custom font so that it is encoded. */
3203 stat = GdipDrawDriverString(graphics, L"Test", 4, font, brush, &pos,
3205 expect(Ok, stat);
3206
3207 /* Delete the custom font so that it is not present during playback. */
3211 expect(TRUE, rval);
3212
3213 GdipDeleteGraphics(graphics);
3214 graphics = NULL;
3215
3216 check_metafile(metafile, unknownfontdecode_records, "unknownfontdecode metafile", dst_points,
3217 &frame, UnitPixel);
3218 sync_metafile(&metafile, "unknownfontdecode.emf");
3219
3221 expect(Ok, stat);
3222
3224 expect(Ok, stat);
3225
3226 play_metafile(metafile, graphics, unknownfontdecode_records, "unknownfontdecode playback",
3227 dst_points, &frame, UnitPixel);
3228
3229 GdipDeleteGraphics(graphics);
3230 GdipDeleteBrush(brush);
3233}
3234
3236 { EMR_HEADER },
3239 { EmfPlusRecordTypeFillRegion, 0x8000 },
3244 { EMR_EOF },
3245 { 0 }
3246};
3247
3248static void test_fillregion(void)
3249{
3250 static const GpPointF dst_points[3] = {{0.0, 0.0}, {100.0, 0.0}, {0.0, 100.0}};
3251 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
3252 static const GpRectF solidrect = {20.0, 20.0, 20.0, 20.0};
3253 static const GpRectF hatchrect = {50.0, 50.0, 20.0, 20.0};
3254
3255 GpStatus stat;
3257 GpGraphics *graphics;
3259 GpBrush *solidbrush, *hatchbrush;
3260 GpRegion *solidregion, *hatchregion;
3261 ARGB color;
3262 HDC hdc;
3263
3266 L"winetest", &metafile);
3267 expect(Ok, stat);
3268 DeleteDC(hdc);
3269 hdc = NULL;
3270
3272 expect(Ok, stat);
3273
3274 stat = GdipCreateRegionRect(&solidrect, &solidregion);
3275 expect(Ok, stat);
3276
3277 stat = GdipCreateSolidFill(0xffaabbcc, (GpSolidFill**)&solidbrush);
3278 expect(Ok, stat);
3279
3280 stat = GdipFillRegion(graphics, solidbrush, solidregion);
3281 expect(Ok, stat);
3282
3283 stat = GdipCreateRegionRect(&hatchrect, &hatchregion);
3284 expect(Ok, stat);
3285
3286 stat = GdipCreateHatchBrush(HatchStyleHorizontal, 0xffff0000, 0xff0000ff,
3287 (GpHatch**)&hatchbrush);
3288 expect(Ok, stat);
3289
3290 stat = GdipFillRegion(graphics, hatchbrush, hatchregion);
3291 expect(Ok, stat);
3292
3293 stat = GdipDeleteGraphics(graphics);
3294 graphics = NULL;
3295 expect(Ok, stat);
3296
3297 check_metafile(metafile, fillregion_records, "regionfill metafile", dst_points,
3298 &frame, UnitPixel);
3299 sync_metafile(&metafile, "regionfill.emf");
3300
3302 expect(Ok, stat);
3303
3305 expect(Ok, stat);
3306
3307 play_metafile(metafile, graphics, fillregion_records, "regionfill playback",
3308 dst_points, &frame, UnitPixel);
3309
3310 stat = GdipBitmapGetPixel(bitmap, 25, 25, &color);
3311 expect(Ok, stat);
3312 expect(0xffaabbcc, color);
3313
3314 stat = GdipBitmapGetPixel(bitmap, 56, 56, &color);
3315 expect(Ok, stat);
3316 expect(0xffff0000, color);
3317
3318 stat = GdipBitmapGetPixel(bitmap, 57, 57, &color);
3319 expect(Ok, stat);
3320 expect(0xff0000ff, color);
3321
3322 GdipDeleteRegion(solidregion);
3323 GdipDeleteRegion(hatchregion);
3324 GdipDeleteBrush(solidbrush);
3325 GdipDeleteBrush(hatchbrush);
3326 GdipDeleteGraphics(graphics);
3329}
3330
3332 { EMR_HEADER },
3335 { EmfPlusRecordTypeFillRects, 0x4000 },
3337 { EmfPlusRecordTypeFillRects, 0x4000 },
3339 { EmfPlusRecordTypeFillRects, 0x4000 },
3341 { EmfPlusRecordTypeFillRects, 0x4000 },
3343 { EMR_EOF },
3344 { 0 }
3345};
3346
3347static void test_lineargradient(void)
3348{
3349 static const GpPointF dst_points[3] = {{0.0, 0.0}, {100.0, 0.0}, {0.0, 100.0}};
3350 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
3351 static const GpRectF horizrect = {10.0, 10.0, 20.0, 20.0};
3352 static const GpRectF vertrect = {50.0, 10.0, 20.0, 20.0};
3353 static const GpRectF blendrect = {10.0, 50.0, 20.0, 20.0};
3354 static const GpRectF presetrect = {50.0, 50.0, 20.0, 20.0};
3355 static const REAL blendfac[3] = {0.0, 0.9, 1.0};
3356 static const REAL blendpos[3] = {0.0, 0.5, 1.0};
3357 static const ARGB pblendcolor[3] = {0xffff0000, 0xff00ff00, 0xff0000ff};
3358 static const REAL pblendpos[3] = {0.0, 0.5, 1.0};
3359
3360 ARGB color;
3362 GpBrush *horizbrush, *vertbrush, *blendbrush, *presetbrush;
3363 GpGraphics *graphics;
3365 GpStatus stat;
3366 HDC hdc;
3367
3370 L"winetest", &metafile);
3371 expect(Ok, stat);
3372 DeleteDC(hdc);
3373 hdc = NULL;
3374
3376 expect(Ok, stat);
3377
3378 /* Test various brush types to cover all valid combinations
3379 of optional serialized data. */
3380 stat = GdipCreateLineBrushFromRect(&horizrect, 0xffff0000, 0xff0000ff,
3382 expect(Ok, stat);
3383
3384 stat = GdipCreateLineBrushFromRect(&vertrect, 0xffff0000, 0xff0000ff,
3386 expect(Ok, stat);
3387
3388 stat = GdipCreateLineBrushFromRect(&blendrect, 0xffff0000, 0xff0000ff,
3390 expect(Ok, stat);
3391
3392 stat = GdipSetLineBlend((GpLineGradient*)blendbrush, blendfac, blendpos, 3);
3393 expect(Ok, stat);
3394
3395 stat = GdipCreateLineBrushFromRect(&presetrect, 0xffff0000, 0xff0000ff,
3397 expect(Ok, stat);
3398
3399 stat = GdipSetLinePresetBlend((GpLineGradient*)presetbrush, pblendcolor, pblendpos, 3);
3400 expect(Ok, stat);
3401
3402 stat = GdipFillRectangles(graphics, vertbrush, &vertrect, 1);
3403 expect(Ok, stat);
3404
3405 stat = GdipFillRectangles(graphics, horizbrush, &horizrect, 1);
3406 expect(Ok, stat);
3407
3408 stat = GdipFillRectangles(graphics, blendbrush, &blendrect, 1);
3409 expect(Ok, stat);
3410
3411 stat = GdipFillRectangles(graphics, presetbrush, &presetrect, 1);
3412 expect(Ok, stat);
3413
3414 stat = GdipDeleteGraphics(graphics);
3415 graphics = NULL;
3416 expect(Ok, stat);
3417
3418 check_metafile(metafile, lineargradient_records, "lineargradient metafile", dst_points,
3419 &frame, UnitPixel);
3420 sync_metafile(&metafile, "lineargradient.emf");
3421
3423 expect(Ok, stat);
3424
3426 expect(Ok, stat);
3427
3428 play_metafile(metafile, graphics, lineargradient_records, "lineargradient playback",
3429 dst_points, &frame, UnitPixel);
3430
3431 /* Verify horizontal gradient fill. */
3432 stat = GdipBitmapGetPixel(bitmap, 10, 10, &color);
3433 expect(Ok, stat);
3434 expect(0xffff0000, color);
3435
3436 stat = GdipBitmapGetPixel(bitmap, 18, 10, &color);
3437 expect(Ok, stat);
3438 expect(0xff990066, color);
3439
3440 /* Verify vertical gradient fill. */
3441 stat = GdipBitmapGetPixel(bitmap, 50, 10, &color);
3442 expect(Ok, stat);
3443 expect(0xffff0000, color);
3444
3445 stat = GdipBitmapGetPixel(bitmap, 50, 18, &color);
3446 expect(Ok, stat);
3447 expect(0xff990066, color);
3448
3449 /* Verify custom blend gradient fill. */
3450 stat = GdipBitmapGetPixel(bitmap, 10, 50, &color);
3451 expect(Ok, stat);
3452 expect(0xffff0000, color);
3453
3454 stat = GdipBitmapGetPixel(bitmap, 18, 50, &color);
3455 expect(Ok, stat);
3456 expect(0xff4700b8, color);
3457
3458 /* Verify preset color gradient fill. */
3459 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
3460 expect(Ok, stat);
3461 expect(0xffff0000, color);
3462
3463 stat = GdipBitmapGetPixel(bitmap, 50, 60, &color);
3464 expect(Ok, stat);
3465 expect(0xff00ff00, color);
3466
3467 GdipDeleteBrush(vertbrush);
3468 GdipDeleteBrush(horizbrush);
3469 GdipDeleteBrush(blendbrush);
3470 GdipDeleteBrush(presetbrush);
3471 GdipDeleteGraphics(graphics);
3474}
3475
3477{
3478 char buffer[260];
3479 DWORD len;
3481 DRIVER_INFO_3A *dbuf = NULL;
3482 HANDLE hprn = 0;
3483 HDC hdc = 0;
3484 HMODULE winspool = LoadLibraryA("winspool.drv");
3485 BOOL (WINAPI *pOpenPrinterA)(LPSTR, HANDLE *, LPPRINTER_DEFAULTSA);
3486 BOOL (WINAPI *pGetDefaultPrinterA)(LPSTR, LPDWORD);
3487 BOOL (WINAPI *pGetPrinterA)(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
3488 BOOL (WINAPI *pGetPrinterDriverA)(HANDLE, LPSTR, DWORD, LPBYTE, DWORD, LPDWORD);
3489 BOOL (WINAPI *pClosePrinter)(HANDLE);
3490
3491 pGetDefaultPrinterA = (void *)GetProcAddress(winspool, "GetDefaultPrinterA");
3492 pOpenPrinterA = (void *)GetProcAddress(winspool, "OpenPrinterA");
3493 pGetPrinterA = (void *)GetProcAddress(winspool, "GetPrinterA");
3494 pGetPrinterDriverA = (void *)GetProcAddress(winspool, "GetPrinterDriverA");
3495 pClosePrinter = (void *)GetProcAddress(winspool, "ClosePrinter");
3496
3497 if (!pGetDefaultPrinterA || !pOpenPrinterA || !pGetPrinterA || !pGetPrinterDriverA || !pClosePrinter)
3498 goto done;
3499
3500 len = sizeof(buffer);
3501 if (!pGetDefaultPrinterA(buffer, &len)) goto done;
3502 if (!pOpenPrinterA(buffer, &hprn, NULL)) goto done;
3503
3504 pGetPrinterA(hprn, 2, NULL, 0, &len);
3505 pbuf = malloc(len);
3506 if (!pGetPrinterA(hprn, 2, (LPBYTE)pbuf, len, &len)) goto done;
3507
3508 pGetPrinterDriverA(hprn, NULL, 3, NULL, 0, &len);
3509 dbuf = malloc(len);
3510 if (!pGetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, len, &len)) goto done;
3511
3512 hdc = CreateDCA(dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, pbuf->pDevMode);
3513 trace("hdc %p for driver '%s' printer '%s' port '%s'\n", hdc,
3514 dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName);
3515done:
3516 free(dbuf);
3517 free(pbuf);
3518 if (hprn) pClosePrinter(hprn);
3519 if (winspool) FreeLibrary(winspool);
3520 return hdc;
3521}
3522
3523static void test_printer_dc(void)
3524{
3525 HDC hdc;
3526 Status status;
3527 RectF frame = { 0.0, 0.0, 1.0, 1.0 };
3529 GpGraphics *graphics;
3530 REAL dpix, dpiy;
3531
3533 if (!hdc)
3534 {
3535 skip("could not create a DC for the default printer\n");
3536 return;
3537 }
3538
3540 expect(Ok, status);
3541
3543 expect(Ok, status);
3544
3545 GdipGetDpiX(graphics, &dpix);
3546 GdipGetDpiX(graphics, &dpiy);
3549
3550 GdipDeleteGraphics(graphics);
3552}
3553
3555{
3556 { EMR_HEADER },
3559 { EmfPlusRecordTypeDrawEllipse, 0x4000 },
3560 { EMR_SAVEDC, 0, 1 },
3561 { EMR_SETICMMODE, 0, 1 },
3562 { EMR_BITBLT, 0, 1 },
3563 { EMR_RESTOREDC, 0, 1 },
3565 { EMR_EOF },
3566 { 0 }
3567};
3568
3569static void test_drawellipse(void)
3570{
3571 static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f };
3572
3574 GpGraphics *graphics;
3575 HENHMETAFILE hemf;
3576 GpStatus stat;
3577 GpPen *pen;
3578 HDC hdc;
3579
3582 expect(Ok, stat);
3583 DeleteDC(hdc);
3584
3586 expect(Ok, stat);
3587
3588 stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
3589 expect(Ok, stat);
3590
3591 stat = GdipDrawEllipse(graphics, pen, 1.0f, 1.0f, 16.0f, 32.0f);
3592 expect(Ok, stat);
3593
3594 stat = GdipDeletePen(pen);
3595 expect(Ok, stat);
3596
3597 stat = GdipDeleteGraphics(graphics);
3598 expect(Ok, stat);
3599 sync_metafile(&metafile, "draw_ellipse.emf");
3600
3602 expect(Ok, stat);
3603
3604 check_emfplus(hemf, draw_ellipse_records, "draw ellipse");
3605 DeleteEnhMetaFile(hemf);
3606
3608 expect(Ok, stat);
3609}
3610
3612{
3613 { EMR_HEADER },
3615 { EmfPlusRecordTypeFillEllipse, 0xc000 },
3616 { EMR_SAVEDC, 0, 1 },
3617 { EMR_SETICMMODE, 0, 1 },
3618 { EMR_BITBLT, 0, 1 },
3619 { EMR_RESTOREDC, 0, 1 },
3621 { EMR_EOF },
3622 { 0 }
3623};
3624
3625static void test_fillellipse(void)
3626{
3627 static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f };
3628
3630 GpGraphics *graphics;
3631 GpSolidFill *brush;
3632 HENHMETAFILE hemf;
3633 GpStatus stat;
3634 HDC hdc;
3635
3638 expect(Ok, stat);
3639 DeleteDC(hdc);
3640
3642 expect(Ok, stat);
3643
3644 stat = GdipCreateSolidFill(0xffaabbcc, &brush);
3645 expect(Ok, stat);
3646
3647 stat = GdipFillEllipse(graphics, (GpBrush *)brush, 0.0f, 0.0f, 10.0f, 20.0f);
3648 expect(Ok, stat);
3649
3650 stat = GdipDeleteBrush((GpBrush*)brush);
3651 expect(Ok, stat);
3652
3653 stat = GdipDeleteGraphics(graphics);
3654 expect(Ok, stat);
3655 sync_metafile(&metafile, "fill_ellipse.emf");
3656
3658 expect(Ok, stat);
3659
3660 check_emfplus(hemf, fill_ellipse_records, "fill ellipse");
3661
3662 DeleteEnhMetaFile(hemf);
3663
3665 expect(Ok, stat);
3666}
3667
3669{
3670 { EMR_HEADER },
3673 { EmfPlusRecordTypeDrawRects, 0x4000 },
3674 { EMR_SAVEDC, 0, 1 },
3675 { EMR_SETICMMODE, 0, 1 },
3676 { EMR_BITBLT, 0, 1 },
3677 { EMR_RESTOREDC, 0, 1 },
3679 { EMR_EOF },
3680 { 0 }
3681};
3682
3683static void test_drawrectangle(void)
3684{
3685 static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f };
3686
3688 GpGraphics *graphics;
3689 HENHMETAFILE hemf;
3690 GpStatus stat;
3691 GpPen *pen;
3692 HDC hdc;
3693
3696 expect(Ok, stat);
3697 DeleteDC(hdc);
3698
3700 expect(Ok, stat);
3701
3702 stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
3703 expect(Ok, stat);
3704
3705 stat = GdipDrawRectangle(graphics, pen, 1.0f, 1.0f, 16.0f, 32.0f);
3706 expect(Ok, stat);
3707
3708 stat = GdipDeletePen(pen);
3709 expect(Ok, stat);
3710
3711 stat = GdipDeleteGraphics(graphics);
3712 expect(Ok, stat);
3713 sync_metafile(&metafile, "draw_rectangle.emf");
3714
3716 expect(Ok, stat);
3717
3718 check_emfplus(hemf, draw_rectangle_records, "draw rectangle");
3719 DeleteEnhMetaFile(hemf);
3720
3722 expect(Ok, stat);
3723}
3724
3725static void test_offsetclip(void)
3726{
3727 static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f };
3728 static const emfplus_record offset_clip_records[] =
3729 {
3730 { EMR_HEADER },
3735 { EMR_EOF },
3736 { 0 },
3737 };
3738
3740 GpGraphics *graphics;
3741 HENHMETAFILE hemf;
3742 GpStatus stat;
3743 HDC hdc;
3744
3747 expect(Ok, stat);
3748 DeleteDC(hdc);
3749
3751 expect(Ok, stat);
3752
3753 stat = GdipTranslateClip(graphics, 1.0f, -1.0f);
3754 expect(Ok, stat);
3755
3756 stat = GdipTranslateClipI(graphics, 2, 3);
3757 expect(Ok, stat);
3758
3759 stat = GdipDeleteGraphics(graphics);
3760 expect(Ok, stat);
3761 sync_metafile(&metafile, "offset_clip.emf");
3762
3764 expect(Ok, stat);
3765
3766 check_emfplus(hemf, offset_clip_records, "offset clip");
3767 DeleteEnhMetaFile(hemf);
3768
3770 expect(Ok, stat);
3771}
3772
3773static void test_resetclip(void)
3774{
3775 static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f };
3776 static const emfplus_record reset_clip_records[] =
3777 {
3778 { EMR_HEADER },
3783 { EMR_EOF },
3784 { 0 },
3785 };
3786
3788 GpGraphics *graphics;
3789 HENHMETAFILE hemf;
3790 GpStatus stat;
3791 HDC hdc;
3792
3795 expect(Ok, stat);
3796 DeleteDC(hdc);
3797
3799 expect(Ok, stat);
3800
3801 stat = GdipResetClip(graphics);
3802 expect(Ok, stat);
3803
3804 stat = GdipResetClip(graphics);
3805 expect(Ok, stat);
3806
3807 stat = GdipDeleteGraphics(graphics);
3808 expect(Ok, stat);
3809 sync_metafile(&metafile, "reset_clip.emf");
3810
3812 expect(Ok, stat);
3813
3814 check_emfplus(hemf, reset_clip_records, "reset clip");
3815 DeleteEnhMetaFile(hemf);
3816
3818 expect(Ok, stat);
3819}
3820
3821static void test_setclippath(void)
3822{
3823 static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f };
3824 static const emfplus_record set_clip_path_records[] =
3825 {
3826 { EMR_HEADER },
3831 { EMR_EOF },
3832 { 0 },
3833 };
3834
3836 GpGraphics *graphics;
3837 HENHMETAFILE hemf;
3838 GpStatus stat;
3839 GpPath *path;
3840 HDC hdc;
3841
3844 expect(Ok, stat);
3845 DeleteDC(hdc);
3846
3848 expect(Ok, stat);
3849
3851 expect(Ok, stat);
3852 stat = GdipAddPathLine(path, 5, 5, 30, 30);
3853 expect(Ok, stat);
3854 stat = GdipAddPathLine(path, 30, 30, 5, 30);
3855 expect(Ok, stat);
3856
3858 expect(Ok, stat);
3859
3861 expect(Ok, stat);
3862
3863 stat = GdipDeleteGraphics(graphics);
3864 expect(Ok, stat);
3865 sync_metafile(&metafile, "set_clip_path.emf");
3866
3868 expect(Ok, stat);
3869
3870 check_emfplus(hemf, set_clip_path_records, "set clip path");
3871 DeleteEnhMetaFile(hemf);
3872
3874 expect(Ok, stat);
3875}
3876
3878{
3879 { EMR_HEADER },
3884 { EMR_SAVEDC, 0, 1 },
3885 { EMR_SETICMMODE, 0, 1 },
3886 { EMR_BITBLT, 0, 1 },
3887 { EMR_RESTOREDC, 0, 1 },
3889 { EMR_EOF },
3890 { 0 }
3891};
3892
3894{
3895 { EMR_HEADER },
3901 { EMR_EOF },
3902 { 0 }
3903};
3904
3905static void test_pen(void)
3906{
3907 static const GpPointF dst_points[3] = {{0.0, 0.0}, {100.0, 0.0}, {0.0, 100.0}};
3908 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
3909 GpMetafile *metafile, *clone_metafile;
3910 GpPath *draw_path, *line_cap_path;
3911 GpCustomLineCap *custom_line_cap;
3912 GpGraphics *graphics;
3913 HENHMETAFILE hemf;
3915 GpStatus stat;
3916 ARGB color;
3917 GpPen *pen;
3918 BOOL ret;
3919 HDC hdc;
3920
3921 /* Record */
3924 expect(Ok, stat);
3925 DeleteDC(hdc);
3926
3928 expect(Ok, stat);
3929
3930 stat = GdipCreatePath(FillModeAlternate, &draw_path);
3931 expect(Ok, stat);
3932 stat = GdipAddPathLine(draw_path, 25, 25, 25, 75);
3933 expect(Ok, stat);
3934
3935 stat = GdipCreatePen1((ARGB)0xffff0000, 1.0f, UnitPixel, &pen);
3936 expect(Ok, stat);
3937 stat = GdipCreatePath(FillModeAlternate, &line_cap_path);
3938 expect(Ok, stat);
3939 stat = GdipAddPathRectangle(line_cap_path, 5.0, 5.0, 10.0, 10.0);
3940 expect(Ok, stat);
3941 stat = GdipCreateCustomLineCap(NULL, line_cap_path, LineCapCustom, 0.0, &custom_line_cap);
3942 expect(Ok, stat);
3943 stat = GdipSetPenCustomStartCap(pen, custom_line_cap);
3944 expect(Ok, stat);
3945 stat = GdipSetPenCustomEndCap(pen, custom_line_cap);
3946 expect(Ok, stat);
3947 stat = GdipDeleteCustomLineCap(custom_line_cap);
3948 expect(Ok, stat);
3949 stat = GdipDeletePath(line_cap_path);
3950 expect(Ok, stat);
3951
3952 stat = GdipDrawPath(graphics, pen, draw_path);
3953 expect(Ok, stat);
3954
3955 stat = GdipDeletePen(pen);
3956 expect(Ok, stat);
3957 stat = GdipDeletePath(draw_path);
3958 expect(Ok, stat);
3959 stat = GdipDeleteGraphics(graphics);
3960 expect(Ok, stat);
3961
3962 sync_metafile(&metafile, "pen.emf");
3963 GdipCloneImage((GpImage *)metafile, (GpImage **)&clone_metafile);
3964
3966 expect(Ok, stat);
3967
3968 check_emfplus(hemf, pen_dc_records, "pen record");
3969
3970 ret = DeleteEnhMetaFile(hemf);
3971 ok(ret != 0, "Failed to delete enhmetafile.\n");
3973 expect(Ok, stat);
3974
3975 /* Play back */
3977 expect(Ok, stat);
3978
3980 expect(Ok, stat);
3981
3982 play_metafile(clone_metafile, graphics, pen_bitmap_records, "pen playback", dst_points, &frame, UnitPixel);
3983
3984 stat = GdipBitmapGetPixel(bitmap, 10, 10, &color);
3985 expect(Ok, stat);
3986 expect(0xffff0000, color);
3987
3988 stat = GdipBitmapGetPixel(bitmap, 40, 90, &color);
3989 expect(Ok, stat);
3990 expect(0xffff0000, color);
3991
3992 stat = GdipDisposeImage((GpImage *)clone_metafile);
3993 expect(Ok, stat);
3994 stat = GdipDeleteGraphics(graphics);
3995 expect(Ok, stat);
3997 expect(Ok, stat);
3998}
3999
4001{
4002 struct GdiplusStartupInput gdiplusStartupInput;
4003 ULONG_PTR gdiplusToken;
4004 int myARGC;
4005 char **myARGV;
4006 HMODULE hmsvcrt;
4007 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
4008
4009 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
4010 hmsvcrt = LoadLibraryA("msvcrt");
4011 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
4012 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
4013
4014 gdiplusStartupInput.GdiplusVersion = 1;
4015 gdiplusStartupInput.DebugEventCallback = NULL;
4016 gdiplusStartupInput.SuppressBackgroundThread = 0;
4017 gdiplusStartupInput.SuppressExternalCodecs = 0;
4018
4019 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
4020
4022
4023 if (myARGC >= 3)
4024 {
4025 if (!strcmp(myARGV[2], "save"))
4027 else if (!strcmp(myARGV[2], "load"))
4029 }
4030
4031 test_empty();
4032 test_getdc();
4033 test_emfonly();
4034 test_fillrect();
4035 test_clear();
4042 test_clipping();
4046 test_drawpath();
4047 test_fillpath();
4060 test_pen();
4061
4062 GdiplusShutdown(gdiplusToken);
4063}
static HDC hDC
Definition: 3dtext.c:33
static INT myARGC
Definition: FindFiles.c:29
static LPSTR * myARGV
Definition: FindFiles.c:30
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
static HBRUSH hbrush
#define stat
Definition: acwin.h:100
static int state
Definition: maze.c:121
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
RECT rect
Definition: combotst.c:67
float rval
Definition: cylfrac.c:48
#define check_record(rec,...)
Definition: db.c:63
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
float REAL
Definition: types.h:41
#define CDECL
Definition: compat.h:29
#define CloseHandle
Definition: compat.h:739
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define CALLBACK
Definition: compat.h:35
GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF *rect, ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap, GpLineGradient **line)
Definition: brush.c:462
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:1020
GpStatus WINGDIPAPI GdipCreateHatchBrush(GpHatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
Definition: brush.c:302
GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush, GDIPCONST ARGB *blend, GDIPCONST REAL *positions, INT count)
Definition: brush.c:2068
GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush, GDIPCONST REAL *factors, GDIPCONST REAL *positions, INT count)
Definition: brush.c:1395
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:783
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
GpStatus WINGDIPAPI GdipDeleteFont(GpFont *font)
Definition: font.c:272
GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc, GDIPCONST LOGFONTA *lfa, GpFont **font)
Definition: font.c:251
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(GpFontCollection *fontCollection, INT *numFound)
Definition: font.c:1528
GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font)
Definition: font.c:150
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(GpFontCollection *fontCollection, INT numSought, GpFontFamily *gpfamilies[], INT *numFound)
Definition: font.c:1543
GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection)
Definition: font.c:1076
GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
Definition: font.c:503
GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection *collection, GDIPCONST WCHAR *name)
Definition: font.c:1095
GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection **fontCollection)
Definition: font.c:1054
GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6988
GpStatus WINGDIPAPI GdipFillRectangles(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRectF *rects, INT count)
Definition: graphics.c:4704
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state)
Definition: graphics.c:6280
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2434
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height)
Definition: graphics.c:4693
GpStatus WINGDIPAPI GdipFillRegion(GpGraphics *graphics, GpBrush *brush, GpRegion *region)
Definition: graphics.c:4891
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:7002
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2616
GpStatus WINGDIPAPI GdipTranslateClip(GpGraphics *graphics, REAL dx, REAL dy)
Definition: graphics.c:7421
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, REAL sy, GpMatrixOrder order)
Definition: graphics.c:6406
GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle, GpMatrixOrder order)
Definition: graphics.c:6217
GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4416
GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx, REAL dy, GpMatrixOrder order)
Definition: graphics.c:6748
GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics, CompositingMode mode)
Definition: graphics.c:6440
GpStatus WINGDIPAPI GdipTranslateClipI(GpGraphics *graphics, INT dx, INT dy)
Definition: graphics.c:7446
GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics)
Definition: graphics.c:6172
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
Definition: graphics.c:7050
GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale)
Definition: graphics.c:5065
GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
Definition: graphics.c:5229
GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics, TextRenderingHint hint)
Definition: graphics.c:6696
GpStatus WINGDIPAPI GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length, GDIPCONST GpFont *font, GDIPCONST GpBrush *brush, GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix)
Definition: graphics.c:7903
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:6724
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, CombineMode mode)
Definition: graphics.c:6899
GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
Definition: graphics.c:7016
GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode mode)
Definition: graphics.c:6842
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics *graphics, GpRectF *rect)
Definition: graphics.c:5157
GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2)
Definition: graphics.c:3646
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
Definition: graphics.c:6267
GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
Definition: graphics.c:4207
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state)
Definition: graphics.c:6394
GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics, CompositingQuality quality)
Definition: graphics.c:6469
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, InterpolationMode mode)
Definition: graphics.c:6498
GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image, GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, VOID *callbackData)
Definition: graphics.c:3173
GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:2985
GpStatus WINGDIPAPI GdipDrawRectangle(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4267
GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)
Definition: graphics.c:4529
GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4682
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:7141
GpStatus WINGDIPAPI GdipSetRenderingOrigin(GpGraphics *graphics, INT x, INT y)
Definition: graphics.c:6616
GpStatus WINGDIPAPI GdipSetClipPath(GpGraphics *graphics, GpPath *path, CombineMode mode)
Definition: graphics.c:6806
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
Definition: graphics.c:6400
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
Definition: graphics.c:6560
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics *graphics, GpUnit *unit)
Definition: graphics.c:5080
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
Definition: graphics.c:6654
GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:5215
GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode mode)
Definition: graphics.c:6587
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
Definition: graphics.c:6194
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
Definition: graphics.c:6533
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state)
Definition: graphics.c:6273
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphicspath.c:804
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
Definition: image.c:2311
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2323
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2213
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1793
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2195
GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO *info, VOID *bits, GpBitmap **bitmap)
Definition: image.c:1462
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2099
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:310
GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap *bitmap, INT x, INT y, ARGB color)
Definition: image.c:521
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
Definition: image.c:2140
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2236
GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
Definition: image.c:1385
GpStatus WINGDIPAPI GdipGetMatrixElements(GDIPCONST GpMatrix *matrix, REAL *out)
Definition: matrix.c:168
GpStatus WINGDIPAPI GdipSetMatrixElements(GpMatrix *matrix, REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
Definition: matrix.c:318
GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix *matrix, BOOL *result)
Definition: matrix.c:513
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:156
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:136
ImageDataType
Definition: metafile.c:419
@ ImageDataTypeBitmap
Definition: metafile.c:421
@ ImageDataTypeUnknown
Definition: metafile.c:420
@ ImageDataTypeMetafile
Definition: metafile.c:422
GpStatus WINGDIPAPI GdipGetMetafileDownLevelRasterizationLimit(GDIPCONST GpMetafile *metafile, UINT *limitDpi)
Definition: metafile.c:4401
static int CALLBACK enum_metafile_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
Definition: metafile.c:3779
GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR *file, GDIPCONST WmfPlaceableFileHeader *placeable, GpMetafile **metafile)
Definition: metafile.c:4341
struct EmfPlusRecordHeader EmfPlusRecordHeader
GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, EmfPlusRecordType recordType, UINT flags, UINT dataSize, GDIPCONST BYTE *data)
Definition: metafile.c:2766
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile)
Definition: metafile.c:4244
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1792
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromEmf(HENHMETAFILE hemf, MetafileHeader *header)
Definition: metafile.c:4128
GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpMetafile *metafile, UINT limitDpi)
Definition: metafile.c:4417
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile *metafile, MetafileHeader *header)
Definition: metafile.c:4072
GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPoints(GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST GpPointF *destPoints, INT count, GDIPCONST GpRectF *srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes)
Definition: metafile.c:3829
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:828
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen)
Definition: pen.c:146
GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
Definition: pen.c:204
GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen *pen, GpCustomLineCap *customCap)
Definition: pen.c:590
GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap *customCap)
Definition: pen.c:609
GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
Definition: region.c:459
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
Definition: region.c:567
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:1999
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
_ACRTIMP errno_t __cdecl _controlfp_s(unsigned int *, unsigned int, unsigned int)
Definition: math.c:1304
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
FxCollectionEntry * cur
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:83
@ ObjectTypeImage
@ ObjectTypeInvalid
@ ObjectTypeImageAttributes
@ ObjectTypePen
@ ObjectTypeFont
@ ObjectTypeRegion
@ ObjectTypeBrush
@ ObjectTypePath
@ ColorAdjustTypeDefault
@ ColorMatrixFlagsDefault
@ HatchStyleHorizontal
Definition: gdiplusenums.h:428
@ SmoothingModeAntiAlias
Definition: gdiplusenums.h:126
@ CompositingModeSourceOver
Definition: gdiplusenums.h:247
@ CompositingModeSourceCopy
Definition: gdiplusenums.h:248
#define GDIP_EMFPLUS_RECORD_BASE
Definition: gdiplusenums.h:487
@ CombineModeReplace
Definition: gdiplusenums.h:388
@ CombineModeIntersect
Definition: gdiplusenums.h:389
@ CombineModeXor
Definition: gdiplusenums.h:391
EmfPlusRecordType
Definition: gdiplusenums.h:491
@ EmfPlusRecordTypeGetDC
Definition: gdiplusenums.h:699
@ EmfPlusRecordTypeSetCompositingQuality
Definition: gdiplusenums.h:731
@ EmfPlusRecordTypeSetClipRect
Definition: gdiplusenums.h:745
@ EmfPlusRecordTypeSetClipPath
Definition: gdiplusenums.h:746
@ EmfPlusRecordTypeResetWorldTransform
Definition: gdiplusenums.h:738
@ EmfPlusRecordTypeResetClip
Definition: gdiplusenums.h:744
@ EmfPlusRecordTypeEndContainer
Definition: gdiplusenums.h:736
@ EmfPlusRecordTypeSave
Definition: gdiplusenums.h:732
@ EmfPlusRecordTypeRotateWorldTransform
Definition: gdiplusenums.h:742
@ EmfPlusRecordTypeTranslateWorldTransform
Definition: gdiplusenums.h:740
@ EmfPlusRecordTypeDrawImagePoints
Definition: gdiplusenums.h:722
@ EmfPlusRecordTypeRestore
Definition: gdiplusenums.h:733
@ EmfPlusRecordTypeClear
Definition: gdiplusenums.h:704
@ EmfPlusRecordTypeFillPath
Definition: gdiplusenums.h:715
@ EmfPlusRecordTypeSetPixelOffsetMode
Definition: gdiplusenums.h:729
@ EmfPlusRecordTypeSetCompositingMode
Definition: gdiplusenums.h:730
@ EmfPlusRecordTypeBeginContainer
Definition: gdiplusenums.h:734
@ EmfPlusRecordTypeDrawDriverString
Definition: gdiplusenums.h:749
@ EmfPlusRecordTypeDrawPath
Definition: gdiplusenums.h:716
@ EmfPlusRecordTypeOffsetClip
Definition: gdiplusenums.h:748
@ EmfPlusRecordTypeObject
Definition: gdiplusenums.h:703
@ EmfPlusRecordTypeSetWorldTransform
Definition: gdiplusenums.h:737
@ EmfPlusRecordTypeFillRects
Definition: gdiplusenums.h:705
@ EmfPlusRecordTypeHeader
Definition: gdiplusenums.h:696
@ EmfPlusRecordTypeDrawEllipse
Definition: gdiplusenums.h:710
@ EmfPlusRecordTypeFillEllipse
Definition: gdiplusenums.h:709
@ EmfPlusRecordTypeSetInterpolationMode
Definition: gdiplusenums.h:728
@ EmfPlusRecordTypeEndOfFile
Definition: gdiplusenums.h:697
@ EmfPlusRecordTypeDrawRects
Definition: gdiplusenums.h:706
@ EmfPlusRecordTypeSetPageTransform
Definition: gdiplusenums.h:743
@ EmfPlusRecordTypeSetRenderingOrigin
Definition: gdiplusenums.h:724
@ EmfPlusRecordTypeSetAntiAliasMode
Definition: gdiplusenums.h:725
@ EmfPlusRecordTypeBeginContainerNoParams
Definition: gdiplusenums.h:735
@ EmfPlusRecordTypeFillRegion
Definition: gdiplusenums.h:714
@ EmfPlusRecordTypeScaleWorldTransform
Definition: gdiplusenums.h:741
@ EmfPlusRecordTypeMultiplyWorldTransform
Definition: gdiplusenums.h:739
@ EmfPlusRecordTypeSetClipRegion
Definition: gdiplusenums.h:747
@ EmfPlusRecordTypeSetTextRenderingHint
Definition: gdiplusenums.h:726
EmfType
Definition: gdiplusenums.h:231
@ EmfTypeEmfPlusOnly
Definition: gdiplusenums.h:233
@ EmfTypeEmfPlusDual
Definition: gdiplusenums.h:234
@ EmfTypeEmfOnly
Definition: gdiplusenums.h:232
@ FontStyleRegular
Definition: gdiplusenums.h:301
@ PixelOffsetModeHighQuality
Definition: gdiplusenums.h:163
@ LineCapCustom
Definition: gdiplusenums.h:72
UINT GraphicsContainer
Definition: gdiplusenums.h:23
@ FillModeAlternate
Definition: gdiplusenums.h:55
@ CompositingQualityHighQuality
Definition: gdiplusenums.h:134
@ WrapModeTile
Definition: gdiplusenums.h:205
@ MatrixOrderAppend
Definition: gdiplusenums.h:188
@ MatrixOrderPrepend
Definition: gdiplusenums.h:187
@ TextRenderingHintAntiAlias
Definition: gdiplusenums.h:257
@ TextRenderingHintSystemDefault
Definition: gdiplusenums.h:253
Unit
Definition: gdiplusenums.h:26
@ UnitInch
Definition: gdiplusenums.h:31
@ UnitDisplay
Definition: gdiplusenums.h:28
@ UnitPixel
Definition: gdiplusenums.h:29
@ DriverStringOptionsRealizedAdvance
Definition: gdiplusenums.h:49
@ DriverStringOptionsCmapLookup
Definition: gdiplusenums.h:47
@ MetafileTypeInvalid
Definition: gdiplusenums.h:214
@ MetafileTypeEmfPlusOnly
Definition: gdiplusenums.h:218
@ MetafileTypeWmf
Definition: gdiplusenums.h:215
@ MetafileTypeWmfPlaceable
Definition: gdiplusenums.h:216
@ MetafileTypeEmf
Definition: gdiplusenums.h:217
UINT GraphicsState
Definition: gdiplusenums.h:22
@ InterpolationModeHighQualityBicubic
Definition: gdiplusenums.h:149
@ InterpolationModeHighQuality
Definition: gdiplusenums.h:144
@ InterpolationModeDefault
Definition: gdiplusenums.h:142
@ LinearGradientModeHorizontal
Definition: gdiplusenums.h:224
@ LinearGradientModeVertical
Definition: gdiplusenums.h:225
@ MetafileFrameUnitMillimeter
Definition: gdiplusenums.h:422
@ MetafileFrameUnitInch
Definition: gdiplusenums.h:420
@ MetafileFrameUnitPixel
Definition: gdiplusenums.h:418
Status GpStatus
void WINAPI GdiplusShutdown(ULONG_PTR)
DWORD ARGB
#define PixelFormat32bppRGB
#define PixelFormat24bppRGB
#define PixelFormat32bppARGB
Status
Definition: gdiplustypes.h:24
@ Ok
Definition: gdiplustypes.h:25
@ WrongState
Definition: gdiplustypes.h:33
@ FileNotFound
Definition: gdiplustypes.h:35
@ InvalidParameter
Definition: gdiplustypes.h:27
@ NotTrueTypeFont
Definition: gdiplustypes.h:41
@ GenericError
Definition: gdiplustypes.h:26
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLeglImageOES image
Definition: gl.h:2204
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLuint res
Definition: glext.h:9613
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLuint buffer
Definition: glext.h:5915
GLintptr offset
Definition: glext.h:5920
GLuint color
Definition: glext.h:6243
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint GLenum matrix
Definition: glext.h:9407
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei dataSize
Definition: glext.h:11123
GLenum GLsizei len
Definition: glext.h:6722
GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix *colorMatrix, GDIPCONST ColorMatrix *grayMatrix, ColorMatrixFlags flags)
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
const char * filename
Definition: ioapi.h:137
#define wine_dbgstr_w
Definition: kernel32.h:34
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define win_skip
Definition: minitest.h:67
#define todo_wine_if(is_todo)
Definition: minitest.h:81
#define todo_wine
Definition: minitest.h:80
LONG_PTR LPARAM
Definition: minwindef.h:175
#define CREATE_ALWAYS
Definition: disk.h:72
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
#define comment(fmt, arg1)
Definition: rebar.c:847
BOOL expected
Definition: store.c:2000
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
#define expect_(expected, got, precision)
Definition: font.c:34
static void test_clear(void)
Definition: metafile.c:1191
ImageDataType
Definition: metafile.c:102
static void test_drawrectangle(void)
Definition: metafile.c:3683
static void test_setclippath(void)
Definition: metafile.c:3821
static void test_drawellipse(void)
Definition: metafile.c:3569
static const emfplus_record fillregion_records[]
Definition: metafile.c:3235
#define expectf_(expected, got, precision)
Definition: metafile.c:33
static void test_lineargradient(void)
Definition: metafile.c:3347
static void test_containers(void)
Definition: metafile.c:2086
static const emfplus_record clipping_records[]
Definition: metafile.c:2263
static void test_clipping(void)
Definition: metafile.c:2279
static const emfplus_record draw_image_metafile_records[]
Definition: metafile.c:2529
static const emfplus_record properties_records[]
Definition: metafile.c:2659
static BOOL CALLBACK play_metafile_proc(EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr, void *userdata)
Definition: metafile.c:276
static const emfplus_record pen_bitmap_records[]
Definition: metafile.c:3893
static const emfplus_record worldtransform_records[]
Definition: metafile.c:1638
static const emfplus_record draw_path_records[]
Definition: metafile.c:2746
static int CALLBACK enum_emf_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
Definition: metafile.c:120
static void test_worldtransform(void)
Definition: metafile.c:1659
static void test_resetclip(void)
Definition: metafile.c:3773
static const emfplus_record pen_dc_records[]
Definition: metafile.c:3877
static const emfplus_record draw_rectangle_records[]
Definition: metafile.c:3668
static void test_drawdriverstring(void)
Definition: metafile.c:3027
static const emfplus_record pagetransform_records[]
Definition: metafile.c:1438
static void test_gditransform(void)
Definition: metafile.c:2422
static HDC create_printer_dc(void)
Definition: metafile.c:3476
static void test_pagetransform(void)
Definition: metafile.c:1455
static const emfplus_record emfonly_records[]
Definition: metafile.c:747
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:330
static const emfplus_record clear_emf_records[]
Definition: metafile.c:1178
static void test_fillrect(void)
Definition: metafile.c:1078
static const emfplus_record empty_records[]
Definition: metafile.c:367
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:205
ObjectType
Definition: metafile.c:88
@ ObjectTypeStringFormat
Definition: metafile.c:96
@ ObjectTypeCustomLineCap
Definition: metafile.c:98
static const emfplus_record container_records[]
Definition: metafile.c:2060
static const emfplus_record fillrect_records[]
Definition: metafile.c:1069
static BOOL save_metafiles
Definition: metafile.c:36
static void test_getdc(void)
Definition: metafile.c:624
static void test_fillellipse(void)
Definition: metafile.c:3625
static BOOL load_metafiles
Definition: metafile.c:37
static const emfplus_record restoredc_records[]
Definition: metafile.c:2893
static void test_printer_dc(void)
Definition: metafile.c:3523
static const emfplus_record fill_ellipse_records[]
Definition: metafile.c:3611
static void test_pen(void)
Definition: metafile.c:3905
static void test_nullframerect(void)
Definition: metafile.c:1266
static const emfplus_record lineargradient_records[]
Definition: metafile.c:3331
static void test_fillregion(void)
Definition: metafile.c:3248
static const emfplus_record drawdriverstring_records[]
Definition: metafile.c:3014
static void test_fillpath(void)
Definition: metafile.c:2825
#define expect(expected, got)
Definition: metafile.c:28
static void test_offsetclip(void)
Definition: metafile.c:3725
static void test_drawpath(void)
Definition: metafile.c:2761
static void test_empty(void)
Definition: metafile.c:375
static const emfplus_record unknownfontdecode_records[]
Definition: metafile.c:3118
static void test_properties(void)
Definition: metafile.c:2675
#define expectf(expected, got)
Definition: metafile.c:34
static void test_emfonly(void)
Definition: metafile.c:778
static void play_metafile(GpMetafile *metafile, GpGraphics *graphics, const emfplus_record *expected, const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
Definition: metafile.c:312
static void test_unknownfontdecode(void)
Definition: metafile.c:3128
static void test_gditransform_cb(GpMetafile *metafile, EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr)
Definition: metafile.c:2397
static const emfplus_record getdc_records[]
Definition: metafile.c:610
static void test_frameunit(void)
Definition: metafile.c:1995
static void test_drawimage(void)
Definition: metafile.c:2556
static void test_converttoemfplus(void)
Definition: metafile.c:1918
static const emfplus_record draw_image_bitmap_records[]
Definition: metafile.c:2514
static void check_metafile(GpMetafile *metafile, const emfplus_record *expected, const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
Definition: metafile.c:246
static const emfplus_record fill_path_records[]
Definition: metafile.c:2811
static const emfplus_record draw_ellipse_records[]
Definition: metafile.c:3554
static void test_restoredc(void)
Definition: metafile.c:2919
static const emfplus_record gditransform_records[]
Definition: metafile.c:2411
static const emfplus_record emfonly_draw_records[]
Definition: metafile.c:758
static const unsigned char metafile[]
Definition: olepicture.c:138
Definition: mk_font.cpp:20
unsigned int UINT
Definition: ndis.h:50
#define LPDWORD
Definition: nt_native.h:46
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
short WCHAR
Definition: pedump.c:58
#define RT_RCDATA
Definition: pedump.c:372
png_const_structrp png_const_inforp int * unit
Definition: png.h:2392
strcpy
Definition: string.h:131
int winetest_get_mainargs(char ***pargv)
#define memset(x, y, z)
Definition: compat.h:39
BOOL SuppressBackgroundThread
Definition: gdiplusinit.h:36
DebugEventProc DebugEventCallback
Definition: gdiplusinit.h:35
LONG lfHeight
Definition: dimm.idl:42
BYTE lfCharSet
Definition: dimm.idl:50
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
EmfPlusRecordHeader Header
Definition: metafile.c:110
DWORD MetafileDataSize
Definition: metafile.c:116
ImageDataType Type
Definition: metafile.c:113
REAL Height
Definition: gdiplustypes.h:659
REAL X
Definition: gdiplustypes.h:656
REAL Width
Definition: gdiplustypes.h:658
REAL Y
Definition: gdiplustypes.h:657
LPSTR pDriverPath
Definition: winspool.h:406
Definition: uimain.c:89
GpMetafile * metafile
Definition: metafile.c:57
const struct emfplus_record * expected
Definition: metafile.c:56
const char * desc
Definition: metafile.c:54
DWORD flags
Definition: metafile.c:44
DWORD record_type
Definition: metafile.c:43
void(* playback_fn)(GpMetafile *metafile, EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr)
Definition: metafile.c:47
BOOL playback_todo
Definition: metafile.c:46
DWORD broken_flags
Definition: metafile.c:49
Definition: fci.c:127
Definition: parser.c:49
Definition: match.c:28
Definition: pbuf.h:186
Definition: stat.h:66
Definition: ps.c:97
const char * LPCSTR
Definition: typedefs.h:52
unsigned char * LPBYTE
Definition: typedefs.h:53
PVOID HANDLE
Definition: typedefs.h:73
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define BI_RGB
Definition: uefivid.c:46
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
const char * description
Definition: directx.c:2497
#define EMR_SAVEDC
Definition: wingdi.h:107
#define EMR_BITBLT
Definition: wingdi.h:149
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
#define EMR_SELECTOBJECT
Definition: wingdi.h:111
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define EMR_SETMITERLIMIT
Definition: wingdi.h:132
HENHMETAFILE WINAPI GetEnhMetaFileA(_In_ LPCSTR)
#define EMR_RESTOREDC
Definition: wingdi.h:108
#define EMR_POLYLINE16
Definition: wingdi.h:160
#define LOGPIXELSY
Definition: wingdi.h:719
#define EMR_EXTCREATEPEN
Definition: wingdi.h:168
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
HENHMETAFILE WINAPI CopyEnhMetaFileW(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCWSTR pszFile)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define EMR_RECTANGLE
Definition: wingdi.h:117
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define EMR_EOF
Definition: wingdi.h:88
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
BOOL WINAPI GdiComment(_In_ HDC hdc, _In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpData)
#define EMR_SETICMMODE
Definition: wingdi.h:171
#define EMR_DELETEOBJECT
Definition: wingdi.h:114
BOOL WINAPI EnumEnhMetaFile(_In_opt_ HDC, _In_ HENHMETAFILE, _In_ ENHMFENUMPROC, _In_opt_ PVOID, _In_opt_ LPCRECT)
#define LOGPIXELSX
Definition: wingdi.h:718
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define EMR_SETVIEWPORTORGEX
Definition: wingdi.h:86
#define EMR_CREATEBRUSHINDIRECT
Definition: wingdi.h:113
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
#define EMR_HEADER
Definition: wingdi.h:75
#define EMR_MODIFYWORLDTRANSFORM
Definition: wingdi.h:110
#define EMR_SETWORLDTRANSFORM
Definition: wingdi.h:109
#define EMR_GDICOMMENT
Definition: wingdi.h:143
int WINAPI SaveDC(_In_ HDC)
HENHMETAFILE WINAPI CopyEnhMetaFileA(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCSTR pszFile)
struct _PRINTER_DEFAULTSA * LPPRINTER_DEFAULTSA
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
unsigned char BYTE
Definition: xxhash.c:193