ReactOS 0.4.17-dev-218-g5635d24
graphics.c
Go to the documentation of this file.
1/*
2 * Unit test suite for graphics objects
3 *
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include <math.h>
23
24#include "objbase.h"
25#include "gdiplus.h"
26#include "winspool.h"
27#include "wine/test.h"
28
29#define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
30#define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
31#define expectf(expected, got) expectf_((expected), (got), 0.001)
32
33static GpStatus (WINAPI *pGdipGraphicsSetAbort)(GpGraphics*,GdiplusAbort*);
34#ifdef __REACTOS__
35static GpStatus (WINAPI *pGdipDrawImageFX)(GpGraphics*, GpImage*, GpRectF*, GpMatrix*, CGpEffect*, GpImageAttributes*, GpUnit);
36#endif
37
38static const REAL mm_per_inch = 25.4;
39static const REAL point_per_inch = 72.0;
40static HWND hwnd;
41
42static void set_rect_empty(RectF *rc)
43{
44 rc->X = 0.0;
45 rc->Y = 0.0;
46 rc->Width = 0.0;
47 rc->Height = 0.0;
48}
49
50/* converts a given unit to its value in pixels */
52{
53 switch (unit)
54 {
55 case UnitPixel:
56 case UnitDisplay:
57 return units;
58 case UnitPoint:
59 return units * dpi / point_per_inch;
60 case UnitInch:
61 return units * dpi;
62 case UnitDocument:
63 return units * dpi / 300.0; /* Per MSDN */
64 case UnitMillimeter:
65 return units * dpi / mm_per_inch;
66 default:
67 ok(0, "Unsupported unit: %d\n", unit);
68 return 0;
69 }
70}
71
72/* converts value in pixels to a given unit */
74{
75 switch (unit)
76 {
77 case UnitPixel:
78 case UnitDisplay:
79 return pixels;
80 case UnitPoint:
81 return pixels * point_per_inch / dpi;
82 case UnitInch:
83 return pixels / dpi;
84 case UnitDocument:
85 return pixels * 300.0 / dpi;
86 case UnitMillimeter:
87 return pixels * mm_per_inch / dpi;
88 default:
89 ok(0, "Unsupported unit: %d\n", unit);
90 return 0;
91 }
92}
93
95{
97 return pixels_to_units(pixels, to, dpi);
98}
99
101{
103 union
104 {
106 GpImage *image;
107 } u;
108 GpGraphics *graphics = NULL;
109 REAL res;
110
112 expect(Ok, status);
113
114 status = GdipBitmapSetResolution(u.bitmap, res_x, res_y);
115 expect(Ok, status);
117 expect(Ok, status);
118 expectf(res_x, res);
120 expect(Ok, status);
121 expectf(res_y, res);
122
123 status = GdipGetImageGraphicsContext(u.image, &graphics);
124 expect(Ok, status);
125
126 *image = u.image;
127
128 status = GdipGetDpiX(graphics, &res);
129 expect(Ok, status);
130 expectf(res_x, res);
131 status = GdipGetDpiY(graphics, &res);
132 expect(Ok, status);
133 expectf(res_y, res);
134
135 status = GdipSetPageUnit(graphics, unit);
136 expect(Ok, status);
137 status = GdipSetPageScale(graphics, scale);
138 expect(Ok, status);
139
140 return graphics;
141}
142
144{
146 GpGraphics *graphics = NULL;
147 HDC hdc = GetDC( hwnd );
148
149 stat = GdipCreateFromHDC(NULL, &graphics);
151 stat = GdipDeleteGraphics(graphics);
153
154 stat = GdipCreateFromHDC(hdc, &graphics);
155 expect(Ok, stat);
156 stat = GdipDeleteGraphics(graphics);
157 expect(Ok, stat);
158
159 stat = GdipCreateFromHWND(NULL, &graphics);
160 expect(Ok, stat);
161 stat = GdipDeleteGraphics(graphics);
162 expect(Ok, stat);
163
164 stat = GdipCreateFromHWNDICM(NULL, &graphics);
165 expect(Ok, stat);
166 stat = GdipDeleteGraphics(graphics);
167 expect(Ok, stat);
168
172}
173
174typedef struct node{
176 struct node * next;
178
179/* Linked list prepend function. */
181{
182 node * new_entry = malloc(sizeof(node));
183
184 new_entry->data = data;
185 new_entry->next = *log;
186 *log = new_entry;
187}
188
189/* Checks if there are duplicates in the list, and frees it. */
191{
192 INT dups = 0;
193 node * temp = NULL;
194 node * temp2 = NULL;
195 node * orig = log;
196
197 if(!log)
198 goto end;
199
200 do{
201 temp = log;
202 while((temp = temp->next)){
203 if(log->data == temp->data){
204 dups++;
205 break;
206 }
207 if(dups > 0)
208 break;
209 }
210 }while((log = log->next));
211
212 temp = orig;
213 do{
214 temp2 = temp->next;
215 free(temp);
216 temp = temp2;
217 }while(temp);
218
219end:
220 expect(0, dups);
221}
222
223static void test_save_restore(void)
224{
226 GraphicsState state_a, state_b, state_c;
228 GpGraphics *graphics1, *graphics2;
229 node * state_log = NULL;
230 HDC hdc = GetDC( hwnd );
231 state_a = state_b = state_c = 0xdeadbeef;
232
233 /* Invalid saving. */
234 GdipCreateFromHDC(hdc, &graphics1);
235 stat = GdipSaveGraphics(graphics1, NULL);
237 stat = GdipSaveGraphics(NULL, &state_a);
239 GdipDeleteGraphics(graphics1);
240
241 log_state(state_a, &state_log);
242
243 /* Basic save/restore. */
244 GdipCreateFromHDC(hdc, &graphics1);
246 stat = GdipSaveGraphics(graphics1, &state_a);
247 expect(Ok, stat);
249 stat = GdipRestoreGraphics(graphics1, state_a);
250 expect(Ok, stat);
251 GdipGetInterpolationMode(graphics1, &mode);
253 GdipDeleteGraphics(graphics1);
254
255 log_state(state_a, &state_log);
256
257 /* Restoring garbage doesn't affect saves. */
258 GdipCreateFromHDC(hdc, &graphics1);
260 GdipSaveGraphics(graphics1, &state_a);
262 GdipSaveGraphics(graphics1, &state_b);
264 stat = GdipRestoreGraphics(graphics1, 0xdeadbeef);
265 expect(Ok, stat);
266 GdipRestoreGraphics(graphics1, state_b);
267 GdipGetInterpolationMode(graphics1, &mode);
269 GdipRestoreGraphics(graphics1, state_a);
270 GdipGetInterpolationMode(graphics1, &mode);
272 GdipDeleteGraphics(graphics1);
273
274 log_state(state_a, &state_log);
275 log_state(state_b, &state_log);
276
277 /* Restoring older state invalidates newer saves (but not older saves). */
278 GdipCreateFromHDC(hdc, &graphics1);
280 GdipSaveGraphics(graphics1, &state_a);
282 GdipSaveGraphics(graphics1, &state_b);
284 GdipSaveGraphics(graphics1, &state_c);
286 GdipRestoreGraphics(graphics1, state_b);
287 GdipGetInterpolationMode(graphics1, &mode);
289 GdipRestoreGraphics(graphics1, state_c);
290 GdipGetInterpolationMode(graphics1, &mode);
292 GdipRestoreGraphics(graphics1, state_a);
293 GdipGetInterpolationMode(graphics1, &mode);
295 GdipDeleteGraphics(graphics1);
296
297 log_state(state_a, &state_log);
298 log_state(state_b, &state_log);
299 log_state(state_c, &state_log);
300
301 /* Restoring older save from one graphics object does not invalidate
302 * newer save from other graphics object. */
303 GdipCreateFromHDC(hdc, &graphics1);
304 GdipCreateFromHDC(hdc, &graphics2);
306 GdipSaveGraphics(graphics1, &state_a);
308 GdipSaveGraphics(graphics2, &state_b);
311 GdipRestoreGraphics(graphics1, state_a);
312 GdipGetInterpolationMode(graphics1, &mode);
314 GdipRestoreGraphics(graphics2, state_b);
315 GdipGetInterpolationMode(graphics2, &mode);
317 GdipDeleteGraphics(graphics1);
318 GdipDeleteGraphics(graphics2);
319
320 /* You can't restore a state to a graphics object that didn't save it. */
321 GdipCreateFromHDC(hdc, &graphics1);
322 GdipCreateFromHDC(hdc, &graphics2);
324 GdipSaveGraphics(graphics1, &state_a);
327 GdipRestoreGraphics(graphics2, state_a);
328 GdipGetInterpolationMode(graphics2, &mode);
330 GdipDeleteGraphics(graphics1);
331 GdipDeleteGraphics(graphics2);
332
333 log_state(state_a, &state_log);
334
335 /* A state created by SaveGraphics cannot be restored with EndContainer. */
336 GdipCreateFromHDC(hdc, &graphics1);
338 stat = GdipSaveGraphics(graphics1, &state_a);
339 expect(Ok, stat);
341 stat = GdipEndContainer(graphics1, state_a);
342 expect(Ok, stat);
343 GdipGetInterpolationMode(graphics1, &mode);
345 stat = GdipRestoreGraphics(graphics1, state_a);
346 expect(Ok, stat);
347 GdipGetInterpolationMode(graphics1, &mode);
349 GdipDeleteGraphics(graphics1);
350
351 log_state(state_a, &state_log);
352
353 /* A state created by BeginContainer cannot be restored with RestoreGraphics. */
354 stat = GdipCreateFromHDC(hdc, &graphics1);
355 expect(Ok, stat);
357 stat = GdipBeginContainer2(graphics1, &state_a);
358 expect(Ok, stat);
360 stat = GdipRestoreGraphics(graphics1, state_a);
361 expect(Ok, stat);
362 GdipGetInterpolationMode(graphics1, &mode);
364 stat = GdipEndContainer(graphics1, state_a);
365 expect(Ok, stat);
366 GdipGetInterpolationMode(graphics1, &mode);
368 GdipDeleteGraphics(graphics1);
369
370 log_state(state_a, &state_log);
371
372 /* BeginContainer and SaveGraphics use the same stack. */
373 stat = GdipCreateFromHDC(hdc, &graphics1);
374 expect(Ok, stat);
376 stat = GdipBeginContainer2(graphics1, &state_a);
377 expect(Ok, stat);
379 stat = GdipSaveGraphics(graphics1, &state_b);
380 expect(Ok, stat);
382 stat = GdipEndContainer(graphics1, state_a);
383 expect(Ok, stat);
384 GdipGetInterpolationMode(graphics1, &mode);
386 stat = GdipRestoreGraphics(graphics1, state_b);
387 expect(Ok, stat);
388 GdipGetInterpolationMode(graphics1, &mode);
390 GdipDeleteGraphics(graphics1);
391
392 log_state(state_a, &state_log);
393 log_state(state_b, &state_log);
394
395 /* The same state value should never be returned twice. */
397 check_no_duplicates(state_log);
398
400}
401
403{
405 GpGraphics *graphics = NULL;
406 GpSolidFill *brush = NULL;
407 HDC hdc = GetDC( hwnd );
408 GpPointF points[3];
409
410 points[0].X = 0;
411 points[0].Y = 0;
412
413 points[1].X = 40;
414 points[1].Y = 20;
415
416 points[2].X = 10;
417 points[2].Y = 40;
418
419 /* make a graphics object and brush object */
420 ok(hdc != NULL, "Expected HDC to be initialized\n");
421
422 status = GdipCreateFromHDC(hdc, &graphics);
423 expect(Ok, status);
424 ok(graphics != NULL, "Expected graphics to be initialized\n");
425
426 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
427
428 /* InvalidParameter cases: null graphics, null brush, null points */
431
434
437
440
441 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, NULL, 3, 0.5, FillModeAlternate);
443
446
449
450 /* InvalidParameter cases: invalid count */
451 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, -1, 0.5, FillModeAlternate);
453
454 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 0, 0.5, FillModeAlternate);
456
457 /* Valid test cases */
458 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 1, 0.5, FillModeAlternate);
459 expect(Ok, status);
460
461 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 2, 0.5, FillModeAlternate);
462 expect(Ok, status);
463
464 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
465 expect(Ok, status);
466
467 GdipDeleteGraphics(graphics);
468 GdipDeleteBrush((GpBrush*)brush);
469
471}
472
474{
476 GpGraphics *graphics = NULL;
477 GpSolidFill *brush = NULL;
478 HDC hdc = GetDC( hwnd );
479 GpPoint points[3];
480
481 points[0].X = 0;
482 points[0].Y = 0;
483
484 points[1].X = 40;
485 points[1].Y = 20;
486
487 points[2].X = 10;
488 points[2].Y = 40;
489
490 /* make a graphics object and brush object */
491 ok(hdc != NULL, "Expected HDC to be initialized\n");
492
493 status = GdipCreateFromHDC(hdc, &graphics);
494 expect(Ok, status);
495 ok(graphics != NULL, "Expected graphics to be initialized\n");
496
497 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
498
499 /* InvalidParameter cases: null graphics, null brush */
500 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
501 when points == NULL, so don't test this condition */
504
507
510
511 /* InvalidParameter cases: invalid count */
512 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 0, 0.5, FillModeAlternate);
514
515 /* OutOfMemory cases: large (unsigned) int */
516 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, -1, 0.5, FillModeAlternate);
518
519 /* Valid test cases */
520 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 1, 0.5, FillModeAlternate);
521 expect(Ok, status);
522
523 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 2, 0.5, FillModeAlternate);
524 expect(Ok, status);
525
526 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
527 expect(Ok, status);
528
529 GdipDeleteGraphics(graphics);
530 GdipDeleteBrush((GpBrush*)brush);
531
533}
534
535static void test_GdipDrawArc(void)
536{
538 GpGraphics *graphics = NULL;
539 GpPen *pen = NULL;
540 HDC hdc = GetDC( hwnd );
541
542 /* make a graphics object and pen object */
543 ok(hdc != NULL, "Expected HDC to be initialized\n");
544
545 status = GdipCreateFromHDC(hdc, &graphics);
546 expect(Ok, status);
547 ok(graphics != NULL, "Expected graphics to be initialized\n");
548
549 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
550 expect(Ok, status);
551 ok(pen != NULL, "Expected pen to be initialized\n");
552
553 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
554 status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
556
557 status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
559
560 status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
562
563 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
565
566 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
568
569 /* successful case */
570 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
571 expect(Ok, status);
572
573 GdipDeletePen(pen);
574 GdipDeleteGraphics(graphics);
575
577}
578
579static void test_GdipDrawArcI(void)
580{
582 GpGraphics *graphics = NULL;
583 GpPen *pen = NULL;
584 HDC hdc = GetDC( hwnd );
585
586 /* make a graphics object and pen object */
587 ok(hdc != NULL, "Expected HDC to be initialized\n");
588
589 status = GdipCreateFromHDC(hdc, &graphics);
590 expect(Ok, status);
591 ok(graphics != NULL, "Expected graphics to be initialized\n");
592
593 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
594 expect(Ok, status);
595 ok(pen != NULL, "Expected pen to be initialized\n");
596
597 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
598 status = GdipDrawArcI(NULL, NULL, 0, 0, 0, 0, 0, 0);
600
601 status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
603
604 status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
606
607 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
609
610 status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
612
613 /* successful case */
614 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
615 expect(Ok, status);
616
617 GdipDeletePen(pen);
618 GdipDeleteGraphics(graphics);
619
621}
622
623static void test_BeginContainer2(void)
624{
626 GpRectF clip;
627 REAL defClip[] = {5, 10, 15, 20};
628 REAL elems[6], defTrans[] = {1, 2, 3, 4, 5, 6};
629 GraphicsContainer cont1, cont2, cont3, cont4;
630 CompositingQuality compqual, defCompqual = CompositingQualityHighSpeed;
631 CompositingMode compmode, defCompmode = CompositingModeSourceOver;
633 REAL scale, defScale = 17;
634 GpUnit unit, defUnit = UnitPixel;
635 PixelOffsetMode offsetmode, defOffsetmode = PixelOffsetModeHighSpeed;
636 SmoothingMode smoothmode, defSmoothmode = SmoothingModeAntiAlias;
637 UINT contrast, defContrast = 5;
638 TextRenderingHint texthint, defTexthint = TextRenderingHintAntiAlias;
639
641 GpGraphics *graphics = NULL;
642 HDC hdc = GetDC( hwnd );
643
644 ok(hdc != NULL, "Expected HDC to be initialized\n");
645
646 status = GdipCreateFromHDC(hdc, &graphics);
647 expect(Ok, status);
648 ok(graphics != NULL, "Expected graphics to be initialized\n");
649
650 /* null graphics, null container */
653
654 status = GdipBeginContainer2(graphics, NULL);
656
657 status = GdipEndContainer(NULL, cont1);
659
660 /* test all quality-related values */
661 GdipSetCompositingMode(graphics, defCompmode);
662 GdipSetCompositingQuality(graphics, defCompqual);
663 GdipSetInterpolationMode(graphics, defInterp);
664 GdipSetPageScale(graphics, defScale);
665 GdipSetPageUnit(graphics, defUnit);
666 GdipSetPixelOffsetMode(graphics, defOffsetmode);
667 GdipSetSmoothingMode(graphics, defSmoothmode);
668 GdipSetTextContrast(graphics, defContrast);
669 GdipSetTextRenderingHint(graphics, defTexthint);
670
671 status = GdipBeginContainer2(graphics, &cont1);
672 expect(Ok, status);
673
677 GdipSetPageScale(graphics, 10);
678 GdipSetPageUnit(graphics, UnitDocument);
681 GdipSetTextContrast(graphics, 7);
683
684 status = GdipEndContainer(graphics, cont1);
685 expect(Ok, status);
686
687 GdipGetCompositingMode(graphics, &compmode);
688 ok(defCompmode == compmode, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode, compmode);
689
690 GdipGetCompositingQuality(graphics, &compqual);
691 ok(defCompqual == compqual, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual, compqual);
692
694 ok(defInterp == interp, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp, interp);
695
696 GdipGetPageScale(graphics, &scale);
697 ok(fabs(defScale - scale) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale, scale);
698
699 GdipGetPageUnit(graphics, &unit);
700 ok(defUnit == unit, "Expected Page Unit to be restored to %d, got %d\n", defUnit, unit);
701
702 GdipGetPixelOffsetMode(graphics, &offsetmode);
703 ok(defOffsetmode == offsetmode, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode, offsetmode);
704
705 GdipGetSmoothingMode(graphics, &smoothmode);
706 ok(defSmoothmode == smoothmode, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode, smoothmode);
707
708 GdipGetTextContrast(graphics, &contrast);
709 ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
710
711 status = GdipGetTextRenderingHint(graphics, &texthint);
712 expect(Ok, status);
713 ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
714
715 /* test world transform */
716 status = GdipBeginContainer2(graphics, &cont1);
717 expect(Ok, status);
718
719 status = GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
720 defTrans[4], defTrans[5], &transform);
721 expect(Ok, status);
724 transform = NULL;
725
726 status = GdipBeginContainer2(graphics, &cont2);
727 expect(Ok, status);
728
729 status = GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
730 expect(Ok, status);
732 expect(Ok, status);
734 transform = NULL;
735
736 status = GdipEndContainer(graphics, cont2);
737 expect(Ok, status);
738
740 expect(Ok, status);
742 expect(Ok, status);
744 expect(Ok, status);
745 ok(fabs(defTrans[0] - elems[0]) < 0.0001 &&
746 fabs(defTrans[1] - elems[1]) < 0.0001 &&
747 fabs(defTrans[2] - elems[2]) < 0.0001 &&
748 fabs(defTrans[3] - elems[3]) < 0.0001 &&
749 fabs(defTrans[4] - elems[4]) < 0.0001 &&
750 fabs(defTrans[5] - elems[5]) < 0.0001,
751 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
752 defTrans[0], defTrans[1], defTrans[2], defTrans[3], defTrans[4], defTrans[5],
753 elems[0], elems[1], elems[2], elems[3], elems[4], elems[5]);
755 transform = NULL;
756
757 status = GdipEndContainer(graphics, cont1);
758 expect(Ok, status);
759
760 /* test clipping */
761 status = GdipBeginContainer2(graphics, &cont1);
762 expect(Ok, status);
763
764 status = GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace);
765 expect(Ok, status);
766
767 status = GdipBeginContainer2(graphics, &cont2);
768 expect(Ok, status);
769
770 status = GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
771 expect(Ok, status);
772
773 status = GdipEndContainer(graphics, cont2);
774 expect(Ok, status);
775
776 status = GdipGetClipBounds(graphics, &clip);
777 expect(Ok, status);
778
779 ok(fabs(defClip[0] - clip.X) < 0.0001 &&
780 fabs(defClip[1] - clip.Y) < 0.0001 &&
781 fabs(defClip[2] - clip.Width) < 0.0001 &&
782 fabs(defClip[3] - clip.Height) < 0.0001,
783 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
784 defClip[0], defClip[1], defClip[2], defClip[3],
785 clip.X, clip.Y, clip.Width, clip.Height);
786
787 status = GdipEndContainer(graphics, cont1);
788 expect(Ok, status);
789
790 /* nesting */
791 status = GdipBeginContainer2(graphics, &cont1);
792 expect(Ok, status);
793
794 status = GdipBeginContainer2(graphics, &cont2);
795 expect(Ok, status);
796
797 status = GdipBeginContainer2(graphics, &cont3);
798 expect(Ok, status);
799
800 status = GdipEndContainer(graphics, cont3);
801 expect(Ok, status);
802
803 status = GdipBeginContainer2(graphics, &cont4);
804 expect(Ok, status);
805
806 status = GdipEndContainer(graphics, cont4);
807 expect(Ok, status);
808
809 /* skip cont2 */
810 status = GdipEndContainer(graphics, cont1);
811 expect(Ok, status);
812
813 /* end an already-ended container */
814 status = GdipEndContainer(graphics, cont1);
815 expect(Ok, status);
816
817 GdipDeleteGraphics(graphics);
819}
820
821static void test_GdipDrawBezierI(void)
822{
824 GpGraphics *graphics = NULL;
825 GpPen *pen = NULL;
826 HDC hdc = GetDC( hwnd );
827
828 /* make a graphics object and pen object */
829 ok(hdc != NULL, "Expected HDC to be initialized\n");
830
831 status = GdipCreateFromHDC(hdc, &graphics);
832 expect(Ok, status);
833 ok(graphics != NULL, "Expected graphics to be initialized\n");
834
835 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
836 expect(Ok, status);
837 ok(pen != NULL, "Expected pen to be initialized\n");
838
839 /* InvalidParameter cases: null graphics, null pen */
840 status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
842
843 status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
845
846 status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
848
849 /* successful case */
850 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
851 expect(Ok, status);
852
853 GdipDeletePen(pen);
854 GdipDeleteGraphics(graphics);
855
857}
858
859static void test_GdipDrawCurve3(void)
860{
862 GpGraphics *graphics = NULL;
863 GpPen *pen = NULL;
864 HDC hdc = GetDC( hwnd );
865 GpPointF points[3];
866
867 points[0].X = 0;
868 points[0].Y = 0;
869
870 points[1].X = 40;
871 points[1].Y = 20;
872
873 points[2].X = 10;
874 points[2].Y = 40;
875
876 /* make a graphics object and pen object */
877 ok(hdc != NULL, "Expected HDC to be initialized\n");
878
879 status = GdipCreateFromHDC(hdc, &graphics);
880 expect(Ok, status);
881 ok(graphics != NULL, "Expected graphics to be initialized\n");
882
883 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
884 expect(Ok, status);
885 ok(pen != NULL, "Expected pen to be initialized\n");
886
887 /* InvalidParameter cases: null graphics, null pen */
888 status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1);
890
891 status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1);
893
894 status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1);
896
897 /* InvalidParameter cases: invalid count */
898 status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1);
900
901 status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1);
903
904 status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1);
906
907 status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1);
909
910 /* InvalidParameter cases: invalid number of segments */
911 status = GdipDrawCurve3(graphics, pen, points, 3, 0, -1, 1);
913
914 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 2, 1);
916
917 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 2, 1);
919
920 /* Valid test cases */
921 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, 1);
922 expect(Ok, status);
923
924 status = GdipDrawCurve3(graphics, pen, points, 3, 0, 2, 2);
925 expect(Ok, status);
926
927 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, -2);
928 expect(Ok, status);
929
930 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 1, 0);
931 expect(Ok, status);
932
933 GdipDeletePen(pen);
934 GdipDeleteGraphics(graphics);
935
937}
938
939static void test_GdipDrawCurve3I(void)
940{
942 GpGraphics *graphics = NULL;
943 GpPen *pen = NULL;
944 HDC hdc = GetDC( hwnd );
945 GpPoint points[3];
946
947 points[0].X = 0;
948 points[0].Y = 0;
949
950 points[1].X = 40;
951 points[1].Y = 20;
952
953 points[2].X = 10;
954 points[2].Y = 40;
955
956 /* make a graphics object and pen object */
957 ok(hdc != NULL, "Expected HDC to be initialized\n");
958
959 status = GdipCreateFromHDC(hdc, &graphics);
960 expect(Ok, status);
961 ok(graphics != NULL, "Expected graphics to be initialized\n");
962
963 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
964 expect(Ok, status);
965 ok(pen != NULL, "Expected pen to be initialized\n");
966
967 /* InvalidParameter cases: null graphics, null pen */
968 status = GdipDrawCurve3I(NULL, NULL, points, 3, 0, 2, 1);
970
971 status = GdipDrawCurve3I(graphics, NULL, points, 3, 0, 2, 1);
973
974 status = GdipDrawCurve3I(NULL, pen, points, 3, 0, 2, 1);
976
977 /* InvalidParameter cases: invalid count */
978 status = GdipDrawCurve3I(graphics, pen, points, -1, -1, -1, 1);
980
981 status = GdipDrawCurve3I(graphics, pen, points, 0, 0, 2, 1);
983
984 status = GdipDrawCurve3I(graphics, pen, points, 1, 0, 0, 1);
986
987 status = GdipDrawCurve3I(graphics, pen, points, 3, 4, 2, 1);
989
990 /* InvalidParameter cases: invalid number of segments */
991 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, -1, 1);
993
994 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 2, 1);
996
997 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 2, 1);
999
1000 /* Valid test cases */
1001 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, 1);
1002 expect(Ok, status);
1003
1004 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, 2, 2);
1005 expect(Ok, status);
1006
1007 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, -2);
1008 expect(Ok, status);
1009
1010 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 1, 0);
1011 expect(Ok, status);
1012
1013 GdipDeletePen(pen);
1014 GdipDeleteGraphics(graphics);
1015
1016 ReleaseDC(hwnd, hdc);
1017}
1018
1019static void test_GdipDrawCurve2(void)
1020{
1022 GpGraphics *graphics = NULL;
1023 GpPen *pen = NULL;
1024 HDC hdc = GetDC( hwnd );
1025 GpPointF points[3];
1026
1027 points[0].X = 0;
1028 points[0].Y = 0;
1029
1030 points[1].X = 40;
1031 points[1].Y = 20;
1032
1033 points[2].X = 10;
1034 points[2].Y = 40;
1035
1036 /* make a graphics object and pen object */
1037 ok(hdc != NULL, "Expected HDC to be initialized\n");
1038
1039 status = GdipCreateFromHDC(hdc, &graphics);
1040 expect(Ok, status);
1041 ok(graphics != NULL, "Expected graphics to be initialized\n");
1042
1043 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1044 expect(Ok, status);
1045 ok(pen != NULL, "Expected pen to be initialized\n");
1046
1047 /* InvalidParameter cases: null graphics, null pen */
1050
1051 status = GdipDrawCurve2(graphics, NULL, points, 3, 1);
1053
1054 status = GdipDrawCurve2(NULL, pen, points, 3, 1);
1056
1057 /* InvalidParameter cases: invalid count */
1058 status = GdipDrawCurve2(graphics, pen, points, -1, 1);
1060
1061 status = GdipDrawCurve2(graphics, pen, points, 0, 1);
1063
1064 status = GdipDrawCurve2(graphics, pen, points, 1, 1);
1066
1067 /* Valid test cases */
1068 status = GdipDrawCurve2(graphics, pen, points, 2, 1);
1069 expect(Ok, status);
1070
1071 status = GdipDrawCurve2(graphics, pen, points, 3, 2);
1072 expect(Ok, status);
1073
1074 status = GdipDrawCurve2(graphics, pen, points, 3, -2);
1075 expect(Ok, status);
1076
1077 status = GdipDrawCurve2(graphics, pen, points, 3, 0);
1078 expect(Ok, status);
1079
1080 GdipDeletePen(pen);
1081 GdipDeleteGraphics(graphics);
1082
1083 ReleaseDC(hwnd, hdc);
1084}
1085
1086static void test_GdipDrawCurve2I(void)
1087{
1089 GpGraphics *graphics = NULL;
1090 GpPen *pen = NULL;
1091 HDC hdc = GetDC( hwnd );
1092 GpPoint points[3];
1093
1094 points[0].X = 0;
1095 points[0].Y = 0;
1096
1097 points[1].X = 40;
1098 points[1].Y = 20;
1099
1100 points[2].X = 10;
1101 points[2].Y = 40;
1102
1103 /* make a graphics object and pen object */
1104 ok(hdc != NULL, "Expected HDC to be initialized\n");
1105
1106 status = GdipCreateFromHDC(hdc, &graphics);
1107 expect(Ok, status);
1108 ok(graphics != NULL, "Expected graphics to be initialized\n");
1109
1110 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1111 expect(Ok, status);
1112 ok(pen != NULL, "Expected pen to be initialized\n");
1113
1114 /* InvalidParameter cases: null graphics, null pen */
1117
1118 status = GdipDrawCurve2I(graphics, NULL, points, 3, 1);
1120
1121 status = GdipDrawCurve2I(NULL, pen, points, 3, 1);
1123
1124 /* InvalidParameter cases: invalid count */
1125 status = GdipDrawCurve2I(graphics, pen, points, -1, 1);
1127
1128 status = GdipDrawCurve2I(graphics, pen, points, 0, 1);
1130
1131 status = GdipDrawCurve2I(graphics, pen, points, 1, 1);
1133
1134 /* Valid test cases */
1135 status = GdipDrawCurve2I(graphics, pen, points, 2, 1);
1136 expect(Ok, status);
1137
1138 status = GdipDrawCurve2I(graphics, pen, points, 3, 2);
1139 expect(Ok, status);
1140
1141 status = GdipDrawCurve2I(graphics, pen, points, 3, -2);
1142 expect(Ok, status);
1143
1144 status = GdipDrawCurve2I(graphics, pen, points, 3, 0);
1145 expect(Ok, status);
1146
1147 GdipDeletePen(pen);
1148 GdipDeleteGraphics(graphics);
1149
1150 ReleaseDC(hwnd, hdc);
1151}
1152
1153static void test_GdipDrawCurve(void)
1154{
1156 GpGraphics *graphics = NULL;
1157 GpPen *pen = NULL;
1158 HDC hdc = GetDC( hwnd );
1159 GpPointF points[3];
1160
1161 points[0].X = 0;
1162 points[0].Y = 0;
1163
1164 points[1].X = 40;
1165 points[1].Y = 20;
1166
1167 points[2].X = 10;
1168 points[2].Y = 40;
1169
1170 /* make a graphics object and pen object */
1171 ok(hdc != NULL, "Expected HDC to be initialized\n");
1172
1173 status = GdipCreateFromHDC(hdc, &graphics);
1174 expect(Ok, status);
1175 ok(graphics != NULL, "Expected graphics to be initialized\n");
1176
1177 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1178 expect(Ok, status);
1179 ok(pen != NULL, "Expected pen to be initialized\n");
1180
1181 /* InvalidParameter cases: null graphics, null pen */
1184
1185 status = GdipDrawCurve(graphics, NULL, points, 3);
1187
1188 status = GdipDrawCurve(NULL, pen, points, 3);
1190
1191 /* InvalidParameter cases: invalid count */
1192 status = GdipDrawCurve(graphics, pen, points, -1);
1194
1195 status = GdipDrawCurve(graphics, pen, points, 0);
1197
1198 status = GdipDrawCurve(graphics, pen, points, 1);
1200
1201 /* Valid test cases */
1202 status = GdipDrawCurve(graphics, pen, points, 2);
1203 expect(Ok, status);
1204
1205 status = GdipDrawCurve(graphics, pen, points, 3);
1206 expect(Ok, status);
1207
1208 GdipDeletePen(pen);
1209 GdipDeleteGraphics(graphics);
1210
1211 ReleaseDC(hwnd, hdc);
1212}
1213
1214static void test_GdipDrawCurveI(void)
1215{
1217 GpGraphics *graphics = NULL;
1218 GpPen *pen = NULL;
1219 HDC hdc = GetDC( hwnd );
1220 GpPoint points[3];
1221
1222 points[0].X = 0;
1223 points[0].Y = 0;
1224
1225 points[1].X = 40;
1226 points[1].Y = 20;
1227
1228 points[2].X = 10;
1229 points[2].Y = 40;
1230
1231 /* make a graphics object and pen object */
1232 ok(hdc != NULL, "Expected HDC to be initialized\n");
1233
1234 status = GdipCreateFromHDC(hdc, &graphics);
1235 expect(Ok, status);
1236 ok(graphics != NULL, "Expected graphics to be initialized\n");
1237
1238 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1239 expect(Ok, status);
1240 ok(pen != NULL, "Expected pen to be initialized\n");
1241
1242 /* InvalidParameter cases: null graphics, null pen */
1245
1246 status = GdipDrawCurveI(graphics, NULL, points, 3);
1248
1249 status = GdipDrawCurveI(NULL, pen, points, 3);
1251
1252 /* InvalidParameter cases: invalid count */
1253 status = GdipDrawCurveI(graphics, pen, points, -1);
1255
1256 status = GdipDrawCurveI(graphics, pen, points, 0);
1258
1259 status = GdipDrawCurveI(graphics, pen, points, 1);
1261
1262 /* Valid test cases */
1263 status = GdipDrawCurveI(graphics, pen, points, 2);
1264 expect(Ok, status);
1265
1266 status = GdipDrawCurveI(graphics, pen, points, 3);
1267 expect(Ok, status);
1268
1269 GdipDeletePen(pen);
1270 GdipDeleteGraphics(graphics);
1271
1272 ReleaseDC(hwnd, hdc);
1273}
1274
1275static void test_GdipDrawLineI(void)
1276{
1278 GpGraphics *graphics = NULL;
1279 GpPen *pen = NULL;
1280 HDC hdc = GetDC( hwnd );
1281
1282 /* make a graphics object and pen object */
1283 ok(hdc != NULL, "Expected HDC to be initialized\n");
1284
1285 status = GdipCreateFromHDC(hdc, &graphics);
1286 expect(Ok, status);
1287 ok(graphics != NULL, "Expected graphics to be initialized\n");
1288
1289 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1290 expect(Ok, status);
1291 ok(pen != NULL, "Expected pen to be initialized\n");
1292
1293 /* InvalidParameter cases: null graphics, null pen */
1294 status = GdipDrawLineI(NULL, NULL, 0, 0, 0, 0);
1296
1297 status = GdipDrawLineI(graphics, NULL, 0, 0, 0, 0);
1299
1300 status = GdipDrawLineI(NULL, pen, 0, 0, 0, 0);
1302
1303 /* successful case */
1304 status = GdipDrawLineI(graphics, pen, 0, 0, 0, 0);
1305 expect(Ok, status);
1306
1307 GdipDeletePen(pen);
1308 GdipDeleteGraphics(graphics);
1309
1310 ReleaseDC(hwnd, hdc);
1311}
1312
1313static void test_GdipDrawImageFX(void)
1314{
1315 GpGraphics *graphics = NULL;
1317 GpBitmap *bm = NULL;
1320 BYTE buff[400];
1321 HDC hdc;
1322
1323#ifdef __REACTOS__
1324 if (!pGdipDrawImageFX)
1325 {
1326 win_skip("GdipDrawImageFX() is not supported.\n");
1327 return;
1328 }
1329#define GdipDrawImageFX pGdipDrawImageFX
1330#endif
1331
1332 if (!(hdc = GetDC( hwnd )))
1333 return;
1334
1335 memset(buff, 0, sizeof(buff));
1337 expect(Ok, status);
1338 ok(NULL != bm, "Expected bitmap to be initialized\n");
1339 status = GdipCreateFromHDC(hdc, &graphics);
1340 expect(Ok, status);
1341
1342 status = GdipCreateMatrix2(2.0, 0.0, 0.0, 1.0, 10.0, 20.0, &transform);
1343 expect(Ok, status);
1344
1345 /* DrawImageFX with source rectangle */
1348
1349 /* DrawImageFX with source bitmap */
1350 status = GdipDrawImageFX(graphics, (GpImage*)bm, NULL, NULL, NULL, NULL, UnitPixel);
1351 expect(Ok, status);
1352
1353 /* DrawImageFX with source bitmap and transform */
1355 expect(Ok, status);
1356
1357 /* DrawImageFX with source bitmap and source rectangle */
1358 source.X = source.Y = 0.0;
1359 source.Height = source.Width = 10.0;
1360
1361 status = GdipDrawImageFX(graphics, (GpImage*)bm, &source, NULL, NULL, NULL, UnitPixel);
1362 expect(Ok, status);
1363
1364 /* DrawImageFX with source bitmap, source rectangle, and transform */
1366 expect(Ok, status);
1367
1369 GdipDeleteGraphics(graphics);
1371 ReleaseDC(hwnd, hdc);
1372}
1373
1375{
1377 GpGraphics *graphics = NULL;
1378 GpPointF ptf[4];
1379 GpBitmap *bm = NULL;
1380 BYTE buff[400];
1381 BITMAPINFOHEADER bmihdr;
1382 HDC hdc = GetDC( hwnd );
1383 if (!hdc)
1384 return;
1385
1386 memset(&bmihdr, 0, sizeof(bmihdr));
1387 bmihdr.biSize = sizeof(BITMAPINFOHEADER);
1388 bmihdr.biWidth = 10;
1389 bmihdr.biHeight = 10;
1390 bmihdr.biPlanes = 1;
1391 bmihdr.biBitCount = 32;
1392 bmihdr.biCompression = BI_RGB;
1394 expect(Ok, status);
1395 ok(NULL != bm, "Expected bitmap to be initialized\n");
1396 status = GdipCreateFromHDC(hdc, &graphics);
1397 expect(Ok, status);
1398 ptf[0].X = 0;
1399 ptf[0].Y = 0;
1400 ptf[1].X = 10;
1401 ptf[1].Y = 0;
1402 ptf[2].X = 0;
1403 ptf[2].Y = 10;
1404 ptf[3].X = 10;
1405 ptf[3].Y = 10;
1406 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 4, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1408 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 5, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1410 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 2, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1412 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1413 expect(Ok, status);
1414 status = GdipDrawImagePointsRect(graphics, NULL, ptf, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1416 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, NULL, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1418 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 0, 0, UnitPixel, NULL, NULL, NULL);
1419 expect(Ok, status);
1420 memset(ptf, 0, sizeof(ptf));
1421 status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL);
1422 expect(Ok, status);
1423
1425 GdipDeleteGraphics(graphics);
1426 ReleaseDC(hwnd, hdc);
1427}
1428
1429static void test_GdipDrawLinesI(void)
1430{
1432 GpGraphics *graphics = NULL;
1433 GpPen *pen = NULL;
1434 GpPoint *ptf = NULL;
1435 HDC hdc = GetDC( hwnd );
1436
1437 /* make a graphics object and pen object */
1438 ok(hdc != NULL, "Expected HDC to be initialized\n");
1439
1440 status = GdipCreateFromHDC(hdc, &graphics);
1441 expect(Ok, status);
1442 ok(graphics != NULL, "Expected graphics to be initialized\n");
1443
1444 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1445 expect(Ok, status);
1446 ok(pen != NULL, "Expected pen to be initialized\n");
1447
1448 /* make some arbitrary valid points*/
1449 ptf = GdipAlloc(2 * sizeof(GpPointF));
1450
1451 ptf[0].X = 1;
1452 ptf[0].Y = 1;
1453
1454 ptf[1].X = 2;
1455 ptf[1].Y = 2;
1456
1457 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1460
1461 status = GdipDrawLinesI(graphics, pen, ptf, 0);
1463
1464 status = GdipDrawLinesI(graphics, NULL, ptf, 2);
1466
1467 status = GdipDrawLinesI(NULL, pen, ptf, 2);
1469
1470 /* successful case */
1471 status = GdipDrawLinesI(graphics, pen, ptf, 2);
1472 expect(Ok, status);
1473
1474 GdipFree(ptf);
1475 GdipDeletePen(pen);
1476 GdipDeleteGraphics(graphics);
1477
1478 ReleaseDC(hwnd, hdc);
1479}
1480
1482{
1484 GpGraphics *graphics = NULL;
1485 GpSolidFill *brush = NULL;
1486 HDC hdc = GetDC( hwnd );
1487 GpPointF points[3];
1488
1489 points[0].X = 0;
1490 points[0].Y = 0;
1491
1492 points[1].X = 40;
1493 points[1].Y = 20;
1494
1495 points[2].X = 10;
1496 points[2].Y = 40;
1497
1498 /* make a graphics object and brush object */
1499 ok(hdc != NULL, "Expected HDC to be initialized\n");
1500
1501 status = GdipCreateFromHDC(hdc, &graphics);
1502 expect(Ok, status);
1503 ok(graphics != NULL, "Expected graphics to be initialized\n");
1504
1505 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1506
1507 /* InvalidParameter cases: null graphics, null brush, null points */
1510
1511 status = GdipFillClosedCurve(graphics, NULL, NULL, 3);
1513
1514 status = GdipFillClosedCurve(NULL, (GpBrush*)brush, NULL, 3);
1516
1519
1520 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, NULL, 3);
1522
1523 status = GdipFillClosedCurve(graphics, NULL, points, 3);
1525
1528
1529 /* InvalidParameter cases: invalid count */
1530 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, -1);
1532
1533 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 0);
1535
1536 /* Valid test cases */
1537 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 1);
1538 expect(Ok, status);
1539
1540 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 2);
1541 expect(Ok, status);
1542
1543 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 3);
1544 expect(Ok, status);
1545
1546 GdipDeleteGraphics(graphics);
1547 GdipDeleteBrush((GpBrush*)brush);
1548
1549 ReleaseDC(hwnd, hdc);
1550}
1551
1553{
1555 GpGraphics *graphics = NULL;
1556 GpSolidFill *brush = NULL;
1557 HDC hdc = GetDC( hwnd );
1558 GpPoint points[3];
1559
1560 points[0].X = 0;
1561 points[0].Y = 0;
1562
1563 points[1].X = 40;
1564 points[1].Y = 20;
1565
1566 points[2].X = 10;
1567 points[2].Y = 40;
1568
1569 /* make a graphics object and brush object */
1570 ok(hdc != NULL, "Expected HDC to be initialized\n");
1571
1572 status = GdipCreateFromHDC(hdc, &graphics);
1573 expect(Ok, status);
1574 ok(graphics != NULL, "Expected graphics to be initialized\n");
1575
1576 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1577
1578 /* InvalidParameter cases: null graphics, null brush */
1579 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1580 when points == NULL, so don't test this condition */
1583
1584 status = GdipFillClosedCurveI(graphics, NULL, points, 3);
1586
1589
1590 /* InvalidParameter cases: invalid count */
1591 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 0);
1593
1594 /* OutOfMemory cases: large (unsigned) int */
1595 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, -1);
1597
1598 /* Valid test cases */
1599 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 1);
1600 expect(Ok, status);
1601
1602 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 2);
1603 expect(Ok, status);
1604
1605 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 3);
1606 expect(Ok, status);
1607
1608 GdipDeleteGraphics(graphics);
1609 GdipDeleteBrush((GpBrush*)brush);
1610
1611 ReleaseDC(hwnd, hdc);
1612}
1613
1614static void test_GdipFillPath(void)
1615{
1617 GpGraphics *graphics;
1618 GpSolidFill *brush;
1619 GpPath *path;
1620 HDC hdc = GetDC(hwnd);
1621
1622 ok(hdc != NULL, "Expected HDC to be initialized\n");
1623 status = GdipCreateFromHDC(hdc, &graphics);
1624 expect(Ok, status);
1625 ok(graphics != NULL, "Expected graphics to be initialized\n");
1626 status = GdipCreateSolidFill((ARGB)0xffffffff, &brush);
1627 expect(Ok, status);
1628 ok(brush != NULL, "Expected brush to be initialized\n");
1630 expect(Ok, status);
1631 ok(path != NULL, "Expected path to be initialized\n");
1632
1633 /* Empty path */
1635 status = GdipFillPath(graphics, (GpBrush *)brush, path);
1636 expect(Ok, status);
1637
1638 /* Not closed path */
1640 status = GdipAddPathLineI(path, 0, 0, 2, 2);
1641 expect(Ok, status);
1642 status = GdipAddPathLineI(path, 2, 2, 4, 0);
1643 expect(Ok, status);
1644 status = GdipFillPath(graphics, (GpBrush *)brush, path);
1645 expect(Ok, status);
1646
1647 /* Closed path */
1649 status = GdipAddPathRectangle(path, 0, 0, 4, 4);
1650 expect(Ok, status);
1651 status = GdipFillPath(graphics, (GpBrush *)brush, path);
1652 expect(Ok, status);
1653
1655 GdipDeleteBrush((GpBrush *)brush);
1656 GdipDeleteGraphics(graphics);
1657 ReleaseDC(hwnd, hdc);
1658}
1659
1660static void test_Get_Release_DC(void)
1661{
1663 GpGraphics *graphics = NULL;
1664 GpPen *pen;
1665 GpSolidFill *brush;
1666 GpPath *path;
1667 HDC hdc = GetDC( hwnd );
1668 HDC retdc;
1669 REAL r;
1671 CompositingMode compmode;
1672 InterpolationMode intmode;
1673 GpMatrix *m;
1674 GpRegion *region;
1675 GpUnit unit;
1676 PixelOffsetMode offsetmode;
1677 SmoothingMode smoothmode;
1678 TextRenderingHint texthint;
1679 GpPointF ptf[5];
1680 GpPoint pt[5];
1681 GpRectF rectf[2];
1682 GpRect rect[2];
1683 GpRegion *clip;
1684 INT i;
1685 BOOL res;
1686 ARGB color = 0x00000000;
1687 HRGN hrgn = CreateRectRgn(0, 0, 10, 10);
1688
1689 pt[0].X = 10;
1690 pt[0].Y = 10;
1691 pt[1].X = 20;
1692 pt[1].Y = 15;
1693 pt[2].X = 40;
1694 pt[2].Y = 80;
1695 pt[3].X = -20;
1696 pt[3].Y = 20;
1697 pt[4].X = 50;
1698 pt[4].Y = 110;
1699
1700 for(i = 0; i < 5;i++){
1701 ptf[i].X = (REAL)pt[i].X;
1702 ptf[i].Y = (REAL)pt[i].Y;
1703 }
1704
1705 rect[0].X = 0;
1706 rect[0].Y = 0;
1707 rect[0].Width = 50;
1708 rect[0].Height = 70;
1709 rect[1].X = 0;
1710 rect[1].Y = 0;
1711 rect[1].Width = 10;
1712 rect[1].Height = 20;
1713
1714 for(i = 0; i < 2;i++){
1715 rectf[i].X = (REAL)rect[i].X;
1716 rectf[i].Y = (REAL)rect[i].Y;
1717 rectf[i].Height = (REAL)rect[i].Height;
1718 rectf[i].Width = (REAL)rect[i].Width;
1719 }
1720
1722 expect(Ok, status);
1723 status = GdipCreateRegion(&region);
1724 expect(Ok, status);
1725 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1727 status = GdipCreateRegion(&clip);
1728 expect(Ok, status);
1729
1730 status = GdipCreateFromHDC(hdc, &graphics);
1731 expect(Ok, status);
1732 ok(graphics != NULL, "Expected graphics to be initialized\n");
1733 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1734 expect(Ok, status);
1735
1736 /* NULL arguments */
1739 status = GdipGetDC(graphics, NULL);
1741 status = GdipGetDC(NULL, &retdc);
1743
1746 status = GdipReleaseDC(graphics, NULL);
1748 status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
1750
1751 /* Release without Get */
1752 status = GdipReleaseDC(graphics, hdc);
1754
1755 retdc = NULL;
1756 status = GdipGetDC(graphics, &retdc);
1757 expect(Ok, status);
1758 ok(retdc == hdc, "Invalid HDC returned\n");
1759 /* call it once more */
1760 status = GdipGetDC(graphics, &retdc);
1762
1763 /* try all Graphics calls here */
1764 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1766 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
1768 status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1770 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
1772 status = GdipDrawBeziers(graphics, pen, ptf, 5);
1774 status = GdipDrawBeziersI(graphics, pen, pt, 5);
1776 status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
1778 status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
1780 status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
1782 status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
1784 status = GdipDrawCurve(graphics, pen, ptf, 5);
1786 status = GdipDrawCurveI(graphics, pen, pt, 5);
1788 status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
1790 status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
1792 status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
1794 status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
1796 /* GdipDrawImage/GdipDrawImageI */
1797 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1798 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1799 /* GdipDrawImageRect/GdipDrawImageRectI */
1800 status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
1802 status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
1804 status = GdipDrawLines(graphics, pen, ptf, 5);
1806 status = GdipDrawLinesI(graphics, pen, pt, 5);
1808 status = GdipDrawPath(graphics, pen, path);
1810 status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1812 status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
1814 status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
1816 status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
1818 status = GdipDrawRectangles(graphics, pen, rectf, 2);
1820 status = GdipDrawRectanglesI(graphics, pen, rect, 2);
1822 /* GdipDrawString */
1823 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0, FillModeAlternate);
1825 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0, FillModeAlternate);
1827 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, ptf, 5);
1829 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, pt, 5);
1831 status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1833 status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1835 status = GdipFillPath(graphics, (GpBrush*)brush, path);
1837 status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1839 status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
1841 status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
1843 status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
1845 status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
1847 status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
1849 status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1851 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1853 status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
1855 status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
1857 status = GdipFillRegion(graphics, (GpBrush*)brush, region);
1861 status = GdipGetClipBounds(graphics, rectf);
1863 status = GdipGetClipBoundsI(graphics, rect);
1865 status = GdipGetCompositingMode(graphics, &compmode);
1869 status = GdipGetInterpolationMode(graphics, &intmode);
1871 status = GdipGetNearestColor(graphics, &color);
1873 status = GdipGetPageScale(graphics, &r);
1875 status = GdipGetPageUnit(graphics, &unit);
1877 status = GdipGetPixelOffsetMode(graphics, &offsetmode);
1879 status = GdipGetSmoothingMode(graphics, &smoothmode);
1881 status = GdipGetTextRenderingHint(graphics, &texthint);
1883 status = GdipGetWorldTransform(graphics, m);
1885 status = GdipGraphicsClear(graphics, 0xdeadbeef);
1887 status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
1889 status = GdipIsVisiblePointI(graphics, 0, 0, &res);
1891 /* GdipMeasureCharacterRanges */
1892 /* GdipMeasureString */
1893 status = GdipResetClip(graphics);
1895 status = GdipResetPageTransform(graphics);
1897 status = GdipResetWorldTransform(graphics);
1899 /* GdipRestoreGraphics */
1902 /* GdipSaveGraphics */
1903 status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
1911 status = GdipSetPageScale(graphics, 1.0);
1913 status = GdipSetPageScale(graphics, 0.0);
1915 status = GdipSetPageUnit(graphics, UnitWorld);
1923 status = GdipSetWorldTransform(graphics, m);
1931 status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
1933 status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
1935 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1937 status = GdipTranslateClip(graphics, 0.0, 0.0);
1939 status = GdipTranslateClipI(graphics, 0, 0);
1941 status = GdipDrawPolygon(graphics, pen, ptf, 5);
1943 status = GdipDrawPolygonI(graphics, pen, pt, 5);
1945 status = GdipGetDpiX(graphics, &r);
1947 status = GdipGetDpiY(graphics, &r);
1951 status = GdipGetClip(graphics, region);
1955
1956 /* try to delete before release */
1957 status = GdipDeleteGraphics(graphics);
1959
1960 status = GdipReleaseDC(graphics, retdc);
1961 expect(Ok, status);
1962
1963 GdipDeletePen(pen);
1964 GdipDeleteGraphics(graphics);
1965
1966 GdipDeleteRegion(clip);
1968 GdipDeleteBrush((GpBrush*)brush);
1969 GdipDeleteRegion(region);
1972
1973 ReleaseDC(hwnd, hdc);
1974}
1975
1976static void test_transformpoints(void)
1977{
1979 GpGraphics *graphics = NULL;
1980 HDC hdc = GetDC( hwnd );
1981 GpPointF ptf[2];
1982 GpPoint pt[2];
1983
1984 status = GdipCreateFromHDC(hdc, &graphics);
1985 expect(Ok, status);
1986
1987 /* NULL arguments */
1996
1999 status = GdipTransformPoints(graphics, -1, CoordinateSpaceWorld, ptf, 2);
2003 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, -1, ptf, 2);
2005
2006 ptf[0].X = 1.0;
2007 ptf[0].Y = 0.0;
2008 ptf[1].X = 0.0;
2009 ptf[1].Y = 1.0;
2011 expect(Ok, status);
2012 expectf(1.0, ptf[0].X);
2013 expectf(0.0, ptf[0].Y);
2014 expectf(0.0, ptf[1].X);
2015 expectf(1.0, ptf[1].Y);
2016
2018 expect(Ok, status);
2019 status = GdipSetPageUnit(graphics, UnitPixel);
2020 expect(Ok, status);
2021 status = GdipSetPageScale(graphics, 3.0);
2022 expect(Ok, status);
2023
2024 ptf[0].X = 1.0;
2025 ptf[0].Y = 0.0;
2026 ptf[1].X = 0.0;
2027 ptf[1].Y = 1.0;
2029 expect(Ok, status);
2030 expectf(18.0, ptf[0].X);
2031 expectf(15.0, ptf[0].Y);
2032 expectf(15.0, ptf[1].X);
2033 expectf(18.0, ptf[1].Y);
2034
2035 ptf[0].X = 1.0;
2036 ptf[0].Y = 0.0;
2037 ptf[1].X = 0.0;
2038 ptf[1].Y = 1.0;
2040 expect(Ok, status);
2041 expectf(6.0, ptf[0].X);
2042 expectf(5.0, ptf[0].Y);
2043 expectf(5.0, ptf[1].X);
2044 expectf(6.0, ptf[1].Y);
2045
2046 ptf[0].X = 1.0;
2047 ptf[0].Y = 0.0;
2048 ptf[1].X = 0.0;
2049 ptf[1].Y = 1.0;
2051 expect(Ok, status);
2052 expectf(3.0, ptf[0].X);
2053 expectf(0.0, ptf[0].Y);
2054 expectf(0.0, ptf[1].X);
2055 expectf(3.0, ptf[1].Y);
2056
2057 ptf[0].X = 18.0;
2058 ptf[0].Y = 15.0;
2059 ptf[1].X = 15.0;
2060 ptf[1].Y = 18.0;
2062 expect(Ok, status);
2063 expectf(1.0, ptf[0].X);
2064 expectf(0.0, ptf[0].Y);
2065 expectf(0.0, ptf[1].X);
2066 expectf(1.0, ptf[1].Y);
2067
2068 ptf[0].X = 6.0;
2069 ptf[0].Y = 5.0;
2070 ptf[1].X = 5.0;
2071 ptf[1].Y = 6.0;
2073 expect(Ok, status);
2074 expectf(1.0, ptf[0].X);
2075 expectf(0.0, ptf[0].Y);
2076 expectf(0.0, ptf[1].X);
2077 expectf(1.0, ptf[1].Y);
2078
2079 ptf[0].X = 3.0;
2080 ptf[0].Y = 0.0;
2081 ptf[1].X = 0.0;
2082 ptf[1].Y = 3.0;
2084 expect(Ok, status);
2085 expectf(1.0, ptf[0].X);
2086 expectf(0.0, ptf[0].Y);
2087 expectf(0.0, ptf[1].X);
2088 expectf(1.0, ptf[1].Y);
2089
2090 pt[0].X = 1;
2091 pt[0].Y = 0;
2092 pt[1].X = 0;
2093 pt[1].Y = 1;
2095 expect(Ok, status);
2096 expect(18, pt[0].X);
2097 expect(15, pt[0].Y);
2098 expect(15, pt[1].X);
2099 expect(18, pt[1].Y);
2100
2101 GdipDeleteGraphics(graphics);
2102 ReleaseDC(hwnd, hdc);
2103}
2104
2105static void test_get_set_clip(void)
2106{
2108 GpGraphics *graphics = NULL;
2109 HDC hdc = GetDC( hwnd );
2110 GpRegion *clip;
2111 GpRectF rect;
2112 BOOL res;
2113
2114 status = GdipCreateFromHDC(hdc, &graphics);
2115 expect(Ok, status);
2116
2117 rect.X = rect.Y = 0.0;
2118 rect.Height = rect.Width = 100.0;
2119
2120 status = GdipCreateRegionRect(&rect, &clip);
2121 expect(Ok, status);
2122
2123 /* NULL arguments */
2126 status = GdipGetClip(graphics, NULL);
2128 status = GdipGetClip(NULL, clip);
2130
2135
2140
2141 res = FALSE;
2142 status = GdipGetClip(graphics, clip);
2143 expect(Ok, status);
2144 status = GdipIsInfiniteRegion(clip, graphics, &res);
2145 expect(Ok, status);
2146 expect(TRUE, res);
2147
2148 /* remains infinite after reset */
2149 res = FALSE;
2150 status = GdipResetClip(graphics);
2151 expect(Ok, status);
2152 status = GdipGetClip(graphics, clip);
2153 expect(Ok, status);
2154 status = GdipIsInfiniteRegion(clip, graphics, &res);
2155 expect(Ok, status);
2156 expect(TRUE, res);
2157
2158 /* set to empty and then reset to infinite */
2159 status = GdipSetEmpty(clip);
2160 expect(Ok, status);
2161 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
2162 expect(Ok, status);
2163
2164 status = GdipGetClip(graphics, clip);
2165 expect(Ok, status);
2166 res = FALSE;
2167 status = GdipIsEmptyRegion(clip, graphics, &res);
2168 expect(Ok, status);
2169 expect(TRUE, res);
2170 status = GdipResetClip(graphics);
2171 expect(Ok, status);
2172 status = GdipGetClip(graphics, clip);
2173 expect(Ok, status);
2174 res = FALSE;
2175 status = GdipIsInfiniteRegion(clip, graphics, &res);
2176 expect(Ok, status);
2177 expect(TRUE, res);
2178
2179 GdipDeleteRegion(clip);
2180
2181 GdipDeleteGraphics(graphics);
2182 ReleaseDC(hwnd, hdc);
2183}
2184
2185static void test_clip_xform(void)
2186{
2188 GpGraphics *graphics = NULL;
2189 HDC hdc = GetDC( hwnd );
2190 GpRegion *clip;
2192 UINT region_data_size;
2193 struct {
2194 DWORD size;
2196 DWORD magic;
2197 DWORD num_children;
2198 DWORD element_type;
2199 REAL x;
2200 REAL y;
2201 REAL width;
2202 REAL height;
2203 } region_data;
2204
2205 status = GdipCreateFromHDC(hdc, &graphics);
2206 expect(Ok, status);
2207 status = GdipCreateRegion(&clip);
2208 expect(Ok, status);
2209
2210 status = GdipGraphicsClear(graphics, 0xff000000);
2211 expect(Ok, status);
2212
2213 status = GdipSetClipRect(graphics, 10, 10, -10, -10, CombineModeReplace);
2214 expect(Ok, status);
2215 status = GdipGetClip(graphics, clip);
2216 expect(Ok, status);
2217 status = GdipGetRegionData(clip, (BYTE*)&region_data, sizeof(region_data), &region_data_size);
2218 expect(Ok, status);
2219 expect(36, region_data_size);
2220 expect(28, region_data.size);
2221 expect(0, region_data.num_children);
2222 expect(0x10000000 /* RegionDataRect */, region_data.element_type);
2223 expectf(0.0, region_data.x);
2224 expectf(0.0, region_data.y);
2225 expectf(10.0, region_data.width);
2226 expectf(10.0, region_data.height);
2227
2228 /* No effect with negative width/height */
2229 status = GdipGraphicsClear(graphics, 0xffff0000);
2230 expect(Ok, status);
2231 color = GetPixel(hdc, 5, 5);
2232 expect(0, color);
2233
2234 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderAppend);
2235 expect(Ok, status);
2236
2237 status = GdipGraphicsClear(graphics, 0xffff0000);
2238 expect(Ok, status);
2239 color = GetPixel(hdc, 5, 5);
2240 expect(0, color);
2241
2242 status = GdipResetClip(graphics);
2243 expect(Ok, status);
2244 status = GdipResetWorldTransform(graphics);
2245 expect(Ok, status);
2246 status = GdipGraphicsClear(graphics, 0xff000000);
2247 expect(Ok, status);
2248
2249 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderAppend);
2250 expect(Ok, status);
2251
2252 status = GdipSetClipRect(graphics, 5, 5, -5, -5, CombineModeReplace);
2253 expect(Ok, status);
2254 status = GdipGetClip(graphics, clip);
2255 expect(Ok, status);
2256 status = GdipGetRegionData(clip, (BYTE*)&region_data, sizeof(region_data), &region_data_size);
2257 expect(Ok, status);
2258 expect(36, region_data_size);
2259 expect(28, region_data.size);
2260 expect(0, region_data.num_children);
2261 expect(0x10000000 /* RegionDataRect */, region_data.element_type);
2262 expectf(0.0, region_data.x);
2263 expectf(0.0, region_data.y);
2264 expectf(5.0, region_data.width);
2265 expectf(5.0, region_data.height);
2266
2267 status = GdipGraphicsClear(graphics, 0xffff0000);
2268 expect(Ok, status);
2269 color = GetPixel(hdc, 5, 5);
2270 expect(0xff, color);
2271
2272 GdipDeleteGraphics(graphics);
2273 GdipDeleteRegion(clip);
2274 ReleaseDC(hwnd, hdc);
2275}
2276
2277static void test_isempty(void)
2278{
2280 GpGraphics *graphics = NULL;
2281 HDC hdc = GetDC( hwnd );
2282 GpRegion *clip;
2283 BOOL res;
2284
2285 status = GdipCreateFromHDC(hdc, &graphics);
2286 expect(Ok, status);
2287
2288 status = GdipCreateRegion(&clip);
2289 expect(Ok, status);
2290
2291 /* NULL */
2294 status = GdipIsClipEmpty(graphics, NULL);
2298
2299 /* default is infinite */
2300 res = TRUE;
2301 status = GdipIsClipEmpty(graphics, &res);
2302 expect(Ok, status);
2303 expect(FALSE, res);
2304
2305 GdipDeleteRegion(clip);
2306
2307 GdipDeleteGraphics(graphics);
2308 ReleaseDC(hwnd, hdc);
2309}
2310
2311static void test_clear(void)
2312{
2314
2315 status = GdipGraphicsClear(NULL, 0xdeadbeef);
2317}
2318
2319static void test_textcontrast(void)
2320{
2322 HDC hdc = GetDC( hwnd );
2323 GpGraphics *graphics;
2324 UINT contrast;
2325
2328
2329 status = GdipCreateFromHDC(hdc, &graphics);
2330 expect(Ok, status);
2331
2332 status = GdipGetTextContrast(graphics, NULL);
2334 status = GdipGetTextContrast(graphics, &contrast);
2335 expect(Ok, status);
2336 expect(4, contrast);
2337
2338 GdipDeleteGraphics(graphics);
2339 ReleaseDC(hwnd, hdc);
2340}
2341
2342static void test_GdipDrawString(void)
2343{
2345 GpGraphics *graphics = NULL;
2346 GpFont *fnt = NULL;
2347 RectF rect;
2349 GpBrush *brush;
2350 LOGFONTA logfont;
2351 HDC hdc = GetDC( hwnd ), temp_hdc;
2352 static const WCHAR string[] = L"Test";
2353 static const PointF positions[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2355
2356 memset(&logfont,0,sizeof(logfont));
2357 strcpy(logfont.lfFaceName,"Arial");
2358 logfont.lfHeight = 12;
2359 logfont.lfCharSet = DEFAULT_CHARSET;
2360
2361 status = GdipCreateFromHDC(hdc, &graphics);
2362 expect(Ok, status);
2363
2364 status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
2366 {
2367 skip("Arial not installed.\n");
2368 return;
2369 }
2370 expect(Ok, status);
2371
2373 expect(Ok, status);
2374
2376 {
2377 status = GdipCreateSolidFill(0xFF000000, (GpSolidFill**)&brush);
2378 expect(Ok, status);
2379 rect.X = 0;
2380 rect.Y = 0;
2381 rect.Width = 0;
2382 rect.Height = 14;
2385 GdipGraphicsClear(graphics, 0xFFFFFFFF);
2386 status = GdipDrawString(graphics, L"\u8336Hola\u8336", 6, fnt, &rect, format, brush);
2387 expect(Ok, status);
2388 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); /* FIXME: In Windows this test works without this line. */
2389 Sleep(4000);
2390 GdipDeleteBrush(brush);
2391 GdipResetWorldTransform(graphics);
2392 }
2393
2394 status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
2395 expect(Ok, status);
2396
2397 rect.X = 0;
2398 rect.Y = 0;
2399 rect.Width = 0;
2400 rect.Height = 12;
2401
2402 status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
2403 expect(Ok, status);
2404
2405 status = GdipGetDC(graphics, &temp_hdc);
2406 expect(Ok, status);
2407 ok(temp_hdc != NULL, "got NULL temp_hdc\n");
2408
2409 status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
2411
2412 status = GdipReleaseDC(graphics, temp_hdc);
2413 expect(Ok, status);
2414
2416 expect(Ok, status);
2417
2418 status = GdipDrawDriverString(NULL, string, 4, fnt, brush, positions, DriverStringOptionsCmapLookup, matrix);
2420
2421 status = GdipDrawDriverString(graphics, NULL, 4, fnt, brush, positions, DriverStringOptionsCmapLookup, matrix);
2423
2424 status = GdipDrawDriverString(graphics, string, 4, NULL, brush, positions, DriverStringOptionsCmapLookup, matrix);
2426
2427 status = GdipDrawDriverString(graphics, string, 4, fnt, NULL, positions, DriverStringOptionsCmapLookup, matrix);
2429
2430 status = GdipDrawDriverString(graphics, string, 4, fnt, brush, NULL, DriverStringOptionsCmapLookup, matrix);
2432
2433 status = GdipDrawDriverString(graphics, string, 4, fnt, brush, positions, DriverStringOptionsCmapLookup|0x10, matrix);
2434 expect(Ok, status);
2435
2436 status = GdipDrawDriverString(graphics, string, 4, fnt, brush, positions, DriverStringOptionsCmapLookup, NULL);
2437 expect(Ok, status);
2438
2439 status = GdipDrawDriverString(graphics, string, 4, fnt, brush, positions, DriverStringOptionsCmapLookup, matrix);
2440 expect(Ok, status);
2441
2443 GdipDeleteGraphics(graphics);
2444 GdipDeleteBrush(brush);
2445 GdipDeleteFont(fnt);
2447
2448 ReleaseDC(hwnd, hdc);
2449}
2450
2452{
2454 GpGraphics *graphics = NULL;
2455 HDC hdc = GetDC(0);
2456 GpRectF rectf, exp, clipr;
2457 GpRect recti;
2458
2459 ok(hdc != NULL, "Expected HDC to be initialized\n");
2460
2461 status = GdipCreateFromHDC(hdc, &graphics);
2462 expect(Ok, status);
2463 ok(graphics != NULL, "Expected graphics to be initialized\n");
2464
2465 /* no clipping rect */
2466 exp.X = 0;
2467 exp.Y = 0;
2468 exp.Width = GetDeviceCaps(hdc, HORZRES);
2469 exp.Height = GetDeviceCaps(hdc, VERTRES);
2470
2471 status = GdipGetVisibleClipBounds(graphics, &rectf);
2472 expect(Ok, status);
2473 ok(rectf.X == exp.X &&
2474 rectf.Y == exp.Y &&
2475 rectf.Width == exp.Width &&
2476 rectf.Height == exp.Height,
2477 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2478 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2479 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2480 exp.X, exp.Y, exp.Width, exp.Height);
2481
2482 /* clipping rect entirely within window */
2483 exp.X = clipr.X = 10;
2484 exp.Y = clipr.Y = 12;
2485 exp.Width = clipr.Width = 14;
2486 exp.Height = clipr.Height = 16;
2487
2488 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2489 expect(Ok, status);
2490
2491 status = GdipGetVisibleClipBounds(graphics, &rectf);
2492 expect(Ok, status);
2493 ok(rectf.X == exp.X &&
2494 rectf.Y == exp.Y &&
2495 rectf.Width == exp.Width &&
2496 rectf.Height == exp.Height,
2497 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2498 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2499 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2500 exp.X, exp.Y, exp.Width, exp.Height);
2501
2502 /* clipping rect partially outside of screen */
2503 clipr.X = -10;
2504 clipr.Y = -12;
2505 clipr.Width = 20;
2506 clipr.Height = 24;
2507
2508 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2509 expect(Ok, status);
2510
2511 exp.X = 0;
2512 exp.Y = 0;
2513 exp.Width = 10;
2514 exp.Height = 12;
2515
2516 status = GdipGetVisibleClipBounds(graphics, &rectf);
2517 expect(Ok, status);
2518 ok(rectf.X == exp.X &&
2519 rectf.Y == exp.Y &&
2520 rectf.Width == exp.Width &&
2521 rectf.Height == exp.Height,
2522 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2523 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2524 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2525 exp.X, exp.Y, exp.Width, exp.Height);
2526
2527 status = GdipGetVisibleClipBoundsI(graphics, &recti);
2528 expect(Ok, status);
2529 ok(recti.X == exp.X &&
2530 recti.Y == exp.Y &&
2531 recti.Width == exp.Width &&
2532 recti.Height == exp.Height,
2533 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2534 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2535 recti.X, recti.Y, recti.Width, recti.Height,
2536 exp.X, exp.Y, exp.Width, exp.Height);
2537
2538 GdipDeleteGraphics(graphics);
2539 ReleaseDC(0, hdc);
2540}
2541
2543{
2545 GpGraphics *graphics = NULL;
2546 GpRectF rectf, window, exp, clipr;
2547 GpRect recti;
2548 HDC hdc;
2549 PAINTSTRUCT ps;
2550 RECT wnd_rect;
2551
2552 /* get client area size */
2553 ok(GetClientRect(hwnd, &wnd_rect), "GetClientRect should have succeeded\n");
2554 window.X = wnd_rect.left;
2555 window.Y = wnd_rect.top;
2556 window.Width = wnd_rect.right - wnd_rect.left;
2557 window.Height = wnd_rect.bottom - wnd_rect.top;
2558
2559 hdc = BeginPaint(hwnd, &ps);
2560
2561 status = GdipCreateFromHDC(hdc, &graphics);
2562 expect(Ok, status);
2563 ok(graphics != NULL, "Expected graphics to be initialized\n");
2564
2565 status = GdipGetVisibleClipBounds(graphics, &rectf);
2566 expect(Ok, status);
2567 ok(rectf.X == window.X &&
2568 rectf.Y == window.Y &&
2569 rectf.Width == window.Width &&
2570 rectf.Height == window.Height,
2571 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2572 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2573 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2574 window.X, window.Y, window.Width, window.Height);
2575
2576 /* clipping rect entirely within window */
2577 exp.X = clipr.X = 20;
2578 exp.Y = clipr.Y = 8;
2579 exp.Width = clipr.Width = 30;
2580 exp.Height = clipr.Height = 20;
2581
2582 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2583 expect(Ok, status);
2584
2585 status = GdipGetVisibleClipBounds(graphics, &rectf);
2586 expect(Ok, status);
2587 ok(rectf.X == exp.X &&
2588 rectf.Y == exp.Y &&
2589 rectf.Width == exp.Width &&
2590 rectf.Height == exp.Height,
2591 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2592 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2593 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2594 exp.X, exp.Y, exp.Width, exp.Height);
2595
2596 /* clipping rect partially outside of window */
2597 clipr.X = window.Width - 10;
2598 clipr.Y = window.Height - 15;
2599 clipr.Width = 20;
2600 clipr.Height = 30;
2601
2602 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2603 expect(Ok, status);
2604
2605 exp.X = window.Width - 10;
2606 exp.Y = window.Height - 15;
2607 exp.Width = 10;
2608 exp.Height = 15;
2609
2610 status = GdipGetVisibleClipBounds(graphics, &rectf);
2611 expect(Ok, status);
2612 ok(rectf.X == exp.X &&
2613 rectf.Y == exp.Y &&
2614 rectf.Width == exp.Width &&
2615 rectf.Height == exp.Height,
2616 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2617 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2618 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2619 exp.X, exp.Y, exp.Width, exp.Height);
2620
2621 status = GdipGetVisibleClipBoundsI(graphics, &recti);
2622 expect(Ok, status);
2623 ok(recti.X == exp.X &&
2624 recti.Y == exp.Y &&
2625 recti.Width == exp.Width &&
2626 recti.Height == exp.Height,
2627 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2628 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2629 recti.X, recti.Y, recti.Width, recti.Height,
2630 exp.X, exp.Y, exp.Width, exp.Height);
2631
2632 /* window bounds with transform applied */
2633 status = GdipResetClip(graphics);
2634 expect(Ok, status);
2635
2636 status = GdipScaleWorldTransform(graphics, 0.5, 0.5, MatrixOrderPrepend);
2637 expect(Ok, status);
2638
2639 exp.X = window.X * 2.0;
2640 exp.Y = window.Y * 2.0;
2641 exp.Width = window.Width * 2.0;
2642 exp.Height = window.Height * 2.0;
2643
2644 status = GdipGetVisibleClipBounds(graphics, &rectf);
2645 expect(Ok, status);
2646 ok(rectf.X == exp.X &&
2647 rectf.Y == exp.Y &&
2648 rectf.Width == exp.Width &&
2649 rectf.Height == exp.Height,
2650 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2651 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2652 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2653 exp.X, exp.Y, exp.Width, exp.Height);
2654
2655 GdipDeleteGraphics(graphics);
2656 EndPaint(hwnd, &ps);
2657}
2658
2660{
2661 GpGraphics* graphics = NULL;
2662 GpRectF rectf;
2663 GpRect rect;
2664 HDC hdc = GetDC( hwnd );
2666
2667 status = GdipCreateFromHDC(hdc, &graphics);
2668 expect(Ok, status);
2669 ok(graphics != NULL, "Expected graphics to be initialized\n");
2670
2671 /* test null parameters */
2674
2677
2680
2683
2684 GdipDeleteGraphics(graphics);
2685 ReleaseDC(hwnd, hdc);
2686
2689}
2690
2691static void test_fromMemoryBitmap(void)
2692{
2694 GpGraphics *graphics = NULL;
2695 GpBitmap *bitmap = NULL;
2696 BYTE bits[48] = {0};
2697 HDC hdc=NULL;
2699
2701 expect(Ok, status);
2702
2704 expect(Ok, status);
2705
2706 status = GdipGraphicsClear(graphics, 0xff686868);
2707 expect(Ok, status);
2708
2709 GdipDeleteGraphics(graphics);
2710
2711 /* drawing writes to the memory provided */
2712 expect(0x68, bits[10]);
2713
2715 expect(Ok, status);
2716
2717 status = GdipGetDC(graphics, &hdc);
2718 expect(Ok, status);
2719 ok(hdc != NULL, "got NULL hdc\n");
2720
2721 color = GetPixel(hdc, 0, 0);
2722 /* The HDC is write-only, and native fills with a solid color to figure out
2723 * which pixels have changed. */
2724 expect(0x0c0b0d, color);
2725
2726 SetPixel(hdc, 0, 0, 0x797979);
2727 SetPixel(hdc, 1, 0, 0x0c0b0d);
2728
2729 status = GdipReleaseDC(graphics, hdc);
2730 expect(Ok, status);
2731
2732 GdipDeleteGraphics(graphics);
2733
2734 expect(0x79, bits[0]);
2735 expect(0x68, bits[3]);
2736
2738
2739 /* We get the same kind of write-only HDC for a "normal" bitmap */
2741 expect(Ok, status);
2742
2744 expect(Ok, status);
2745
2746 status = GdipGetDC(graphics, &hdc);
2747 expect(Ok, status);
2748 ok(hdc != NULL, "got NULL hdc\n");
2749
2750 color = GetPixel(hdc, 0, 0);
2751 expect(0x0c0b0d, color);
2752
2753 status = GdipReleaseDC(graphics, hdc);
2754 expect(Ok, status);
2755
2756 GdipDeleteGraphics(graphics);
2757
2759
2760 /* If we don't draw to the HDC, the bits are never accessed */
2762 expect(Ok, status);
2763
2765 expect(Ok, status);
2766
2767 status = GdipGetDC(graphics, &hdc);
2768 expect(Ok, status);
2769 ok(hdc != NULL, "got NULL hdc\n");
2770
2771 color = GetPixel(hdc, 0, 0);
2772 expect(0x0c0b0d, color);
2773
2774 status = GdipReleaseDC(graphics, hdc);
2775 expect(Ok, status);
2776
2777 GdipDeleteGraphics(graphics);
2778
2780}
2781
2783{
2785 GpGraphics *graphics = NULL;
2786 HDC hdc = GetDC( hwnd );
2787 REAL x, y;
2788 BOOL val;
2789
2790 ok(hdc != NULL, "Expected HDC to be initialized\n");
2791
2792 status = GdipCreateFromHDC(hdc, &graphics);
2793 expect(Ok, status);
2794 ok(graphics != NULL, "Expected graphics to be initialized\n");
2795
2796 /* null parameters */
2797 status = GdipIsVisiblePoint(NULL, 0, 0, &val);
2799
2800 status = GdipIsVisiblePoint(graphics, 0, 0, NULL);
2802
2805
2806 status = GdipIsVisiblePointI(graphics, 0, 0, NULL);
2808
2809 x = 0;
2810 y = 0;
2811 status = GdipIsVisiblePoint(graphics, x, y, &val);
2812 expect(Ok, status);
2813 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2814
2815 x = -10;
2816 y = 0;
2817 status = GdipIsVisiblePoint(graphics, x, y, &val);
2818 expect(Ok, status);
2819 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2820
2821 x = 0;
2822 y = -5;
2823 status = GdipIsVisiblePoint(graphics, x, y, &val);
2824 expect(Ok, status);
2825 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2826
2827 x = 1;
2828 y = 1;
2829 status = GdipIsVisiblePoint(graphics, x, y, &val);
2830 expect(Ok, status);
2831 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2832
2833 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2834 expect(Ok, status);
2835
2836 x = 1;
2837 y = 1;
2838 status = GdipIsVisiblePoint(graphics, x, y, &val);
2839 expect(Ok, status);
2840 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2841
2842 x = 15.5;
2843 y = 40.5;
2844 status = GdipIsVisiblePoint(graphics, x, y, &val);
2845 expect(Ok, status);
2846 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2847
2848 /* translate into the center of the rect */
2850
2851 x = 0;
2852 y = 0;
2853 status = GdipIsVisiblePoint(graphics, x, y, &val);
2854 expect(Ok, status);
2855 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2856
2857 x = 25;
2858 y = 40;
2859 status = GdipIsVisiblePoint(graphics, x, y, &val);
2860 expect(Ok, status);
2861 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2862
2864
2865 /* corner cases */
2866 x = 9;
2867 y = 19;
2868 status = GdipIsVisiblePoint(graphics, x, y, &val);
2869 expect(Ok, status);
2870 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2871
2872 x = 9.25;
2873 y = 19.25;
2874 status = GdipIsVisiblePoint(graphics, x, y, &val);
2875 expect(Ok, status);
2876 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2877
2878 x = 9.5;
2879 y = 19.5;
2880 status = GdipIsVisiblePoint(graphics, x, y, &val);
2881 expect(Ok, status);
2882 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2883
2884 x = 9.75;
2885 y = 19.75;
2886 status = GdipIsVisiblePoint(graphics, x, y, &val);
2887 expect(Ok, status);
2888 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2889
2890 x = 10;
2891 y = 20;
2892 status = GdipIsVisiblePoint(graphics, x, y, &val);
2893 expect(Ok, status);
2894 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2895
2896 x = 40;
2897 y = 20;
2898 status = GdipIsVisiblePoint(graphics, x, y, &val);
2899 expect(Ok, status);
2900 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2901
2902 x = 39;
2903 y = 59;
2904 status = GdipIsVisiblePoint(graphics, x, y, &val);
2905 expect(Ok, status);
2906 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2907
2908 x = 39.25;
2909 y = 59.25;
2910 status = GdipIsVisiblePoint(graphics, x, y, &val);
2911 expect(Ok, status);
2912 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2913
2914 x = 39.5;
2915 y = 39.5;
2916 status = GdipIsVisiblePoint(graphics, x, y, &val);
2917 expect(Ok, status);
2918 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2919
2920 x = 39.75;
2921 y = 59.75;
2922 status = GdipIsVisiblePoint(graphics, x, y, &val);
2923 expect(Ok, status);
2924 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2925
2926 x = 40;
2927 y = 60;
2928 status = GdipIsVisiblePoint(graphics, x, y, &val);
2929 expect(Ok, status);
2930 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2931
2932 x = 40.15;
2933 y = 60.15;
2934 status = GdipIsVisiblePoint(graphics, x, y, &val);
2935 expect(Ok, status);
2936 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2937
2938 x = 10;
2939 y = 60;
2940 status = GdipIsVisiblePoint(graphics, x, y, &val);
2941 expect(Ok, status);
2942 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2943
2944 /* integer version */
2945 x = 25;
2946 y = 30;
2947 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2948 expect(Ok, status);
2949 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2950
2951 x = 50;
2952 y = 100;
2953 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2954 expect(Ok, status);
2955 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2956
2957 GdipDeleteGraphics(graphics);
2958 ReleaseDC(hwnd, hdc);
2959}
2960
2961static void test_GdipIsVisibleRect(void)
2962{
2964 GpGraphics *graphics = NULL;
2965 HDC hdc = GetDC( hwnd );
2966 REAL x, y, width, height;
2967 BOOL val;
2968
2969 ok(hdc != NULL, "Expected HDC to be initialized\n");
2970
2971 status = GdipCreateFromHDC(hdc, &graphics);
2972 expect(Ok, status);
2973 ok(graphics != NULL, "Expected graphics to be initialized\n");
2974
2975 status = GdipIsVisibleRect(NULL, 0, 0, 0, 0, &val);
2977
2978 status = GdipIsVisibleRect(graphics, 0, 0, 0, 0, NULL);
2980
2981 status = GdipIsVisibleRectI(NULL, 0, 0, 0, 0, &val);
2983
2984 status = GdipIsVisibleRectI(graphics, 0, 0, 0, 0, NULL);
2986
2987 /* entirely within the visible region */
2988 x = 0; width = 10;
2989 y = 0; height = 10;
2990 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2991 expect(Ok, status);
2992 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2993
2994 /* partially outside */
2995 x = -10; width = 20;
2996 y = -10; height = 20;
2997 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2998 expect(Ok, status);
2999 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3000
3001 /* entirely outside */
3002 x = -10; width = 5;
3003 y = -10; height = 5;
3004 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3005 expect(Ok, status);
3006 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3007
3008 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
3009 expect(Ok, status);
3010
3011 /* entirely within the visible region */
3012 x = 12; width = 10;
3013 y = 22; height = 10;
3014 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3015 expect(Ok, status);
3016 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3017
3018 /* partially outside */
3019 x = 35; width = 10;
3020 y = 55; height = 10;
3021 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3022 expect(Ok, status);
3023 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3024
3025 /* entirely outside */
3026 x = 45; width = 5;
3027 y = 65; height = 5;
3028 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3029 expect(Ok, status);
3030 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3031
3032 /* translate into center of clipping rect */
3034
3035 x = 0; width = 10;
3036 y = 0; height = 10;
3037 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3038 expect(Ok, status);
3039 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3040
3041 x = 25; width = 5;
3042 y = 40; height = 5;
3043 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3044 expect(Ok, status);
3045 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3046
3048
3049 /* corners entirely outside, but some intersections */
3050 x = 0; width = 70;
3051 y = 0; height = 90;
3052 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3053 expect(Ok, status);
3054 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3055
3056 x = 0; width = 70;
3057 y = 0; height = 30;
3058 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3059 expect(Ok, status);
3060 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3061
3062 x = 0; width = 30;
3063 y = 0; height = 90;
3064 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3065 expect(Ok, status);
3066 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3067
3068 /* edge cases */
3069 x = 0; width = 10;
3070 y = 20; height = 40;
3071 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3072 expect(Ok, status);
3073 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3074
3075 x = 10; width = 30;
3076 y = 0; height = 20;
3077 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3078 expect(Ok, status);
3079 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3080
3081 x = 40; width = 10;
3082 y = 20; height = 40;
3083 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3084 expect(Ok, status);
3085 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3086
3087 x = 10; width = 30;
3088 y = 60; height = 10;
3089 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3090 expect(Ok, status);
3091 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
3092
3093 /* rounding tests */
3094 x = 0.4; width = 10.4;
3095 y = 20; height = 40;
3096 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3097 expect(Ok, status);
3098 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3099
3100 x = 10; width = 30;
3101 y = 0.4; height = 20.4;
3102 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
3103 expect(Ok, status);
3104 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3105
3106 /* integer version */
3107 x = 0; width = 30;
3108 y = 0; height = 90;
3109 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
3110 expect(Ok, status);
3111 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3112
3113 x = 12; width = 10;
3114 y = 22; height = 10;
3115 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
3116 expect(Ok, status);
3117 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
3118
3119 GdipDeleteGraphics(graphics);
3120 ReleaseDC(hwnd, hdc);
3121}
3122
3124{
3126 GpGraphics *graphics;
3128 ARGB color = 0xdeadbeef;
3129 HDC hdc = GetDC( hwnd );
3130
3131 /* create a graphics object */
3132 ok(hdc != NULL, "Expected HDC to be initialized\n");
3133
3134 status = GdipCreateFromHDC(hdc, &graphics);
3135 expect(Ok, status);
3136 ok(graphics != NULL, "Expected graphics to be initialized\n");
3137
3138 status = GdipGetNearestColor(graphics, NULL);
3140
3143 GdipDeleteGraphics(graphics);
3144
3146 expect(Ok, status);
3148 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
3149 if (status == Ok)
3150 {
3151 status = GdipGetNearestColor(graphics, &color);
3152 expect(Ok, status);
3153 expect(0xdeadbeef, color);
3154 GdipDeleteGraphics(graphics);
3155 }
3157
3159 expect(Ok, status);
3161 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
3162 if (status == Ok)
3163 {
3164 status = GdipGetNearestColor(graphics, &color);
3165 expect(Ok, status);
3166 expect(0xdeadbeef, color);
3167 GdipDeleteGraphics(graphics);
3168 }
3170
3172 expect(Ok, status);
3174 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
3175 if (status == Ok)
3176 {
3177 status = GdipGetNearestColor(graphics, &color);
3178 expect(Ok, status);
3179 expect(0xdeadbeef, color);
3180 GdipDeleteGraphics(graphics);
3181 }
3183
3185 expect(Ok, status);
3188 if (status == Ok)
3189 GdipDeleteGraphics(graphics);
3191
3193 expect(Ok, status);
3195 expect(Ok, status);
3196 status = GdipGetNearestColor(graphics, &color);
3197 expect(Ok, status);
3198 expect(0xdeadbeef, color);
3199 GdipDeleteGraphics(graphics);
3201
3203 expect(Ok, status);
3205 expect(Ok, status);
3206 status = GdipGetNearestColor(graphics, &color);
3207 expect(Ok, status);
3208 expect(0xdeadbeef, color);
3209 GdipDeleteGraphics(graphics);
3211
3213 expect(Ok, status);
3215 expect(Ok, status);
3216 status = GdipGetNearestColor(graphics, &color);
3217 expect(Ok, status);
3218 expect(0xdeadbeef, color);
3219 GdipDeleteGraphics(graphics);
3221
3223 expect(Ok, status);
3224 if (status == Ok)
3225 {
3227 expect(Ok, status);
3228 status = GdipGetNearestColor(graphics, &color);
3229 expect(Ok, status);
3230 expect(0xdeadbeef, color);
3231 GdipDeleteGraphics(graphics);
3233 }
3234
3236 expect(Ok, status);
3237 if (status == Ok)
3238 {
3240 expect(Ok, status);
3241 status = GdipGetNearestColor(graphics, &color);
3242 expect(Ok, status);
3243 expect(0xdeadbeef, color);
3244 GdipDeleteGraphics(graphics);
3246 }
3247
3249 expect(Ok, status);
3250 if (status == Ok)
3251 {
3253 expect(Ok, status);
3254 status = GdipGetNearestColor(graphics, &color);
3255 expect(Ok, status);
3256 expect(0xdeadbeef, color);
3257 GdipDeleteGraphics(graphics);
3259 }
3260
3262 expect(Ok, status);
3264 expect(Ok, status);
3265 status = GdipGetNearestColor(graphics, &color);
3266 expect(Ok, status);
3267 todo_wine expect(0xffa8bce8, color);
3268 GdipDeleteGraphics(graphics);
3270
3272 expect(Ok, status);
3274 expect(Ok, status);
3275 status = GdipGetNearestColor(graphics, &color);
3276 expect(Ok, status);
3277 todo_wine
3278 ok(color == 0xffa8b8e8 ||
3279 broken(color == 0xffa0b8e0), /* Win98/WinMe */
3280 "Expected ffa8b8e8, got %.8lx\n", color);
3281 GdipDeleteGraphics(graphics);
3283
3284 ReleaseDC(hwnd, hdc);
3285}
3286
3287static void test_string_functions(void)
3288{
3290 GpGraphics *graphics;
3291 GpFontFamily *family;
3292 GpFont *font;
3293 RectF rc, char_bounds, bounds;
3294 GpBrush *brush;
3295 ARGB color = 0xff000000;
3296 HDC hdc = GetDC( hwnd );
3297 const WCHAR teststring[] = L"MM M\nM";
3298 const WCHAR teststring2[] = L"j";
3299 const WCHAR teststring3[] = L"MM M\r\nM\0";
3300 REAL char_width, char_height;
3301 INT codepointsfitted, linesfilled;
3303 CharacterRange ranges[3] = {{0, 1}, {1, 3}, {5, 1}};
3304 GpRegion *regions[4];
3305 BOOL region_isempty[4];
3306 int i;
3307 PointF positions[8];
3309
3310 ok(hdc != NULL, "Expected HDC to be initialized\n");
3311 status = GdipCreateFromHDC(hdc, &graphics);
3312 expect(Ok, status);
3313 ok(graphics != NULL, "Expected graphics to be initialized\n");
3314
3315 status = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
3316 expect(Ok, status);
3317
3319 expect(Ok, status);
3320
3322 expect(Ok, status);
3323
3325 expect(Ok, status);
3326
3327 rc.X = 0;
3328 rc.Y = 0;
3329 rc.Width = 100.0;
3330 rc.Height = 100.0;
3331
3332 status = GdipDrawString(NULL, teststring, 6, font, &rc, NULL, brush);
3334
3335 status = GdipDrawString(graphics, NULL, 6, font, &rc, NULL, brush);
3337
3338 status = GdipDrawString(graphics, teststring, 6, NULL, &rc, NULL, brush);
3340
3341 status = GdipDrawString(graphics, teststring, 6, font, NULL, NULL, brush);
3343
3344 status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, NULL);
3346
3347 status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, brush);
3348 expect(Ok, status);
3349
3350 status = GdipMeasureString(NULL, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3352
3353 status = GdipMeasureString(graphics, NULL, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3355
3356 status = GdipMeasureString(graphics, teststring, 6, NULL, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3358
3359 status = GdipMeasureString(graphics, teststring, 6, font, NULL, NULL, &bounds, &codepointsfitted, &linesfilled);
3361
3362 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, NULL, &codepointsfitted, &linesfilled);
3364
3365 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, NULL, &linesfilled);
3366 expect(Ok, status);
3367
3368 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, NULL);
3369 expect(Ok, status);
3370
3371 /* new line handling */
3372 status = GdipMeasureString(graphics, teststring3, -1, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3373 expect(Ok, status);
3374 expect(7, codepointsfitted);
3375 expect(2, linesfilled);
3376
3377 status = GdipMeasureString(graphics, teststring, 1, font, &rc, NULL, &char_bounds, &codepointsfitted, &linesfilled);
3378 expect(Ok, status);
3379 expectf(0.0, char_bounds.X);
3380 expectf(0.0, char_bounds.Y);
3381 ok(char_bounds.Width > 0, "got %0.2f\n", bounds.Width);
3382 ok(char_bounds.Height > 0, "got %0.2f\n", bounds.Height);
3383 expect(1, codepointsfitted);
3384 expect(1, linesfilled);
3385
3386 status = GdipMeasureString(graphics, teststring, 2, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3387 expect(Ok, status);
3388 expectf(0.0, bounds.X);
3389 expectf(0.0, bounds.Y);
3390 ok(bounds.Width > char_bounds.Width, "got %0.2f, expected at least %0.2f\n", bounds.Width, char_bounds.Width);
3391 expectf(char_bounds.Height, bounds.Height);
3392 expect(2, codepointsfitted);
3393 expect(1, linesfilled);
3394 char_width = bounds.Width - char_bounds.Width;
3395
3396 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3397 expect(Ok, status);
3398 expectf(0.0, bounds.X);
3399 expectf(0.0, bounds.Y);
3400 ok(bounds.Width > char_bounds.Width + char_width * 2, "got %0.2f, expected at least %0.2f\n",
3401 bounds.Width, char_bounds.Width + char_width * 2);
3402 ok(bounds.Height > char_bounds.Height, "got %0.2f, expected at least %0.2f\n", bounds.Height, char_bounds.Height);
3403 expect(6, codepointsfitted);
3404 expect(2, linesfilled);
3405 char_height = bounds.Height - char_bounds.Height;
3406
3407 /* Measure the first line. */
3408 status = GdipMeasureString(graphics, teststring, 4, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3409 expect(Ok, status);
3410 expectf(0.0, bounds.X);
3411 expectf(0.0, bounds.Y);
3412 expect(4, codepointsfitted);
3413 expect(1, linesfilled);
3414
3415 /* Give just enough space to fit the first line. */
3416 rc.Width = bounds.Width;
3417 status = GdipMeasureString(graphics, teststring, 5, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3418 expect(Ok, status);
3419 expectf(0.0, bounds.X);
3420 expectf(0.0, bounds.Y);
3421 todo_wine expect(5, codepointsfitted);
3422 todo_wine expect(1, linesfilled);
3423
3424 /* Cut off everything after the first space. */
3425 rc.Width = char_bounds.Width + char_width * 2.1;
3426
3427 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3428 expect(Ok, status);
3429 expectf(0.0, bounds.X);
3430 expectf(0.0, bounds.Y);
3431 expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
3432 expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
3433 expect(6, codepointsfitted);
3434 expect(3, linesfilled);
3435
3436 /* Cut off everything including the first space. */
3437 rc.Width = char_bounds.Width + char_width * 1.7;
3438
3439 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3440 expect(Ok, status);
3441 expectf(0.0, bounds.X);
3442 expectf(0.0, bounds.Y);
3443 expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
3444 expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
3445 expect(6, codepointsfitted);
3446 expect(3, linesfilled);
3447
3448 /* Cut off everything after the first character. */
3449 rc.Width = char_bounds.Width + char_width * 0.8;
3450
3451 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
3452 expect(Ok, status);
3453 expectf(0.0, bounds.X);
3454 expectf(0.0, bounds.Y);
3455 expectf_(char_bounds.Width, bounds.Width, 0.01);
3456 expectf_(char_bounds.Height + char_height * 3, bounds.Height, 0.05);
3457 expect(6, codepointsfitted);
3458 todo_wine expect(4, linesfilled);
3459
3460 for (i = 0; i < 4; i++)
3461 regions[i] = (GpRegion *)0xdeadbeef;
3462
3463 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 0, regions);
3464 expect(Ok, status);
3465
3466 for (i = 0; i < 4; i++)
3467 ok(regions[i] == (GpRegion *)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions[i]);
3468
3469 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
3470 expect(Ok, status);
3471
3472 for (i = 0; i < 4; i++)
3473 ok(regions[i] == (GpRegion *)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions[i]);
3474
3476 expect(Ok, status);
3477
3478 set_rect_empty(&rc);
3479
3480 for (i=0; i<4; i++)
3481 {
3482 status = GdipCreateRegion(&regions[i]);
3483 expect(Ok, status);
3484 status = GdipSetEmpty(regions[i]);
3485 expect(Ok, status);
3486 }
3487
3488 status = GdipMeasureCharacterRanges(NULL, teststring, 6, font, &rc, format, 3, regions);
3490
3491 status = GdipMeasureCharacterRanges(graphics, NULL, 6, font, &rc, format, 3, regions);
3493
3494 status = GdipMeasureCharacterRanges(graphics, teststring, 6, NULL, &rc, format, 3, regions);
3496
3497 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, NULL, format, 3, regions);
3499
3500 if (0)
3501 {
3502 /* Crashes on Windows XP */
3503 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, NULL, 3, regions);
3505 }
3506
3507 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, NULL);
3509
3510 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 2, regions);
3512
3513 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
3514 expect(Ok, status);
3515
3516 for (i = 0; i < 4; i++)
3517 {
3518 status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
3519 expect(Ok, status);
3520 }
3521
3522 ok(region_isempty[0], "region should be empty\n");
3523 ok(region_isempty[1], "region should be empty\n");
3524 ok(region_isempty[2], "region should be empty\n");
3525 ok(region_isempty[3], "region should be empty\n");
3526
3527 rc.Width = 100.0;
3528 rc.Height = 100.0;
3529
3530 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 4, regions);
3531 expect(Ok, status);
3532
3533 for (i=0; i<4; i++)
3534 {
3535 status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
3536 expect(Ok, status);
3537 }
3538
3539 ok(!region_isempty[0], "region shouldn't be empty\n");
3540 ok(!region_isempty[1], "region shouldn't be empty\n");
3541 ok(!region_isempty[2], "region shouldn't be empty\n");
3542 ok(region_isempty[3], "region should be empty\n");
3543
3544 /* Cut off everything after the first space, and the second line. */
3545 rc.Width = char_bounds.Width + char_width * 2.1;
3546 rc.Height = char_bounds.Height + char_height * 0.5;
3547
3548 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
3549 expect(Ok, status);
3550
3551 for (i=0; i<4; i++)
3552 {
3553 status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
3554 expect(Ok, status);
3555 }
3556
3557 ok(!region_isempty[0], "region shouldn't be empty\n");
3558 ok(!region_isempty[1], "region shouldn't be empty\n");
3559 ok(region_isempty[2], "region should be empty\n");
3560 ok(region_isempty[3], "region should be empty\n");
3561
3562 for (i=0; i<4; i++)
3563 GdipDeleteRegion(regions[i]);
3564
3566 expect(Ok, status);
3567
3568 rc.X = 0;
3569 rc.Y = 0;
3570 rc.Width = 0;
3571 rc.Height = 0;
3572 memset(positions, 0, sizeof(positions));
3573 status = GdipMeasureDriverString(NULL, teststring, 6, font, positions,
3575 identity, &rc);
3577
3578 status = GdipMeasureDriverString(graphics, NULL, 6, font, positions,
3580 identity, &rc);
3582
3583 status = GdipMeasureDriverString(graphics, teststring, 6, NULL, positions,
3585 identity, &rc);
3587
3588 status = GdipMeasureDriverString(graphics, teststring, 6, font, NULL,
3590 identity, &rc);
3592
3593 status = GdipMeasureDriverString(graphics, teststring, 6, font, positions,
3594 0x100, identity, &rc);
3595 expect(Ok, status);
3596
3597 status = GdipMeasureDriverString(graphics, teststring, 6, font, positions,
3599 NULL, &rc);
3600 expect(Ok, status);
3601
3602 status = GdipMeasureDriverString(graphics, teststring, 6, font, positions,
3604 identity, NULL);
3606
3607 rc.X = 0;
3608 rc.Y = 0;
3609 rc.Width = 0;
3610 rc.Height = 0;
3611 status = GdipMeasureDriverString(graphics, teststring, 6, font, positions,
3613 identity, &rc);
3614 expect(Ok, status);
3615
3616 expectf(0.0, rc.X);
3617 ok(rc.Y < 0.0, "unexpected Y %0.2f\n", rc.Y);
3618 ok(rc.Width > 0.0, "unexpected Width %0.2f\n", rc.Width);
3619 ok(rc.Height > 0.0, "unexpected Y %0.2f\n", rc.Y);
3620
3621 char_width = rc.Width;
3622 char_height = rc.Height;
3623
3624 rc.X = 0;
3625 rc.Y = 0;
3626 rc.Width = 0;
3627 rc.Height = 0;
3628 status = GdipMeasureDriverString(graphics, teststring, 4, font, positions,
3630 identity, &rc);
3631 expect(Ok, status);
3632
3633 expectf(0.0, rc.X);
3634 ok(rc.Y < 0.0, "unexpected Y %0.2f\n", rc.Y);
3635 ok(rc.Width < char_width, "got Width %0.2f, expecting less than %0.2f\n", rc.Width, char_width);
3636 expectf(char_height, rc.Height);
3637
3638 rc.X = 0;
3639 rc.Y = 0;
3640 rc.Width = 0;
3641 rc.Height = 0;
3642 status = GdipMeasureDriverString(graphics, teststring2, 1, font, positions,
3644 identity, &rc);
3645 expect(Ok, status);
3646
3647 expectf(rc.X, 0.0);
3648 ok(rc.Y < 0.0, "unexpected Y %0.2f\n", rc.Y);
3649 ok(rc.Width > 0, "unexpected Width %0.2f\n", rc.Width);
3650 expectf(rc.Height, char_height);
3651
3654 GdipDeleteBrush(brush);
3656 GdipDeleteFontFamily(family);
3657 GdipDeleteGraphics(graphics);
3658
3659 ReleaseDC(hwnd, hdc);
3660}
3661
3663{
3664 GpGraphics *graphics;
3665 HDC hdc = GetDC( hwnd );
3668
3669 ok(hdc != NULL, "Expected HDC to be initialized\n");
3670 status = GdipCreateFromHDC(hdc, &graphics);
3671 expect(Ok, status);
3672 ok(graphics != NULL, "Expected graphics to be initialized\n");
3673
3676
3677 if (0)
3678 {
3679 /* Crashes on Windows XP */
3682 }
3683
3686
3687 /* out of range */
3690
3693
3694 status = GdipGetInterpolationMode(graphics, &mode);
3695 expect(Ok, status);
3697
3699 expect(Ok, status);
3700
3701 status = GdipGetInterpolationMode(graphics, &mode);
3702 expect(Ok, status);
3704
3706 expect(Ok, status);
3707
3708 status = GdipGetInterpolationMode(graphics, &mode);
3709 expect(Ok, status);
3711
3713 expect(Ok, status);
3714
3715 status = GdipGetInterpolationMode(graphics, &mode);
3716 expect(Ok, status);
3718
3720 expect(Ok, status);
3721
3722 status = GdipGetInterpolationMode(graphics, &mode);
3723 expect(Ok, status);
3725
3726 GdipDeleteGraphics(graphics);
3727
3728 ReleaseDC(hwnd, hdc);
3729}
3730
3732{
3733 GpGraphics *graphics;
3734 HDC hdc = GetDC( hwnd );
3737
3738 ok(hdc != NULL, "Expected HDC to be initialized\n");
3739 status = GdipCreateFromHDC(hdc, &graphics);
3740 expect(Ok, status);
3741 ok(graphics != NULL, "Expected graphics to be initialized\n");
3742
3745
3748
3751
3752 /* out of range */
3755
3756 status = GdipGetTextRenderingHint(graphics, &hint);
3757 expect(Ok, status);
3759
3761 expect(Ok, status);
3762
3763 status = GdipGetTextRenderingHint(graphics, &hint);
3764 expect(Ok, status);
3766
3768 expect(Ok, status);
3769
3770 status = GdipGetTextRenderingHint(graphics, &hint);
3771 expect(Ok, status);
3773
3774 GdipDeleteGraphics(graphics);
3775
3776 ReleaseDC(hwnd, hdc);
3777}
3778
3779static void test_getdc_scaled(void)
3780{
3782 GpGraphics *graphics = NULL;
3783 GpBitmap *bitmap = NULL;
3784 HDC hdc=NULL;
3785 HBRUSH hbrush, holdbrush;
3786 ARGB color;
3787
3789 expect(Ok, status);
3790
3792 expect(Ok, status);
3793
3794 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
3795 expect(Ok, status);
3796
3797 status = GdipGetDC(graphics, &hdc);
3798 expect(Ok, status);
3799 ok(hdc != NULL, "got NULL hdc\n");
3800
3801 hbrush = CreateSolidBrush(RGB(255, 0, 0));
3802
3803 holdbrush = SelectObject(hdc, hbrush);
3804
3805 Rectangle(hdc, 2, 2, 6, 6);
3806
3807 SelectObject(hdc, holdbrush);
3808
3810
3811 status = GdipReleaseDC(graphics, hdc);
3812 expect(Ok, status);
3813
3814 GdipDeleteGraphics(graphics);
3815
3817 expect(Ok, status);
3818 expect(0xffff0000, color);
3819
3821 expect(Ok, status);
3822 expect(0xff000000, color);
3823
3825}
3826
3827static void test_GdipMeasureString(void)
3828{
3829 static const struct test_data
3830 {
3831 REAL res_x, res_y, page_scale;
3832 GpUnit unit;
3833 } td[] =
3834 {
3835 { 200.0, 200.0, 1.0, UnitPixel }, /* base */
3836 { 200.0, 200.0, 2.0, UnitPixel },
3837 { 200.0, 200.0, 1.0, UnitDisplay },
3838 { 200.0, 200.0, 2.0, UnitDisplay },
3839 { 200.0, 200.0, 1.0, UnitInch },
3840 { 200.0, 200.0, 2.0, UnitInch },
3841 { 200.0, 600.0, 1.0, UnitPoint },
3842 { 200.0, 600.0, 2.0, UnitPoint },
3843 { 200.0, 600.0, 1.0, UnitDocument },
3844 { 200.0, 600.0, 2.0, UnitDocument },
3845 { 200.0, 600.0, 1.0, UnitMillimeter },
3846 { 200.0, 600.0, 2.0, UnitMillimeter },
3847 { 200.0, 600.0, 1.0, UnitDisplay },
3848 { 200.0, 600.0, 2.0, UnitDisplay },
3849 { 200.0, 600.0, 1.0, UnitPixel },
3850 { 200.0, 600.0, 2.0, UnitPixel },
3851 };
3852 static const WCHAR string[] = L"1234567";
3854 GpGraphics *graphics;
3855 GpFontFamily *family;
3856 GpFont *font;
3858 RectF bounds, rc;
3859 REAL base_cx = 0, base_cy = 0, height;
3860 INT chars, lines;
3861 LOGFONTW lf;
3862 UINT i;
3863 REAL font_size;
3864 GpUnit font_unit, unit;
3865
3867 expect(Ok, status);
3868 status = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
3869 expect(Ok, status);
3870
3871 /* font size in pixels */
3873 expect(Ok, status);
3874 status = GdipGetFontSize(font, &font_size);
3875 expect(Ok, status);
3876 expectf(100.0, font_size);
3877 status = GdipGetFontUnit(font, &font_unit);
3878 expect(Ok, status);
3879 expect(UnitPixel, font_unit);
3880
3881 for (i = 0; i < ARRAY_SIZE(td); i++)
3882 {
3883 GpImage *image;
3884
3885 graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
3886
3887 lf.lfHeight = 0xdeadbeef;
3888 status = GdipGetLogFontW(font, graphics, &lf);
3889 expect(Ok, status);
3890 height = units_to_pixels(font_size, td[i].unit, td[i].res_y);
3891 if (td[i].unit != UnitDisplay)
3892 height *= td[i].page_scale;
3893 ok(-lf.lfHeight == (LONG)(height + 0.5), "%u: expected %ld (%f), got %ld\n",
3894 i, (LONG)(height + 0.5), height, lf.lfHeight);
3895
3896 height = font_size + 2.0 * font_size / 6.0;
3897
3898 set_rect_empty(&rc);
3899 set_rect_empty(&bounds);
3900 status = GdipMeasureString(graphics, string, -1, font, &rc, format, &bounds, &chars, &lines);
3901 expect(Ok, status);
3902
3903 if (i == 0)
3904 {
3905 base_cx = bounds.Width;
3906 base_cy = bounds.Height;
3907 }
3908
3909 expectf(0.0, bounds.X);
3910 expectf(0.0, bounds.Y);
3911 todo_wine
3912 expectf_(height, bounds.Height, height / 100.0);
3913 expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
3914 expect(7, chars);
3915 expect(1, lines);
3916
3917 /* make sure it really fits */
3918 bounds.Width += 1.0;
3919 bounds.Height += 1.0;
3920 rc = bounds;
3921 rc.X = 50.0;
3922 rc.Y = 50.0;
3923 set_rect_empty(&bounds);
3924 status = GdipMeasureString(graphics, string, -1, font, &rc, format, &bounds, &chars, &lines);
3925 expect(Ok, status);
3926 expectf(50.0, bounds.X);
3927 expectf(50.0, bounds.Y);
3928 todo_wine
3929 expectf_(height, bounds.Height, height / 100.0);
3930 expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
3931 expect(7, chars);
3932 expect(1, lines);
3933
3934 status = GdipDeleteGraphics(graphics);
3935 expect(Ok, status);
3936
3938 expect(Ok, status);
3939 }
3940
3942
3943 /* font size in logical units */
3944 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3945 for (unit = 3; unit <= 6; unit++)
3946 {
3947 /* create a font which final height is 100.0 pixels with 200 dpi device */
3948 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3949 height = pixels_to_units(75.0, unit, 200.0);
3951 expect(Ok, status);
3952 status = GdipGetFontSize(font, &font_size);
3953 expect(Ok, status);
3954 expectf(height, font_size);
3955 status = GdipGetFontUnit(font, &font_unit);
3956 expect(Ok, status);
3957 expect(unit, font_unit);
3958
3959 for (i = 0; i < ARRAY_SIZE(td); i++)
3960 {
3961 REAL unit_scale;
3962 GpImage *image;
3963
3964 graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
3965
3966 lf.lfHeight = 0xdeadbeef;
3967 status = GdipGetLogFontW(font, graphics, &lf);
3968 expect(Ok, status);
3969 if (td[i].unit == UnitDisplay || td[i].unit == UnitPixel)
3970 height = units_to_pixels(font_size, font_unit, td[i].res_x);
3971 else
3972 height = units_to_pixels(font_size, font_unit, td[i].res_y);
3973 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3974 ok(-lf.lfHeight == (LONG)(height + 0.5), "%u: expected %ld (%f), got %ld\n",
3975 i, (LONG)(height + 0.5), height, lf.lfHeight);
3976
3977 if (td[i].unit == UnitDisplay || td[i].unit == UnitPixel)
3978 unit_scale = units_scale(font_unit, td[i].unit, td[i].res_x);
3979 else
3980 unit_scale = units_scale(font_unit, td[i].unit, td[i].res_y);
3981 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3982 height = (font_size + 2.0 * font_size / 6.0) * unit_scale;
3983 if (td[i].unit != UnitDisplay)
3984 height /= td[i].page_scale;
3985 /*trace("%u: %.1f font units = %f units with %.1f dpi, page_scale %.1f\n", i, font_size, height, td[i].res_y, td[i].page_scale);*/
3986
3987 set_rect_empty(&rc);
3988 set_rect_empty(&bounds);
3989 status = GdipMeasureString(graphics, string, -1, font, &rc, format, &bounds, &chars, &lines);
3990 expect(Ok, status);
3991
3992 if (i == 0)
3993 {
3994 base_cx = bounds.Width;
3995 base_cy = bounds.Height;
3996 }
3997
3998 expectf(0.0, bounds.X);
3999 expectf(0.0, bounds.Y);
4000 todo_wine
4001 expectf_(height, bounds.Height, height / 85.0);
4002 expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
4003 expect(7, chars);
4004 expect(1, lines);
4005
4006 /* make sure it really fits */
4007 bounds.Width += 1.0;
4008 bounds.Height += 1.0;
4009 rc = bounds;
4010 rc.X = 50.0;
4011 rc.Y = 50.0;
4012 set_rect_empty(&bounds);
4013 status = GdipMeasureString(graphics, string, -1, font, &rc, format, &bounds, &chars, &lines);
4014 expect(Ok, status);
4015 expectf(50.0, bounds.X);
4016 expectf(50.0, bounds.Y);
4017 todo_wine
4018 expectf_(height, bounds.Height, height / 85.0);
4019 expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
4020 expect(7, chars);
4021 expect(1, lines);
4022
4023 /* verify the result */
4024 height = units_to_pixels(bounds.Height, td[i].unit, td[i].res_x);
4025 if (td[i].unit != UnitDisplay)
4026 height *= td[i].page_scale;
4027 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
4028 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
4029 todo_wine
4030 expectf_(100.0, height, 1.1);
4031
4032 status = GdipDeleteGraphics(graphics);
4033 expect(Ok, status);
4034
4036 expect(Ok, status);
4037 }
4038
4040 }
4041
4042 /* Font with units = UnitWorld */
4043 for (i = 0; i < ARRAY_SIZE(td); i++)
4044 {
4045 GpPointF pt = {0.0, 100.0};
4046 GpImage* image;
4047 REAL expected_width, expected_height;
4048
4049 graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
4050
4052 expect(Ok, status);
4053
4055 expect(Ok, status);
4056
4057 status = GdipGetFontUnit(font, &font_unit);
4058 expect(Ok, status);
4059 expect(UnitWorld, font_unit);
4060
4061 lf.lfHeight = 0xdeadbeef;
4062 status = GdipGetLogFontW(font, graphics, &lf);
4063 expect(Ok, status);
4064 ok(lf.lfHeight == -100, "%u: expected -100, got %ld\n", i, lf.lfHeight);
4065
4066 set_rect_empty(&rc);
4067 set_rect_empty(&bounds);
4068 status = GdipMeasureString(graphics, string, -1, font, &rc, format, &bounds, &chars, &lines);
4069 expect(Ok, status);
4070
4071 if (i == 0)
4072 {
4073 base_cx = bounds.Width;
4074 base_cy = bounds.Height;
4075 }
4076
4077 pt.X = 1.0;
4078 pt.Y = 1.0;
4079
4081 expect(Ok, status);
4082
4083 /* height is constant in device space, width is proportional to height in world space */
4084 expected_width = base_cx * pt.Y;
4085 expected_height = base_cy * pt.Y;
4086
4087 todo_wine_if(td[i].unit != UnitDisplay && td[i].unit != UnitPixel)
4088 ok(fabs(expected_width - bounds.Width) <= 0.001, "%u: expected %f, got %f\n", i, expected_width, bounds.Width);
4089 ok(fabs(expected_height - bounds.Height) <= 0.001, "%u: expected %f, got %f\n", i, expected_height, bounds.Height);
4090
4091 GdipDeleteGraphics(graphics);
4094 }
4095
4096 GdipDeleteFontFamily(family);
4098}
4099
4100static void test_transform(void)
4101{
4102 static const struct test_data
4103 {
4104 REAL res_x, res_y, scale;
4105 GpUnit unit;
4106 GpPointF in[2], out[2];
4107 } td[] =
4108 {
4109 { 96.0, 96.0, 1.0, UnitPixel,
4110 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4111 { 96.0, 96.0, 1.0, UnitDisplay,
4112 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4113 { 96.0, 96.0, 1.0, UnitInch,
4114 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
4115 { 123.0, 456.0, 1.0, UnitPoint,
4116 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
4117 { 123.0, 456.0, 1.0, UnitDocument,
4118 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
4119 { 123.0, 456.0, 2.0, UnitMillimeter,
4120 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
4121 { 196.0, 296.0, 1.0, UnitDisplay,
4122 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4123 { 196.0, 296.0, 1.0, UnitPixel,
4124 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4125 };
4127 GpGraphics *graphics;
4128 GpImage *image;
4129 GpPointF ptf[2];
4130 UINT i;
4131
4132 for (i = 0; i < ARRAY_SIZE(td); i++)
4133 {
4134 graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale, &image);
4135 ptf[0].X = td[i].in[0].X;
4136 ptf[0].Y = td[i].in[0].Y;
4137 ptf[1].X = td[i].in[1].X;
4138 ptf[1].Y = td[i].in[1].Y;
4140 expect(Ok, status);
4141 expectf(td[i].out[0].X, ptf[0].X);
4142 expectf(td[i].out[0].Y, ptf[0].Y);
4143 expectf(td[i].out[1].X, ptf[1].X);
4144 expectf(td[i].out[1].Y, ptf[1].Y);
4146 expect(Ok, status);
4147 expectf(td[i].in[0].X, ptf[0].X);
4148 expectf(td[i].in[0].Y, ptf[0].Y);
4149 expectf(td[i].in[1].X, ptf[1].X);
4150 expectf(td[i].in[1].Y, ptf[1].Y);
4151 status = GdipDeleteGraphics(graphics);
4152 expect(Ok, status);
4154 expect(Ok, status);
4155 }
4156}
4157
4159{
4160 static const struct
4161 {
4162 GpUnit unit;
4163 BOOL isInvalid;
4164 } td_unit[] =
4165 {
4166 {UnitWorld, TRUE},
4167 {UnitDisplay},
4168 {UnitPixel},
4169 {UnitPoint},
4170 {UnitInch},
4171 {UnitDocument},
4173 {UnitMillimeter + 1, TRUE},
4174 };
4175 static const struct {
4176 REAL scale;
4177 BOOL isInvalid;
4178 } td_scale[] =
4179 {
4180 {-1.0, TRUE},
4181 {0.0, TRUE},
4182 {0.5},
4183 {1.0},
4184 {2.0},
4185 };
4187 GpGraphics *graphics;
4188 HDC hdc = GetDC( hwnd );
4189 GpUnit unit;
4190 REAL scale;
4191 UINT i;
4192
4193 status = GdipCreateFromHDC(hdc, &graphics);
4194 expect(Ok, status);
4195
4196 for (i = 0; i < ARRAY_SIZE(td_unit); i++)
4197 {
4198 winetest_push_context("%u", i);
4199 status = GdipSetPageUnit(graphics, td_unit[i].unit);
4200 expect(td_unit[i].isInvalid ? InvalidParameter : Ok, status);
4201 if (status == Ok)
4202 {
4203 status = GdipGetPageUnit(graphics, &unit);
4204 expect(Ok, status);
4205 expect(td_unit[i].unit, unit);
4206 }
4208 }
4209
4210 for (i = 0; i < ARRAY_SIZE(td_scale); i++)
4211 {
4212 winetest_push_context("%u", i);
4213 status = GdipSetPageScale(graphics, td_scale[i].scale);
4214 expect(td_scale[i].isInvalid ? InvalidParameter : Ok, status);
4215 if (status == Ok)
4216 {
4217 status = GdipGetPageScale(graphics, &scale);
4218 expect(Ok, status);
4219 expectf_(td_scale[i].scale, scale, 0);
4220 }
4222 }
4223
4224 status = GdipGetPageUnit(graphics, &unit);
4225 expect(Ok, status);
4227 status = GdipGetPageScale(graphics, &scale);
4228 expect(Ok, status);
4229 expectf_(2.0, scale, 0);
4230 status = GdipResetPageTransform(graphics);
4231 expect(Ok, status);
4232 status = GdipGetPageUnit(graphics, &unit);
4233 expect(Ok, status);
4235 status = GdipGetPageScale(graphics, &scale);
4236 expect(Ok, status);
4237 expectf_(1.0, scale, 0);
4238
4239 GdipDeleteGraphics(graphics);
4240 ReleaseDC(hwnd, hdc);
4241}
4242
4243static void test_pen_thickness(void)
4244{
4245 static const struct test_data
4246 {
4247 REAL res_x, res_y, scale;
4248 GpUnit pen_unit, page_unit;
4249 REAL pen_width;
4250 INT cx, cy, path_cx, path_cy;
4251 } td[] =
4252 {
4253 { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 1.0, 1, 1, 1, 1 },
4254 { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 0.0, 0, 0, 1, 1 },
4255 { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 0.1, 1, 1, 1, 1 },
4256 { 10.0, 10.0, 3.0, UnitPixel, UnitPixel, 2.0, 2, 2, 2, 2 },
4257 { 10.0, 10.0, 30.0, UnitPixel, UnitInch, 1.0, 1, 1, 1, 1 },
4258 { 10.0, 10.0, 1.0, UnitWorld, UnitPixel, 1.0, 1, 1, 1, 1 },
4259 { 10.0, 10.0, 1.0, UnitWorld, UnitPixel, 0.0, 1, 1, 1, 1 },
4260 { 10.0, 10.0, 3.0, UnitWorld, UnitPixel, 2.0, 6, 6, 6, 6 },
4261 { 10.0, 10.0, 2.0, UnitWorld, UnitInch, 1.0, 20, 20, 20, 20 },
4262 };
4264 int i, j;
4265 GpGraphics *graphics;
4266 union
4267 {
4269 GpImage *image;
4270 } u;
4271 GpPen *pen;
4272 GpPointF corner;
4273 GpPath *path;
4274 BitmapData bd;
4275 INT min, max, size;
4276
4277 for (i = 0; i < ARRAY_SIZE(td); i++)
4278 {
4279 status = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB, NULL, &u.bitmap);
4280 expect(Ok, status);
4281
4282 status = GdipBitmapSetResolution(u.bitmap, td[i].res_x, td[i].res_y);
4283 expect(Ok, status);
4284
4285 status = GdipGetImageGraphicsContext(u.image, &graphics);
4286 expect(Ok, status);
4287
4288 status = GdipSetPageUnit(graphics, td[i].page_unit);
4289 expect(Ok, status);
4290
4291 status = GdipSetPageScale(graphics, td[i].scale);
4292 expect(Ok, status);
4293
4294 status = GdipCreatePen1(0xffffffff, td[i].pen_width, td[i].pen_unit, &pen);
4295 expect(Ok, status);
4296
4297 corner.X = corner.Y = 100.0;
4299 expect(Ok, status);
4300
4301 status = GdipDrawLine(graphics, pen, corner.X/2, 0, corner.X/2, corner.Y);
4302 expect(Ok, status);
4303
4304 status = GdipDrawLine(graphics, pen, 0, corner.Y/2, corner.X, corner.Y/2);
4305 expect(Ok, status);
4306
4308 expect(Ok, status);
4309
4310 min = -1;
4311 max = -2;
4312
4313 for (j=0; j<100; j++)
4314 {
4315 if (((BYTE*)bd.Scan0)[j*3] == 0xff)
4316 {
4317 min = j;
4318 break;
4319 }
4320 }
4321
4322 for (j=99; j>=0; j--)
4323 {
4324 if (((BYTE*)bd.Scan0)[j*3] == 0xff)
4325 {
4326 max = j;
4327 break;
4328 }
4329 }
4330
4331 size = max-min+1;
4332
4333 ok(size == td[i].cx || broken (i == 1 && size == 1), "%u: expected %d, got %d\n", i, td[i].cx, size);
4334
4335 min = -1;
4336 max = -2;
4337
4338 for (j=0; j<100; j++)
4339 {
4340 if (((BYTE*)bd.Scan0)[bd.Stride*j] == 0xff)
4341 {
4342 min = j;
4343 break;
4344 }
4345 }
4346
4347 for (j=99; j>=0; j--)
4348 {
4349 if (((BYTE*)bd.Scan0)[bd.Stride*j] == 0xff)
4350 {
4351 max = j;
4352 break;
4353 }
4354 }
4355
4356 size = max-min+1;
4357
4358 ok(size == td[i].cy || broken (i == 1 && size == 1), "%u: expected %d, got %d\n", i, td[i].cy, size);
4359
4360 status = GdipBitmapUnlockBits(u.bitmap, &bd);
4361 expect(Ok, status);
4362
4363 status = GdipGraphicsClear(graphics, 0xff000000);
4364 expect(Ok, status);
4365
4367 expect(Ok, status);
4368
4369 status = GdipAddPathLine(path, corner.X/2, 0, corner.X/2, corner.Y);
4370 expect(Ok, status);
4371
4373 expect(Ok, status);
4374
4375 status = GdipAddPathLine(path, 0, corner.Y/2, corner.X, corner.Y/2);
4376 expect(Ok, status);
4377
4378 status = GdipDrawPath(graphics, pen, path);
4379 expect(Ok, status);
4380
4382
4384 expect(Ok, status);
4385
4386 min = -1;
4387 max = -2;
4388
4389 for (j=0; j<100; j++)
4390 {
4391 if (((BYTE*)bd.Scan0)[j*3] == 0xff)
4392 {
4393 min = j;
4394 break;
4395 }
4396 }
4397
4398 for (j=99; j>=0; j--)
4399 {
4400 if (((BYTE*)bd.Scan0)[j*3] == 0xff)
4401 {
4402 max = j;
4403 break;
4404 }
4405 }
4406
4407 size = max-min+1;
4408
4409 ok(size == td[i].path_cx, "%u: expected %d, got %d\n", i, td[i].path_cx, size);
4410
4411 min = -1;
4412 max = -2;
4413
4414 for (j=0; j<100; j++)
4415 {
4416 if (((BYTE*)bd.Scan0)[bd.Stride*j] == 0xff)
4417 {
4418 min = j;
4419 break;
4420 }
4421 }
4422
4423 for (j=99; j>=0; j--)
4424 {
4425 if (((BYTE*)bd.Scan0)[bd.Stride*j] == 0xff)
4426 {
4427 max = j;
4428 break;
4429 }
4430 }
4431
4432 size = max-min+1;
4433
4434 ok(size == td[i].path_cy, "%u: expected %d, got %d\n", i, td[i].path_cy, size);
4435
4436 status = GdipBitmapUnlockBits(u.bitmap, &bd);
4437 expect(Ok, status);
4438
4439 GdipDeletePen(pen);
4440 GdipDeleteGraphics(graphics);
4441 GdipDisposeImage(u.image);
4442 }
4443}
4444
4445/* Many people on the net ask why there is so much difference in rendered
4446 * text height between gdiplus and gdi32, this test suggests an answer to
4447 * that question. Important: this test assumes that font dpi == device dpi.
4448 */
4450{
4451 static const WCHAR string[] = L"1234567";
4452 HDC hdc;
4454 CharacterRange range = { 0, 7 };
4455 GpRegion *region;
4456 GpGraphics *graphics;
4457 GpFontFamily *family;
4458 GpFont *font;
4460 RectF bounds, rect;
4461 REAL height, dpi, scale;
4462 PointF ptf;
4463 GpUnit gfx_unit, font_unit;
4464
4466 expect(Ok, status);
4468 expect(Ok, status);
4469 status = GdipCreateRegion(&region);
4470 expect(Ok, status);
4471
4472 status = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
4473 expect(Ok, status);
4474
4476 status = GdipCreateFromHDC(hdc, &graphics);
4477 expect(Ok, status);
4478
4479 status = GdipGetDpiY(graphics, &dpi);
4480 expect(Ok, status);
4481
4482 /* First check if tested functionality works:
4483 * under XP if font and graphics units differ then GdipTransformPoints
4484 * followed by GdipSetPageUnit to change the graphics units breaks region
4485 * scaling in GdipMeasureCharacterRanges called later.
4486 */
4487 status = GdipSetPageUnit(graphics, UnitDocument);
4488 expect(Ok, status);
4489
4490 ptf.X = 0.0;
4491 ptf.Y = 0.0;
4493 expect(Ok, status);
4494
4495 status = GdipSetPageUnit(graphics, UnitInch);
4496 expect(Ok, status);
4497
4499 expect(Ok, status);
4500
4502 set_rect_empty(&bounds);
4503 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
4504 expect(Ok, status);
4505 trace("test bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);
4506
4508 rect.Width = 32000.0;
4509 rect.Height = 32000.0;
4510 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4511 expect(Ok, status);
4512
4514 status = GdipGetRegionBounds(region, graphics, &rect);
4515 expect(Ok, status);
4516 trace("test region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);
4517
4519
4520 scale = rect.Height / bounds.Height;
4521 if (fabs(scale - 1.0) > 0.1)
4522 {
4523 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale);
4524 goto cleanup;
4525 }
4526
4527 status = GdipScaleWorldTransform(graphics, 0.01, 0.01, MatrixOrderAppend);
4528 expect(Ok, status);
4529
4530 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4531 /* UnitPixel as a font base unit is not tested because it drastically
4532 differs in behaviour */
4533 for (font_unit = 3; font_unit <= 6; font_unit++)
4534 {
4535 /* create a font for the final text height of 100 pixels */
4536 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4537 status = GdipSetPageUnit(graphics, font_unit);
4538 expect(Ok, status);
4539 ptf.X = 0;
4540 ptf.Y = 75.0;
4542 expect(Ok, status);
4543 height = ptf.Y;
4544 /*trace("height %f units\n", height);*/
4545 status = GdipCreateFont(family, height, FontStyleRegular, font_unit, &font);
4546 expect(Ok, status);
4547
4548 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4549 for (gfx_unit = 2; gfx_unit <= 6; gfx_unit++)
4550 {
4551 RectF bounds_1, bounds_2;
4552 REAL margin, margin_y, font_height;
4553 int match;
4554
4555 status = GdipSetPageUnit(graphics, gfx_unit);
4556 expect(Ok, status);
4557
4558 margin_y = units_to_pixels(height / 8.0, font_unit, dpi);
4559 margin_y = pixels_to_units(margin_y, gfx_unit, dpi);
4560
4561 status = GdipGetFontHeight(font, graphics, &font_height);
4562 expect(Ok, status);
4563
4565 set_rect_empty(&bounds);
4566 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
4567 expect(Ok, status);
4568 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4569 todo_wine
4570 expectf_(font_height + margin_y, bounds.Height, 0.005);
4571
4572 ptf.X = 0;
4573 ptf.Y = bounds.Height;
4575 expect(Ok, status);
4576 match = fabs(100.0 - ptf.Y) <= 1.0;
4577 todo_wine
4578 ok(match, "Expected 100.0, got %f\n", ptf.Y);
4579
4580 /* verify the result */
4581 ptf.Y = units_to_pixels(bounds.Height, gfx_unit, dpi);
4582 ptf.Y /= 100.0;
4583 match = fabs(100.0 - ptf.Y) <= 1.0;
4584 todo_wine
4585 ok(match, "Expected 100.0, got %f\n", ptf.Y);
4586
4587 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4589 set_rect_empty(&bounds_1);
4590 status = GdipMeasureString(graphics, L"W", 1, font, &rect, format, &bounds_1, NULL, NULL);
4591 expect(Ok, status);
4592 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4594 set_rect_empty(&bounds_2);
4595 status = GdipMeasureString(graphics, L"WW", 2, font, &rect, format, &bounds_2, NULL, NULL);
4596 expect(Ok, status);
4597
4598 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4599 margin = bounds_1.Width - bounds_2.Width / 2.0;
4600 /*trace("margin %f\n", margin);*/
4601 ok(margin > 0.0, "wrong margin %f\n", margin);
4602
4604 rect.Width = 320000.0;
4605 rect.Height = 320000.0;
4606 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4607 expect(Ok, status);
4609 status = GdipGetRegionBounds(region, graphics, &rect);
4610 expect(Ok, status);
4611 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4612 ok(rect.X > 0.0, "wrong rect.X %f\n", rect.X);
4613 expectf(0.0, rect.Y);
4614 match = fabs(1.0 - margin / rect.X) <= 0.05;
4615 ok(match, "Expected %f, got %f\n", margin, rect.X);
4616 match = fabs(1.0 - font_height / rect.Height) <= 0.1;
4617 ok(match, "Expected %f, got %f\n", font_height, rect.Height);
4618 match = fabs(1.0 - bounds.Width / (rect.Width + margin * 2.0)) <= 0.05;
4619 ok(match, "Expected %f, got %f\n", bounds.Width, rect.Width + margin * 2.0);
4620 }
4621
4623 }
4624
4625cleanup:
4626 status = GdipDeleteGraphics(graphics);
4627 expect(Ok, status);
4628 DeleteDC(hdc);
4629
4630 GdipDeleteFontFamily(family);
4631 GdipDeleteRegion(region);
4633}
4634
4635static void test_measure_string(void)
4636{
4637 static const WCHAR string[] = L"A01";
4638 static const WCHAR string2[] = L"M MM";
4639 HDC hdc;
4640 GpStringFormat *format, *format_no_wrap;
4642 GpRegion *region;
4643 GpGraphics *graphics;
4644 GpFontFamily *family;
4645 GpFont *font;
4647 RectF bounds, rect;
4648 REAL width, height, width_1, width_2, width_MM, width_M_M;
4649 REAL margin_x, margin_y, width_rgn, height_rgn;
4650 int lines, glyphs;
4651
4653 expect(Ok, status);
4654 expect(Ok, status);
4655
4656 status = GdipCreateRegion(&region);
4657 expect(Ok, status);
4658
4659 status = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
4660 expect(Ok, status);
4661
4663 status = GdipCreateFromHDC(hdc, &graphics);
4664
4666 expect(Ok, status);
4667
4668 margin_x = 20.0 / 6.0;
4669 margin_y = 20.0 / 8.0;
4670
4672 set_rect_empty(&bounds);
4673 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4674 expect(Ok, status);
4675 expect(3, glyphs);
4676 expect(1, lines);
4677 expectf(0.0, bounds.X);
4678 expectf(0.0, bounds.Y);
4679 width = bounds.Width;
4680 height = bounds.Height;
4681
4683 rect.Height = height / 2.0;
4684 set_rect_empty(&bounds);
4685 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4686 expect(Ok, status);
4687 expect(3, glyphs);
4688 expect(1, lines);
4689 expectf(0.0, bounds.X);
4690 expectf(0.0, bounds.Y);
4691 expectf(width, bounds.Width);
4692 expectf(height / 2.0, bounds.Height);
4693
4694 range.First = 0;
4695 range.Length = lstrlenW(string);
4697 expect(Ok, status);
4698
4699 rect.X = 5.0;
4700 rect.Y = 5.0;
4701 rect.Width = 32000.0;
4702 rect.Height = 32000.0;
4703 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4704 expect(Ok, status);
4705 set_rect_empty(&bounds);
4706 status = GdipGetRegionBounds(region, graphics, &bounds);
4707 expect(Ok, status);
4708 expectf_(5.0 + margin_x, bounds.X, 1.0);
4709 expectf(5.0, bounds.Y);
4710 expectf_(width - margin_x*2.0, bounds.Width, 1.0);
4711 todo_wine
4712 expectf_(height - margin_y, bounds.Height, 1.0);
4713
4714 width_rgn = bounds.Width;
4715 height_rgn = bounds.Height;
4716
4717 range.First = 0;
4718 range.Length = 1;
4720 expect(Ok, status);
4721
4723 rect.Width = 32000.0;
4724 rect.Height = 32000.0;
4725 status = GdipMeasureCharacterRanges(graphics, string, 1, font, &rect, format, 1, &region);
4726 expect(Ok, status);
4727 set_rect_empty(&bounds);
4728 status = GdipGetRegionBounds(region, graphics, &bounds);
4729 expect(Ok, status);
4730 expectf_(margin_x, bounds.X, 1.0);
4731 expectf(0.0, bounds.Y);
4732 ok(bounds.Width < width_rgn / 2.0, "width of 1 glyph is wrong\n");
4733 expectf(height_rgn, bounds.Height);
4734 width_1 = bounds.Width;
4735
4736 range.First = 0;
4737 range.Length = lstrlenW(string);
4739 expect(Ok, status);
4740
4741 rect.X = 5.0;
4742 rect.Y = 5.0;
4743 rect.Width = 0.0;
4744 rect.Height = 0.0;
4745 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4746 expect(Ok, status);
4747 set_rect_empty(&bounds);
4748 status = GdipGetRegionBounds(region, graphics, &bounds);
4749 expect(Ok, status);
4750 expectf(0.0, bounds.X);
4751 expectf(0.0, bounds.Y);
4752 expectf(0.0, bounds.Width);
4753 expectf(0.0, bounds.Height);
4754
4755 rect.X = 5.0;
4756 rect.Y = 5.0;
4757 rect.Width = width_rgn / 2.0;
4758 rect.Height = 32000.0;
4759 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4760 expect(Ok, status);
4761 set_rect_empty(&bounds);
4762 status = GdipGetRegionBounds(region, graphics, &bounds);
4763 expect(Ok, status);
4764 expectf_(5.0 + margin_x, bounds.X, 1.0);
4765 expectf(5.0, bounds.Y);
4766 expectf_(width_1, bounds.Width, 1.0);
4767 todo_wine
4768 expectf_(height - margin_y, bounds.Height, 1.0);
4769
4771
4772 rect.X = 5.0;
4773 rect.Y = 5.0;
4774 rect.Width = 0.0;
4775 rect.Height = 0.0;
4776 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4777 expect(Ok, status);
4778 set_rect_empty(&bounds);
4779 status = GdipGetRegionBounds(region, graphics, &bounds);
4780 expect(Ok, status);
4781 expectf_(5.0 + margin_x, bounds.X, 1.0);
4782 expectf(5.0, bounds.Y);
4783 expectf(width_rgn, bounds.Width);
4784 expectf(height_rgn, bounds.Height);
4785
4786 rect.X = 5.0;
4787 rect.Y = 5.0;
4788 rect.Width = width_rgn / 2.0;
4789 rect.Height = 32000.0;
4790 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4791 expect(Ok, status);
4792 set_rect_empty(&bounds);
4793 status = GdipGetRegionBounds(region, graphics, &bounds);
4794 expect(Ok, status);
4795 expectf_(5.0 + margin_x, bounds.X, 1.0);
4796 expectf(5.0, bounds.Y);
4797 expectf_(width_1, bounds.Width, 1.0);
4798 expectf(height_rgn, bounds.Height);
4799
4801 rect.Height = height / 2.0;
4802 set_rect_empty(&bounds);
4803 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4804 expect(Ok, status);
4805 expect(3, glyphs);
4806 expect(1, lines);
4807 expectf(0.0, bounds.X);
4808 expectf(0.0, bounds.Y);
4809 expectf_(width, bounds.Width, 0.01);
4810 todo_wine
4811 expectf(height, bounds.Height);
4812
4814 set_rect_empty(&bounds);
4815 status = GdipMeasureString(graphics, string, 1, font, &rect, format, &bounds, &glyphs, &lines);
4816 expect(Ok, status);
4817 expect(1, glyphs);
4818 expect(1, lines);
4819 expectf(0.0, bounds.X);
4820 expectf(0.0, bounds.Y);
4821 ok(bounds.Width < width / 2.0, "width of 1 glyph is wrong\n");
4822 expectf(height, bounds.Height);
4823 width_1 = bounds.Width;
4824
4826 set_rect_empty(&bounds);
4827 status = GdipMeasureString(graphics, string, 2, font, &rect, format, &bounds, &glyphs, &lines);
4828 expect(Ok, status);
4829 expect(2, glyphs);
4830 expect(1, lines);
4831 expectf(0.0, bounds.X);
4832 expectf(0.0, bounds.Y);
4833 ok(bounds.Width < width, "width of 2 glyphs is wrong\n");
4834 ok(bounds.Width > width_1, "width of 2 glyphs is wrong\n");
4835 expectf(height, bounds.Height);
4836 width_2 = bounds.Width;
4837
4839 rect.Width = width / 2.0;
4840 set_rect_empty(&bounds);
4841 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4842 expect(Ok, status);
4843 expect(1, glyphs);
4844 expect(1, lines);
4845 expectf(0.0, bounds.X);
4846 expectf(0.0, bounds.Y);
4847 expectf_(width_1, bounds.Width, 0.01);
4848 expectf(height, bounds.Height);
4849
4851 rect.Height = height;
4852 rect.Width = width - 0.05;
4853 set_rect_empty(&bounds);
4854 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4855 expect(Ok, status);
4856 expect(2, glyphs);
4857 expect(1, lines);
4858 expectf(0.0, bounds.X);
4859 expectf(0.0, bounds.Y);
4860 expectf_(width_2, bounds.Width, 0.01);
4861 expectf(height, bounds.Height);
4862
4864 rect.Height = height;
4865 rect.Width = width_2 - 0.006;
4866 set_rect_empty(&bounds);
4867 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4868 expect(Ok, status);
4869 expect(1, glyphs);
4870 expect(1, lines);
4871 expectf(0.0, bounds.X);
4872 expectf(0.0, bounds.Y);
4873 expectf_(width_1, bounds.Width, 0.01);
4874 expectf(height, bounds.Height);
4875
4877 rect.Height = height;
4878 rect.Width = width_2 - 0.004;
4879 set_rect_empty(&bounds);
4880 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4881 expect(Ok, status);
4882 expect(2, glyphs);
4883 expect(1, lines);
4884 expectf(0.0, bounds.X);
4885 expectf(0.0, bounds.Y);
4886 expectf_(width_2, bounds.Width, 0.01);
4887 expectf(height, bounds.Height);
4888
4889 /* Default (Near) alignment */
4890 rect.X = 5.0;
4891 rect.Y = 5.0;
4892 rect.Width = width * 2.0;
4893 rect.Height = height * 2.0;
4894 set_rect_empty(&bounds);
4895 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4896 expect(Ok, status);
4897 expect(3, glyphs);
4898 expect(1, lines);
4899 expectf(5.0, bounds.X);
4900 expectf(5.0, bounds.Y);
4901 expectf_(width, bounds.Width, 0.01);
4902 expectf(height, bounds.Height);
4903
4904 rect.X = 5.0;
4905 rect.Y = 5.0;
4906 rect.Width = 32000.0;
4907 rect.Height = 32000.0;
4908 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4909 expect(Ok, status);
4910 set_rect_empty(&bounds);
4911 status = GdipGetRegionBounds(region, graphics, &bounds);
4912 expect(Ok, status);
4913 expectf_(5.0 + margin_x, bounds.X, 1.0);
4914 expectf(5.0, bounds.Y);
4915 expectf_(width - margin_x*2.0, bounds.Width, 1.0);
4916 todo_wine
4917 expectf_(height - margin_y, bounds.Height, 1.0);
4918
4919 width_rgn = bounds.Width;
4920 height_rgn = bounds.Height;
4921
4922 /* Center alignment */
4925
4926 rect.X = 5.0;
4927 rect.Y = 5.0;
4928 rect.Width = width * 2.0;
4929 rect.Height = height * 2.0;
4930 set_rect_empty(&bounds);
4931 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4932 expect(Ok, status);
4933 expect(3, glyphs);
4934 expect(1, lines);
4935 expectf_(5.0 + width/2.0, bounds.X, 0.01);
4936 todo_wine
4937 expectf(5.0 + height/2.0, bounds.Y);
4938 expectf_(width, bounds.Width, 0.01);
4939 expectf(height, bounds.Height);
4940
4941 rect.X = 5.0;
4942 rect.Y = 5.0;
4943 rect.Width = 0.0;
4944 rect.Height = 0.0;
4945 set_rect_empty(&bounds);
4946 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4947 expect(Ok, status);
4948 expect(3, glyphs);
4949 expect(1, lines);
4950 todo_wine
4951 expectf_(5.0 - width/2.0, bounds.X, 0.01);
4952 todo_wine
4953 expectf(5.0 - height/2.0, bounds.Y);
4954 expectf_(width, bounds.Width, 0.01);
4955 expectf(height, bounds.Height);
4956
4957 rect.X = 5.0;
4958 rect.Y = 5.0;
4959 rect.Width = width_rgn * 2.0;
4960 rect.Height = height_rgn * 2.0;
4961 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4962 expect(Ok, status);
4963 set_rect_empty(&bounds);
4964 status = GdipGetRegionBounds(region, graphics, &bounds);
4965 expect(Ok, status);
4966 todo_wine
4967 expectf_(5.0 + width_rgn/2.0, bounds.X, 1.0);
4968 todo_wine
4969 expectf_(5.0 + height_rgn/2.0, bounds.Y, 1.0);
4970 expectf_(width_rgn, bounds.Width, 1.0);
4971 expectf_(height_rgn, bounds.Height, 1.0);
4972
4973 rect.X = 5.0;
4974 rect.Y = 5.0;
4975 rect.Width = 0.0;
4976 rect.Height = 0.0;
4977 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4978 expect(Ok, status);
4979 set_rect_empty(&bounds);
4980 status = GdipGetRegionBounds(region, graphics, &bounds);
4981 expect(Ok, status);
4982 todo_wine
4983 expectf_(5.0 - width_rgn/2.0, bounds.X, 1.0);
4984 todo_wine
4985 expectf_(5.0 - height_rgn/2.0, bounds.Y, 1.0);
4986 expectf_(width_rgn, bounds.Width, 1.0);
4987 expectf_(height_rgn, bounds.Height, 1.0);
4988
4989 /* Far alignment */
4992
4993 rect.X = 5.0;
4994 rect.Y = 5.0;
4995 rect.Width = width * 2.0;
4996 rect.Height = height * 2.0;
4997 set_rect_empty(&bounds);
4998 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
4999 expect(Ok, status);
5000 expect(3, glyphs);
5001 expect(1, lines);
5002 expectf_(5.0 + width, bounds.X, 0.01);
5003 todo_wine
5004 expectf(5.0 + height, bounds.Y);
5005 expectf_(width, bounds.Width, 0.01);
5006 expectf(height, bounds.Height);
5007
5008 rect.X = 5.0;
5009 rect.Y = 5.0;
5010 rect.Width = 0.0;
5011 rect.Height = 0.0;
5012 set_rect_empty(&bounds);
5013 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
5014 expect(Ok, status);
5015 expect(3, glyphs);
5016 expect(1, lines);
5017 todo_wine
5018 expectf_(5.0 - width, bounds.X, 0.01);
5019 todo_wine
5020 expectf(5.0 - height, bounds.Y);
5021 expectf_(width, bounds.Width, 0.01);
5022 expectf(height, bounds.Height);
5023
5024 rect.X = 5.0;
5025 rect.Y = 5.0;
5026 rect.Width = width_rgn * 2.0;
5027 rect.Height = height_rgn * 2.0;
5028 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
5029 expect(Ok, status);
5030 set_rect_empty(&bounds);
5031 status = GdipGetRegionBounds(region, graphics, &bounds);
5032 expect(Ok, status);
5033 todo_wine
5034 expectf_(5.0 + width_rgn, bounds.X, 2.0);
5035 todo_wine
5036 expectf_(5.0 + height_rgn, bounds.Y, 1.0);
5037 expectf_(width_rgn, bounds.Width, 1.0);
5038 expectf_(height_rgn, bounds.Height, 1.0);
5039
5040 rect.X = 5.0;
5041 rect.Y = 5.0;
5042 rect.Width = 0.0;
5043 rect.Height = 0.0;
5044 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
5045 expect(Ok, status);
5046 set_rect_empty(&bounds);
5047 status = GdipGetRegionBounds(region, graphics, &bounds);
5048 expect(Ok, status);
5049 todo_wine
5050 expectf_(5.0 - width_rgn, bounds.X, 2.0);
5051 todo_wine
5052 expectf_(5.0 - height_rgn, bounds.Y, 1.0);
5053 expectf_(width_rgn, bounds.Width, 1.0);
5054 expectf_(height_rgn, bounds.Height, 1.0);
5055
5056 /* Measure "MM" */
5057 rect.X = 5.0;
5058 rect.Y = 5.0;
5059 rect.Width = 32000.0;
5060 rect.Height = 32000.0;
5061 status = GdipMeasureString(graphics, string2 + 2, 2, font, &rect, NULL, &bounds, &glyphs, &lines);
5062 expect(Ok, status);
5063 expect(2, glyphs);
5064 expect(1, lines);
5065 width_MM = bounds.Width;
5066
5067 /* Measure "M M" */
5068 rect.X = 5.0;
5069 rect.Y = 5.0;
5070 rect.Width = 32000.0;
5071 rect.Height = 32000.0;
5072 status = GdipMeasureString(graphics, string2, 3, font, &rect, NULL, &bounds, &glyphs, &lines);
5073 expect(Ok, status);
5074 expect(3, glyphs);
5075 expect(1, lines);
5076 width_M_M = bounds.Width;
5077
5078 /* With wrap */
5079 rect.X = 5.0;
5080 rect.Y = 5.0;
5081 rect.Width = width_M_M;
5082 rect.Height = 32000.0;
5083 status = GdipMeasureString(graphics, string2, -1, font, &rect, NULL, &bounds, &glyphs, &lines);
5084 expect(Ok, status);
5085 expectf_(width_MM, bounds.Width, 0.1);
5086 expect(4, glyphs);
5087 expect(2, lines);
5088
5089 /* Without wrap */
5091 expect(Ok, status);
5092
5093 rect.X = 5.0;
5094 rect.Y = 5.0;
5095 rect.Width = width_M_M;
5096 rect.Height = 32000.0;
5097 status = GdipMeasureString(graphics, string2, -1, font, &rect, format_no_wrap, &bounds, &glyphs, &lines);
5098 expect(Ok, status);
5099 expectf_(width_M_M, bounds.Width, 0.1);
5100 expect(3, glyphs);
5101 expect(1, lines);
5102
5104 expect(Ok, status);
5105
5106 status = GdipDeleteGraphics(graphics);
5107 expect(Ok, status);
5108 DeleteDC(hdc);
5109
5110 GdipDeleteFontFamily(family);
5111 GdipDeleteRegion(region);
5113 GdipDeleteStringFormat(format_no_wrap);
5114}
5115
5117{
5119 HDC hdc;
5120 GpGraphics *graphics;
5121 GpFontFamily *family;
5122 GpFont *font;
5124 GpUnit gfx_unit, font_unit;
5125 RectF bounds_1, bounds_2, rect;
5126 REAL margin, font_size, dpi;
5127
5129 expect(Ok, status);
5130
5131 status = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
5132 expect(Ok, status);
5134 status = GdipCreateFromHDC(hdc, &graphics);
5135 expect(Ok, status);
5136
5137 status = GdipGetDpiX(graphics, &dpi);
5138 expect(Ok, status);
5139
5140 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
5141 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
5142 for (font_unit = 3; font_unit <= 6; font_unit++)
5143 {
5144 status = GdipCreateFont(family, 1234.0, FontStyleRegular, font_unit, &font);
5145 expect(Ok, status);
5146
5147 status = GdipGetFontSize(font, &font_size);
5148 expect(Ok, status);
5149 font_size = units_to_pixels(font_size, font_unit, dpi);
5150 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
5151
5152 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
5153 for (gfx_unit = 2; gfx_unit <= 6; gfx_unit++)
5154 {
5155 status = GdipSetPageUnit(graphics, gfx_unit);
5156 expect(Ok, status);
5157
5158 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
5160 set_rect_empty(&bounds_1);
5161 status = GdipMeasureString(graphics, L"W", 1, font, &rect, format, &bounds_1, NULL, NULL);
5162 expect(Ok, status);
5163 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
5165 set_rect_empty(&bounds_2);
5166 status = GdipMeasureString(graphics, L"WW", 2, font, &rect, format, &bounds_2, NULL, NULL);
5167 expect(Ok, status);
5168
5169 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
5170 margin = units_to_pixels(bounds_1.Width - bounds_2.Width / 2.0, gfx_unit, dpi);
5171 /*trace("margin %f pixels\n", margin);*/
5172 expectf_(font_size / 6.0, margin, font_size / 100.0);
5173 }
5174
5176 }
5177
5178 GdipDeleteGraphics(graphics);
5179 DeleteDC(hdc);
5180 GdipDeleteFontFamily(family);
5182}
5183
5184static void test_alpha_hdc(void)
5185{
5187 HDC hdc, gp_hdc;
5188 HBITMAP hbm, old_hbm;
5189 GpGraphics *graphics;
5190 ULONG *bits;
5191 BITMAPINFO bmi;
5192 GpRectF bounds;
5193 COLORREF colorref;
5194
5196 ok(hdc != NULL, "CreateCompatibleDC failed\n");
5197 bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
5198 bmi.bmiHeader.biHeight = 5;
5199 bmi.bmiHeader.biWidth = 5;
5200 bmi.bmiHeader.biBitCount = 32;
5201 bmi.bmiHeader.biPlanes = 1;
5203 bmi.bmiHeader.biClrUsed = 0;
5204
5205 hbm = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
5206 ok(hbm != NULL, "CreateDIBSection failed\n");
5207
5208 old_hbm = SelectObject(hdc, hbm);
5209
5210 status = GdipCreateFromHDC(hdc, &graphics);
5211 expect(Ok, status);
5212
5213 status = GdipGetVisibleClipBounds(graphics, &bounds);
5214 expect(Ok, status);
5215 expectf(0.0, bounds.X);
5216 expectf(0.0, bounds.Y);
5217 expectf(5.0, bounds.Width);
5218 expectf(5.0, bounds.Height);
5219
5220 bits[0] = 0xdeadbeef;
5221
5222 status = GdipGraphicsClear(graphics, 0xffaaaaaa);
5223 expect(Ok, status);
5224
5225 expect(0xffaaaaaa, bits[0]);
5226
5227 bits[0] = 0xdeadbeef;
5228
5229 status = GdipGetDC(graphics, &gp_hdc);
5230 expect(Ok, status);
5231
5232 colorref = GetPixel(gp_hdc, 0, 4);
5233 expect(0xefbead, colorref);
5234
5235 SetPixel(gp_hdc, 0, 4, 0xffffff);
5236
5237 expect(0xffffff, bits[0]);
5238
5239 status = GdipReleaseDC(graphics, gp_hdc);
5240 expect(Ok, status);
5241
5242 SelectObject(hdc, old_hbm);
5243
5244 bits[0] = 0xdeadbeef;
5245
5246 status = GdipGraphicsClear(graphics, 0xffbbbbbb);
5247 expect(Ok, status);
5248
5249 todo_wine expect(0xffbbbbbb, bits[0]);
5250
5251 GdipDeleteGraphics(graphics);
5252
5254 DeleteDC(hdc);
5255}
5256
5258{
5259 GpStatus stat;
5260 GpGraphics *graphics = NULL;
5261 HDC hdc = GetDC( hwnd );
5262 GpBitmap *bitmap = NULL;
5264 REAL imageres, graphicsres;
5265 UINT width, height;
5266
5267 stat = GdipCreateFromHDC(hdc, &graphics);
5268 expect(Ok, stat);
5269
5272
5273 stat = GdipCreateBitmapFromGraphics(12, 13, graphics, NULL);
5275
5276 stat = GdipCreateBitmapFromGraphics(12, 13, graphics, &bitmap);
5277 expect(Ok, stat);
5278
5280 expect(Ok, stat);
5282
5283 stat = GdipGetDpiX(graphics, &graphicsres);
5284 expect(Ok, stat);
5285
5287 expect(Ok, stat);
5288 expectf(graphicsres, imageres);
5289
5290 stat = GdipGetDpiY(graphics, &graphicsres);
5291 expect(Ok, stat);
5292
5294 expect(Ok, stat);
5295 expectf(graphicsres, imageres);
5296
5298 expect(Ok, stat);
5299 expect(12, width);
5300
5302 expect(Ok, stat);
5303 expect(13, height);
5304
5305 GdipDeleteGraphics(graphics);
5307}
5308
5309static void test_clipping(void)
5310{
5311 HDC hdc;
5313 GpGraphics *graphics;
5314 GpRegion *region, *region100x100;
5316 GpRectF rect;
5317 GpRect recti;
5318 GpPointF ptf[4];
5319 GpUnit unit;
5320 HRGN hrgn;
5321 int ret;
5322 RECT rc;
5323
5325 status = GdipCreateFromHDC(hdc, &graphics);
5326 expect(Ok, status);
5327
5328 status = GdipGetPageUnit(graphics, &unit);
5329 expect(Ok, status);
5331
5332 status = GdipCreateRegion(&region);
5333 expect(Ok, status);
5334 status = GdipSetEmpty(region);
5335 expect(Ok, status);
5336
5337 status = GdipCreateRegion(&region100x100);
5338 expect(Ok, status);
5339 status = GdipSetEmpty(region100x100);
5340 expect(Ok, status);
5341
5342 rect.X = rect.Y = 100.0;
5343 rect.Width = rect.Height = 100.0;
5345 expect(Ok, status);
5346 status = GdipSetClipRegion(graphics, region100x100, CombineModeReplace);
5347 expect(Ok, status);
5348
5349 status = GdipGetClipBounds(graphics, &rect);
5350 expect(Ok, status);
5351 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5352 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5353
5354 status = GdipGetClipBoundsI(graphics, &recti);
5355 expect(Ok, status);
5356 ok(recti.X == 100 && recti.Y == 100 && recti.Width == 100 && recti.Height == 100,
5357 "expected 100,100-100,100, got %i,%i-%i,%i\n", recti.X, recti.Y, recti.Width, recti.Height);
5358
5359 /* Clip region does not account for changes to gdi32 transform */
5360 SetViewportOrgEx(hdc, 10, 10, NULL);
5361
5362 status = GdipGetClipBounds(graphics, &rect);
5363 expect(Ok, status);
5364 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5365 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5366
5367 SetViewportOrgEx(hdc, 0, 0, NULL);
5368
5369 status = GdipSetEmpty(region);
5370 expect(Ok, status);
5371 status = GdipGetClip(graphics, region);
5372 expect(Ok, status);
5373 status = GdipGetRegionBounds(region, graphics, &rect);
5374 expect(Ok, status);
5375 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5376 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5377
5378 ptf[0].X = 100.0;
5379 ptf[0].Y = 100.0;
5380 ptf[1].X = 200.0;
5381 ptf[1].Y = 200.0;
5383 expect(Ok, status);
5384 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5385 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5386
5388 expect(Ok, status);
5390 expect(Ok, status);
5392 expect(Ok, status);
5393 status = GdipSetWorldTransform(graphics, matrix);
5394 expect(Ok, status);
5395
5396 status = GdipGetClipBounds(graphics, &rect);
5397 expect(Ok, status);
5398 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5399 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5400
5401 status = GdipGetClipBoundsI(graphics, &recti);
5402 expect(Ok, status);
5403 ok(recti.X == 45 && recti.Y == 20 && recti.Width == 50 && recti.Height == 25,
5404 "expected 45,20-50,25, got %i,%i-%i,%i\n", recti.X, recti.Y, recti.Width, recti.Height);
5405
5406 status = GdipSetEmpty(region);
5407 expect(Ok, status);
5408 status = GdipGetClip(graphics, region);
5409 expect(Ok, status);
5410 status = GdipGetRegionBounds(region, graphics, &rect);
5411 expect(Ok, status);
5412 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5413 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5414
5415 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5416 expect(Ok, status);
5417 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5418 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5419
5420 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5421 expect(Ok, status);
5422 ret = GetRgnBox(hrgn, &rc);
5423 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5424 ok(rc.left == 45 && rc.top == 20 && rc.right == 95 && rc.bottom == 45,
5425 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc));
5427
5428 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5429 expect(Ok, status);
5430 ret = GetRgnBox(hrgn, &rc);
5431 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5432 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5433 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5435
5436 ptf[0].X = 100.0;
5437 ptf[0].Y = 100.0;
5438 ptf[1].X = 200.0;
5439 ptf[1].Y = 200.0;
5441 expect(Ok, status);
5442 ok(ptf[0].X == 45.0 && ptf[0].Y == 20.0 && ptf[1].X == 95.0 && ptf[1].Y == 45.0,
5443 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5444
5445 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5446 expect(Ok, status);
5447 ret = GetRgnBox(hrgn, &rc);
5448 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5449 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5450 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5452
5453 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5454 expect(Ok, status);
5455 ret = GetRgnBox(hrgn, &rc);
5456 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5457 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5458 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5460
5461 ptf[0].X = 210.0;
5462 ptf[0].Y = 420.0;
5463 ptf[1].X = 410.0;
5464 ptf[1].Y = 820.0;
5466 expect(Ok, status);
5467 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5468 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5469
5470 status = GdipSetPageScale(graphics, 2.0);
5471 expect(Ok, status);
5472
5473 status = GdipGetClipBounds(graphics, &rect);
5474 expect(Ok, status);
5475 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5476 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5477
5478 status = GdipSetEmpty(region);
5479 expect(Ok, status);
5480 status = GdipGetClip(graphics, region);
5481 expect(Ok, status);
5482 status = GdipGetRegionBounds(region, graphics, &rect);
5483 expect(Ok, status);
5484 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5485 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5486
5487 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5488 expect(Ok, status);
5489 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5490 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5491
5492 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5493 expect(Ok, status);
5494 ret = GetRgnBox(hrgn, &rc);
5495 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5496 ok(rc.left == 45 && rc.top == 20 && rc.right == 95 && rc.bottom == 45,
5497 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc));
5499
5500 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5501 expect(Ok, status);
5502 ret = GetRgnBox(hrgn, &rc);
5503 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5504 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5505 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5507
5508 ptf[0].X = 100.0;
5509 ptf[0].Y = 100.0;
5510 ptf[1].X = 200.0;
5511 ptf[1].Y = 200.0;
5513 expect(Ok, status);
5514 ok(ptf[0].X == 45.0 && ptf[0].Y == 20.0 && ptf[1].X == 95.0 && ptf[1].Y == 45.0,
5515 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5516
5517 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5518 expect(Ok, status);
5519 ret = GetRgnBox(hrgn, &rc);
5520 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5521 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5522 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5524
5525 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5526 expect(Ok, status);
5527 ret = GetRgnBox(hrgn, &rc);
5528 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5529 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5530 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5532
5533 ptf[0].X = 210.0;
5534 ptf[0].Y = 420.0;
5535 ptf[1].X = 410.0;
5536 ptf[1].Y = 820.0;
5538 expect(Ok, status);
5539 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5540 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5541
5542 GdipSetPageUnit(graphics, UnitPoint);
5543 expect(Ok, status);
5544
5545 status = GdipGetClipBounds(graphics, &rect);
5546 expect(Ok, status);
5547 ok((rect.X == 13.75 && rect.Y == 4.375 && rect.Width == 18.75 && rect.Height == 9.375) ||
5548 /* rounding under Wine is slightly different */
5549 (rect.X == 14.0 && rect.Y == 4.0 && rect.Width == 19.0 && rect.Height == 10.0) /* Wine */ ||
5550 broken(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0) /* before Win7 */,
5551 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5552
5553 status = GdipSetEmpty(region);
5554 expect(Ok, status);
5555 status = GdipGetClip(graphics, region);
5556 expect(Ok, status);
5557 status = GdipGetRegionBounds(region, graphics, &rect);
5558 expect(Ok, status);
5559 ok((rect.X == 13.75 && rect.Y == 4.375 && rect.Width == 18.75 && rect.Height == 9.375) ||
5560 /* rounding under Wine is slightly different */
5561 (rect.X == 14.0 && rect.Y == 4.0 && rect.Width == 19.0 && rect.Height == 10.0) /* Wine */ ||
5562 broken(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0) /* before Win7 */,
5563 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5564
5565 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5566 expect(Ok, status);
5567 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5568 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5569
5570 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5571 expect(Ok, status);
5572 ret = GetRgnBox(hrgn, &rc);
5573 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5574 ok((rc.left == 14 && rc.top == 5 && rc.right == 33 && rc.bottom == 14) ||
5575 /* rounding under Wine is slightly different */
5576 (rc.left == 14 && rc.top == 4 && rc.right == 33 && rc.bottom == 14) /* Wine */ ||
5577 broken(rc.left == 45 && rc.top == 20 && rc.right == 95 && rc.bottom == 45) /* before Win7 */,
5578 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc));
5580
5581 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5582 expect(Ok, status);
5583 ret = GetRgnBox(hrgn, &rc);
5584 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5585 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
5586 broken(rc.left == 267 && rc.top == 267 && rc.right == 534 && rc.bottom == 534) /* before Win7 */,
5587 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5589
5590 ptf[0].X = 100.0;
5591 ptf[0].Y = 100.0;
5592 ptf[1].X = 200.0;
5593 ptf[1].Y = 200.0;
5595 expect(Ok, status);
5596 ok((ptf[0].X == 13.75 && ptf[0].Y == 4.375 && ptf[1].X == 32.5 && ptf[1].Y == 13.75) ||
5597 broken(ptf[0].X == 45.0 && ptf[0].Y == 20.0 && ptf[1].X == 95.0 && ptf[1].Y == 45.0) /* before Win7 */,
5598 "expected 13.75,4.375-32.5,13.75, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5599
5600 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5601 expect(Ok, status);
5602 ret = GetRgnBox(hrgn, &rc);
5603 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5604 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5605 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5607
5608 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5609 expect(Ok, status);
5610 ret = GetRgnBox(hrgn, &rc);
5611 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5612 ok((rc.left == 560 && rc.top == 1120 && rc.right == 1094 && rc.bottom == 2187) ||
5613 /* rounding under Wine is slightly different */
5614 (rc.left == 560 && rc.top == 1120 && rc.right == 1093 && rc.bottom == 2187) /* Wine */,
5615 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc));
5617
5618 ptf[0].X = 560.0;
5619 ptf[0].Y = 1120.0;
5620 ptf[1].X = 1094.0;
5621 ptf[1].Y = 2187.0;
5623 expect(Ok, status);
5624 if (fabs(ptf[0].X - 100.0) < 0.001)
5625 {
5626 expectf(100.0, ptf[0].X);
5627 expectf(100.0, ptf[0].Y);
5628 expectf(200.125, ptf[1].X);
5629 expectf(200.03125, ptf[1].Y);
5630 }
5631 else /* before Win7 */
5632 {
5633 ok(broken(fabs(ptf[0].X - 275.0) < 0.001), "expected 275.0, got %f\n", ptf[0].X);
5634 ok(broken(fabs(ptf[0].Y - 275.0) < 0.001), "expected 275.0, got %f\n", ptf[0].Y);
5635 ok(broken(fabs(ptf[1].X - 542.0) < 0.001), "expected 542.0, got %f\n", ptf[1].X);
5636 ok(broken(fabs(ptf[1].Y - 541.75) < 0.001), "expected 541.75, got %f\n", ptf[1].Y);
5637 }
5638
5639 status = GdipTransformRegion(region100x100, matrix);
5640 expect(Ok, status);
5641
5642 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5643 expect(Ok, status);
5644 ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
5645 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5646
5647 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5648 expect(Ok, status);
5649 ret = GetRgnBox(hrgn, &rc);
5650 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5651 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5652 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5654
5655 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5656 expect(Ok, status);
5657 ret = GetRgnBox(hrgn, &rc);
5658 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5659 ok((rc.left == 1147 && rc.top == 4534 && rc.right == 2214 && rc.bottom == 8800) ||
5660 /* rounding under Wine is slightly different */
5661 (rc.left == 1147 && rc.top == 4533 && rc.right == 2213 && rc.bottom == 8800) /* Wine */,
5662 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc));
5664
5665 ptf[0].X = 1147.0;
5666 ptf[0].Y = 4534.0;
5667 ptf[1].X = 2214.0;
5668 ptf[1].Y = 8800.0;
5670 expect(Ok, status);
5671 if (fabs(ptf[0].X - 210.0625) < 0.001)
5672 {
5673 expectf(210.0625, ptf[0].X);
5674 expectf(420.0625, ptf[0].Y);
5675 expectf(410.125, ptf[1].X);
5676 expectf(820.0, ptf[1].Y);
5677 }
5678 else /* before Win7 */
5679 {
5680 ok(broken(fabs(ptf[0].X - 568.5) < 0.001), "expected 568.5, got %f\n", ptf[0].X);
5681 ok(broken(fabs(ptf[0].Y - 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf[0].Y);
5682 ok(broken(fabs(ptf[1].X - 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf[1].X);
5683 ok(broken(fabs(ptf[1].Y - 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf[1].Y);
5684 }
5685
5687 expect(Ok, status);
5688 status = GdipSetWorldTransform(graphics, matrix);
5689 expect(Ok, status);
5690
5691 status = GdipGetClipBounds(graphics, &rect);
5692 expect(Ok, status);
5693 expectf_(20.612978, rect.X, 1.0);
5694 expectf_(-6.256012, rect.Y, 1.5);
5695 expectf_(25.612978, rect.Width, 1.0);
5696 expectf_(12.806489, rect.Height, 1.0);
5697
5698 status = GdipSetEmpty(region);
5699 expect(Ok, status);
5700 status = GdipGetClip(graphics, region);
5701 expect(Ok, status);
5702 status = GdipGetRegionBounds(region, graphics, &rect);
5703 expect(Ok, status);
5704 /* rounding under Wine is slightly different */
5705 expectf_(20.612978, rect.X, 1.0);
5706 expectf_(-6.256012, rect.Y, 1.5);
5707 expectf_(25.612978, rect.Width, 1.0);
5708 expectf_(12.806489, rect.Height, 1.0);
5709
5710 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5711 expect(Ok, status);
5712 ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
5713 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);
5714
5715 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5716 expect(Ok, status);
5717 ret = GetRgnBox(hrgn, &rc);
5718 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5719 ok((rc.left == 22 && rc.top == -6 && rc.right == 46 && rc.bottom == 7) ||
5720 /* rounding under Wine is slightly different */
5721 (rc.left == 21 && rc.top == -5 && rc.right == 46 && rc.bottom == 7) /* Wine */,
5722 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc));
5724
5725 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5726 expect(Ok, status);
5727 ret = GetRgnBox(hrgn, &rc);
5728 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5729 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5730 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5732
5733 ptf[0].X = 100.0;
5734 ptf[0].Y = 100.0;
5735 ptf[1].X = 200.0;
5736 ptf[1].Y = 200.0;
5737 ptf[2].X = 200.0;
5738 ptf[2].Y = 100.0;
5739 ptf[3].X = 100.0;
5740 ptf[3].Y = 200.0;
5742 expect(Ok, status);
5743 expectf(20.612978, ptf[0].X);
5744 expectf(-1.568512, ptf[0].Y);
5745 expectf(46.225956, ptf[1].X);
5746 expectf(1.862977, ptf[1].Y);
5747 expectf(36.850956, ptf[2].X);
5748 expectf(-6.256012, ptf[2].Y);
5749 expectf(29.987980, ptf[3].X);
5750 expectf(6.550478, ptf[3].Y);
5751
5752 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5753 expect(Ok, status);
5754 ret = GetRgnBox(hrgn, &rc);
5755 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5756 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5757 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5759
5760 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5761 expect(Ok, status);
5762 ret = GetRgnBox(hrgn, &rc);
5763 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5764 ok((rc.left == -3406 && rc.top == 4500 && rc.right == -350 && rc.bottom == 8728) ||
5765 /* rounding under Wine is slightly different */
5766 (rc.left == -3407 && rc.top == 4500 && rc.right == -350 && rc.bottom == 8728) /* Wine */,
5767 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc));
5769
5770 ptf[0].X = -3406.0;
5771 ptf[0].Y = 4500.0;
5772 ptf[1].X = -350.0;
5773 ptf[1].Y = 8728.0;
5774 ptf[2].X = -350.0;
5775 ptf[2].Y = 4500.0;
5776 ptf[3].X = -3406.0;
5777 ptf[3].Y = 8728.0;
5779 expect(Ok, status);
5780 expectf(-136.190491, ptf[0].X);
5781 expectf(520.010742, ptf[0].Y);
5782 expectf(756.417175, ptf[1].X);
5783 expectf(720.031616, ptf[1].Y);
5784 expectf(360.042114, ptf[2].X);
5785 expectf(376.760742, ptf[2].Y);
5786 expectf(260.184570, ptf[3].X);
5787 expectf(863.281616, ptf[3].Y);
5788
5790 expect(Ok, status);
5791 status = GdipSetWorldTransform(graphics, matrix);
5792 expect(Ok, status);
5793
5794 status = GdipGetClipBounds(graphics, &rect);
5795 expect(Ok, status);
5796 expectf_(-28.100956, rect.X, 1.0);
5797 expectf_(7.806488, rect.Y, 1.5);
5798 expectf_(25.612978, rect.Width, 1.0);
5799 expectf_(12.806489, rect.Height, 1.0);
5800
5801 status = GdipSetEmpty(region);
5802 expect(Ok, status);
5803 status = GdipGetClip(graphics, region);
5804 expect(Ok, status);
5805 status = GdipGetRegionBounds(region, graphics, &rect);
5806 expect(Ok, status);
5807 /* rounding under Wine is slightly different */
5808 expectf_(-28.100956, rect.X, 1.0);
5809 expectf_(7.806488, rect.Y, 1.5);
5810 expectf_(25.612978, rect.Width, 1.0);
5811 expectf_(12.806489, rect.Height, 1.0);
5812
5813 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5814 expect(Ok, status);
5815 ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
5816 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);
5817
5818 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5819 expect(Ok, status);
5820 ret = GetRgnBox(hrgn, &rc);
5821 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5822 ok((rc.left == -27 && rc.top == 8 && rc.right == -2 && rc.bottom == 21) ||
5823 /* rounding under Wine is slightly different */
5824 (rc.left == -28 && rc.top == 9 && rc.right == -2 && rc.bottom == 21) /* Wine */,
5825 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc));
5827
5828 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5829 expect(Ok, status);
5830 ret = GetRgnBox(hrgn, &rc);
5831 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5832 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5833 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5835
5836 ptf[0].X = 100.0;
5837 ptf[0].Y = 100.0;
5838 ptf[1].X = 200.0;
5839 ptf[1].Y = 200.0;
5840 ptf[2].X = 200.0;
5841 ptf[2].Y = 100.0;
5842 ptf[3].X = 100.0;
5843 ptf[3].Y = 200.0;
5845 expect(Ok, status);
5846 expectf(-11.862979, ptf[0].X);
5847 expectf(7.806488, ptf[0].Y);
5848 expectf(-18.725958, ptf[1].X);
5849 expectf(20.612976, ptf[1].Y);
5850 expectf(-2.487981, ptf[2].X);
5851 expectf(15.925477, ptf[2].Y);
5852 expectf(-28.100956, ptf[3].X);
5853 expectf(12.493987, ptf[3].Y);
5854
5855 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5856 expect(Ok, status);
5857 ret = GetRgnBox(hrgn, &rc);
5858 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5859 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5860 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5862
5863 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5864 expect(Ok, status);
5865 ret = GetRgnBox(hrgn, &rc);
5866 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5867 ok((rc.left == 4500 && rc.top == 351 && rc.right == 8728 && rc.bottom == 3407) ||
5868 /* rounding under Wine is slightly different */
5869 (rc.left == 4499 && rc.top == 351 && rc.right == 8728 && rc.bottom == 3407) /* Wine */,
5870 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc));
5872
5873 ptf[0].X = -3406.0;
5874 ptf[0].Y = 4500.0;
5875 ptf[1].X = -350.0;
5876 ptf[1].Y = 8728.0;
5877 ptf[2].X = -350.0;
5878 ptf[2].Y = 4500.0;
5879 ptf[3].X = -3406.0;
5880 ptf[3].Y = 8728.0;
5882 expect(Ok, status);
5883 expectf(-1055.021484, ptf[0].X);
5884 expectf(-70.595329, ptf[0].Y);
5885 expectf(-1455.063232, ptf[1].X);
5886 expectf(375.708435, ptf[1].Y);
5887 expectf(-768.521484, ptf[2].X);
5888 expectf(177.520981, ptf[2].Y);
5889 expectf(-1741.563110, ptf[3].X);
5890 expectf(127.592125, ptf[3].Y);
5891
5893 GdipDeleteRegion(region);
5894 GdipDeleteRegion(region100x100);
5895 GdipDeleteGraphics(graphics);
5896 DeleteDC(hdc);
5897}
5898
5899static void test_clipping_2(void)
5900{
5901
5902 HDC hdc;
5904 GpGraphics *graphics;
5905 GpRegion *region;
5907 GpRectF rect;
5908 GpPointF ptf[4];
5909 GpUnit unit;
5910 HRGN hrgn;
5911 int ret;
5912 RECT rc;
5913
5915 status = GdipCreateFromHDC(hdc, &graphics);
5916 expect(Ok, status);
5917
5918 status = GdipGetPageUnit(graphics, &unit);
5919 expect(Ok, status);
5921
5922 GdipSetPageUnit(graphics, UnitInch);
5923
5924 status = GdipCreateRegion(&region);
5925 expect(Ok, status);
5926 status = GdipSetEmpty(region);
5927 expect(Ok, status);
5928 rect.X = rect.Y = 100.0;
5929 rect.Width = rect.Height = 100.0;
5931 expect(Ok, status);
5932 status = GdipSetClipRegion(graphics, region, CombineModeReplace);
5933 expect(Ok, status);
5934
5935 status = GdipGetClip(graphics, region);
5936 expect(Ok, status);
5937 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5938 expect(Ok, status);
5939 ret = GetRgnBox(hrgn, &rc);
5940 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5941 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5942 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5944 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5945 expect(Ok, status);
5946 ret = GetRgnBox(hrgn, &rc);
5947 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5948 ok(rc.left == 9600 && rc.top == 9600 && rc.right == 19200 && rc.bottom == 19200,
5949 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc));
5951
5952 ptf[0].X = 9600.0;
5953 ptf[0].Y = 9600.0;
5954 ptf[1].X = 19200.0;
5955 ptf[1].Y = 19200.0;
5957 expect(Ok, status);
5958 expectf(100.0, ptf[0].X);
5959 expectf(100.0, ptf[0].Y);
5960 expectf(200.0, ptf[1].X);
5961 expectf(200.0, ptf[1].X);
5962
5963 GdipSetPageUnit(graphics, UnitPoint);
5964
5965 status = GdipGetClip(graphics, region);
5966 expect(Ok, status);
5967 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5968 expect(Ok, status);
5969 ret = GetRgnBox(hrgn, &rc);
5970 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5971 ok((rc.left == 7200 && rc.top == 7200 && rc.right == 14400 && rc.bottom == 14400) ||
5972 broken(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) /* before Win7 */,
5973 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc));
5975 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5976 expect(Ok, status);
5977 ret = GetRgnBox(hrgn, &rc);
5978 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5979 ok((rc.left == 9600 && rc.top == 9600 && rc.right == 19200 && rc.bottom == 19200) ||
5980 broken(rc.left == 134 && rc.top == 134 && rc.right == 267 && rc.bottom == 267) /* before Win7 */,
5981 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc));
5983
5984 ptf[0].X = 9600.0;
5985 ptf[0].Y = 9600.0;
5986 ptf[1].X = 19200.0;
5987 ptf[1].Y = 19200.0;
5989 expect(Ok, status);
5990 if (fabs(ptf[0].X - 7200.0) < 0.001)
5991 ok(ptf[0].X == 7200.0 && ptf[0].Y == 7200.0 && ptf[1].X == 14400.0 && ptf[1].Y == 14400.0,
5992 "expected 7200.0,7200.0-14400.0,14400.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5993 else /* before Win7 */
5994 {
5995 ok(broken(fabs(ptf[0].X - 100.0) < 0.001), "expected 100.0, got %f\n", ptf[0].X);
5996 ok(broken(fabs(ptf[0].Y - 100.0) < 0.001), "expected 100.0, got %f\n", ptf[0].Y);
5997 ok(broken(fabs(ptf[1].X - 200.0) < 0.001), "expected 200.0, got %f\n", ptf[1].X);
5998 ok(broken(fabs(ptf[1].Y - 200.0) < 0.001), "expected 200.0, got %f\n", ptf[1].Y);
5999 }
6000
6001 GdipDeleteRegion(region);
6002
6003 GdipSetPageUnit(graphics, UnitPixel);
6004
6005 status = GdipCreateRegion(&region);
6006 expect(Ok, status);
6007 status = GdipSetEmpty(region);
6008 expect(Ok, status);
6009 rect.X = rect.Y = 100.0;
6010 rect.Width = rect.Height = 100.0;
6012 expect(Ok, status);
6013 status = GdipSetClipRegion(graphics, region, CombineModeReplace);
6014 expect(Ok, status);
6015
6016 status = GdipGetClip(graphics, region);
6017 expect(Ok, status);
6018 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6019 expect(Ok, status);
6020 ret = GetRgnBox(hrgn, &rc);
6021 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6022 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
6023 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
6024 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6026 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6027 expect(Ok, status);
6028 ret = GetRgnBox(hrgn, &rc);
6029 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6030 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
6031 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
6032 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6034
6035 ptf[0].X = 100.0;
6036 ptf[0].Y = 100.0;
6037 ptf[1].X = 200.0;
6038 ptf[1].Y = 200.0;
6040 expect(Ok, status);
6041 if (fabs(ptf[0].X - 100.0) < 0.001)
6042 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
6043 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
6044 else /* before Win7 */
6045 {
6046 ok(broken(fabs(ptf[0].X - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].X);
6047 ok(broken(fabs(ptf[0].Y - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].Y);
6048 ok(broken(fabs(ptf[1].X - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].X);
6049 ok(broken(fabs(ptf[1].Y - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].Y);
6050 }
6051
6052 GdipSetPageUnit(graphics, UnitPoint);
6053
6054 status = GdipGetClip(graphics, region);
6055 expect(Ok, status);
6056 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6057 expect(Ok, status);
6058 ret = GetRgnBox(hrgn, &rc);
6059 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6060 ok((rc.left == 75 && rc.top == 75 && rc.right == 150 && rc.bottom == 150) ||
6061 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
6062 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc));
6064 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6065 expect(Ok, status);
6066 ret = GetRgnBox(hrgn, &rc);
6067 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6068 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
6069 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
6070 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6072
6073 ptf[0].X = 100.0;
6074 ptf[0].Y = 100.0;
6075 ptf[1].X = 200.0;
6076 ptf[1].Y = 200.0;
6078 expect(Ok, status);
6079 if (fabs(ptf[0].X - 75.0) < 0.001)
6080 ok(ptf[0].X == 75.0 && ptf[0].Y == 75.0 && ptf[1].X == 150.0 && ptf[1].Y == 150.0,
6081 "expected 75.0,75.0-150.0,150.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
6082 else /* before Win7 */
6083 {
6084 ok(broken(fabs(ptf[0].X - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].X);
6085 ok(broken(fabs(ptf[0].Y - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].Y);
6086 ok(broken(fabs(ptf[1].X - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].X);
6087 ok(broken(fabs(ptf[1].Y - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].Y);
6088 }
6089
6091 expect(Ok, status);
6093 expect(Ok, status);
6094 status = GdipSetWorldTransform(graphics, matrix);
6095 expect(Ok, status);
6097
6098 status = GdipGetClip(graphics, region);
6099 expect(Ok, status);
6100 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6101 expect(Ok, status);
6102 ret = GetRgnBox(hrgn, &rc);
6103 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6104 ok(rc.left == 65 && rc.top == 65 && rc.right == 140 && rc.bottom == 140,
6105 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc));
6107 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6108 expect(Ok, status);
6109 ret = GetRgnBox(hrgn, &rc);
6110 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6111 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
6112 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6114
6115 ptf[0].X = 100.0;
6116 ptf[0].Y = 100.0;
6117 ptf[1].X = 200.0;
6118 ptf[1].Y = 200.0;
6120 expect(Ok, status);
6121 expectf(65.0, ptf[0].X);
6122 expectf(65.0, ptf[0].Y);
6123 expectf(140.0, ptf[1].X);
6124 expectf(140.0, ptf[1].X);
6125
6127 expect(Ok, status);
6129 expect(Ok, status);
6130 status = GdipSetWorldTransform(graphics, matrix);
6131 expect(Ok, status);
6133
6134 status = GdipGetClip(graphics, region);
6135 expect(Ok, status);
6136 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6137 expect(Ok, status);
6138 ret = GetRgnBox(hrgn, &rc);
6139 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6140 ok(rc.left == 300 && rc.top == 150 && rc.right == 600 && rc.bottom == 300,
6141 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc));
6143 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6144 expect(Ok, status);
6145 ret = GetRgnBox(hrgn, &rc);
6146 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6147 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
6148 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6150
6151 ptf[0].X = 100.0;
6152 ptf[0].Y = 100.0;
6153 ptf[1].X = 200.0;
6154 ptf[1].Y = 200.0;
6156 expect(Ok, status);
6157 expectf(300.0, ptf[0].X);
6158 expectf(150.0, ptf[0].Y);
6159 expectf(600.0, ptf[1].X);
6160 expectf(300.0, ptf[1].Y);
6161
6162 status = GdipSetPageScale(graphics, 2.0);
6163 expect(Ok, status);
6164
6165 status = GdipGetClip(graphics, region);
6166 expect(Ok, status);
6167 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6168 expect(Ok, status);
6169 ret = GetRgnBox(hrgn, &rc);
6170 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6171 ok((rc.left == 150 && rc.top == 75 && rc.right == 300 && rc.bottom == 150) ||
6172 broken(rc.left == 300 && rc.top == 150 && rc.right == 600 && rc.bottom == 300) /* before Win7 */,
6173 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc));
6175 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6176 expect(Ok, status);
6177 ret = GetRgnBox(hrgn, &rc);
6178 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6179 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
6180 broken(rc.left == 200 && rc.top == 200 && rc.right == 400 && rc.bottom == 400) /* before Win7 */,
6181 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6183
6184 ptf[0].X = 100.0;
6185 ptf[0].Y = 100.0;
6186 ptf[1].X = 200.0;
6187 ptf[1].Y = 200.0;
6189 expect(Ok, status);
6190 if (fabs(ptf[0].X - 150.0) < 0.001)
6191 {
6192 expectf(150.0, ptf[0].X);
6193 expectf(75.0, ptf[0].Y);
6194 expectf(300.0, ptf[1].X);
6195 expectf(150.0, ptf[1].Y);
6196 }
6197 else /* before Win7 */
6198 {
6199 ok(broken(fabs(ptf[0].X - 300.0) < 0.001), "expected 300.0, got %f\n", ptf[0].X);
6200 ok(broken(fabs(ptf[0].Y - 150.0) < 0.001), "expected 150.0, got %f\n", ptf[0].Y);
6201 ok(broken(fabs(ptf[1].X - 600.0) < 0.001), "expected 600.0, got %f\n", ptf[1].X);
6202 ok(broken(fabs(ptf[1].Y - 300.0) < 0.001), "expected 300.0, got %f\n", ptf[1].Y);
6203 }
6204
6206 expect(Ok, status);
6208 expect(Ok, status);
6209 status = GdipSetWorldTransform(graphics, matrix);
6210 expect(Ok, status);
6212
6213 status = GdipGetClip(graphics, region);
6214 expect(Ok, status);
6215 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6216 expect(Ok, status);
6217 ret = GetRgnBox(hrgn, &rc);
6218 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
6219 ok((rc.left == 54 && rc.top == -26 && rc.right == 107 && rc.bottom == 27) ||
6220 /* rounding under Wine is slightly different */
6221 (rc.left == 53 && rc.top == -26 && rc.right == 106 && rc.bottom == 27) /* Wine */,
6222 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc));
6224 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6225 expect(Ok, status);
6226 ret = GetRgnBox(hrgn, &rc);
6227 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6228 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
6229 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6231
6232 ptf[0].X = 100.0;
6233 ptf[0].Y = 100.0;
6234 ptf[1].X = 200.0;
6235 ptf[1].Y = 200.0;
6236 ptf[2].X = 200.0;
6237 ptf[2].Y = 100.0;
6238 ptf[3].X = 100.0;
6239 ptf[3].Y = 200.0;
6241 expect(Ok, status);
6242 expectf(53.033016, ptf[0].X);
6243 expectf(0.0, ptf[0].Y);
6244 expectf(106.066032, ptf[1].X);
6245 expectf(0.0, ptf[1].Y);
6246 expectf(79.549522, ptf[2].X);
6247 expectf(-26.516510, ptf[2].Y);
6248 expectf(79.549522, ptf[3].X);
6249 expectf(26.516508, ptf[3].Y);
6250
6252 expect(Ok, status);
6254 expect(Ok, status);
6255 status = GdipSetWorldTransform(graphics, matrix);
6256 expect(Ok, status);
6258
6259 status = GdipGetClip(graphics, region);
6260 expect(Ok, status);
6261 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6262 expect(Ok, status);
6263 ret = GetRgnBox(hrgn, &rc);
6264 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
6265 ok((rc.left == -26 && rc.top == 54 && rc.right == 27 && rc.bottom == 107) ||
6266 /* rounding under Wine is slightly different */
6267 (rc.left == -27 && rc.top == 54 && rc.right == 27 && rc.bottom == 106) /* Wine */,
6268 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc));
6270 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6271 expect(Ok, status);
6272 ret = GetRgnBox(hrgn, &rc);
6273 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6274 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
6275 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6277
6278 ptf[0].X = 100.0;
6279 ptf[0].Y = 100.0;
6280 ptf[1].X = 200.0;
6281 ptf[1].Y = 200.0;
6282 ptf[2].X = 200.0;
6283 ptf[2].Y = 100.0;
6284 ptf[3].X = 100.0;
6285 ptf[3].Y = 200.0;
6287 expect(Ok, status);
6288 expectf(0.0, ptf[0].X);
6289 expectf(53.033005, ptf[0].Y);
6290 expectf(0.0, ptf[1].X);
6291 expectf(106.066010, ptf[1].Y);
6292 expectf(26.516491, ptf[2].X);
6293 expectf(79.549507, ptf[2].Y);
6294 expectf(-26.516520, ptf[3].X);
6295 expectf(79.549500, ptf[3].Y);
6296
6297 GdipDeleteRegion(region);
6298 GdipDeleteGraphics(graphics);
6299 DeleteDC(hdc);
6300}
6301
6302
6304{
6306 GpGraphics *graphics = NULL;
6307 GpBrush *brush = NULL;
6308 HDC hdc = GetDC( hwnd );
6309 GpRectF rects[2] = {{0,0,10,10}, {10,10,10,10}};
6310
6311 ok(hdc != NULL, "Expected HDC to be initialized\n");
6312
6313 status = GdipCreateFromHDC(hdc, &graphics);
6314 expect(Ok, status);
6315 ok(graphics != NULL, "Expected graphics to be initialized\n");
6316
6317 status = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
6318 expect(Ok, status);
6319 ok(brush != NULL, "Expected brush to be initialized\n");
6320
6321 status = GdipFillRectangles(NULL, brush, rects, 2);
6323
6324 status = GdipFillRectangles(graphics, NULL, rects, 2);
6326
6327 status = GdipFillRectangles(graphics, brush, NULL, 2);
6329
6330 status = GdipFillRectangles(graphics, brush, rects, 0);
6332
6333 status = GdipFillRectangles(graphics, brush, rects, -1);
6335
6336 status = GdipFillRectangles(graphics, brush, rects, 1);
6337 expect(Ok, status);
6338
6339 status = GdipFillRectangles(graphics, brush, rects, 2);
6340 expect(Ok, status);
6341
6342 GdipDeleteBrush(brush);
6343 GdipDeleteGraphics(graphics);
6344
6345 ReleaseDC(hwnd, hdc);
6346}
6347
6349{
6350 HDC hdc,dc;
6351 HBITMAP bmp;
6352 HGDIOBJ old;
6353 RECT rect;
6354 POINT pt;
6355 int width = 0;
6356 int height = 0;
6357 GpGraphics* graphics = NULL;
6358 GpRect boundRect;
6360
6361 ok(GetClientRect(hwnd, &rect), "GetClientRect should have succeeded\n");
6362 width = rect.right - rect.left;
6364
6365 dc = GetDC(hwnd);
6368 old = SelectObject (hdc, bmp);
6369
6370 /*change the window origin is the key test point*/
6371 SetWindowOrgEx (hdc, rect.left+10, rect.top+10, &pt);
6372
6373 status = GdipCreateFromHDC(hdc, &graphics);
6374 expect(Ok, status);
6375
6376 status = GdipGetVisibleClipBoundsI(graphics, &boundRect);
6377 expect(Ok, status);
6378
6379 ok(boundRect.X==rect.left+10 &&
6380 boundRect.Y==rect.top+10 &&
6381 boundRect.Width==width &&
6382 boundRect.Height==height, "Expected GdipGetVisibleClipBoundsI ok\n");
6383
6385 expect(Ok, status);
6386
6387 status = GdipGetVisibleClipBoundsI(graphics, &boundRect);
6388 expect(Ok, status);
6389
6390 ok(boundRect.X==rect.left+10 &&
6391 boundRect.Y==rect.top+10 &&
6392 boundRect.Width==width-10 &&
6393 boundRect.Height==height-10, "Expected GdipGetVisibleClipBoundsI ok\n");
6394
6395 GdipDeleteGraphics(graphics);
6396
6397 SelectObject (hdc, old);
6398 DeleteObject (bmp);
6399 DeleteDC (hdc);
6400 ReleaseDC(hwnd, dc);
6401}
6402
6403static void test_container_rects(void)
6404{
6406 GpGraphics *graphics;
6407 HDC hdc = GetDC( hwnd );
6408 GpRectF dstrect, srcrect;
6410 static const GpPointF test_points[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
6411 GpPointF points[3];
6412 REAL dpix, dpiy;
6413
6414 status = GdipCreateFromHDC(hdc, &graphics);
6415 expect(Ok, status);
6416
6417 dstrect.X = 0.0;
6418 dstrect.Y = 0.0;
6419 dstrect.Width = 1.0;
6420 dstrect.Height = 1.0;
6421 srcrect = dstrect;
6422
6423 status = GdipGetDpiX(graphics, &dpix);
6424 expect(Ok, status);
6425
6426 status = GdipGetDpiY(graphics, &dpiy);
6427 expect(Ok, status);
6428
6429 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitWorld, &state);
6431
6432 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitDisplay, &state);
6434
6435 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitMillimeter+1, &state);
6437
6438 status = GdipBeginContainer(NULL, &dstrect, &srcrect, UnitPixel, &state);
6440
6441 status = GdipBeginContainer(graphics, NULL, &srcrect, UnitPixel, &state);
6443
6444 status = GdipBeginContainer(graphics, &dstrect, NULL, UnitPixel, &state);
6446
6447 status = GdipBeginContainer(graphics, &dstrect, &srcrect, -1, &state);
6449
6450 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, NULL);
6452
6453 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, &state);
6454 expect(Ok, status);
6455
6456 memcpy(points, test_points, sizeof(points));
6458 expect(Ok, status);
6459 expectf(0.0, points[0].X);
6460 expectf(0.0, points[0].Y);
6461 expectf(1.0, points[1].X);
6462 expectf(0.0, points[1].Y);
6463 expectf(0.0, points[2].X);
6464 expectf(1.0, points[2].Y);
6465
6466 status = GdipEndContainer(graphics, state);
6467 expect(Ok, status);
6468
6469 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state);
6470 expect(Ok, status);
6471
6472 memcpy(points, test_points, sizeof(points));
6474 expect(Ok, status);
6475 expectf(0.0, points[0].X);
6476 expectf(0.0, points[0].Y);
6477 expectf(1.0/dpix, points[1].X);
6478 expectf(0.0, points[1].Y);
6479 expectf(0.0, points[2].X);
6480 expectf(1.0/dpiy, points[2].Y);
6481
6482 status = GdipEndContainer(graphics, state);
6483 expect(Ok, status);
6484
6485 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
6486 expect(Ok, status);
6487
6488 dstrect.X = 1.0;
6489 dstrect.Height = 3.0;
6490 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, &state);
6491 expect(Ok, status);
6492
6493 memcpy(points, test_points, sizeof(points));
6495 expect(Ok, status);
6496 expectf(2.0, points[0].X);
6497 expectf(0.0, points[0].Y);
6498 expectf(4.0, points[1].X);
6499 expectf(0.0, points[1].Y);
6500 expectf(2.0, points[2].X);
6501 expectf(6.0, points[2].Y);
6502
6503 status = GdipEndContainer(graphics, state);
6504 expect(Ok, status);
6505
6506 memcpy(points, test_points, sizeof(points));
6508 expect(Ok, status);
6509 expectf(0.0, points[0].X);
6510 expectf(0.0, points[0].Y);
6511 expectf(2.0, points[1].X);
6512 expectf(0.0, points[1].Y);
6513 expectf(0.0, points[2].X);
6514 expectf(2.0, points[2].Y);
6515
6516 status = GdipResetWorldTransform(graphics);
6517 expect(Ok, status);
6518
6519 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state);
6520 expect(Ok, status);
6521
6522 memcpy(points, test_points, sizeof(points));
6524 expect(Ok, status);
6525 expectf(1.0, points[0].X);
6526 expectf(0.0, points[0].Y);
6527 expectf((dpix+1.0)/dpix, points[1].X);
6528 expectf(0.0, points[1].Y);
6529 expectf(1.0, points[2].X);
6530 expectf(3.0/dpiy, points[2].Y);
6531
6532 status = GdipEndContainer(graphics, state);
6533 expect(Ok, status);
6534
6535 status = GdipSetPageUnit(graphics, UnitInch);
6536 expect(Ok, status);
6537
6538 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, &state);
6539 expect(Ok, status);
6540
6541 memcpy(points, test_points, sizeof(points));
6543 expect(Ok, status);
6544 expectf(dpix, points[0].X);
6545 expectf(0.0, points[0].Y);
6546 expectf(dpix*2, points[1].X);
6547 expectf(0.0, points[1].Y);
6548 expectf(dpix, points[2].X);
6549 expectf(dpiy*3, points[2].Y);
6550
6551 status = GdipEndContainer(graphics, state);
6552 expect(Ok, status);
6553
6554 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state);
6555 expect(Ok, status);
6556
6557 memcpy(points, test_points, sizeof(points));
6559 expect(Ok, status);
6560 expectf(dpix, points[0].X);
6561 expectf(0.0, points[0].Y);
6562 expectf(dpix+1.0, points[1].X);
6563 expectf(0.0, points[1].Y);
6564 expectf(dpix, points[2].X);
6565 expectf(3.0, points[2].Y);
6566
6567 status = GdipEndContainer(graphics, state);
6568 expect(Ok, status);
6569
6570 GdipDeleteGraphics(graphics);
6571
6572 ReleaseDC(hwnd, hdc);
6573}
6574
6576{
6577 HDC hdc;
6579 GpGraphics *graphics;
6580
6581 if (!pGdipGraphicsSetAbort)
6582 {
6583 win_skip("GdipGraphicsSetAbort() is not supported.\n");
6584 return;
6585 }
6586
6587 hdc = GetDC(hwnd);
6588
6589 status = GdipCreateFromHDC(hdc, &graphics);
6590 expect(Ok, status);
6591
6592 status = pGdipGraphicsSetAbort(NULL, NULL);
6594
6595 status = pGdipGraphicsSetAbort(graphics, NULL);
6596 expect(Ok, status);
6597
6598 GdipDeleteGraphics(graphics);
6599
6600 ReleaseDC(hwnd, hdc);
6601}
6602
6603#define BLUE_COLOR (0xff0000ff)
6604#define is_blue_color(color) ( ((color) & 0x00ffffff) == 0xff )
6605#define get_bitmap_pixel(x,y) pixel[(y)*(width) + (x)]
6607{
6609 UINT lines = 0;
6611
6612 bi.biSize = sizeof(BITMAPINFOHEADER);
6613 bi.biWidth = width;
6614 bi.biHeight = -height; /*very Important, set negative, indicating a top-down DIB*/
6615 bi.biPlanes = 1;
6616 bi.biBitCount = 32;
6617 bi.biCompression = BI_RGB;
6618 bi.biSizeImage = 0;
6619 bi.biXPelsPerMeter = 0;
6620 bi.biYPelsPerMeter = 0;
6621 bi.biClrUsed = 0;
6622 bi.biClrImportant = 0;
6623
6625 ok(lines == height, "Expected GetDIBits:%p,%d->%d,%ld\n", buffer, height, lines, GetLastError());
6626
6627 return buffer;
6628}
6629
6631{
6632 ARGB color[6] = {0,0,0,0,0,0};
6633 POINT pt = {0,0};
6634 RECT rect = {100, 100, 180, 180};
6637 GpStatus status = 0;
6638 GpSolidFill *brush = NULL;
6639 GpGraphics *graphics = NULL;
6640 HDC dc = GetDC( hwnd);
6643 HGDIOBJ old = SelectObject(hdc, bmp);
6644 DWORD* pixel = NULL;
6645
6646 /*Change the window origin is the key test point*/
6648
6650 expect(Ok, status);
6651
6652 status = GdipCreateFromHDC(hdc, &graphics);
6653 expect(Ok, status);
6654
6657 expect(Ok, status);
6658
6659 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, rect.right, rect.bottom);
6660 expect(Ok, status);
6661
6662 GdipDeleteBrush((GpBrush*)brush);
6663 GdipDeleteGraphics(graphics);
6664
6666 if (pixel)
6667 {
6669 color[1] = get_bitmap_pixel(width/2+1, height/2);
6670 color[2] = get_bitmap_pixel(width/2, height/2+1);
6671 color[3] = get_bitmap_pixel(width/2-1, height/2-1);
6672 color[4] = get_bitmap_pixel(width/2-1, height-1);
6673 color[5] = get_bitmap_pixel(width-1, height/2-1);
6674 }
6675
6677 color[3] == 0 && color[4] == 0 && color[5] == 0,
6678 "Expected GdipFillRectangleI take effect!\n" );
6679 GdipFree(pixel);
6680
6681 SelectObject(hdc, old);
6683 DeleteDC(hdc);
6684 ReleaseDC(hwnd, dc);
6685}
6686
6688{
6689 ARGB color[6] = {0,0,0,0,0,0};
6690 POINT pt = {0,0};
6691 RECT rect = {100, 100, 180, 180};
6694 GpStatus status = 0;
6695 union
6696 {
6698 GpImage *image;
6699 } src_img;
6700 GpTexture *brush = NULL;
6701 GpGraphics *graphics = NULL;
6702 HDC dc = GetDC( hwnd);
6705 HGDIOBJ old = SelectObject(hdc, bmp);
6706
6707 UINT x = 0;
6708 UINT y = 0;
6709 UINT src_img_width = width/2;
6710 UINT src_img_height = height/2;
6711 BYTE *src_img_data = GdipAlloc(src_img_width*src_img_height*4);
6712 DWORD *pixel = (DWORD *)src_img_data;
6713 ok(pixel != NULL, "Expected src_img_data is valid\n");
6714
6715 /*Change the window origin is the key test point*/
6717
6718 /*build a blue solid image!*/
6719 for(y = 0; y < src_img_height; ++y)
6720 {
6721 for(x = 0; x < src_img_width; ++x)
6722 {
6723 pixel[x] = BLUE_COLOR;
6724 }
6725
6726 pixel += src_img_width;
6727 }
6728
6729 status = GdipCreateBitmapFromScan0(src_img_width, src_img_height, src_img_width*4,
6730 PixelFormat32bppARGB, src_img_data, &src_img.bitmap);
6731 expect(Ok, status);
6732
6733 status = GdipCreateTexture(src_img.image, 0, &brush);
6734 expect(Ok, status);
6735
6736 status = GdipCreateFromHDC(hdc, &graphics);
6737 expect(Ok, status);
6738
6741 expect(Ok, status);
6742
6743 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, rect.right, rect.bottom);
6744 expect(Ok, status);
6745
6746 GdipDisposeImage(src_img.image);
6747 GdipDeleteBrush((GpBrush*)brush);
6748 GdipDeleteGraphics(graphics);
6749 GdipFree(src_img_data);
6750
6752 if (pixel)
6753 {
6755 color[1] = get_bitmap_pixel(width/2+1, height/2);
6756 color[2] = get_bitmap_pixel(width/2, height/2+1);
6757 color[3] = get_bitmap_pixel(width/2-1, height/2-1);
6758 color[4] = get_bitmap_pixel(width/2-1, height-1);
6759 color[5] = get_bitmap_pixel(width-1, height/2-1);
6760 }
6762 color[3] == 0 && color[4] == 0 && color[5] == 0,
6763 "Expected GdipFillRectangleI take effect!\n" );
6764 GdipFree(pixel);
6765
6766 SelectObject(hdc, old);
6768 DeleteDC(hdc);
6769 ReleaseDC(hwnd, dc);
6770}
6771
6773{
6774 ARGB color[6] = {0,0,0,0,0,0};
6775 UINT x = 0;
6776 UINT y = 0;
6777 RECT rect = {100, 100, 180, 180};
6780 UINT src_img_width = width/2;
6781 UINT src_img_height = height/2;
6782
6783 GpStatus status = 0;
6784 union
6785 {
6787 GpImage *image;
6788 } src_img;
6789 union
6790 {
6792 GpImage *image;
6793 } dst_img;
6794
6795 GpTexture *brush = NULL;
6796 GpGraphics *graphics = NULL;
6797 BYTE *src_img_data = GdipAlloc(src_img_width*src_img_height*4);
6798 DWORD *pixel = (DWORD *)src_img_data;
6799 ok(pixel != NULL, "Expected src_img_data is valid\n");
6800
6802 PixelFormat32bppARGB, NULL, &dst_img.bitmap);
6803 expect(Ok, status);
6804
6805 /*build a blue solid image!*/
6806 for(y = 0; y < src_img_height; ++y)
6807 {
6808 for(x = 0; x < src_img_width; ++x)
6809 {
6810 pixel[x] = BLUE_COLOR;
6811 }
6812
6813 pixel += src_img_width;
6814 }
6815
6816 status = GdipCreateBitmapFromScan0(src_img_width, src_img_height, src_img_width*4,
6817 PixelFormat32bppARGB, src_img_data, &src_img.bitmap);
6818 expect(Ok, status);
6819
6820 status = GdipCreateTexture(src_img.image, 0, &brush);
6821 expect(Ok, status);
6822
6823 status = GdipGetImageGraphicsContext(dst_img.image, &graphics);
6824 expect(Ok, status);
6825
6827 expect(Ok, status);
6828
6829 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, width/2, height/2);
6830 expect(Ok, status);
6831
6832 GdipDeleteBrush((GpBrush*)brush);
6833 GdipDeleteGraphics(graphics);
6834
6835 status = GdipBitmapGetPixel(dst_img.bitmap, 0, 0, &color[0]);
6836 expect(Ok, status);
6837 status = GdipBitmapGetPixel(dst_img.bitmap, 0, 1, &color[1]);
6838 expect(Ok, status);
6839 status = GdipBitmapGetPixel(dst_img.bitmap, 1, 0, &color[2]);
6840 expect(Ok, status);
6841 status = GdipBitmapGetPixel(dst_img.bitmap, width/2, 0, &color[3]);
6842 expect(Ok, status);
6843 status = GdipBitmapGetPixel(dst_img.bitmap, width/2, height/2, &color[4]);
6844 expect(Ok, status);
6845 status = GdipBitmapGetPixel(dst_img.bitmap, 0, height/2, &color[5]);
6846 expect(Ok, status);
6847
6849 color[3] == 0 && color[4] == 0 && color[5] == 0,
6850 "Expected GdipFillRectangleI take effect!\n" );
6851
6852 GdipDisposeImage(src_img.image);
6853 GdipDisposeImage(dst_img.image);
6854 GdipFree(src_img_data);
6855}
6856
6858{
6859 ARGB color[6] = {0,0,0,0,0,0};
6860 POINT pt = {0,0};
6861 RECT rect = {100, 100, 180, 180};
6864 GpStatus status = 0;
6865 union
6866 {
6868 GpImage *image;
6869 } src_img;
6870 GpGraphics *graphics = NULL;
6871 HDC dc = GetDC( hwnd);
6874 HGDIOBJ old = SelectObject(hdc, bmp);
6875
6876 UINT x = 0;
6877 UINT y = 0;
6878 UINT src_img_width = width/2;
6879 UINT src_img_height = height/2;
6880 BYTE *src_img_data = GdipAlloc(src_img_width*src_img_height*4);
6881 DWORD *pixel = (DWORD *)src_img_data;
6882 ok(pixel != NULL, "Expected src_img_data is valid\n");
6883
6884 /*Change the window origin is the key test point*/
6886
6887 /*build a blue solid image!*/
6888 for(y = 0; y < src_img_height; ++y)
6889 {
6890 for(x = 0; x < src_img_width; ++x)
6891 {
6892 pixel[x] = BLUE_COLOR;
6893 }
6894
6895 pixel += src_img_width;
6896 }
6897
6898 status = GdipCreateBitmapFromScan0(src_img_width, src_img_height, src_img_width*4,
6899 PixelFormat32bppARGB, src_img_data, &src_img.bitmap);
6900 expect(Ok, status);
6901
6902 status = GdipCreateFromHDC(hdc, &graphics);
6903 expect(Ok, status);
6904
6905 status = GdipDrawImageRectRectI(graphics, src_img.image,
6906 rect.left+width/2, rect.top+height/2, width/2, height/2,
6907 0, 0, src_img_width, src_img_height, UnitPixel, NULL, NULL, NULL);
6908 expect(Ok, status);
6909
6910 GdipDisposeImage(src_img.image);
6911 GdipDeleteGraphics(graphics);
6912 GdipFree(src_img_data);
6913
6915 if (pixel)
6916 {
6918 color[1] = get_bitmap_pixel(width/2+1, height/2);
6919 color[2] = get_bitmap_pixel(width/2, height/2+1);
6920 color[3] = get_bitmap_pixel(width/2-1, height/2-1);
6921 color[4] = get_bitmap_pixel(width/2-1, height-1);
6922 color[5] = get_bitmap_pixel(width-1, height/2-1);
6923 }
6925 color[3] == 0 && color[4] == 0 && color[5] == 0,
6926 "Expected GdipDrawImageRectRectI take effect!\n" );
6927 GdipFree(pixel);
6928
6929 SelectObject(hdc, old);
6931 DeleteDC(hdc);
6932 ReleaseDC(hwnd, dc);
6933}
6934
6936{
6937 HDC hdc;
6939 GpGraphics *graphics;
6940 HRGN rgn;
6941 RectF rectf;
6942 BOOL res;
6943
6944 hdc = GetDC(hwnd);
6945
6946 SetViewportOrgEx(hdc, 10, 10, NULL);
6947
6948 status = GdipCreateFromHDC(hdc, &graphics);
6949 expect(Ok, status);
6950
6951 rgn = CreateRectRgn(0, 0, 100, 100);
6952
6953 status = GdipSetClipHrgn(graphics, rgn, CombineModeReplace);
6954 expect(Ok, status);
6955
6956 status = GdipGetVisibleClipBounds(graphics, &rectf);
6957 expect(Ok, status);
6958 expectf(-10.0, rectf.X);
6959 expectf(-10.0, rectf.Y);
6960 expectf(100.0, rectf.Width);
6961 expectf(100.0, rectf.Height);
6962
6963 status = GdipIsVisiblePoint(graphics, 95, 95, &res);
6964 expect(Ok, status);
6965 expect(FALSE, res);
6966
6967 status = GdipIsVisiblePoint(graphics, -5, -5, &res);
6968 expect(Ok, status);
6969 expect(TRUE, res);
6970
6971 DeleteObject(rgn);
6972
6973 GdipDeleteGraphics(graphics);
6974
6975 SetViewportOrgEx(hdc, 0, 0, NULL);
6976
6977 ReleaseDC(hwnd, hdc);
6978}
6979
6980static void test_hdc_caching(void)
6981{
6983 HDC hdc;
6984 HBITMAP hbm;
6985 GpGraphics *graphics;
6986 ULONG *bits;
6987 BITMAPINFO bmi;
6988 HRGN hrgn;
6989 GpBrush *brush;
6990
6992 ok(hdc != NULL, "CreateCompatibleDC failed\n");
6993 bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
6994 bmi.bmiHeader.biHeight = -5;
6995 bmi.bmiHeader.biWidth = 5;
6996 bmi.bmiHeader.biBitCount = 32;
6997 bmi.bmiHeader.biPlanes = 1;
6999 bmi.bmiHeader.biClrUsed = 0;
7000
7001 hbm = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
7002 ok(hbm != NULL, "CreateDIBSection failed\n");
7003
7005
7006 SetViewportOrgEx(hdc, 1, 1, NULL);
7007
7008 hrgn = CreateRectRgn(0, 0, 3, 3);
7011
7012 status = GdipCreateSolidFill((ARGB)0xffaaaaaa, (GpSolidFill**)&brush);
7013 expect(Ok, status);
7014
7015 status = GdipCreateFromHDC(hdc, &graphics);
7016 expect(Ok, status);
7017
7018 memset(bits, 0, sizeof(*bits) * 25);
7019 status = GdipFillRectangleI(graphics, brush, 0, 0, 4, 4);
7020 expect(Ok, status);
7021
7022 expect(0, bits[0]);
7023 expect(0xffaaaaaa, bits[6]);
7024 expect(0xffaaaaaa, bits[12]);
7025 expect(0, bits[18]);
7026 expect(0, bits[24]);
7027
7028 SetViewportOrgEx(hdc, 0, 0, NULL);
7029 OffsetClipRgn(hdc, 2, 2);
7030
7031 memset(bits, 0, sizeof(*bits) * 25);
7032 status = GdipFillRectangleI(graphics, brush, 0, 0, 4, 4);
7033 expect(Ok, status);
7034
7035 expect(0, bits[0]);
7036 expect(0xffaaaaaa, bits[6]);
7037 expect(0xffaaaaaa, bits[12]);
7038 expect(0, bits[18]);
7039 expect(0, bits[24]);
7040
7041 GdipDeleteGraphics(graphics);
7042
7043 GdipDeleteBrush(brush);
7044
7045 DeleteDC(hdc);
7047}
7048
7050{
7052 GpGraphics *graphics;
7054 GpBrush *brush;
7055 GpStatus stat;
7056 HDC hdc;
7057 HBRUSH hbrush, holdbrush;
7058 ARGB color;
7059
7061 expect(Ok, stat);
7062
7064 expect(Ok, stat);
7065
7067 expect(Ok, stat);
7068
7069 stat = GdipSetMatrixElements(transform, 1.0, 0.0, 0.0, 1.0, 50.0, 50.0);
7070 expect(Ok, stat);
7071
7072 /* GDI+: Set world transform. Should not matter to GDI. */
7074 expect(Ok, stat);
7075
7076 stat = GdipGetDC(graphics, &hdc);
7077 expect(Ok, stat);
7078
7079 hbrush = CreateSolidBrush(0xff0000);
7080
7081 holdbrush = SelectObject(hdc, hbrush);
7082
7083 /* GDI: Draw a rectangle at physical coords (5, 5) to (12, 10). */
7084 Rectangle(hdc, 5, 5, 12, 10);
7085
7086 holdbrush = SelectObject(hdc, holdbrush);
7087
7088 /* GDI: Set view port origin. Should not matter to GDI+. */
7089 SetViewportOrgEx(hdc, 20, 20, NULL);
7090
7091 GdipReleaseDC(graphics, hdc);
7092
7093 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
7094 expect(Ok, stat);
7095
7096 /* GDI+: Draw a rectangle at physical coords (85, 85) to (88, 95). */
7097 stat = GdipFillRectangleI(graphics, brush, 35, 35, 3, 10);
7098 expect(Ok, stat);
7099
7100 stat = GdipDeleteBrush(brush);
7101 expect(Ok, stat);
7102
7103 stat = GdipGetDC(graphics, &hdc);
7104 expect(Ok, stat);
7105
7106 holdbrush = SelectObject(hdc, hbrush);
7107
7108 /* GDI: Draw a rectangle at physical coords (25, 25) to (30, 34).
7109 Updated view port origin should still be in effect. */
7110 Rectangle(hdc, 5, 5, 10, 14);
7111
7112 SelectObject(hdc, holdbrush);
7113
7115 stat = GdipReleaseDC(graphics, hdc);
7116 expect(Ok, stat);
7117
7119 expect(Ok, stat);
7120
7122 expect(Ok, stat);
7123 expect(0xff0000ff, color);
7124
7125 stat = GdipBitmapGetPixel(bitmap, 26, 26, &color);
7126 expect(Ok, stat);
7127 expect(0xff0000ff, color);
7128
7129 stat = GdipBitmapGetPixel(bitmap, 86, 86, &color);
7130 expect(Ok, stat);
7131 expect(0xff0000ff, color);
7132
7133 stat = GdipDeleteGraphics(graphics);
7134 expect(Ok, stat);
7135
7137 expect(Ok, stat);
7138}
7139
7140static void test_gdi_interop_hdc(void)
7141{
7142 BITMAPINFO bmi;
7143 GpBrush *brush;
7144 GpGraphics *graphics;
7146 GpStatus stat;
7147 HBITMAP hbm;
7148 HBRUSH hbrush, holdbrush;
7149 HDC gdi_hdc;
7150 HDC src_hdc;
7151 ULONG *bits;
7152 XFORM xform = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
7153
7154 src_hdc = CreateCompatibleDC(0);
7155 ok(src_hdc != NULL, "CreateCompatibleDC failed\n");
7156
7157 bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
7158 bmi.bmiHeader.biHeight = -100;
7159 bmi.bmiHeader.biWidth = 100;
7160 bmi.bmiHeader.biBitCount = 32;
7161 bmi.bmiHeader.biPlanes = 1;
7163 bmi.bmiHeader.biClrUsed = 0;
7164 bmi.bmiHeader.biClrImportant = 0;
7165
7166 hbm = CreateDIBSection(src_hdc, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
7167 ok(hbm != NULL, "CreateDIBSection failed\n");
7168
7169 SelectObject(src_hdc, hbm);
7170
7171 SetGraphicsMode(src_hdc, GM_ADVANCED);
7172
7173 xform.eDx = 10.0;
7174 xform.eDy = 10.0;
7175 SetWorldTransform(src_hdc, &xform);
7176
7177 stat = GdipCreateFromHDC(src_hdc, &graphics);
7178 expect(Ok, stat);
7179
7181 expect(Ok, stat);
7182
7183 stat = GdipSetMatrixElements(transform, 1.0, 0.0, 0.0, 1.0, 40.0, 40.0);
7184 expect(Ok, stat);
7185
7186 /* GDI+: Set world transform. Should not matter to GDI. */
7188 expect(Ok, stat);
7189
7190 stat = GdipGetDC(graphics, &gdi_hdc);
7191 expect(Ok, stat);
7192 ok( gdi_hdc == src_hdc, "wrong dc\n" );
7193
7194 /* GDI: Set GDI transform back to (0, 0).
7195 Should not matter to GDI+. */
7196 xform.eDx = 0.0;
7197 xform.eDy = 0.0;
7198 SetWorldTransform(gdi_hdc, &xform);
7199
7200 hbrush = CreateSolidBrush(0xff00aa);
7201
7202 holdbrush = SelectObject(gdi_hdc, hbrush);
7203
7204 /* GDI: Draw a rectangle at physical coords (5, 5) to (12, 10). */
7205 Rectangle(gdi_hdc, 5, 5, 12, 10);
7206
7207 holdbrush = SelectObject(gdi_hdc, holdbrush);
7208
7209 /* GDI: Set GDI transform to translate (+20, +20).
7210 Should not matter to GDI+. */
7211 xform.eDx = 20.0;
7212 xform.eDy = 20.0;
7213 SetWorldTransform(gdi_hdc, &xform);
7214
7215 GdipReleaseDC(graphics, gdi_hdc);
7216
7217 /* GDI world transform should still be intact, even when back
7218 in GDI+ mode. */
7219 stat = GetWorldTransform(src_hdc, &xform);
7220 expect(TRUE, stat);
7221 expect(20.0, xform.eDx);
7222 expect(20.0, xform.eDy);
7223
7224 stat = GdipCreateSolidFill((ARGB)0xffaa00ff, (GpSolidFill**)&brush);
7225 expect(Ok, stat);
7226
7227 /* GDI+: Draw a rectangle at physical coords (85, 85) to (88, 95).
7228 The fact that the GDI world transform has been updated should
7229 not influence the GDI+ world transform. GDI+ should still apply
7230 the world transform from the when HDC backed graphics object was
7231 instantiated. */
7232 stat = GdipFillRectangleI(graphics, brush, 35, 35, 3, 10);
7233 expect(Ok, stat);
7234
7235 stat = GdipDeleteBrush(brush);
7236 expect(Ok, stat);
7237
7238 stat = GdipGetDC(graphics, &gdi_hdc);
7239 expect(Ok, stat);
7240
7241 holdbrush = SelectObject(gdi_hdc, hbrush);
7242
7243 /* GDI: Draw a rectangle at physical coords (25, 25) to (30, 34).
7244 Updated transform should still be in effect. */
7245 Rectangle(gdi_hdc, 5, 5, 10, 14);
7246
7247 SelectObject(gdi_hdc, holdbrush);
7248
7249 stat = GdipReleaseDC(graphics, gdi_hdc);
7250 expect(Ok, stat);
7251
7252 GdipDeleteGraphics(graphics);
7254 expect(Ok, stat);
7255
7256 holdbrush = SelectObject(src_hdc, hbrush);
7257
7258 /* GDI: Draw a rectangle at physical coords (35, 35) to (40, 38).
7259 Updated transform should still be in effect on src_hdc. */
7260 Rectangle(gdi_hdc, 15, 15, 20, 18);
7261
7262 SelectObject(gdi_hdc, holdbrush);
7263
7265
7266 expect(0x00aa00ff, bits[6 * 100 + 6]);
7267 expect(0x00aa00ff, bits[26 * 100 + 26]);
7268 expect(0x00aa00ff, bits[36 * 100 + 36]);
7269 expect(0xffaa00ff, bits[86 * 100 + 86]);
7270
7271 DeleteDC(src_hdc);
7273}
7274
7276{
7277 char buffer[260];
7278 DWORD len;
7280 DRIVER_INFO_3A *dbuf = NULL;
7281 HANDLE hprn = 0;
7282 HDC hdc = 0;
7283 HMODULE winspool = LoadLibraryA("winspool.drv");
7284 BOOL (WINAPI *pOpenPrinterA)(LPSTR, HANDLE *, LPPRINTER_DEFAULTSA);
7285 BOOL (WINAPI *pGetDefaultPrinterA)(LPSTR, LPDWORD);
7286 BOOL (WINAPI *pGetPrinterA)(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
7287 BOOL (WINAPI *pGetPrinterDriverA)(HANDLE, LPSTR, DWORD, LPBYTE, DWORD, LPDWORD);
7288 BOOL (WINAPI *pClosePrinter)(HANDLE);
7289
7290 pGetDefaultPrinterA = (void *)GetProcAddress(winspool, "GetDefaultPrinterA");
7291 pOpenPrinterA = (void *)GetProcAddress(winspool, "OpenPrinterA");
7292 pGetPrinterA = (void *)GetProcAddress(winspool, "GetPrinterA");
7293 pGetPrinterDriverA = (void *)GetProcAddress(winspool, "GetPrinterDriverA");
7294 pClosePrinter = (void *)GetProcAddress(winspool, "ClosePrinter");
7295
7296 if (!pGetDefaultPrinterA || !pOpenPrinterA || !pGetPrinterA || !pGetPrinterDriverA || !pClosePrinter)
7297 goto done;
7298
7299 len = sizeof(buffer);
7300 if (!pGetDefaultPrinterA(buffer, &len)) goto done;
7301 if (!pOpenPrinterA(buffer, &hprn, NULL)) goto done;
7302
7303 pGetPrinterA(hprn, 2, NULL, 0, &len);
7304 pbuf = malloc(len);
7305 if (!pGetPrinterA(hprn, 2, (LPBYTE)pbuf, len, &len)) goto done;
7306
7307 pGetPrinterDriverA(hprn, NULL, 3, NULL, 0, &len);
7308 dbuf = malloc(len);
7309 if (!pGetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, len, &len)) goto done;
7310
7311 hdc = CreateDCA(dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, pbuf->pDevMode);
7312 trace("hdc %p for driver '%s' printer '%s' port '%s'\n", hdc,
7313 dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName);
7314done:
7315 free(dbuf);
7316 free(pbuf);
7317 if (hprn) pClosePrinter(hprn);
7318 if (winspool) FreeLibrary(winspool);
7319 return hdc;
7320}
7321
7322static BOOL check_rect_pixels(const DWORD *pixel, const RectF *rect, UINT width, DWORD expected, Point *failed)
7323{
7324 UINT x, y;
7325 BOOL ret = TRUE;
7326
7327 for (y = (UINT)rect->Y; y < (UINT)(rect->Y + rect->Height); y++)
7328 {
7329 for (x = (UINT)rect->X; x < (UINT)(rect->X + rect->Width); x++)
7330 {
7331 if (pixel[x + y * width] != expected)
7332 {
7333 ret = FALSE;
7334 goto done;
7335 }
7336 }
7337 }
7338
7339done:
7340 if (!ret)
7341 {
7342 failed->X = x;
7343 failed->Y = y;
7344 }
7345 else
7346 {
7347 failed->X = 0;
7348 failed->Y = 0;
7349 }
7350 return ret;
7351}
7352
7353static void test_printer_dc(void)
7354{
7355 HDC hdc_printer, hdc;
7356 Status status;
7357 GpGraphics *graphics;
7358 REAL dpi_x, dpi_y, pixel_per_unit_x, pixel_per_unit_y;
7360 UINT width = 16, height = 16;
7361 GpUnit unit;
7362 GpSolidFill *brush;
7363 DWORD *pixel;
7364 BOOL match;
7365 RectF rect;
7366 Point pt;
7367
7368 hdc_printer = create_printer_dc();
7369 if (!hdc_printer)
7370 {
7371 skip("could not create a DC for the default printer\n");
7372 return;
7373 }
7374
7375 hdc = CreateCompatibleDC(hdc_printer);
7378
7379 status = GdipCreateFromHDC(hdc, &graphics);
7380 expect(Ok, status);
7381
7382 GdipGetPageUnit(graphics, &unit);
7384
7385 GdipGetDpiX(graphics, &dpi_x);
7386 GdipGetDpiY(graphics, &dpi_y);
7389
7390 /* For graphics created from printer DC, UnitDisplay specifies that a unit is 1/100 inch */
7391 pixel_per_unit_x = dpi_x / 100.0;
7392 pixel_per_unit_y = dpi_y / 100.0;
7393
7394 status = GdipCreateSolidFill((ARGB)0xffffffff, &brush);
7395 expect(Ok, status);
7396
7397 status = GdipFillRectangleI(graphics, (GpBrush *)brush, 1, 1, 1, 1);
7398 expect(Ok, status);
7399
7401
7402 /* pixels at (0, 0) should all be 0 */
7403 rect.X = 0;
7404 rect.Y = 0;
7405 rect.Width = pixel_per_unit_x;
7406 rect.Height = pixel_per_unit_y;
7407 match = check_rect_pixels(pixel, &rect, width, 0, &pt);
7408 ok(match, "Expected pixel (%u, %u) to be %08x, got %08lx\n",
7409 pt.X, pt.Y, 0, pixel[pt.X + pt.Y * width]);
7410
7411 /* pixels at (1, 1) should all be 0x00ffffff */
7412 rect.X = pixel_per_unit_x;
7413 rect.Y = pixel_per_unit_y;
7414 rect.Width = pixel_per_unit_x;
7415 rect.Height = pixel_per_unit_y;
7416 match = check_rect_pixels(pixel, &rect, width, 0x00ffffff, &pt);
7417 ok(match, "Expected pixel (%u, %u) to be %08x, got %08lx\n",
7418 pt.X, pt.Y, 0x00ffffff, pixel[pt.X + pt.Y * width]);
7419
7420 GdipFree(pixel);
7421 GdipDeleteBrush((GpBrush *)brush);
7422 GdipDeleteGraphics(graphics);
7424 DeleteDC(hdc);
7425 DeleteDC(hdc_printer);
7426}
7427
7429{
7431 GpBitmap *bitmap = NULL;
7432 BitmapData locked_data;
7433 GpRect bounds = {0, 0, 10, 10};
7434 BYTE buffer[400];
7435 BYTE *scan0;
7436 int i;
7437 struct {
7438 INT stride;
7439 BOOL use_scan0;
7440 INT expected_stride;
7442 } test_data[] = {
7443 { 12, FALSE, 20 },
7444 { 40, FALSE, 20 },
7445 { 0, FALSE, 20 },
7446 { 20, FALSE, 20 },
7447 { -12, FALSE, 20 },
7448 { -32, FALSE, 20 },
7449 { 30, TRUE, 0, InvalidParameter },
7450 { 12, TRUE, 12 },
7451 { 40, TRUE, 40 },
7452 { 0, TRUE, 0, InvalidParameter },
7453 { 32, TRUE, 32 },
7454 { -12, TRUE, -12 },
7455 { -32, TRUE, -32 },
7456 { -13, TRUE, 0, InvalidParameter },
7457 };
7458
7459 for (i=0; i < ARRAY_SIZE(test_data); i++)
7460 {
7461 if (test_data[i].use_scan0)
7462 {
7463 if (test_data[i].stride >= 0)
7464 scan0 = buffer;
7465 else
7466 scan0 = buffer + sizeof(buffer) + test_data[i].stride;
7467 }
7468 else
7469 scan0 = NULL;
7470
7471 winetest_push_context("%i: %i %i", i, test_data[i].stride, test_data[i].use_scan0);
7472
7475
7476 if (status == Ok)
7477 {
7479 expect(Ok, status);
7480
7481 expect(10, locked_data.Width);
7482 expect(10, locked_data.Height);
7483 expect(test_data[i].expected_stride, locked_data.Stride);
7485 if (test_data[i].use_scan0)
7486 ok(locked_data.Scan0 == scan0, "got %p, expected %p\n", locked_data.Scan0, scan0);
7487
7488 status = GdipBitmapUnlockBits(bitmap, &locked_data);
7489 expect(Ok, status);
7490
7492 }
7493
7495 }
7496}
7497
7498START_TEST(graphics)
7499{
7500 struct GdiplusStartupInput gdiplusStartupInput;
7501 ULONG_PTR gdiplusToken;
7502 WNDCLASSA class;
7503 HMODULE gdiplus_mod = GetModuleHandleA("gdiplus.dll");
7504 HMODULE hmsvcrt;
7505 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
7506
7507 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
7508 hmsvcrt = LoadLibraryA("msvcrt");
7509 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
7510 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
7511
7512 pGdipGraphicsSetAbort = (void*)GetProcAddress(gdiplus_mod, "GdipGraphicsSetAbort");
7513#ifdef __REACTOS__
7514 pGdipDrawImageFX = (void*)GetProcAddress(gdiplus_mod, "GdipDrawImageFX");
7515#endif
7516
7517 memset( &class, 0, sizeof(class) );
7518 class.lpszClassName = "gdiplus_test";
7519 class.style = CS_HREDRAW | CS_VREDRAW;
7520 class.lpfnWndProc = DefWindowProcA;
7521 class.hInstance = GetModuleHandleA(0);
7522 class.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
7523 class.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
7524 class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
7525 RegisterClassA( &class );
7526 hwnd = CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
7527 CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
7528 ok(hwnd != NULL, "Expected window to be created\n");
7529
7530 gdiplusStartupInput.GdiplusVersion = 1;
7531 gdiplusStartupInput.DebugEventCallback = NULL;
7532 gdiplusStartupInput.SuppressBackgroundThread = 0;
7533 gdiplusStartupInput.SuppressExternalCodecs = 0;
7534
7535 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
7536
7537 test_clipping();
7576 test_isempty();
7577 test_clear();
7600
7601 GdiplusShutdown(gdiplusToken);
7603}
static HRGN hrgn
static HBRUSH hbrush
#define stat
Definition: acwin.h:100
static int state
Definition: maze.c:121
VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
#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
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define ARRAY_SIZE(A)
Definition: main.h:20
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
HBITMAP hbmp
RECT rect
Definition: combotst.c:67
HDC dc
Definition: cylfrac.c:34
#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 Y(I)
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define lstrlenW
Definition: compat.h:750
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:1020
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:783
GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode, GpTexture **texture)
Definition: brush.c:812
GpStatus WINGDIPAPI GdipGetFontSize(GpFont *font, REAL *size)
Definition: font.c:352
GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height)
Definition: font.c:530
GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
Definition: font.c:821
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 GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
Definition: font.c:457
GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font)
Definition: font.c:150
GpStatus WINGDIPAPI GdipGetFontUnit(GpFont *font, Unit *unit)
Definition: font.c:419
GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, GpFontCollection *collection, GpFontFamily **family)
Definition: font.c:701
GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6988
GpStatus WINGDIPAPI GdipDrawCurve(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:2864
GpStatus WINGDIPAPI GdipDrawImageFX(GpGraphics *graphics, GpImage *image, GpRectF *src_rect, GpMatrix *transform, CGpEffect *effect, GpImageAttributes *imageattr, GpUnit src_unit)
Definition: graphics.c:3042
GpStatus WINGDIPAPI GdipDrawClosedCurve(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:2794
GpStatus WINGDIPAPI GdipFillClosedCurve(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:4400
GpStatus WINGDIPAPI GdipFillRectangles(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRectF *rects, INT count)
Definition: graphics.c:4704
GpStatus WINGDIPAPI GdipDrawBezierI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4)
Definition: graphics.c:2729
GpStatus WINGDIPAPI GdipFillPolygon2I(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:4674
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 GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, REAL tension)
Definition: graphics.c:2928
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height)
Definition: graphics.c:4693
GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics, TextRenderingHint *hint)
Definition: graphics.c:5141
GpStatus WINGDIPAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height)
Definition: graphics.c:3017
GpStatus WINGDIPAPI GdipDrawCurve3(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, INT offset, INT numberOfSegments, REAL tension)
Definition: graphics.c:2955
GpStatus WINGDIPAPI GdipFillRegion(GpGraphics *graphics, GpBrush *brush, GpRegion *region)
Definition: graphics.c:4891
GpStatus WINGDIPAPI GdipFillPolygonI(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count, GpFillMode fillMode)
Definition: graphics.c:4637
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:7002
GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB *argb)
Definition: graphics.c:5044
GpStatus WINGDIPAPI GdipDrawLine(GpGraphics *graphics, GpPen *pen, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphics.c:3626
GpStatus WINGDIPAPI GdipDrawBeziersI(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:2763
GpStatus WINGDIPAPI GdipSetClipHrgn(GpGraphics *graphics, HRGN hrgn, CombineMode mode)
Definition: graphics.c:6774
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2616
GpStatus WINGDIPAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention)
Definition: graphics.c:4924
GpStatus WINGDIPAPI GdipFillRectanglesI(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRect *rects, INT count)
Definition: graphics.c:4733
GpStatus WINGDIPAPI GdipTranslateClip(GpGraphics *graphics, REAL dx, REAL dy)
Definition: graphics.c:7421
GpStatus WINGDIPAPI GdipResetPageTransform(GpGraphics *graphics)
Definition: graphics.c:7940
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, REAL sy, GpMatrixOrder order)
Definition: graphics.c:6406
GpStatus WINGDIPAPI GdipFillClosedCurve2I(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count, REAL tension, GpFillMode fill)
Definition: graphics.c:4368
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 GdipGetClip(GpGraphics *graphics, GpRegion *region)
Definition: graphics.c:7195
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 GdipFillClosedCurve2(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count, REAL tension, GpFillMode fill)
Definition: graphics.c:4339
GpStatus WINGDIPAPI GdipDrawPolygonI(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:6964
GpStatus WINGDIPAPI GdipDrawPie(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:4232
GpStatus WINGDIPAPI GdipDrawPolygon(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:6938
GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics)
Definition: graphics.c:6172
GpStatus WINGDIPAPI GdipGetSmoothingMode(GpGraphics *graphics, SmoothingMode *mode)
Definition: graphics.c:5113
GpStatus WINGDIPAPI GdipGetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode *mode)
Definition: graphics.c:5096
GpStatus WINGDIPAPI GdipDrawLines(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:3654
GpStatus WINGDIPAPI GdipGetTextContrast(GpGraphics *graphics, UINT *contrast)
Definition: graphics.c:5128
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 GdipSetClipRectI(GpGraphics *graphics, INT x, INT y, INT width, INT height, CombineMode mode)
Definition: graphics.c:6884
GpStatus WINGDIPAPI GdipDrawBeziers(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:2738
GpStatus WINGDIPAPI GdipDrawRectangles(GpGraphics *graphics, GpPen *pen, GDIPCONST GpRectF *rects, INT count)
Definition: graphics.c:4286
GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:4562
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 GdipMeasureString(GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, RectF *bounds, INT *codepointsfitted, INT *linesfilled)
Definition: graphics.c:5890
GpStatus WINGDIPAPI GdipGetClipBounds(GpGraphics *graphics, GpRectF *rect)
Definition: graphics.c:4945
GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics *graphics, CompositingMode *mode)
Definition: graphics.c:4993
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:6724
GpStatus WINGDIPAPI GdipDrawClosedCurveI(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:2802
GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1, REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4)
Definition: graphics.c:2704
GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics *graphics, CompositingQuality *quality)
Definition: graphics.c:5010
GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics *graphics, GpPen *pen, GDIPCONST GpRect *rects, INT count)
Definition: graphics.c:4314
GpStatus WINGDIPAPI GdipDrawImageRectRectI(GpGraphics *graphics, GpImage *image, INT dstx, INT dsty, INT dstwidth, INT dstheight, INT srcx, INT srcy, INT srcwidth, INT srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, VOID *callbackData)
Definition: graphics.c:3574
GpStatus WINGDIPAPI GdipFillPolygon2(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:4666
GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics *graphics, GpRect *rect)
Definition: graphics.c:5194
GpStatus WINGDIPAPI GdipTransformPointsI(GpGraphics *graphics, GpCoordinateSpace dst_space, GpCoordinateSpace src_space, GpPoint *points, INT count)
Definition: graphics.c:7373
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, CombineMode mode)
Definition: graphics.c:6899
GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics *graphics, REAL x, REAL y, BOOL *result)
Definition: graphics.c:5276
GpStatus WINGDIPAPI GdipDrawCurveI(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:2872
GpStatus WINGDIPAPI GdipFillClosedCurveI(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:4408
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 GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count)
Definition: graphics.c:3679
GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics *graphics, INT x, INT y, BOOL *result)
Definition: graphics.c:5309
GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length, GDIPCONST GpFont *font, GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix, RectF *boundingBox)
Definition: graphics.c:7456
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 GdipIsClipEmpty(GpGraphics *graphics, BOOL *res)
Definition: graphics.c:5266
GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics, CompositingQuality quality)
Definition: graphics.c:6469
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, InterpolationMode mode)
Definition: graphics.c:6498
GpStatus WINGDIPAPI GdipIsVisibleRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, BOOL *result)
Definition: graphics.c:5314
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 GdipGetInterpolationMode(GpGraphics *graphics, InterpolationMode *mode)
Definition: graphics.c:5027
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 GdipFillPolygon(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count, GpFillMode fillMode)
Definition: graphics.c:4608
GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *stringFormat, INT regionCount, GpRegion **regions)
Definition: graphics.c:5758
GpStatus WINGDIPAPI GdipDrawPieI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:4258
GpStatus WINGDIPAPI GdipIsVisibleRectI(GpGraphics *graphics, INT x, INT y, INT width, INT height, BOOL *result)
Definition: graphics.c:5353
GpStatus WINGDIPAPI GdipCreateFromHWNDICM(HWND hwnd, GpGraphics **graphics)
Definition: graphics.c:2586
GpStatus WINGDIPAPI GdipDrawClosedCurve2(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, REAL tension)
Definition: graphics.c:2810
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:7141
GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
Definition: graphics.c:2561
GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, REAL tension)
Definition: graphics.c:2900
GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:2662
GpStatus WINGDIPAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:2695
GpStatus WINGDIPAPI GdipGetClipBoundsI(GpGraphics *graphics, GpRect *rect)
Definition: graphics.c:4972
GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace dst_space, GpCoordinateSpace src_space, GpPointF *points, INT count)
Definition: graphics.c:7356
GpStatus WINGDIPAPI GdipFillPieI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:4599
GpStatus WINGDIPAPI GdipSetClipPath(GpGraphics *graphics, GpPath *path, CombineMode mode)
Definition: graphics.c:6806
GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, GDIPCONST GpBrush *brush)
Definition: graphics.c:6043
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
Definition: graphics.c:6400
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
Definition: graphics.c:6560
GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height)
Definition: graphics.c:4278
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics *graphics, GpUnit *unit)
Definition: graphics.c:5080
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
Definition: graphics.c:6654
GpStatus WINGDIPAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height)
Definition: graphics.c:4452
GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:5215
GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode mode)
Definition: graphics.c:6587
GpStatus WINGDIPAPI GdipSetTextContrast(GpGraphics *graphics, UINT contrast)
Definition: graphics.c:6684
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
Definition: graphics.c:6194
GpStatus WINGDIPAPI GdipDrawClosedCurve2I(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, REAL tension)
Definition: graphics.c:2836
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
Definition: graphics.c:6533
GpStatus WINGDIPAPI GdipDrawCurve3I(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, INT offset, INT numberOfSegments, REAL tension)
Definition: graphics.c:2968
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 GdipResetPath(GpPath *path)
GpStatus WINGDIPAPI GdipClosePathFigure(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathLineI(GpPath *path, INT x1, INT y1, INT x2, INT y2)
Definition: graphicspath.c:826
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 GdipCreateBitmapFromGraphics(INT width, INT height, GpGraphics *target, GpBitmap **bitmap)
Definition: image.c:1597
GpStatus WINGDIPAPI GdipBitmapSetResolution(GpBitmap *bitmap, REAL xdpi, REAL ydpi)
Definition: image.c:1239
GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO *info, VOID *bits, GpBitmap **bitmap)
Definition: image.c:1462
GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
Definition: image.c:1107
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2099
GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
Definition: image.c:2272
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:310
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2236
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap *bitmap, BitmapData *lockeddata)
Definition: image.c:1252
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:288
GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
Definition: matrix.c:59
GpStatus WINGDIPAPI GdipTranslateMatrix(GpMatrix *matrix, REAL offsetX, REAL offsetY, GpMatrixOrder order)
Definition: matrix.c:420
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 GdipRotateMatrix(GpMatrix *matrix, REAL angle, GpMatrixOrder order)
Definition: matrix.c:257
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:156
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:136
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 GdipIsEmptyRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
Definition: region.c:1211
GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
Definition: region.c:1268
GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
Definition: region.c:1581
GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
Definition: region.c:1201
GpStatus WINGDIPAPI GdipTransformRegion(GpRegion *region, GpMatrix *matrix)
Definition: region.c:1702
GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
Definition: region.c:459
GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
Definition: region.c:390
GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region, GDIPCONST GpRectF *rect, CombineMode mode)
Definition: region.c:282
GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *region, BYTE *buffer, UINT size, UINT *needed)
Definition: region.c:740
GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
Definition: region.c:583
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
Definition: region.c:567
GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, GpStringFormat **format)
Definition: stringformat.c:76
GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges)
Definition: stringformat.c:290
GpStatus WINGDIPAPI GdipSetStringFormatLineAlign(GpStringFormat *format, StringAlignment align)
Definition: stringformat.c:277
GpStatus WINGDIPAPI GdipSetStringFormatAlign(GpStringFormat *format, StringAlignment align)
Definition: stringformat.c:236
GpStatus WINGDIPAPI GdipSetStringFormatFlags(GpStringFormat *format, INT flags)
Definition: stringformat.c:350
GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
Definition: stringformat.c:105
static void cleanup(void)
Definition: main.c:1335
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
_ACRTIMP errno_t __cdecl _controlfp_s(unsigned int *, unsigned int, unsigned int)
Definition: math.c:1304
_ACRTIMP double __cdecl fabs(double)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define pt(x, y)
Definition: drawing.c:79
#define RGB(r, g, b)
Definition: precomp.h:67
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
FxCollectionEntry * cur
void WINGDIPAPI GdipFree(void *ptr)
Definition: gdiplus.c:152
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:83
REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi, BOOL printer_display)
Definition: gdiplus.c:329
void *WINGDIPAPI GdipAlloc(SIZE_T size)
Definition: gdiplus.c:144
REAL units_scale(GpUnit from, GpUnit to, REAL dpi, BOOL printer_display)
Definition: gdiplus.c:382
SmoothingMode
Definition: gdiplusenums.h:120
@ SmoothingModeNone
Definition: gdiplusenums.h:125
@ SmoothingModeAntiAlias
Definition: gdiplusenums.h:126
@ SmoothingModeDefault
Definition: gdiplusenums.h:122
CompositingMode
Definition: gdiplusenums.h:246
@ CompositingModeSourceOver
Definition: gdiplusenums.h:247
@ CompositingModeSourceCopy
Definition: gdiplusenums.h:248
@ StringAlignmentCenter
Definition: gdiplusenums.h:264
@ StringAlignmentFar
Definition: gdiplusenums.h:265
@ CombineModeUnion
Definition: gdiplusenums.h:390
@ CombineModeReplace
Definition: gdiplusenums.h:388
@ FontStyleRegular
Definition: gdiplusenums.h:301
PixelOffsetMode
Definition: gdiplusenums.h:159
@ PixelOffsetModeHighSpeed
Definition: gdiplusenums.h:162
@ PixelOffsetModeHalf
Definition: gdiplusenums.h:165
@ PixelOffsetModeDefault
Definition: gdiplusenums.h:161
UINT GraphicsContainer
Definition: gdiplusenums.h:23
@ FillModeAlternate
Definition: gdiplusenums.h:55
CompositingQuality
Definition: gdiplusenums.h:130
@ CompositingQualityDefault
Definition: gdiplusenums.h:132
@ CompositingQualityHighSpeed
Definition: gdiplusenums.h:133
@ CompositingQualityHighQuality
Definition: gdiplusenums.h:134
@ MatrixOrderAppend
Definition: gdiplusenums.h:188
@ MatrixOrderPrepend
Definition: gdiplusenums.h:187
TextRenderingHint
Definition: gdiplusenums.h:252
@ TextRenderingHintAntiAlias
Definition: gdiplusenums.h:257
@ TextRenderingHintAntiAliasGridFit
Definition: gdiplusenums.h:256
@ TextRenderingHintClearTypeGridFit
Definition: gdiplusenums.h:258
@ TextRenderingHintSystemDefault
Definition: gdiplusenums.h:253
Unit
Definition: gdiplusenums.h:26
@ UnitDocument
Definition: gdiplusenums.h:32
@ UnitInch
Definition: gdiplusenums.h:31
@ UnitMillimeter
Definition: gdiplusenums.h:33
@ UnitDisplay
Definition: gdiplusenums.h:28
@ UnitWorld
Definition: gdiplusenums.h:27
@ UnitPoint
Definition: gdiplusenums.h:30
@ UnitPixel
Definition: gdiplusenums.h:29
@ FlushIntentionFlush
Definition: gdiplusenums.h:398
@ StringFormatFlagsNoWrap
Definition: gdiplusenums.h:284
@ StringFormatFlagsNoClip
Definition: gdiplusenums.h:286
@ DriverStringOptionsRealizedAdvance
Definition: gdiplusenums.h:49
@ DriverStringOptionsCmapLookup
Definition: gdiplusenums.h:47
UINT GraphicsState
Definition: gdiplusenums.h:22
@ CoordinateSpaceDevice
Definition: gdiplusenums.h:406
@ CoordinateSpaceWorld
Definition: gdiplusenums.h:404
@ CoordinateSpacePage
Definition: gdiplusenums.h:405
InterpolationMode
Definition: gdiplusenums.h:140
@ InterpolationModeHighQualityBicubic
Definition: gdiplusenums.h:149
@ InterpolationModeBicubic
Definition: gdiplusenums.h:146
@ InterpolationModeHighQualityBilinear
Definition: gdiplusenums.h:148
@ InterpolationModeInvalid
Definition: gdiplusenums.h:141
@ InterpolationModeHighQuality
Definition: gdiplusenums.h:144
@ InterpolationModeDefault
Definition: gdiplusenums.h:142
@ InterpolationModeBilinear
Definition: gdiplusenums.h:145
@ InterpolationModeNearestNeighbor
Definition: gdiplusenums.h:147
@ InterpolationModeLowQuality
Definition: gdiplusenums.h:143
Unit GpUnit
Status GpStatus
@ ImageLockModeRead
void WINAPI GdiplusShutdown(ULONG_PTR)
DWORD ARGB
#define PixelFormat32bppPARGB
#define PixelFormat64bppARGB
#define PixelFormat32bppRGB
#define PixelFormat4bppIndexed
#define PixelFormat64bppPARGB
#define PixelFormat16bppRGB555
#define PixelFormat16bppGrayScale
#define PixelFormat8bppIndexed
INT PixelFormat
#define PixelFormat24bppRGB
#define PixelFormat16bppRGB565
#define PixelFormat1bppIndexed
#define PixelFormat32bppARGB
#define PixelFormat48bppRGB
struct GdiplusAbort GdiplusAbort
Definition: gdiplustypes.h:57
Status
Definition: gdiplustypes.h:24
@ Ok
Definition: gdiplustypes.h:25
@ FileNotFound
Definition: gdiplustypes.h:35
@ ObjectBusy
Definition: gdiplustypes.h:29
@ InvalidParameter
Definition: gdiplustypes.h:27
@ OutOfMemory
Definition: gdiplustypes.h:28
@ NotTrueTypeFont
Definition: gdiplustypes.h:41
@ NotImplemented
Definition: gdiplustypes.h:31
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLeglImageOES image
Definition: gl.h:2204
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLsizei stride
Definition: glext.h:5848
GLuint res
Definition: glext.h:9613
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint color
Definition: glext.h:6243
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLint * range
Definition: glext.h:7539
GLuint GLenum matrix
Definition: glext.h:9407
GLenum mode
Definition: glext.h:6217
GLfloat units
Definition: glext.h:11727
GLuint in
Definition: glext.h:9616
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLuint interp
Definition: glext.h:9512
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
GLsizei const GLfloat * points
Definition: glext.h:8112
const GLfloat * m
Definition: glext.h:10848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define bits
Definition: infblock.c:15
int quality
Definition: jpeglib.h:994
#define win_skip
Definition: minitest.h:67
int winetest_interactive
#define todo_wine_if(is_todo)
Definition: minitest.h:81
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
#define todo_wine
Definition: minitest.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BITMAP bmp
Definition: alphablend.c:62
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
BOOL expected
Definition: store.c:2000
static void test_GdipDrawCurveI(void)
Definition: graphics.c:1214
static void test_clear(void)
Definition: graphics.c:2311
static GpGraphics * create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL scale, GpImage **image)
Definition: graphics.c:100
void test_bitmap_stride(void)
Definition: graphics.c:7428
static void log_state(GraphicsState data, node **log)
Definition: graphics.c:180
#define expectf_(expected, got, precision)
Definition: graphics.c:30
static void test_GdipDrawImagePointsRectOnMemoryDC(void)
Definition: graphics.c:6857
static void test_clipping(void)
Definition: graphics.c:5309
static void test_fromMemoryBitmap(void)
Definition: graphics.c:2691
static void test_isempty(void)
Definition: graphics.c:2277
static void check_no_duplicates(node *log)
Definition: graphics.c:190
static void test_GdipDrawCurve2(void)
Definition: graphics.c:1019
static void test_gdi_interop_bitmap(void)
Definition: graphics.c:7049
static void test_GdipGetVisibleClipBounds_window(void)
Definition: graphics.c:2542
static void test_GdipGetVisibleClipBounds_memoryDC(void)
Definition: graphics.c:6348
#define BLUE_COLOR
Definition: graphics.c:6603
static void test_GdipFillClosedCurve2I(void)
Definition: graphics.c:473
static void test_clipping_2(void)
Definition: graphics.c:5899
static void test_set_page_transform(void)
Definition: graphics.c:4158
static void test_GdipDrawCurve3I(void)
Definition: graphics.c:939
static HDC create_printer_dc(void)
Definition: graphics.c:7275
static void test_GdipIsVisiblePoint(void)
Definition: graphics.c:2782
static void test_string_functions(void)
Definition: graphics.c:3287
static void test_GdipDrawCurve(void)
Definition: graphics.c:1153
static void test_font_height_scaling(void)
Definition: graphics.c:4449
static void test_save_restore(void)
Definition: graphics.c:223
static REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi)
Definition: graphics.c:73
static void test_GdipFillClosedCurveI(void)
Definition: graphics.c:1552
static void test_GdipGetVisibleClipBounds_screen(void)
Definition: graphics.c:2451
static void test_GdipDrawImageFX(void)
Definition: graphics.c:1313
static void test_GdipDrawLinesI(void)
Definition: graphics.c:1429
static void test_GdipFillRectanglesOnMemoryDCSolidBrush(void)
Definition: graphics.c:6630
static void test_pen_thickness(void)
Definition: graphics.c:4243
static void test_measure_string(void)
Definition: graphics.c:4635
static void test_GdipFillClosedCurve(void)
Definition: graphics.c:1481
static void test_get_set_interpolation(void)
Definition: graphics.c:3662
static void test_bitmapfromgraphics(void)
Definition: graphics.c:5257
static GdiplusAbort *static const REAL mm_per_inch
Definition: graphics.c:38
static void test_GdipDrawCurve2I(void)
Definition: graphics.c:1086
static void test_GdipIsVisibleRect(void)
Definition: graphics.c:2961
static void set_rect_empty(RectF *rc)
Definition: graphics.c:42
static void test_GdipFillRectangles(void)
Definition: graphics.c:6303
static void test_printer_dc(void)
Definition: graphics.c:7353
static void test_clip_xform(void)
Definition: graphics.c:2185
static void test_GdipGetNearestColor(void)
Definition: graphics.c:3123
static void test_get_set_textrenderinghint(void)
Definition: graphics.c:3731
static void test_GdipDrawArc(void)
Definition: graphics.c:535
#define get_bitmap_pixel(x, y)
Definition: graphics.c:6605
static void test_GdipFillClosedCurve2(void)
Definition: graphics.c:402
static void test_GdipDrawArcI(void)
Definition: graphics.c:579
static void test_GdipDrawLineI(void)
Definition: graphics.c:1275
static void test_container_rects(void)
Definition: graphics.c:6403
#define expect(expected, got)
Definition: graphics.c:29
static void test_measured_extra_space(void)
Definition: graphics.c:5116
static void test_textcontrast(void)
Definition: graphics.c:2319
static void test_cliphrgn_transform(void)
Definition: graphics.c:6935
static void test_GdipFillRectanglesOnMemoryDCTextureBrush(void)
Definition: graphics.c:6687
static DWORD * GetBitmapPixelBuffer(HDC hdc, HBITMAP hbmp, int width, int height)
Definition: graphics.c:6606
#define expectf(expected, got)
Definition: graphics.c:31
static const REAL point_per_inch
Definition: graphics.c:39
static void test_Get_Release_DC(void)
Definition: graphics.c:1660
static void test_GdipDrawImagePointsRect(void)
Definition: graphics.c:1374
static void test_GdipDrawBezierI(void)
Definition: graphics.c:821
static void test_GdipFillPath(void)
Definition: graphics.c:1614
static void test_get_set_clip(void)
Definition: graphics.c:2105
static void test_getdc_scaled(void)
Definition: graphics.c:3779
static void test_GdipDrawString(void)
Definition: graphics.c:2342
static void test_GdipMeasureString(void)
Definition: graphics.c:3827
static void test_gdi_interop_hdc(void)
Definition: graphics.c:7140
static void test_transformpoints(void)
Definition: graphics.c:1976
static void test_constructor_destructor(void)
Definition: graphics.c:143
static void test_alpha_hdc(void)
Definition: graphics.c:5184
static void test_GdipGraphicsSetAbort(void)
Definition: graphics.c:6575
static void test_GdipFillRectanglesOnBitmapTextureBrush(void)
Definition: graphics.c:6772
static void test_GdipDrawCurve3(void)
Definition: graphics.c:859
#define is_blue_color(color)
Definition: graphics.c:6604
static void test_GdipGetVisibleClipBounds(void)
Definition: graphics.c:2659
static void test_BeginContainer2(void)
Definition: graphics.c:623
static BOOL check_rect_pixels(const DWORD *pixel, const RectF *rect, UINT width, DWORD expected, Point *failed)
Definition: graphics.c:7322
static void test_hdc_caching(void)
Definition: graphics.c:6980
static void test_transform(void)
Definition: graphics.c:4100
static IHTMLWindow2 * window
Definition: events.c:77
static CHAR string2[MAX_PATH]
Definition: automation.c:345
DWORD exp
Definition: msg.c:18625
#define min(a, b)
Definition: monoChain.cc:55
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 WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
short WCHAR
Definition: pedump.c:58
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
png_const_structrp png_const_inforp int * unit
Definition: png.h:2392
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
static calc_node_t temp
Definition: rpn_ieee.c:38
#define LANG_NEUTRAL
Definition: nls.h:22
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
#define log(outFile, fmt,...)
Definition: util.h:15
CardRegion * from
Definition: spigame.cpp:19
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD biCompression
Definition: amvideo.idl:35
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
DWORD biSizeImage
Definition: amvideo.idl:36
PixelFormat PixelFormat
BOOL SuppressBackgroundThread
Definition: gdiplusinit.h:36
DebugEventProc DebugEventCallback
Definition: gdiplusinit.h:35
GpImage * image
LONG lfHeight
Definition: dimm.idl:42
BYTE lfCharSet
Definition: dimm.idl:50
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
LONG lfHeight
Definition: dimm.idl:59
REAL Y
Definition: gdiplustypes.h:644
REAL X
Definition: gdiplustypes.h:643
REAL Height
Definition: gdiplustypes.h:659
REAL X
Definition: gdiplustypes.h:656
REAL Width
Definition: gdiplustypes.h:658
REAL Y
Definition: gdiplustypes.h:657
INT Width
Definition: gdiplustypes.h:666
INT Height
Definition: gdiplustypes.h:667
INT X
Definition: gdiplustypes.h:664
INT Y
Definition: gdiplustypes.h:665
LPSTR pDriverPath
Definition: winspool.h:406
FLOAT eDy
Definition: wingdi.h:2172
FLOAT eDx
Definition: wingdi.h:2171
Definition: uimain.c:89
struct define * next
Definition: compiler.c:65
Definition: format.c:58
Definition: match.c:28
Definition: pbuf.h:186
Definition: stat.h:66
Definition: ps.c:97
ULONG biClrImportant
Definition: precomp.h:40
USHORT biBitCount
Definition: precomp.h:34
ULONG biCompression
Definition: precomp.h:35
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define max(a, b)
Definition: svc.c:63
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
eMaj lines
Definition: tritemp.h:206
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
uint32_t ULONG
Definition: typedefs.h:59
#define BI_RGB
Definition: uefivid.c:46
Definition: dlist.c:348
GLvoid * data
Definition: dlist.c:359
struct node * next
Definition: graphics.c:176
GraphicsState data
Definition: graphics.c:175
void * next
Definition: dlist.c:360
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
DWORD hint
Definition: vfdcmd.c:88
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define dpi
Definition: sysparams.c:23
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define WINAPI
Definition: msvc.h:6
#define COMPLEXREGION
Definition: wingdi.h:363
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define HORZRES
Definition: wingdi.h:716
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1233
#define GM_ADVANCED
Definition: wingdi.h:865
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
#define LOGPIXELSY
Definition: wingdi.h:719
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
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define VERTRES
Definition: wingdi.h:717
BOOL WINAPI GetWorldTransform(_In_ HDC, _Out_ LPXFORM)
Definition: coord.c:278
#define SIMPLEREGION
Definition: wingdi.h:362
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define LOGPIXELSX
Definition: wingdi.h:718
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI OffsetClipRgn(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
struct _PRINTER_DEFAULTSA * LPPRINTER_DEFAULTSA
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CS_VREDRAW
Definition: winuser.h:666
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define COLOR_WINDOW
Definition: winuser.h:929
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
#define CS_HREDRAW
Definition: winuser.h:661
#define IDC_ARROW
Definition: winuser.h:695
#define RDW_UPDATENOW
Definition: winuser.h:1231
#define IDI_APPLICATION
Definition: winuser.h:712
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2429
HDC WINAPI GetDC(_In_opt_ HWND)
#define CW_USEDEFAULT
Definition: winuser.h:225
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define RDW_INVALIDATE
Definition: winuser.h:1225
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2459
unsigned char BYTE
Definition: xxhash.c:193