gdiplus: Implemented GdipFillClosedCurve and GdipFillClosedCurveI.
[wine/multimedia.git] / dlls / gdiplus / tests / graphics.c
blob441367e07320f328c2cd7d8a766b7f8f31482041
1 /*
2 * Unit test suite for graphics objects
4 * Copyright (C) 2007 Google (Evan Stade)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "windows.h"
22 #include "gdiplus.h"
23 #include "wingdi.h"
24 #include "wine/test.h"
25 #include <math.h>
27 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
28 #define expectf_(expected, got, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
29 #define expectf(expected, got) expectf_(expected, got, 0.0001)
30 #define TABLE_LEN (23)
32 static HWND hwnd;
34 static void test_constructor_destructor(void)
36 GpStatus stat;
37 GpGraphics *graphics = NULL;
38 HDC hdc = GetDC( hwnd );
40 stat = GdipCreateFromHDC(NULL, &graphics);
41 expect(OutOfMemory, stat);
42 stat = GdipDeleteGraphics(graphics);
43 expect(InvalidParameter, stat);
45 stat = GdipCreateFromHDC(hdc, &graphics);
46 expect(Ok, stat);
47 stat = GdipDeleteGraphics(graphics);
48 expect(Ok, stat);
50 stat = GdipCreateFromHWND(NULL, &graphics);
51 expect(Ok, stat);
52 stat = GdipDeleteGraphics(graphics);
53 expect(Ok, stat);
55 stat = GdipCreateFromHWNDICM(NULL, &graphics);
56 expect(Ok, stat);
57 stat = GdipDeleteGraphics(graphics);
58 expect(Ok, stat);
60 stat = GdipDeleteGraphics(NULL);
61 expect(InvalidParameter, stat);
62 ReleaseDC(hwnd, hdc);
65 typedef struct node{
66 GraphicsState data;
67 struct node * next;
68 } node;
70 /* Linked list prepend function. */
71 static void log_state(GraphicsState data, node ** log)
73 node * new_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(node));
75 new_entry->data = data;
76 new_entry->next = *log;
77 *log = new_entry;
80 /* Checks if there are duplicates in the list, and frees it. */
81 static void check_no_duplicates(node * log)
83 INT dups = 0;
84 node * temp = NULL;
85 node * temp2 = NULL;
86 node * orig = log;
88 if(!log)
89 goto end;
91 do{
92 temp = log;
93 while((temp = temp->next)){
94 if(log->data == temp->data){
95 dups++;
96 break;
98 if(dups > 0)
99 break;
101 }while((log = log->next));
103 temp = orig;
105 temp2 = temp->next;
106 HeapFree(GetProcessHeap(), 0, temp);
107 temp = temp2;
108 }while(temp);
110 end:
111 expect(0, dups);
114 static void test_save_restore(void)
116 GpStatus stat;
117 GraphicsState state_a, state_b, state_c;
118 InterpolationMode mode;
119 GpGraphics *graphics1, *graphics2;
120 node * state_log = NULL;
121 HDC hdc = GetDC( hwnd );
122 state_a = state_b = state_c = 0xdeadbeef;
124 /* Invalid saving. */
125 GdipCreateFromHDC(hdc, &graphics1);
126 stat = GdipSaveGraphics(graphics1, NULL);
127 expect(InvalidParameter, stat);
128 stat = GdipSaveGraphics(NULL, &state_a);
129 expect(InvalidParameter, stat);
130 GdipDeleteGraphics(graphics1);
132 log_state(state_a, &state_log);
134 /* Basic save/restore. */
135 GdipCreateFromHDC(hdc, &graphics1);
136 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
137 stat = GdipSaveGraphics(graphics1, &state_a);
138 expect(Ok, stat);
139 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
140 stat = GdipRestoreGraphics(graphics1, state_a);
141 expect(Ok, stat);
142 GdipGetInterpolationMode(graphics1, &mode);
143 expect(InterpolationModeBilinear, mode);
144 GdipDeleteGraphics(graphics1);
146 log_state(state_a, &state_log);
148 /* Restoring garbage doesn't affect saves. */
149 GdipCreateFromHDC(hdc, &graphics1);
150 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
151 GdipSaveGraphics(graphics1, &state_a);
152 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
153 GdipSaveGraphics(graphics1, &state_b);
154 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
155 stat = GdipRestoreGraphics(graphics1, 0xdeadbeef);
156 expect(Ok, stat);
157 GdipRestoreGraphics(graphics1, state_b);
158 GdipGetInterpolationMode(graphics1, &mode);
159 expect(InterpolationModeBicubic, mode);
160 GdipRestoreGraphics(graphics1, state_a);
161 GdipGetInterpolationMode(graphics1, &mode);
162 expect(InterpolationModeBilinear, mode);
163 GdipDeleteGraphics(graphics1);
165 log_state(state_a, &state_log);
166 log_state(state_b, &state_log);
168 /* Restoring older state invalidates newer saves (but not older saves). */
169 GdipCreateFromHDC(hdc, &graphics1);
170 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
171 GdipSaveGraphics(graphics1, &state_a);
172 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
173 GdipSaveGraphics(graphics1, &state_b);
174 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
175 GdipSaveGraphics(graphics1, &state_c);
176 GdipSetInterpolationMode(graphics1, InterpolationModeHighQualityBilinear);
177 GdipRestoreGraphics(graphics1, state_b);
178 GdipGetInterpolationMode(graphics1, &mode);
179 expect(InterpolationModeBicubic, mode);
180 GdipRestoreGraphics(graphics1, state_c);
181 GdipGetInterpolationMode(graphics1, &mode);
182 expect(InterpolationModeBicubic, mode);
183 GdipRestoreGraphics(graphics1, state_a);
184 GdipGetInterpolationMode(graphics1, &mode);
185 expect(InterpolationModeBilinear, mode);
186 GdipDeleteGraphics(graphics1);
188 log_state(state_a, &state_log);
189 log_state(state_b, &state_log);
190 log_state(state_c, &state_log);
192 /* Restoring older save from one graphics object does not invalidate
193 * newer save from other graphics object. */
194 GdipCreateFromHDC(hdc, &graphics1);
195 GdipCreateFromHDC(hdc, &graphics2);
196 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
197 GdipSaveGraphics(graphics1, &state_a);
198 GdipSetInterpolationMode(graphics2, InterpolationModeBicubic);
199 GdipSaveGraphics(graphics2, &state_b);
200 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
201 GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
202 GdipRestoreGraphics(graphics1, state_a);
203 GdipGetInterpolationMode(graphics1, &mode);
204 expect(InterpolationModeBilinear, mode);
205 GdipRestoreGraphics(graphics2, state_b);
206 GdipGetInterpolationMode(graphics2, &mode);
207 expect(InterpolationModeBicubic, mode);
208 GdipDeleteGraphics(graphics1);
209 GdipDeleteGraphics(graphics2);
211 /* You can't restore a state to a graphics object that didn't save it. */
212 GdipCreateFromHDC(hdc, &graphics1);
213 GdipCreateFromHDC(hdc, &graphics2);
214 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
215 GdipSaveGraphics(graphics1, &state_a);
216 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
217 GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
218 GdipRestoreGraphics(graphics2, state_a);
219 GdipGetInterpolationMode(graphics2, &mode);
220 expect(InterpolationModeNearestNeighbor, mode);
221 GdipDeleteGraphics(graphics1);
222 GdipDeleteGraphics(graphics2);
224 log_state(state_a, &state_log);
226 /* The same state value should never be returned twice. */
227 todo_wine
228 check_no_duplicates(state_log);
230 ReleaseDC(hwnd, hdc);
233 static void test_GdipFillClosedCurve2(void)
235 GpStatus status;
236 GpGraphics *graphics = NULL;
237 GpSolidFill *brush = NULL;
238 HDC hdc = GetDC( hwnd );
239 GpPointF points[3];
241 points[0].X = 0;
242 points[0].Y = 0;
244 points[1].X = 40;
245 points[1].Y = 20;
247 points[2].X = 10;
248 points[2].Y = 40;
250 /* make a graphics object and brush object */
251 ok(hdc != NULL, "Expected HDC to be initialized\n");
253 status = GdipCreateFromHDC(hdc, &graphics);
254 expect(Ok, status);
255 ok(graphics != NULL, "Expected graphics to be initialized\n");
257 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
259 /* InvalidParameter cases: null graphics, null brush, null points */
260 status = GdipFillClosedCurve2(NULL, NULL, NULL, 3, 0.5, FillModeAlternate);
261 expect(InvalidParameter, status);
263 status = GdipFillClosedCurve2(graphics, NULL, NULL, 3, 0.5, FillModeAlternate);
264 expect(InvalidParameter, status);
266 status = GdipFillClosedCurve2(NULL, (GpBrush*)brush, NULL, 3, 0.5, FillModeAlternate);
267 expect(InvalidParameter, status);
269 status = GdipFillClosedCurve2(NULL, NULL, points, 3, 0.5, FillModeAlternate);
270 expect(InvalidParameter, status);
272 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, NULL, 3, 0.5, FillModeAlternate);
273 expect(InvalidParameter, status);
275 status = GdipFillClosedCurve2(graphics, NULL, points, 3, 0.5, FillModeAlternate);
276 expect(InvalidParameter, status);
278 status = GdipFillClosedCurve2(NULL, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
279 expect(InvalidParameter, status);
281 /* InvalidParameter cases: invalid count */
282 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, -1, 0.5, FillModeAlternate);
283 expect(InvalidParameter, status);
285 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 0, 0.5, FillModeAlternate);
286 expect(InvalidParameter, status);
288 /* Valid test cases */
289 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 1, 0.5, FillModeAlternate);
290 expect(Ok, status);
292 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 2, 0.5, FillModeAlternate);
293 expect(Ok, status);
295 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
296 expect(Ok, status);
298 GdipDeleteGraphics(graphics);
299 GdipDeleteBrush((GpBrush*)brush);
301 ReleaseDC(hwnd, hdc);
304 static void test_GdipFillClosedCurve2I(void)
306 GpStatus status;
307 GpGraphics *graphics = NULL;
308 GpSolidFill *brush = NULL;
309 HDC hdc = GetDC( hwnd );
310 GpPoint points[3];
312 points[0].X = 0;
313 points[0].Y = 0;
315 points[1].X = 40;
316 points[1].Y = 20;
318 points[2].X = 10;
319 points[2].Y = 40;
321 /* make a graphics object and brush object */
322 ok(hdc != NULL, "Expected HDC to be initialized\n");
324 status = GdipCreateFromHDC(hdc, &graphics);
325 expect(Ok, status);
326 ok(graphics != NULL, "Expected graphics to be initialized\n");
328 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
330 /* InvalidParameter cases: null graphics, null brush */
331 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
332 when points == NULL, so don't test this condition */
333 status = GdipFillClosedCurve2I(NULL, NULL, points, 3, 0.5, FillModeAlternate);
334 expect(InvalidParameter, status);
336 status = GdipFillClosedCurve2I(graphics, NULL, points, 3, 0.5, FillModeAlternate);
337 expect(InvalidParameter, status);
339 status = GdipFillClosedCurve2I(NULL, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
340 expect(InvalidParameter, status);
342 /* InvalidParameter cases: invalid count */
343 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 0, 0.5, FillModeAlternate);
344 expect(InvalidParameter, status);
346 /* OutOfMemory cases: large (unsigned) int */
347 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, -1, 0.5, FillModeAlternate);
348 expect(OutOfMemory, status);
350 /* Valid test cases */
351 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 1, 0.5, FillModeAlternate);
352 expect(Ok, status);
354 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 2, 0.5, FillModeAlternate);
355 expect(Ok, status);
357 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
358 expect(Ok, status);
360 GdipDeleteGraphics(graphics);
361 GdipDeleteBrush((GpBrush*)brush);
363 ReleaseDC(hwnd, hdc);
366 static void test_GdipDrawArc(void)
368 GpStatus status;
369 GpGraphics *graphics = NULL;
370 GpPen *pen = NULL;
371 HDC hdc = GetDC( hwnd );
373 /* make a graphics object and pen object */
374 ok(hdc != NULL, "Expected HDC to be initialized\n");
376 status = GdipCreateFromHDC(hdc, &graphics);
377 expect(Ok, status);
378 ok(graphics != NULL, "Expected graphics to be initialized\n");
380 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
381 expect(Ok, status);
382 ok(pen != NULL, "Expected pen to be initialized\n");
384 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
385 status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
386 expect(InvalidParameter, status);
388 status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
389 expect(InvalidParameter, status);
391 status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
392 expect(InvalidParameter, status);
394 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
395 expect(InvalidParameter, status);
397 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
398 expect(InvalidParameter, status);
400 /* successful case */
401 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
402 expect(Ok, status);
404 GdipDeletePen(pen);
405 GdipDeleteGraphics(graphics);
407 ReleaseDC(hwnd, hdc);
410 static void test_GdipDrawArcI(void)
412 GpStatus status;
413 GpGraphics *graphics = NULL;
414 GpPen *pen = NULL;
415 HDC hdc = GetDC( hwnd );
417 /* make a graphics object and pen object */
418 ok(hdc != NULL, "Expected HDC to be initialized\n");
420 status = GdipCreateFromHDC(hdc, &graphics);
421 expect(Ok, status);
422 ok(graphics != NULL, "Expected graphics to be initialized\n");
424 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
425 expect(Ok, status);
426 ok(pen != NULL, "Expected pen to be initialized\n");
428 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
429 status = GdipDrawArcI(NULL, NULL, 0, 0, 0, 0, 0, 0);
430 expect(InvalidParameter, status);
432 status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
433 expect(InvalidParameter, status);
435 status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
436 expect(InvalidParameter, status);
438 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
439 expect(InvalidParameter, status);
441 status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
442 expect(InvalidParameter, status);
444 /* successful case */
445 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
446 expect(Ok, status);
448 GdipDeletePen(pen);
449 GdipDeleteGraphics(graphics);
451 ReleaseDC(hwnd, hdc);
454 static void test_BeginContainer2(void)
456 GpMatrix *transform;
457 GpRectF clip;
458 REAL defClip[] = {5, 10, 15, 20};
459 REAL elems[6], defTrans[] = {1, 2, 3, 4, 5, 6};
460 GraphicsContainer cont1, cont2, cont3, cont4;
461 CompositingQuality compqual, defCompqual = CompositingQualityHighSpeed;
462 CompositingMode compmode, defCompmode = CompositingModeSourceOver;
463 InterpolationMode interp, defInterp = InterpolationModeHighQualityBicubic;
464 REAL scale, defScale = 17;
465 GpUnit unit, defUnit = UnitPixel;
466 PixelOffsetMode offsetmode, defOffsetmode = PixelOffsetModeHighSpeed;
467 SmoothingMode smoothmode, defSmoothmode = SmoothingModeAntiAlias;
468 UINT contrast, defContrast = 5;
469 TextRenderingHint texthint, defTexthint = TextRenderingHintAntiAlias;
471 GpStatus status;
472 GpGraphics *graphics = NULL;
473 HDC hdc = GetDC( hwnd );
475 ok(hdc != NULL, "Expected HDC to be initialized\n");
477 status = GdipCreateFromHDC(hdc, &graphics);
478 expect(Ok, status);
479 ok(graphics != NULL, "Expected graphics to be initialized\n");
481 /* null graphics, null container */
482 status = GdipBeginContainer2(NULL, &cont1);
483 expect(InvalidParameter, status);
485 status = GdipBeginContainer2(graphics, NULL);
486 expect(InvalidParameter, status);
488 status = GdipEndContainer(NULL, cont1);
489 expect(InvalidParameter, status);
491 /* test all quality-related values */
492 GdipSetCompositingMode(graphics, defCompmode);
493 GdipSetCompositingQuality(graphics, defCompqual);
494 GdipSetInterpolationMode(graphics, defInterp);
495 GdipSetPageScale(graphics, defScale);
496 GdipSetPageUnit(graphics, defUnit);
497 GdipSetPixelOffsetMode(graphics, defOffsetmode);
498 GdipSetSmoothingMode(graphics, defSmoothmode);
499 GdipSetTextContrast(graphics, defContrast);
500 GdipSetTextRenderingHint(graphics, defTexthint);
502 status = GdipBeginContainer2(graphics, &cont1);
503 expect(Ok, status);
505 GdipSetCompositingMode(graphics, CompositingModeSourceCopy);
506 GdipSetCompositingQuality(graphics, CompositingQualityHighQuality);
507 GdipSetInterpolationMode(graphics, InterpolationModeBilinear);
508 GdipSetPageScale(graphics, 10);
509 GdipSetPageUnit(graphics, UnitDocument);
510 GdipSetPixelOffsetMode(graphics, PixelOffsetModeHalf);
511 GdipSetSmoothingMode(graphics, SmoothingModeNone);
512 GdipSetTextContrast(graphics, 7);
513 GdipSetTextRenderingHint(graphics, TextRenderingHintClearTypeGridFit);
515 status = GdipEndContainer(graphics, cont1);
516 expect(Ok, status);
518 GdipGetCompositingMode(graphics, &compmode);
519 ok(defCompmode == compmode, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode, compmode);
521 GdipGetCompositingQuality(graphics, &compqual);
522 ok(defCompqual == compqual, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual, compqual);
524 GdipGetInterpolationMode(graphics, &interp);
525 ok(defInterp == interp, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp, interp);
527 GdipGetPageScale(graphics, &scale);
528 ok(fabs(defScale - scale) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale, scale);
530 GdipGetPageUnit(graphics, &unit);
531 ok(defUnit == unit, "Expected Page Unit to be restored to %d, got %d\n", defUnit, unit);
533 GdipGetPixelOffsetMode(graphics, &offsetmode);
534 ok(defOffsetmode == offsetmode, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode, offsetmode);
536 GdipGetSmoothingMode(graphics, &smoothmode);
537 ok(defSmoothmode == smoothmode, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode, smoothmode);
539 GdipGetTextContrast(graphics, &contrast);
540 ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
542 GdipGetTextRenderingHint(graphics, &texthint);
543 ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
545 /* test world transform */
546 status = GdipBeginContainer2(graphics, &cont1);
547 expect(Ok, status);
549 GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
550 defTrans[4], defTrans[5], &transform);
551 GdipSetWorldTransform(graphics, transform);
552 GdipDeleteMatrix(transform);
553 transform = NULL;
555 status = GdipBeginContainer2(graphics, &cont2);
556 expect(Ok, status);
558 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
559 GdipSetWorldTransform(graphics, transform);
560 GdipDeleteMatrix(transform);
561 transform = NULL;
563 status = GdipEndContainer(graphics, cont2);
564 expect(Ok, status);
566 GdipCreateMatrix(&transform);
567 GdipGetWorldTransform(graphics, transform);
568 GdipGetMatrixElements(transform, elems);
569 ok(fabs(defTrans[0] - elems[0]) < 0.0001 &&
570 fabs(defTrans[1] - elems[1]) < 0.0001 &&
571 fabs(defTrans[2] - elems[2]) < 0.0001 &&
572 fabs(defTrans[3] - elems[3]) < 0.0001 &&
573 fabs(defTrans[4] - elems[4]) < 0.0001 &&
574 fabs(defTrans[5] - elems[5]) < 0.0001,
575 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
576 defTrans[0], defTrans[1], defTrans[2], defTrans[3], defTrans[4], defTrans[5],
577 elems[0], elems[1], elems[2], elems[3], elems[4], elems[5]);
578 GdipDeleteMatrix(transform);
579 transform = NULL;
581 status = GdipEndContainer(graphics, cont1);
582 expect(Ok, status);
584 /* test clipping */
585 status = GdipBeginContainer2(graphics, &cont1);
586 expect(Ok, status);
588 GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace);
590 status = GdipBeginContainer2(graphics, &cont2);
591 expect(Ok, status);
593 GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
595 status = GdipEndContainer(graphics, cont2);
597 GdipGetClipBounds(graphics, &clip);
598 ok(fabs(defClip[0] - clip.X) < 0.0001 &&
599 fabs(defClip[1] - clip.Y) < 0.0001 &&
600 fabs(defClip[2] - clip.Width) < 0.0001 &&
601 fabs(defClip[3] - clip.Height) < 0.0001,
602 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
603 defClip[0], defClip[1], defClip[2], defClip[3],
604 clip.X, clip.Y, clip.Width, clip.Height);
606 status = GdipEndContainer(graphics, cont1);
608 /* nesting */
609 status = GdipBeginContainer2(graphics, &cont1);
610 expect(Ok, status);
612 status = GdipBeginContainer2(graphics, &cont2);
613 expect(Ok, status);
615 status = GdipBeginContainer2(graphics, &cont3);
616 expect(Ok, status);
618 status = GdipEndContainer(graphics, cont3);
619 expect(Ok, status);
621 status = GdipBeginContainer2(graphics, &cont4);
622 expect(Ok, status);
624 status = GdipEndContainer(graphics, cont4);
625 expect(Ok, status);
627 /* skip cont2 */
628 status = GdipEndContainer(graphics, cont1);
629 expect(Ok, status);
631 /* end an already-ended container */
632 status = GdipEndContainer(graphics, cont1);
633 expect(Ok, status);
635 GdipDeleteGraphics(graphics);
636 ReleaseDC(hwnd, hdc);
639 static void test_GdipDrawBezierI(void)
641 GpStatus status;
642 GpGraphics *graphics = NULL;
643 GpPen *pen = NULL;
644 HDC hdc = GetDC( hwnd );
646 /* make a graphics object and pen object */
647 ok(hdc != NULL, "Expected HDC to be initialized\n");
649 status = GdipCreateFromHDC(hdc, &graphics);
650 expect(Ok, status);
651 ok(graphics != NULL, "Expected graphics to be initialized\n");
653 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
654 expect(Ok, status);
655 ok(pen != NULL, "Expected pen to be initialized\n");
657 /* InvalidParameter cases: null graphics, null pen */
658 status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
659 expect(InvalidParameter, status);
661 status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
662 expect(InvalidParameter, status);
664 status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
665 expect(InvalidParameter, status);
667 /* successful case */
668 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
669 expect(Ok, status);
671 GdipDeletePen(pen);
672 GdipDeleteGraphics(graphics);
674 ReleaseDC(hwnd, hdc);
677 static void test_GdipDrawCurve3(void)
679 GpStatus status;
680 GpGraphics *graphics = NULL;
681 GpPen *pen = NULL;
682 HDC hdc = GetDC( hwnd );
683 GpPointF points[3];
685 points[0].X = 0;
686 points[0].Y = 0;
688 points[1].X = 40;
689 points[1].Y = 20;
691 points[2].X = 10;
692 points[2].Y = 40;
694 /* make a graphics object and pen object */
695 ok(hdc != NULL, "Expected HDC to be initialized\n");
697 status = GdipCreateFromHDC(hdc, &graphics);
698 expect(Ok, status);
699 ok(graphics != NULL, "Expected graphics to be initialized\n");
701 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
702 expect(Ok, status);
703 ok(pen != NULL, "Expected pen to be initialized\n");
705 /* InvalidParameter cases: null graphics, null pen */
706 status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1);
707 expect(InvalidParameter, status);
709 status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1);
710 expect(InvalidParameter, status);
712 status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1);
713 expect(InvalidParameter, status);
715 /* InvalidParameter cases: invalid count */
716 status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1);
717 expect(InvalidParameter, status);
719 status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1);
720 expect(InvalidParameter, status);
722 status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1);
723 expect(InvalidParameter, status);
725 status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1);
726 expect(InvalidParameter, status);
728 /* InvalidParameter cases: invalid number of segments */
729 status = GdipDrawCurve3(graphics, pen, points, 3, 0, -1, 1);
730 expect(InvalidParameter, status);
732 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 2, 1);
733 expect(InvalidParameter, status);
735 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 2, 1);
736 expect(InvalidParameter, status);
738 /* Valid test cases */
739 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, 1);
740 expect(Ok, status);
742 status = GdipDrawCurve3(graphics, pen, points, 3, 0, 2, 2);
743 expect(Ok, status);
745 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, -2);
746 expect(Ok, status);
748 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 1, 0);
749 expect(Ok, status);
751 GdipDeletePen(pen);
752 GdipDeleteGraphics(graphics);
754 ReleaseDC(hwnd, hdc);
757 static void test_GdipDrawCurve3I(void)
759 GpStatus status;
760 GpGraphics *graphics = NULL;
761 GpPen *pen = NULL;
762 HDC hdc = GetDC( hwnd );
763 GpPoint points[3];
765 points[0].X = 0;
766 points[0].Y = 0;
768 points[1].X = 40;
769 points[1].Y = 20;
771 points[2].X = 10;
772 points[2].Y = 40;
774 /* make a graphics object and pen object */
775 ok(hdc != NULL, "Expected HDC to be initialized\n");
777 status = GdipCreateFromHDC(hdc, &graphics);
778 expect(Ok, status);
779 ok(graphics != NULL, "Expected graphics to be initialized\n");
781 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
782 expect(Ok, status);
783 ok(pen != NULL, "Expected pen to be initialized\n");
785 /* InvalidParameter cases: null graphics, null pen */
786 status = GdipDrawCurve3I(NULL, NULL, points, 3, 0, 2, 1);
787 expect(InvalidParameter, status);
789 status = GdipDrawCurve3I(graphics, NULL, points, 3, 0, 2, 1);
790 expect(InvalidParameter, status);
792 status = GdipDrawCurve3I(NULL, pen, points, 3, 0, 2, 1);
793 expect(InvalidParameter, status);
795 /* InvalidParameter cases: invalid count */
796 status = GdipDrawCurve3I(graphics, pen, points, -1, -1, -1, 1);
797 expect(OutOfMemory, status);
799 status = GdipDrawCurve3I(graphics, pen, points, 0, 0, 2, 1);
800 expect(InvalidParameter, status);
802 status = GdipDrawCurve3I(graphics, pen, points, 1, 0, 0, 1);
803 expect(InvalidParameter, status);
805 status = GdipDrawCurve3I(graphics, pen, points, 3, 4, 2, 1);
806 expect(InvalidParameter, status);
808 /* InvalidParameter cases: invalid number of segments */
809 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, -1, 1);
810 expect(InvalidParameter, status);
812 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 2, 1);
813 expect(InvalidParameter, status);
815 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 2, 1);
816 expect(InvalidParameter, status);
818 /* Valid test cases */
819 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, 1);
820 expect(Ok, status);
822 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, 2, 2);
823 expect(Ok, status);
825 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, -2);
826 expect(Ok, status);
828 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 1, 0);
829 expect(Ok, status);
831 GdipDeletePen(pen);
832 GdipDeleteGraphics(graphics);
834 ReleaseDC(hwnd, hdc);
837 static void test_GdipDrawCurve2(void)
839 GpStatus status;
840 GpGraphics *graphics = NULL;
841 GpPen *pen = NULL;
842 HDC hdc = GetDC( hwnd );
843 GpPointF points[3];
845 points[0].X = 0;
846 points[0].Y = 0;
848 points[1].X = 40;
849 points[1].Y = 20;
851 points[2].X = 10;
852 points[2].Y = 40;
854 /* make a graphics object and pen object */
855 ok(hdc != NULL, "Expected HDC to be initialized\n");
857 status = GdipCreateFromHDC(hdc, &graphics);
858 expect(Ok, status);
859 ok(graphics != NULL, "Expected graphics to be initialized\n");
861 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
862 expect(Ok, status);
863 ok(pen != NULL, "Expected pen to be initialized\n");
865 /* InvalidParameter cases: null graphics, null pen */
866 status = GdipDrawCurve2(NULL, NULL, points, 3, 1);
867 expect(InvalidParameter, status);
869 status = GdipDrawCurve2(graphics, NULL, points, 3, 1);
870 expect(InvalidParameter, status);
872 status = GdipDrawCurve2(NULL, pen, points, 3, 1);
873 expect(InvalidParameter, status);
875 /* InvalidParameter cases: invalid count */
876 status = GdipDrawCurve2(graphics, pen, points, -1, 1);
877 expect(InvalidParameter, status);
879 status = GdipDrawCurve2(graphics, pen, points, 0, 1);
880 expect(InvalidParameter, status);
882 status = GdipDrawCurve2(graphics, pen, points, 1, 1);
883 expect(InvalidParameter, status);
885 /* Valid test cases */
886 status = GdipDrawCurve2(graphics, pen, points, 2, 1);
887 expect(Ok, status);
889 status = GdipDrawCurve2(graphics, pen, points, 3, 2);
890 expect(Ok, status);
892 status = GdipDrawCurve2(graphics, pen, points, 3, -2);
893 expect(Ok, status);
895 status = GdipDrawCurve2(graphics, pen, points, 3, 0);
896 expect(Ok, status);
898 GdipDeletePen(pen);
899 GdipDeleteGraphics(graphics);
901 ReleaseDC(hwnd, hdc);
904 static void test_GdipDrawCurve2I(void)
906 GpStatus status;
907 GpGraphics *graphics = NULL;
908 GpPen *pen = NULL;
909 HDC hdc = GetDC( hwnd );
910 GpPoint points[3];
912 points[0].X = 0;
913 points[0].Y = 0;
915 points[1].X = 40;
916 points[1].Y = 20;
918 points[2].X = 10;
919 points[2].Y = 40;
921 /* make a graphics object and pen object */
922 ok(hdc != NULL, "Expected HDC to be initialized\n");
924 status = GdipCreateFromHDC(hdc, &graphics);
925 expect(Ok, status);
926 ok(graphics != NULL, "Expected graphics to be initialized\n");
928 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
929 expect(Ok, status);
930 ok(pen != NULL, "Expected pen to be initialized\n");
932 /* InvalidParameter cases: null graphics, null pen */
933 status = GdipDrawCurve2I(NULL, NULL, points, 3, 1);
934 expect(InvalidParameter, status);
936 status = GdipDrawCurve2I(graphics, NULL, points, 3, 1);
937 expect(InvalidParameter, status);
939 status = GdipDrawCurve2I(NULL, pen, points, 3, 1);
940 expect(InvalidParameter, status);
942 /* InvalidParameter cases: invalid count */
943 status = GdipDrawCurve2I(graphics, pen, points, -1, 1);
944 expect(OutOfMemory, status);
946 status = GdipDrawCurve2I(graphics, pen, points, 0, 1);
947 expect(InvalidParameter, status);
949 status = GdipDrawCurve2I(graphics, pen, points, 1, 1);
950 expect(InvalidParameter, status);
952 /* Valid test cases */
953 status = GdipDrawCurve2I(graphics, pen, points, 2, 1);
954 expect(Ok, status);
956 status = GdipDrawCurve2I(graphics, pen, points, 3, 2);
957 expect(Ok, status);
959 status = GdipDrawCurve2I(graphics, pen, points, 3, -2);
960 expect(Ok, status);
962 status = GdipDrawCurve2I(graphics, pen, points, 3, 0);
963 expect(Ok, status);
965 GdipDeletePen(pen);
966 GdipDeleteGraphics(graphics);
968 ReleaseDC(hwnd, hdc);
971 static void test_GdipDrawCurve(void)
973 GpStatus status;
974 GpGraphics *graphics = NULL;
975 GpPen *pen = NULL;
976 HDC hdc = GetDC( hwnd );
977 GpPointF points[3];
979 points[0].X = 0;
980 points[0].Y = 0;
982 points[1].X = 40;
983 points[1].Y = 20;
985 points[2].X = 10;
986 points[2].Y = 40;
988 /* make a graphics object and pen object */
989 ok(hdc != NULL, "Expected HDC to be initialized\n");
991 status = GdipCreateFromHDC(hdc, &graphics);
992 expect(Ok, status);
993 ok(graphics != NULL, "Expected graphics to be initialized\n");
995 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
996 expect(Ok, status);
997 ok(pen != NULL, "Expected pen to be initialized\n");
999 /* InvalidParameter cases: null graphics, null pen */
1000 status = GdipDrawCurve(NULL, NULL, points, 3);
1001 expect(InvalidParameter, status);
1003 status = GdipDrawCurve(graphics, NULL, points, 3);
1004 expect(InvalidParameter, status);
1006 status = GdipDrawCurve(NULL, pen, points, 3);
1007 expect(InvalidParameter, status);
1009 /* InvalidParameter cases: invalid count */
1010 status = GdipDrawCurve(graphics, pen, points, -1);
1011 expect(InvalidParameter, status);
1013 status = GdipDrawCurve(graphics, pen, points, 0);
1014 expect(InvalidParameter, status);
1016 status = GdipDrawCurve(graphics, pen, points, 1);
1017 expect(InvalidParameter, status);
1019 /* Valid test cases */
1020 status = GdipDrawCurve(graphics, pen, points, 2);
1021 expect(Ok, status);
1023 status = GdipDrawCurve(graphics, pen, points, 3);
1024 expect(Ok, status);
1026 GdipDeletePen(pen);
1027 GdipDeleteGraphics(graphics);
1029 ReleaseDC(hwnd, hdc);
1032 static void test_GdipDrawCurveI(void)
1034 GpStatus status;
1035 GpGraphics *graphics = NULL;
1036 GpPen *pen = NULL;
1037 HDC hdc = GetDC( hwnd );
1038 GpPoint points[3];
1040 points[0].X = 0;
1041 points[0].Y = 0;
1043 points[1].X = 40;
1044 points[1].Y = 20;
1046 points[2].X = 10;
1047 points[2].Y = 40;
1049 /* make a graphics object and pen object */
1050 ok(hdc != NULL, "Expected HDC to be initialized\n");
1052 status = GdipCreateFromHDC(hdc, &graphics);
1053 expect(Ok, status);
1054 ok(graphics != NULL, "Expected graphics to be initialized\n");
1056 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1057 expect(Ok, status);
1058 ok(pen != NULL, "Expected pen to be initialized\n");
1060 /* InvalidParameter cases: null graphics, null pen */
1061 status = GdipDrawCurveI(NULL, NULL, points, 3);
1062 expect(InvalidParameter, status);
1064 status = GdipDrawCurveI(graphics, NULL, points, 3);
1065 expect(InvalidParameter, status);
1067 status = GdipDrawCurveI(NULL, pen, points, 3);
1068 expect(InvalidParameter, status);
1070 /* InvalidParameter cases: invalid count */
1071 status = GdipDrawCurveI(graphics, pen, points, -1);
1072 expect(OutOfMemory, status);
1074 status = GdipDrawCurveI(graphics, pen, points, 0);
1075 expect(InvalidParameter, status);
1077 status = GdipDrawCurveI(graphics, pen, points, 1);
1078 expect(InvalidParameter, status);
1080 /* Valid test cases */
1081 status = GdipDrawCurveI(graphics, pen, points, 2);
1082 expect(Ok, status);
1084 status = GdipDrawCurveI(graphics, pen, points, 3);
1085 expect(Ok, status);
1087 GdipDeletePen(pen);
1088 GdipDeleteGraphics(graphics);
1090 ReleaseDC(hwnd, hdc);
1093 static void test_GdipDrawLineI(void)
1095 GpStatus status;
1096 GpGraphics *graphics = NULL;
1097 GpPen *pen = NULL;
1098 HDC hdc = GetDC( hwnd );
1100 /* make a graphics object and pen object */
1101 ok(hdc != NULL, "Expected HDC to be initialized\n");
1103 status = GdipCreateFromHDC(hdc, &graphics);
1104 expect(Ok, status);
1105 ok(graphics != NULL, "Expected graphics to be initialized\n");
1107 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1108 expect(Ok, status);
1109 ok(pen != NULL, "Expected pen to be initialized\n");
1111 /* InvalidParameter cases: null graphics, null pen */
1112 status = GdipDrawLineI(NULL, NULL, 0, 0, 0, 0);
1113 expect(InvalidParameter, status);
1115 status = GdipDrawLineI(graphics, NULL, 0, 0, 0, 0);
1116 expect(InvalidParameter, status);
1118 status = GdipDrawLineI(NULL, pen, 0, 0, 0, 0);
1119 expect(InvalidParameter, status);
1121 /* successful case */
1122 status = GdipDrawLineI(graphics, pen, 0, 0, 0, 0);
1123 expect(Ok, status);
1125 GdipDeletePen(pen);
1126 GdipDeleteGraphics(graphics);
1128 ReleaseDC(hwnd, hdc);
1131 static void test_GdipDrawLinesI(void)
1133 GpStatus status;
1134 GpGraphics *graphics = NULL;
1135 GpPen *pen = NULL;
1136 GpPoint *ptf = NULL;
1137 HDC hdc = GetDC( hwnd );
1139 /* make a graphics object and pen object */
1140 ok(hdc != NULL, "Expected HDC to be initialized\n");
1142 status = GdipCreateFromHDC(hdc, &graphics);
1143 expect(Ok, status);
1144 ok(graphics != NULL, "Expected graphics to be initialized\n");
1146 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1147 expect(Ok, status);
1148 ok(pen != NULL, "Expected pen to be initialized\n");
1150 /* make some arbitrary valid points*/
1151 ptf = GdipAlloc(2 * sizeof(GpPointF));
1153 ptf[0].X = 1;
1154 ptf[0].Y = 1;
1156 ptf[1].X = 2;
1157 ptf[1].Y = 2;
1159 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1160 status = GdipDrawLinesI(NULL, NULL, NULL, 0);
1161 expect(InvalidParameter, status);
1163 status = GdipDrawLinesI(graphics, pen, ptf, 0);
1164 expect(InvalidParameter, status);
1166 status = GdipDrawLinesI(graphics, NULL, ptf, 2);
1167 expect(InvalidParameter, status);
1169 status = GdipDrawLinesI(NULL, pen, ptf, 2);
1170 expect(InvalidParameter, status);
1172 /* successful case */
1173 status = GdipDrawLinesI(graphics, pen, ptf, 2);
1174 expect(Ok, status);
1176 GdipFree(ptf);
1177 GdipDeletePen(pen);
1178 GdipDeleteGraphics(graphics);
1180 ReleaseDC(hwnd, hdc);
1183 static void test_GdipFillClosedCurve(void)
1185 GpStatus status;
1186 GpGraphics *graphics = NULL;
1187 GpSolidFill *brush = NULL;
1188 HDC hdc = GetDC( hwnd );
1189 GpPointF points[3];
1191 points[0].X = 0;
1192 points[0].Y = 0;
1194 points[1].X = 40;
1195 points[1].Y = 20;
1197 points[2].X = 10;
1198 points[2].Y = 40;
1200 /* make a graphics object and brush object */
1201 ok(hdc != NULL, "Expected HDC to be initialized\n");
1203 status = GdipCreateFromHDC(hdc, &graphics);
1204 expect(Ok, status);
1205 ok(graphics != NULL, "Expected graphics to be initialized\n");
1207 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1209 /* InvalidParameter cases: null graphics, null brush, null points */
1210 status = GdipFillClosedCurve(NULL, NULL, NULL, 3);
1211 expect(InvalidParameter, status);
1213 status = GdipFillClosedCurve(graphics, NULL, NULL, 3);
1214 expect(InvalidParameter, status);
1216 status = GdipFillClosedCurve(NULL, (GpBrush*)brush, NULL, 3);
1217 expect(InvalidParameter, status);
1219 status = GdipFillClosedCurve(NULL, NULL, points, 3);
1220 expect(InvalidParameter, status);
1222 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, NULL, 3);
1223 expect(InvalidParameter, status);
1225 status = GdipFillClosedCurve(graphics, NULL, points, 3);
1226 expect(InvalidParameter, status);
1228 status = GdipFillClosedCurve(NULL, (GpBrush*)brush, points, 3);
1229 expect(InvalidParameter, status);
1231 /* InvalidParameter cases: invalid count */
1232 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, -1);
1233 expect(InvalidParameter, status);
1235 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 0);
1236 expect(InvalidParameter, status);
1238 /* Valid test cases */
1239 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 1);
1240 expect(Ok, status);
1242 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 2);
1243 expect(Ok, status);
1245 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 3);
1246 expect(Ok, status);
1248 GdipDeleteGraphics(graphics);
1249 GdipDeleteBrush((GpBrush*)brush);
1251 ReleaseDC(hwnd, hdc);
1254 static void test_GdipFillClosedCurveI(void)
1256 GpStatus status;
1257 GpGraphics *graphics = NULL;
1258 GpSolidFill *brush = NULL;
1259 HDC hdc = GetDC( hwnd );
1260 GpPoint points[3];
1262 points[0].X = 0;
1263 points[0].Y = 0;
1265 points[1].X = 40;
1266 points[1].Y = 20;
1268 points[2].X = 10;
1269 points[2].Y = 40;
1271 /* make a graphics object and brush object */
1272 ok(hdc != NULL, "Expected HDC to be initialized\n");
1274 status = GdipCreateFromHDC(hdc, &graphics);
1275 expect(Ok, status);
1276 ok(graphics != NULL, "Expected graphics to be initialized\n");
1278 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1280 /* InvalidParameter cases: null graphics, null brush */
1281 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1282 when points == NULL, so don't test this condition */
1283 status = GdipFillClosedCurveI(NULL, NULL, points, 3);
1284 expect(InvalidParameter, status);
1286 status = GdipFillClosedCurveI(graphics, NULL, points, 3);
1287 expect(InvalidParameter, status);
1289 status = GdipFillClosedCurveI(NULL, (GpBrush*)brush, points, 3);
1290 expect(InvalidParameter, status);
1292 /* InvalidParameter cases: invalid count */
1293 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 0);
1294 expect(InvalidParameter, status);
1296 /* OutOfMemory cases: large (unsigned) int */
1297 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, -1);
1298 expect(OutOfMemory, status);
1300 /* Valid test cases */
1301 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 1);
1302 expect(Ok, status);
1304 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 2);
1305 expect(Ok, status);
1307 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 3);
1308 expect(Ok, status);
1310 GdipDeleteGraphics(graphics);
1311 GdipDeleteBrush((GpBrush*)brush);
1313 ReleaseDC(hwnd, hdc);
1316 static void test_Get_Release_DC(void)
1318 GpStatus status;
1319 GpGraphics *graphics = NULL;
1320 GpPen *pen;
1321 GpSolidFill *brush;
1322 GpPath *path;
1323 HDC hdc = GetDC( hwnd );
1324 HDC retdc;
1325 REAL r;
1326 CompositingQuality quality;
1327 CompositingMode compmode;
1328 InterpolationMode intmode;
1329 GpMatrix *m;
1330 GpRegion *region;
1331 GpUnit unit;
1332 PixelOffsetMode offsetmode;
1333 SmoothingMode smoothmode;
1334 TextRenderingHint texthint;
1335 GpPointF ptf[5];
1336 GpPoint pt[5];
1337 GpRectF rectf[2];
1338 GpRect rect[2];
1339 GpRegion *clip;
1340 INT i;
1341 BOOL res;
1342 ARGB color = 0x00000000;
1343 HRGN hrgn = CreateRectRgn(0, 0, 10, 10);
1345 pt[0].X = 10;
1346 pt[0].Y = 10;
1347 pt[1].X = 20;
1348 pt[1].Y = 15;
1349 pt[2].X = 40;
1350 pt[2].Y = 80;
1351 pt[3].X = -20;
1352 pt[3].Y = 20;
1353 pt[4].X = 50;
1354 pt[4].Y = 110;
1356 for(i = 0; i < 5;i++){
1357 ptf[i].X = (REAL)pt[i].X;
1358 ptf[i].Y = (REAL)pt[i].Y;
1361 rect[0].X = 0;
1362 rect[0].Y = 0;
1363 rect[0].Width = 50;
1364 rect[0].Height = 70;
1365 rect[1].X = 0;
1366 rect[1].Y = 0;
1367 rect[1].Width = 10;
1368 rect[1].Height = 20;
1370 for(i = 0; i < 2;i++){
1371 rectf[i].X = (REAL)rect[i].X;
1372 rectf[i].Y = (REAL)rect[i].Y;
1373 rectf[i].Height = (REAL)rect[i].Height;
1374 rectf[i].Width = (REAL)rect[i].Width;
1377 GdipCreateMatrix(&m);
1378 GdipCreateRegion(&region);
1379 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1380 GdipCreatePath(FillModeAlternate, &path);
1381 GdipCreateRegion(&clip);
1383 status = GdipCreateFromHDC(hdc, &graphics);
1384 expect(Ok, status);
1385 ok(graphics != NULL, "Expected graphics to be initialized\n");
1386 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1387 expect(Ok, status);
1389 /* NULL arguments */
1390 status = GdipGetDC(NULL, NULL);
1391 expect(InvalidParameter, status);
1392 status = GdipGetDC(graphics, NULL);
1393 expect(InvalidParameter, status);
1394 status = GdipGetDC(NULL, &retdc);
1395 expect(InvalidParameter, status);
1397 status = GdipReleaseDC(NULL, NULL);
1398 expect(InvalidParameter, status);
1399 status = GdipReleaseDC(graphics, NULL);
1400 expect(InvalidParameter, status);
1401 status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
1402 expect(InvalidParameter, status);
1404 /* Release without Get */
1405 status = GdipReleaseDC(graphics, hdc);
1406 expect(InvalidParameter, status);
1408 retdc = NULL;
1409 status = GdipGetDC(graphics, &retdc);
1410 expect(Ok, status);
1411 ok(retdc == hdc, "Invalid HDC returned\n");
1412 /* call it once more */
1413 status = GdipGetDC(graphics, &retdc);
1414 expect(ObjectBusy, status);
1416 /* try all Graphics calls here */
1417 status = Ok;
1418 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1419 expect(ObjectBusy, status); status = Ok;
1420 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
1421 expect(ObjectBusy, status); status = Ok;
1422 status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1423 expect(ObjectBusy, status); status = Ok;
1424 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
1425 expect(ObjectBusy, status); status = Ok;
1426 status = GdipDrawBeziers(graphics, pen, ptf, 5);
1427 expect(ObjectBusy, status); status = Ok;
1428 status = GdipDrawBeziersI(graphics, pen, pt, 5);
1429 expect(ObjectBusy, status); status = Ok;
1430 status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
1431 expect(ObjectBusy, status); status = Ok;
1432 status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
1433 expect(ObjectBusy, status); status = Ok;
1434 status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
1435 expect(ObjectBusy, status); status = Ok;
1436 status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
1437 expect(ObjectBusy, status); status = Ok;
1438 status = GdipDrawCurve(graphics, pen, ptf, 5);
1439 expect(ObjectBusy, status); status = Ok;
1440 status = GdipDrawCurveI(graphics, pen, pt, 5);
1441 expect(ObjectBusy, status); status = Ok;
1442 status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
1443 expect(ObjectBusy, status); status = Ok;
1444 status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
1445 expect(ObjectBusy, status); status = Ok;
1446 status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
1447 expect(ObjectBusy, status); status = Ok;
1448 status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
1449 expect(ObjectBusy, status); status = Ok;
1450 /* GdipDrawImage/GdipDrawImageI */
1451 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1452 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1453 /* GdipDrawImageRect/GdipDrawImageRectI */
1454 status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
1455 expect(ObjectBusy, status); status = Ok;
1456 status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
1457 expect(ObjectBusy, status); status = Ok;
1458 status = GdipDrawLines(graphics, pen, ptf, 5);
1459 expect(ObjectBusy, status); status = Ok;
1460 status = GdipDrawLinesI(graphics, pen, pt, 5);
1461 expect(ObjectBusy, status); status = Ok;
1462 status = GdipDrawPath(graphics, pen, path);
1463 expect(ObjectBusy, status); status = Ok;
1464 status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1465 expect(ObjectBusy, status); status = Ok;
1466 status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
1467 expect(ObjectBusy, status); status = Ok;
1468 status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
1469 expect(ObjectBusy, status); status = Ok;
1470 status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
1471 expect(ObjectBusy, status); status = Ok;
1472 status = GdipDrawRectangles(graphics, pen, rectf, 2);
1473 expect(ObjectBusy, status); status = Ok;
1474 status = GdipDrawRectanglesI(graphics, pen, rect, 2);
1475 expect(ObjectBusy, status); status = Ok;
1476 /* GdipDrawString */
1477 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0, FillModeAlternate);
1478 expect(ObjectBusy, status); status = Ok;
1479 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0, FillModeAlternate);
1480 expect(ObjectBusy, status); status = Ok;
1481 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, ptf, 5);
1482 expect(ObjectBusy, status); status = Ok;
1483 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, pt, 5);
1484 expect(ObjectBusy, status); status = Ok;
1485 status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1486 expect(ObjectBusy, status); status = Ok;
1487 status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1488 expect(ObjectBusy, status); status = Ok;
1489 status = GdipFillPath(graphics, (GpBrush*)brush, path);
1490 expect(ObjectBusy, status); status = Ok;
1491 status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1492 expect(ObjectBusy, status); status = Ok;
1493 status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
1494 expect(ObjectBusy, status); status = Ok;
1495 status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
1496 expect(ObjectBusy, status); status = Ok;
1497 status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
1498 expect(ObjectBusy, status); status = Ok;
1499 status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
1500 expect(ObjectBusy, status); status = Ok;
1501 status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
1502 expect(ObjectBusy, status); status = Ok;
1503 status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1504 expect(ObjectBusy, status); status = Ok;
1505 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1506 expect(ObjectBusy, status); status = Ok;
1507 status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
1508 expect(ObjectBusy, status); status = Ok;
1509 status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
1510 expect(ObjectBusy, status); status = Ok;
1511 status = GdipFillRegion(graphics, (GpBrush*)brush, region);
1512 expect(ObjectBusy, status); status = Ok;
1513 status = GdipFlush(graphics, FlushIntentionFlush);
1514 expect(ObjectBusy, status); status = Ok;
1515 status = GdipGetClipBounds(graphics, rectf);
1516 expect(ObjectBusy, status); status = Ok;
1517 status = GdipGetClipBoundsI(graphics, rect);
1518 expect(ObjectBusy, status); status = Ok;
1519 status = GdipGetCompositingMode(graphics, &compmode);
1520 expect(ObjectBusy, status); status = Ok;
1521 status = GdipGetCompositingQuality(graphics, &quality);
1522 expect(ObjectBusy, status); status = Ok;
1523 status = GdipGetInterpolationMode(graphics, &intmode);
1524 expect(ObjectBusy, status); status = Ok;
1525 status = GdipGetNearestColor(graphics, &color);
1526 expect(ObjectBusy, status); status = Ok;
1527 status = GdipGetPageScale(graphics, &r);
1528 expect(ObjectBusy, status); status = Ok;
1529 status = GdipGetPageUnit(graphics, &unit);
1530 expect(ObjectBusy, status); status = Ok;
1531 status = GdipGetPixelOffsetMode(graphics, &offsetmode);
1532 expect(ObjectBusy, status); status = Ok;
1533 status = GdipGetSmoothingMode(graphics, &smoothmode);
1534 expect(ObjectBusy, status); status = Ok;
1535 status = GdipGetTextRenderingHint(graphics, &texthint);
1536 expect(ObjectBusy, status); status = Ok;
1537 status = GdipGetWorldTransform(graphics, m);
1538 expect(ObjectBusy, status); status = Ok;
1539 status = GdipGraphicsClear(graphics, 0xdeadbeef);
1540 expect(ObjectBusy, status); status = Ok;
1541 status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
1542 expect(ObjectBusy, status); status = Ok;
1543 status = GdipIsVisiblePointI(graphics, 0, 0, &res);
1544 expect(ObjectBusy, status); status = Ok;
1545 /* GdipMeasureCharacterRanges */
1546 /* GdipMeasureString */
1547 status = GdipResetClip(graphics);
1548 expect(ObjectBusy, status); status = Ok;
1549 status = GdipResetWorldTransform(graphics);
1550 expect(ObjectBusy, status); status = Ok;
1551 /* GdipRestoreGraphics */
1552 status = GdipRotateWorldTransform(graphics, 15.0, MatrixOrderPrepend);
1553 expect(ObjectBusy, status); status = Ok;
1554 /* GdipSaveGraphics */
1555 status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
1556 expect(ObjectBusy, status); status = Ok;
1557 status = GdipSetCompositingMode(graphics, CompositingModeSourceOver);
1558 expect(ObjectBusy, status); status = Ok;
1559 status = GdipSetCompositingQuality(graphics, CompositingQualityDefault);
1560 expect(ObjectBusy, status); status = Ok;
1561 status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
1562 expect(ObjectBusy, status); status = Ok;
1563 status = GdipSetPageScale(graphics, 1.0);
1564 expect(ObjectBusy, status); status = Ok;
1565 status = GdipSetPageUnit(graphics, UnitWorld);
1566 expect(ObjectBusy, status); status = Ok;
1567 status = GdipSetPixelOffsetMode(graphics, PixelOffsetModeDefault);
1568 expect(ObjectBusy, status); status = Ok;
1569 status = GdipSetSmoothingMode(graphics, SmoothingModeDefault);
1570 expect(ObjectBusy, status); status = Ok;
1571 status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
1572 expect(ObjectBusy, status); status = Ok;
1573 status = GdipSetWorldTransform(graphics, m);
1574 expect(ObjectBusy, status); status = Ok;
1575 status = GdipTranslateWorldTransform(graphics, 0.0, 0.0, MatrixOrderPrepend);
1576 expect(ObjectBusy, status); status = Ok;
1577 status = GdipSetClipHrgn(graphics, hrgn, CombineModeReplace);
1578 expect(ObjectBusy, status); status = Ok;
1579 status = GdipSetClipPath(graphics, path, CombineModeReplace);
1580 expect(ObjectBusy, status); status = Ok;
1581 status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
1582 expect(ObjectBusy, status); status = Ok;
1583 status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
1584 expect(ObjectBusy, status); status = Ok;
1585 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1586 expect(ObjectBusy, status); status = Ok;
1587 status = GdipTranslateClip(graphics, 0.0, 0.0);
1588 expect(ObjectBusy, status); status = Ok;
1589 status = GdipTranslateClipI(graphics, 0, 0);
1590 expect(ObjectBusy, status); status = Ok;
1591 status = GdipDrawPolygon(graphics, pen, ptf, 5);
1592 expect(ObjectBusy, status); status = Ok;
1593 status = GdipDrawPolygonI(graphics, pen, pt, 5);
1594 expect(ObjectBusy, status); status = Ok;
1595 status = GdipGetDpiX(graphics, &r);
1596 expect(ObjectBusy, status); status = Ok;
1597 status = GdipGetDpiY(graphics, &r);
1598 expect(ObjectBusy, status); status = Ok;
1599 status = GdipMultiplyWorldTransform(graphics, m, MatrixOrderPrepend);
1600 status = GdipGetClip(graphics, region);
1601 expect(ObjectBusy, status); status = Ok;
1602 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
1603 expect(ObjectBusy, status); status = Ok;
1604 /* try to delete before release */
1605 status = GdipDeleteGraphics(graphics);
1606 expect(ObjectBusy, status);
1608 status = GdipReleaseDC(graphics, retdc);
1609 expect(Ok, status);
1611 GdipDeletePen(pen);
1612 GdipDeleteGraphics(graphics);
1614 GdipDeleteRegion(clip);
1615 GdipDeletePath(path);
1616 GdipDeleteBrush((GpBrush*)brush);
1617 GdipDeleteRegion(region);
1618 GdipDeleteMatrix(m);
1619 DeleteObject(hrgn);
1621 ReleaseDC(hwnd, hdc);
1624 static void test_transformpoints(void)
1626 GpStatus status;
1627 GpGraphics *graphics = NULL;
1628 HDC hdc = GetDC( hwnd );
1629 GpPointF ptf[2];
1630 GpPoint pt[2];
1632 status = GdipCreateFromHDC(hdc, &graphics);
1633 expect(Ok, status);
1635 /* NULL arguments */
1636 status = GdipTransformPoints(NULL, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
1637 expect(InvalidParameter, status);
1638 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
1639 expect(InvalidParameter, status);
1640 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 0);
1641 expect(InvalidParameter, status);
1642 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, -1);
1643 expect(InvalidParameter, status);
1645 ptf[0].X = 1.0;
1646 ptf[0].Y = 0.0;
1647 ptf[1].X = 0.0;
1648 ptf[1].Y = 1.0;
1649 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
1650 expect(Ok, status);
1651 expectf(1.0, ptf[0].X);
1652 expectf(0.0, ptf[0].Y);
1653 expectf(0.0, ptf[1].X);
1654 expectf(1.0, ptf[1].Y);
1656 status = GdipTranslateWorldTransform(graphics, 5.0, 5.0, MatrixOrderAppend);
1657 expect(Ok, status);
1658 status = GdipSetPageUnit(graphics, UnitPixel);
1659 expect(Ok, status);
1660 status = GdipSetPageScale(graphics, 3.0);
1661 expect(Ok, status);
1663 ptf[0].X = 1.0;
1664 ptf[0].Y = 0.0;
1665 ptf[1].X = 0.0;
1666 ptf[1].Y = 1.0;
1667 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
1668 expect(Ok, status);
1669 expectf(18.0, ptf[0].X);
1670 expectf(15.0, ptf[0].Y);
1671 expectf(15.0, ptf[1].X);
1672 expectf(18.0, ptf[1].Y);
1674 ptf[0].X = 1.0;
1675 ptf[0].Y = 0.0;
1676 ptf[1].X = 0.0;
1677 ptf[1].Y = 1.0;
1678 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 2);
1679 expect(Ok, status);
1680 expectf(6.0, ptf[0].X);
1681 expectf(5.0, ptf[0].Y);
1682 expectf(5.0, ptf[1].X);
1683 expectf(6.0, ptf[1].Y);
1685 ptf[0].X = 1.0;
1686 ptf[0].Y = 0.0;
1687 ptf[1].X = 0.0;
1688 ptf[1].Y = 1.0;
1689 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpacePage, ptf, 2);
1690 expect(Ok, status);
1691 expectf(3.0, ptf[0].X);
1692 expectf(0.0, ptf[0].Y);
1693 expectf(0.0, ptf[1].X);
1694 expectf(3.0, ptf[1].Y);
1696 ptf[0].X = 18.0;
1697 ptf[0].Y = 15.0;
1698 ptf[1].X = 15.0;
1699 ptf[1].Y = 18.0;
1700 status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, ptf, 2);
1701 expect(Ok, status);
1702 expectf(1.0, ptf[0].X);
1703 expectf(0.0, ptf[0].Y);
1704 expectf(0.0, ptf[1].X);
1705 expectf(1.0, ptf[1].Y);
1707 ptf[0].X = 6.0;
1708 ptf[0].Y = 5.0;
1709 ptf[1].X = 5.0;
1710 ptf[1].Y = 6.0;
1711 status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpacePage, ptf, 2);
1712 expect(Ok, status);
1713 expectf(1.0, ptf[0].X);
1714 expectf(0.0, ptf[0].Y);
1715 expectf(0.0, ptf[1].X);
1716 expectf(1.0, ptf[1].Y);
1718 ptf[0].X = 3.0;
1719 ptf[0].Y = 0.0;
1720 ptf[1].X = 0.0;
1721 ptf[1].Y = 3.0;
1722 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceDevice, ptf, 2);
1723 expect(Ok, status);
1724 expectf(1.0, ptf[0].X);
1725 expectf(0.0, ptf[0].Y);
1726 expectf(0.0, ptf[1].X);
1727 expectf(1.0, ptf[1].Y);
1729 pt[0].X = 1;
1730 pt[0].Y = 0;
1731 pt[1].X = 0;
1732 pt[1].Y = 1;
1733 status = GdipTransformPointsI(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, pt, 2);
1734 expect(Ok, status);
1735 expect(18, pt[0].X);
1736 expect(15, pt[0].Y);
1737 expect(15, pt[1].X);
1738 expect(18, pt[1].Y);
1740 GdipDeleteGraphics(graphics);
1741 ReleaseDC(hwnd, hdc);
1744 static void test_get_set_clip(void)
1746 GpStatus status;
1747 GpGraphics *graphics = NULL;
1748 HDC hdc = GetDC( hwnd );
1749 GpRegion *clip;
1750 GpRectF rect;
1751 BOOL res;
1753 status = GdipCreateFromHDC(hdc, &graphics);
1754 expect(Ok, status);
1756 rect.X = rect.Y = 0.0;
1757 rect.Height = rect.Width = 100.0;
1759 status = GdipCreateRegionRect(&rect, &clip);
1761 /* NULL arguments */
1762 status = GdipGetClip(NULL, NULL);
1763 expect(InvalidParameter, status);
1764 status = GdipGetClip(graphics, NULL);
1765 expect(InvalidParameter, status);
1766 status = GdipGetClip(NULL, clip);
1767 expect(InvalidParameter, status);
1769 status = GdipSetClipRegion(NULL, NULL, CombineModeReplace);
1770 expect(InvalidParameter, status);
1771 status = GdipSetClipRegion(graphics, NULL, CombineModeReplace);
1772 expect(InvalidParameter, status);
1774 status = GdipSetClipPath(NULL, NULL, CombineModeReplace);
1775 expect(InvalidParameter, status);
1776 status = GdipSetClipPath(graphics, NULL, CombineModeReplace);
1777 expect(InvalidParameter, status);
1779 res = FALSE;
1780 status = GdipGetClip(graphics, clip);
1781 expect(Ok, status);
1782 status = GdipIsInfiniteRegion(clip, graphics, &res);
1783 expect(Ok, status);
1784 expect(TRUE, res);
1786 /* remains infinite after reset */
1787 res = FALSE;
1788 status = GdipResetClip(graphics);
1789 expect(Ok, status);
1790 status = GdipGetClip(graphics, clip);
1791 expect(Ok, status);
1792 status = GdipIsInfiniteRegion(clip, graphics, &res);
1793 expect(Ok, status);
1794 expect(TRUE, res);
1796 /* set to empty and then reset to infinite */
1797 status = GdipSetEmpty(clip);
1798 expect(Ok, status);
1799 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1800 expect(Ok, status);
1802 status = GdipGetClip(graphics, clip);
1803 expect(Ok, status);
1804 res = FALSE;
1805 status = GdipIsEmptyRegion(clip, graphics, &res);
1806 expect(Ok, status);
1807 expect(TRUE, res);
1808 status = GdipResetClip(graphics);
1809 expect(Ok, status);
1810 status = GdipGetClip(graphics, clip);
1811 expect(Ok, status);
1812 res = FALSE;
1813 status = GdipIsInfiniteRegion(clip, graphics, &res);
1814 expect(Ok, status);
1815 expect(TRUE, res);
1817 GdipDeleteRegion(clip);
1819 GdipDeleteGraphics(graphics);
1820 ReleaseDC(hwnd, hdc);
1823 static void test_isempty(void)
1825 GpStatus status;
1826 GpGraphics *graphics = NULL;
1827 HDC hdc = GetDC( hwnd );
1828 GpRegion *clip;
1829 BOOL res;
1831 status = GdipCreateFromHDC(hdc, &graphics);
1832 expect(Ok, status);
1834 status = GdipCreateRegion(&clip);
1835 expect(Ok, status);
1837 /* NULL */
1838 status = GdipIsClipEmpty(NULL, NULL);
1839 expect(InvalidParameter, status);
1840 status = GdipIsClipEmpty(graphics, NULL);
1841 expect(InvalidParameter, status);
1842 status = GdipIsClipEmpty(NULL, &res);
1843 expect(InvalidParameter, status);
1845 /* default is infinite */
1846 res = TRUE;
1847 status = GdipIsClipEmpty(graphics, &res);
1848 expect(Ok, status);
1849 expect(FALSE, res);
1851 GdipDeleteRegion(clip);
1853 GdipDeleteGraphics(graphics);
1854 ReleaseDC(hwnd, hdc);
1857 static void test_clear(void)
1859 GpStatus status;
1861 status = GdipGraphicsClear(NULL, 0xdeadbeef);
1862 expect(InvalidParameter, status);
1865 static void test_textcontrast(void)
1867 GpStatus status;
1868 HDC hdc = GetDC( hwnd );
1869 GpGraphics *graphics;
1870 UINT contrast;
1872 status = GdipGetTextContrast(NULL, NULL);
1873 expect(InvalidParameter, status);
1875 status = GdipCreateFromHDC(hdc, &graphics);
1876 expect(Ok, status);
1878 status = GdipGetTextContrast(graphics, NULL);
1879 expect(InvalidParameter, status);
1880 status = GdipGetTextContrast(graphics, &contrast);
1881 expect(4, contrast);
1883 GdipDeleteGraphics(graphics);
1884 ReleaseDC(hwnd, hdc);
1887 static void test_GdipDrawString(void)
1889 GpStatus status;
1890 GpGraphics *graphics = NULL;
1891 GpFont *fnt = NULL;
1892 RectF rect;
1893 GpStringFormat *format;
1894 GpBrush *brush;
1895 LOGFONTA logfont;
1896 HDC hdc = GetDC( hwnd );
1897 static const WCHAR string[] = {'T','e','s','t',0};
1899 memset(&logfont,0,sizeof(logfont));
1900 strcpy(logfont.lfFaceName,"Arial");
1901 logfont.lfHeight = 12;
1902 logfont.lfCharSet = DEFAULT_CHARSET;
1904 status = GdipCreateFromHDC(hdc, &graphics);
1905 expect(Ok, status);
1907 status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
1908 if (status == FileNotFound)
1910 skip("Arial not installed.\n");
1911 return;
1913 expect(Ok, status);
1915 status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
1916 expect(Ok, status);
1918 status = GdipCreateStringFormat(0,0,&format);
1919 expect(Ok, status);
1921 rect.X = 0;
1922 rect.Y = 0;
1923 rect.Width = 0;
1924 rect.Height = 12;
1926 status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
1927 expect(Ok, status);
1929 GdipDeleteGraphics(graphics);
1930 GdipDeleteBrush(brush);
1931 GdipDeleteFont(fnt);
1932 GdipDeleteStringFormat(format);
1934 ReleaseDC(hwnd, hdc);
1937 static void test_GdipGetVisibleClipBounds_screen(void)
1939 GpStatus status;
1940 GpGraphics *graphics = NULL;
1941 HDC hdc = GetDC(0);
1942 GpRectF rectf, exp, clipr;
1943 GpRect recti;
1945 ok(hdc != NULL, "Expected HDC to be initialized\n");
1947 status = GdipCreateFromHDC(hdc, &graphics);
1948 expect(Ok, status);
1949 ok(graphics != NULL, "Expected graphics to be initialized\n");
1951 /* no clipping rect */
1952 exp.X = 0;
1953 exp.Y = 0;
1954 exp.Width = GetDeviceCaps(hdc, HORZRES);
1955 exp.Height = GetDeviceCaps(hdc, VERTRES);
1957 status = GdipGetVisibleClipBounds(graphics, &rectf);
1958 expect(Ok, status);
1959 ok(rectf.X == exp.X &&
1960 rectf.Y == exp.Y &&
1961 rectf.Width == exp.Width &&
1962 rectf.Height == exp.Height,
1963 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1964 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1965 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1966 exp.X, exp.Y, exp.Width, exp.Height);
1968 /* clipping rect entirely within window */
1969 exp.X = clipr.X = 10;
1970 exp.Y = clipr.Y = 12;
1971 exp.Width = clipr.Width = 14;
1972 exp.Height = clipr.Height = 16;
1974 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1975 expect(Ok, status);
1977 status = GdipGetVisibleClipBounds(graphics, &rectf);
1978 expect(Ok, status);
1979 ok(rectf.X == exp.X &&
1980 rectf.Y == exp.Y &&
1981 rectf.Width == exp.Width &&
1982 rectf.Height == exp.Height,
1983 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1984 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1985 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1986 exp.X, exp.Y, exp.Width, exp.Height);
1988 /* clipping rect partially outside of screen */
1989 clipr.X = -10;
1990 clipr.Y = -12;
1991 clipr.Width = 20;
1992 clipr.Height = 24;
1994 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1995 expect(Ok, status);
1997 exp.X = 0;
1998 exp.Y = 0;
1999 exp.Width = 10;
2000 exp.Height = 12;
2002 status = GdipGetVisibleClipBounds(graphics, &rectf);
2003 expect(Ok, status);
2004 ok(rectf.X == exp.X &&
2005 rectf.Y == exp.Y &&
2006 rectf.Width == exp.Width &&
2007 rectf.Height == exp.Height,
2008 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2009 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2010 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2011 exp.X, exp.Y, exp.Width, exp.Height);
2013 status = GdipGetVisibleClipBoundsI(graphics, &recti);
2014 expect(Ok, status);
2015 ok(recti.X == exp.X &&
2016 recti.Y == exp.Y &&
2017 recti.Width == exp.Width &&
2018 recti.Height == exp.Height,
2019 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2020 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2021 recti.X, recti.Y, recti.Width, recti.Height,
2022 exp.X, exp.Y, exp.Width, exp.Height);
2024 GdipDeleteGraphics(graphics);
2025 ReleaseDC(0, hdc);
2028 static void test_GdipGetVisibleClipBounds_window(void)
2030 GpStatus status;
2031 GpGraphics *graphics = NULL;
2032 GpRectF rectf, window, exp, clipr;
2033 GpRect recti;
2034 HDC hdc;
2035 PAINTSTRUCT ps;
2036 RECT wnd_rect;
2038 /* get client area size */
2039 ok(GetClientRect(hwnd, &wnd_rect), "GetClientRect should have succeeded\n");
2040 window.X = wnd_rect.left;
2041 window.Y = wnd_rect.top;
2042 window.Width = wnd_rect.right - wnd_rect.left;
2043 window.Height = wnd_rect.bottom - wnd_rect.top;
2045 hdc = BeginPaint(hwnd, &ps);
2047 status = GdipCreateFromHDC(hdc, &graphics);
2048 expect(Ok, status);
2049 ok(graphics != NULL, "Expected graphics to be initialized\n");
2051 status = GdipGetVisibleClipBounds(graphics, &rectf);
2052 expect(Ok, status);
2053 ok(rectf.X == window.X &&
2054 rectf.Y == window.Y &&
2055 rectf.Width == window.Width &&
2056 rectf.Height == window.Height,
2057 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2058 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2059 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2060 window.X, window.Y, window.Width, window.Height);
2062 /* clipping rect entirely within window */
2063 exp.X = clipr.X = 20;
2064 exp.Y = clipr.Y = 8;
2065 exp.Width = clipr.Width = 30;
2066 exp.Height = clipr.Height = 20;
2068 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2069 expect(Ok, status);
2071 status = GdipGetVisibleClipBounds(graphics, &rectf);
2072 expect(Ok, status);
2073 ok(rectf.X == exp.X &&
2074 rectf.Y == exp.Y &&
2075 rectf.Width == exp.Width &&
2076 rectf.Height == exp.Height,
2077 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2078 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2079 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2080 exp.X, exp.Y, exp.Width, exp.Height);
2082 /* clipping rect partially outside of window */
2083 clipr.X = window.Width - 10;
2084 clipr.Y = window.Height - 15;
2085 clipr.Width = 20;
2086 clipr.Height = 30;
2088 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2089 expect(Ok, status);
2091 exp.X = window.Width - 10;
2092 exp.Y = window.Height - 15;
2093 exp.Width = 10;
2094 exp.Height = 15;
2096 status = GdipGetVisibleClipBounds(graphics, &rectf);
2097 expect(Ok, status);
2098 ok(rectf.X == exp.X &&
2099 rectf.Y == exp.Y &&
2100 rectf.Width == exp.Width &&
2101 rectf.Height == exp.Height,
2102 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2103 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2104 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2105 exp.X, exp.Y, exp.Width, exp.Height);
2107 status = GdipGetVisibleClipBoundsI(graphics, &recti);
2108 expect(Ok, status);
2109 ok(recti.X == exp.X &&
2110 recti.Y == exp.Y &&
2111 recti.Width == exp.Width &&
2112 recti.Height == exp.Height,
2113 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2114 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2115 recti.X, recti.Y, recti.Width, recti.Height,
2116 exp.X, exp.Y, exp.Width, exp.Height);
2118 GdipDeleteGraphics(graphics);
2119 EndPaint(hwnd, &ps);
2122 static void test_GdipGetVisibleClipBounds(void)
2124 GpGraphics* graphics = NULL;
2125 GpRectF rectf;
2126 GpRect rect;
2127 HDC hdc = GetDC( hwnd );
2128 GpStatus status;
2130 status = GdipCreateFromHDC(hdc, &graphics);
2131 expect(Ok, status);
2132 ok(graphics != NULL, "Expected graphics to be initialized\n");
2134 /* test null parameters */
2135 status = GdipGetVisibleClipBounds(graphics, NULL);
2136 expect(InvalidParameter, status);
2138 status = GdipGetVisibleClipBounds(NULL, &rectf);
2139 expect(InvalidParameter, status);
2141 status = GdipGetVisibleClipBoundsI(graphics, NULL);
2142 expect(InvalidParameter, status);
2144 status = GdipGetVisibleClipBoundsI(NULL, &rect);
2145 expect(InvalidParameter, status);
2147 GdipDeleteGraphics(graphics);
2148 ReleaseDC(hwnd, hdc);
2150 test_GdipGetVisibleClipBounds_screen();
2151 test_GdipGetVisibleClipBounds_window();
2154 static void test_fromMemoryBitmap(void)
2156 GpStatus status;
2157 GpGraphics *graphics = NULL;
2158 GpBitmap *bitmap = NULL;
2159 BYTE bits[48] = {0};
2161 status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, bits, &bitmap);
2162 expect(Ok, status);
2164 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2165 expect(Ok, status);
2167 status = GdipGraphicsClear(graphics, 0xff686868);
2168 expect(Ok, status);
2170 GdipDeleteGraphics(graphics);
2172 /* drawing writes to the memory provided */
2173 todo_wine expect(0x68, bits[10]);
2175 GdipDisposeImage((GpImage*)bitmap);
2178 static void test_GdipIsVisiblePoint(void)
2180 GpStatus status;
2181 GpGraphics *graphics = NULL;
2182 HDC hdc = GetDC( hwnd );
2183 REAL x, y;
2184 BOOL val;
2186 ok(hdc != NULL, "Expected HDC to be initialized\n");
2188 status = GdipCreateFromHDC(hdc, &graphics);
2189 expect(Ok, status);
2190 ok(graphics != NULL, "Expected graphics to be initialized\n");
2192 /* null parameters */
2193 status = GdipIsVisiblePoint(NULL, 0, 0, &val);
2194 expect(InvalidParameter, status);
2196 status = GdipIsVisiblePoint(graphics, 0, 0, NULL);
2197 expect(InvalidParameter, status);
2199 status = GdipIsVisiblePointI(NULL, 0, 0, &val);
2200 expect(InvalidParameter, status);
2202 status = GdipIsVisiblePointI(graphics, 0, 0, NULL);
2203 expect(InvalidParameter, status);
2205 x = 0;
2206 y = 0;
2207 status = GdipIsVisiblePoint(graphics, x, y, &val);
2208 expect(Ok, status);
2209 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2211 x = -10;
2212 y = 0;
2213 status = GdipIsVisiblePoint(graphics, x, y, &val);
2214 expect(Ok, status);
2215 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2217 x = 0;
2218 y = -5;
2219 status = GdipIsVisiblePoint(graphics, x, y, &val);
2220 expect(Ok, status);
2221 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2223 x = 1;
2224 y = 1;
2225 status = GdipIsVisiblePoint(graphics, x, y, &val);
2226 expect(Ok, status);
2227 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2229 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2230 expect(Ok, status);
2232 x = 1;
2233 y = 1;
2234 status = GdipIsVisiblePoint(graphics, x, y, &val);
2235 expect(Ok, status);
2236 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2238 x = 15.5;
2239 y = 40.5;
2240 status = GdipIsVisiblePoint(graphics, x, y, &val);
2241 expect(Ok, status);
2242 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2244 /* translate into the center of the rect */
2245 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2247 x = 0;
2248 y = 0;
2249 status = GdipIsVisiblePoint(graphics, x, y, &val);
2250 expect(Ok, status);
2251 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2253 x = 25;
2254 y = 40;
2255 status = GdipIsVisiblePoint(graphics, x, y, &val);
2256 expect(Ok, status);
2257 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2259 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2261 /* corner cases */
2262 x = 9;
2263 y = 19;
2264 status = GdipIsVisiblePoint(graphics, x, y, &val);
2265 expect(Ok, status);
2266 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2268 x = 9.25;
2269 y = 19.25;
2270 status = GdipIsVisiblePoint(graphics, x, y, &val);
2271 expect(Ok, status);
2272 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2274 x = 9.5;
2275 y = 19.5;
2276 status = GdipIsVisiblePoint(graphics, x, y, &val);
2277 expect(Ok, status);
2278 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2280 x = 9.75;
2281 y = 19.75;
2282 status = GdipIsVisiblePoint(graphics, x, y, &val);
2283 expect(Ok, status);
2284 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2286 x = 10;
2287 y = 20;
2288 status = GdipIsVisiblePoint(graphics, x, y, &val);
2289 expect(Ok, status);
2290 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2292 x = 40;
2293 y = 20;
2294 status = GdipIsVisiblePoint(graphics, x, y, &val);
2295 expect(Ok, status);
2296 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2298 x = 39;
2299 y = 59;
2300 status = GdipIsVisiblePoint(graphics, x, y, &val);
2301 expect(Ok, status);
2302 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2304 x = 39.25;
2305 y = 59.25;
2306 status = GdipIsVisiblePoint(graphics, x, y, &val);
2307 expect(Ok, status);
2308 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2310 x = 39.5;
2311 y = 39.5;
2312 status = GdipIsVisiblePoint(graphics, x, y, &val);
2313 expect(Ok, status);
2314 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2316 x = 39.75;
2317 y = 59.75;
2318 status = GdipIsVisiblePoint(graphics, x, y, &val);
2319 expect(Ok, status);
2320 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2322 x = 40;
2323 y = 60;
2324 status = GdipIsVisiblePoint(graphics, x, y, &val);
2325 expect(Ok, status);
2326 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2328 x = 40.15;
2329 y = 60.15;
2330 status = GdipIsVisiblePoint(graphics, x, y, &val);
2331 expect(Ok, status);
2332 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2334 x = 10;
2335 y = 60;
2336 status = GdipIsVisiblePoint(graphics, x, y, &val);
2337 expect(Ok, status);
2338 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2340 /* integer version */
2341 x = 25;
2342 y = 30;
2343 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2344 expect(Ok, status);
2345 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2347 x = 50;
2348 y = 100;
2349 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2350 expect(Ok, status);
2351 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2353 GdipDeleteGraphics(graphics);
2354 ReleaseDC(hwnd, hdc);
2357 static void test_GdipIsVisibleRect(void)
2359 GpStatus status;
2360 GpGraphics *graphics = NULL;
2361 HDC hdc = GetDC( hwnd );
2362 REAL x, y, width, height;
2363 BOOL val;
2365 ok(hdc != NULL, "Expected HDC to be initialized\n");
2367 status = GdipCreateFromHDC(hdc, &graphics);
2368 expect(Ok, status);
2369 ok(graphics != NULL, "Expected graphics to be initialized\n");
2371 status = GdipIsVisibleRect(NULL, 0, 0, 0, 0, &val);
2372 expect(InvalidParameter, status);
2374 status = GdipIsVisibleRect(graphics, 0, 0, 0, 0, NULL);
2375 expect(InvalidParameter, status);
2377 status = GdipIsVisibleRectI(NULL, 0, 0, 0, 0, &val);
2378 expect(InvalidParameter, status);
2380 status = GdipIsVisibleRectI(graphics, 0, 0, 0, 0, NULL);
2381 expect(InvalidParameter, status);
2383 /* entirely within the visible region */
2384 x = 0; width = 10;
2385 y = 0; height = 10;
2386 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2387 expect(Ok, status);
2388 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2390 /* partially outside */
2391 x = -10; width = 20;
2392 y = -10; height = 20;
2393 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2394 expect(Ok, status);
2395 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2397 /* entirely outside */
2398 x = -10; width = 5;
2399 y = -10; height = 5;
2400 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2401 expect(Ok, status);
2402 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2404 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2405 expect(Ok, status);
2407 /* entirely within the visible region */
2408 x = 12; width = 10;
2409 y = 22; height = 10;
2410 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2411 expect(Ok, status);
2412 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2414 /* partially outside */
2415 x = 35; width = 10;
2416 y = 55; height = 10;
2417 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2418 expect(Ok, status);
2419 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2421 /* entirely outside */
2422 x = 45; width = 5;
2423 y = 65; height = 5;
2424 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2425 expect(Ok, status);
2426 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2428 /* translate into center of clipping rect */
2429 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2431 x = 0; width = 10;
2432 y = 0; height = 10;
2433 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2434 expect(Ok, status);
2435 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2437 x = 25; width = 5;
2438 y = 40; height = 5;
2439 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2440 expect(Ok, status);
2441 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2443 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2445 /* corners entirely outside, but some intersections */
2446 x = 0; width = 70;
2447 y = 0; height = 90;
2448 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2449 expect(Ok, status);
2450 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2452 x = 0; width = 70;
2453 y = 0; height = 30;
2454 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2455 expect(Ok, status);
2456 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2458 x = 0; width = 30;
2459 y = 0; height = 90;
2460 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2461 expect(Ok, status);
2462 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2464 /* edge cases */
2465 x = 0; width = 10;
2466 y = 20; height = 40;
2467 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2468 expect(Ok, status);
2469 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2471 x = 10; width = 30;
2472 y = 0; height = 20;
2473 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2474 expect(Ok, status);
2475 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2477 x = 40; width = 10;
2478 y = 20; height = 40;
2479 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2480 expect(Ok, status);
2481 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2483 x = 10; width = 30;
2484 y = 60; height = 10;
2485 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2486 expect(Ok, status);
2487 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2489 /* rounding tests */
2490 x = 0.4; width = 10.4;
2491 y = 20; height = 40;
2492 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2493 expect(Ok, status);
2494 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2496 x = 10; width = 30;
2497 y = 0.4; height = 20.4;
2498 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2499 expect(Ok, status);
2500 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2502 /* integer version */
2503 x = 0; width = 30;
2504 y = 0; height = 90;
2505 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
2506 expect(Ok, status);
2507 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2509 x = 12; width = 10;
2510 y = 22; height = 10;
2511 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
2512 expect(Ok, status);
2513 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2515 GdipDeleteGraphics(graphics);
2516 ReleaseDC(hwnd, hdc);
2519 static void test_GdipGetNearestColor(void)
2521 GpStatus status;
2522 GpGraphics *graphics;
2523 GpBitmap *bitmap;
2524 ARGB color = 0xdeadbeef;
2525 HDC hdc = GetDC( hwnd );
2527 /* create a graphics object */
2528 ok(hdc != NULL, "Expected HDC to be initialized\n");
2530 status = GdipCreateFromHDC(hdc, &graphics);
2531 expect(Ok, status);
2532 ok(graphics != NULL, "Expected graphics to be initialized\n");
2534 status = GdipGetNearestColor(graphics, NULL);
2535 expect(InvalidParameter, status);
2537 status = GdipGetNearestColor(NULL, &color);
2538 expect(InvalidParameter, status);
2539 GdipDeleteGraphics(graphics);
2541 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed, NULL, &bitmap);
2542 expect(Ok, status);
2543 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2544 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2545 if (status == Ok)
2547 status = GdipGetNearestColor(graphics, &color);
2548 expect(Ok, status);
2549 expect(0xdeadbeef, color);
2550 GdipDeleteGraphics(graphics);
2552 GdipDisposeImage((GpImage*)bitmap);
2554 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed, NULL, &bitmap);
2555 expect(Ok, status);
2556 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2557 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2558 if (status == Ok)
2560 status = GdipGetNearestColor(graphics, &color);
2561 expect(Ok, status);
2562 expect(0xdeadbeef, color);
2563 GdipDeleteGraphics(graphics);
2565 GdipDisposeImage((GpImage*)bitmap);
2567 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed, NULL, &bitmap);
2568 expect(Ok, status);
2569 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2570 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2571 if (status == Ok)
2573 status = GdipGetNearestColor(graphics, &color);
2574 expect(Ok, status);
2575 expect(0xdeadbeef, color);
2576 GdipDeleteGraphics(graphics);
2578 GdipDisposeImage((GpImage*)bitmap);
2580 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale, NULL, &bitmap);
2581 expect(Ok, status);
2582 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2583 todo_wine expect(OutOfMemory, status);
2584 if (status == Ok)
2585 GdipDeleteGraphics(graphics);
2586 GdipDisposeImage((GpImage*)bitmap);
2588 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bitmap);
2589 expect(Ok, status);
2590 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2591 expect(Ok, status);
2592 status = GdipGetNearestColor(graphics, &color);
2593 expect(Ok, status);
2594 expect(0xdeadbeef, color);
2595 GdipDeleteGraphics(graphics);
2596 GdipDisposeImage((GpImage*)bitmap);
2598 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB, NULL, &bitmap);
2599 expect(Ok, status);
2600 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2601 expect(Ok, status);
2602 status = GdipGetNearestColor(graphics, &color);
2603 expect(Ok, status);
2604 expect(0xdeadbeef, color);
2605 GdipDeleteGraphics(graphics);
2606 GdipDisposeImage((GpImage*)bitmap);
2608 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB, NULL, &bitmap);
2609 expect(Ok, status);
2610 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2611 expect(Ok, status);
2612 status = GdipGetNearestColor(graphics, &color);
2613 expect(Ok, status);
2614 expect(0xdeadbeef, color);
2615 GdipDeleteGraphics(graphics);
2616 GdipDisposeImage((GpImage*)bitmap);
2618 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap);
2619 todo_wine expect(Ok, status);
2620 if (status == Ok)
2622 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2623 expect(Ok, status);
2624 status = GdipGetNearestColor(graphics, &color);
2625 expect(Ok, status);
2626 expect(0xdeadbeef, color);
2627 GdipDeleteGraphics(graphics);
2628 GdipDisposeImage((GpImage*)bitmap);
2631 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap);
2632 todo_wine expect(Ok, status);
2633 if (status == Ok)
2635 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2636 expect(Ok, status);
2637 status = GdipGetNearestColor(graphics, &color);
2638 expect(Ok, status);
2639 expect(0xdeadbeef, color);
2640 GdipDeleteGraphics(graphics);
2641 GdipDisposeImage((GpImage*)bitmap);
2644 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap);
2645 todo_wine expect(Ok, status);
2646 if (status == Ok)
2648 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2649 expect(Ok, status);
2650 status = GdipGetNearestColor(graphics, &color);
2651 expect(Ok, status);
2652 expect(0xdeadbeef, color);
2653 GdipDeleteGraphics(graphics);
2654 GdipDisposeImage((GpImage*)bitmap);
2657 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap);
2658 expect(Ok, status);
2659 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2660 expect(Ok, status);
2661 status = GdipGetNearestColor(graphics, &color);
2662 expect(Ok, status);
2663 todo_wine expect(0xffa8bce8, color);
2664 GdipDeleteGraphics(graphics);
2665 GdipDisposeImage((GpImage*)bitmap);
2667 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555, NULL, &bitmap);
2668 expect(Ok, status);
2669 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2670 expect(Ok, status);
2671 status = GdipGetNearestColor(graphics, &color);
2672 expect(Ok, status);
2673 todo_wine
2674 ok(color == 0xffa8b8e8 ||
2675 broken(color == 0xffa0b8e0), /* Win98/WinMe */
2676 "Expected ffa8b8e8, got %.8x\n", color);
2677 GdipDeleteGraphics(graphics);
2678 GdipDisposeImage((GpImage*)bitmap);
2680 ReleaseDC(hwnd, hdc);
2683 static void test_string_functions(void)
2685 GpStatus status;
2686 GpGraphics *graphics;
2687 GpFontFamily *family;
2688 GpFont *font;
2689 RectF rc, char_bounds, bounds;
2690 GpBrush *brush;
2691 ARGB color = 0xff000000;
2692 HDC hdc = GetDC( hwnd );
2693 const WCHAR fontname[] = {'T','a','h','o','m','a',0};
2694 const WCHAR teststring[] = {'M','M',' ','M','\n','M',0};
2695 REAL char_width, char_height;
2696 INT codepointsfitted, linesfilled;
2697 GpStringFormat *format;
2698 CharacterRange ranges[3] = {{0, 1}, {1, 3}, {5, 1}};
2699 GpRegion *regions[4] = {0};
2700 BOOL region_isempty[4];
2701 int i;
2703 ok(hdc != NULL, "Expected HDC to be initialized\n");
2704 status = GdipCreateFromHDC(hdc, &graphics);
2705 expect(Ok, status);
2706 ok(graphics != NULL, "Expected graphics to be initialized\n");
2708 status = GdipCreateFontFamilyFromName(fontname, NULL, &family);
2709 expect(Ok, status);
2711 status = GdipCreateFont(family, 10.0, FontStyleRegular, UnitPixel, &font);
2712 expect(Ok, status);
2714 status = GdipCreateSolidFill(color, (GpSolidFill**)&brush);
2715 expect(Ok, status);
2717 status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
2718 expect(Ok, status);
2720 rc.X = 0;
2721 rc.Y = 0;
2722 rc.Width = 100.0;
2723 rc.Height = 100.0;
2725 status = GdipDrawString(NULL, teststring, 6, font, &rc, NULL, brush);
2726 expect(InvalidParameter, status);
2728 status = GdipDrawString(graphics, NULL, 6, font, &rc, NULL, brush);
2729 expect(InvalidParameter, status);
2731 status = GdipDrawString(graphics, teststring, 6, NULL, &rc, NULL, brush);
2732 expect(InvalidParameter, status);
2734 status = GdipDrawString(graphics, teststring, 6, font, NULL, NULL, brush);
2735 expect(InvalidParameter, status);
2737 status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, NULL);
2738 expect(InvalidParameter, status);
2740 status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, brush);
2741 expect(Ok, status);
2743 status = GdipMeasureString(NULL, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2744 expect(InvalidParameter, status);
2746 status = GdipMeasureString(graphics, NULL, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2747 expect(InvalidParameter, status);
2749 status = GdipMeasureString(graphics, teststring, 6, NULL, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2750 expect(InvalidParameter, status);
2752 status = GdipMeasureString(graphics, teststring, 6, font, NULL, NULL, &bounds, &codepointsfitted, &linesfilled);
2753 expect(InvalidParameter, status);
2755 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, NULL, &codepointsfitted, &linesfilled);
2756 expect(InvalidParameter, status);
2758 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, NULL, &linesfilled);
2759 expect(Ok, status);
2761 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, NULL);
2762 expect(Ok, status);
2764 status = GdipMeasureString(graphics, teststring, 1, font, &rc, NULL, &char_bounds, &codepointsfitted, &linesfilled);
2765 expect(Ok, status);
2766 expectf(0.0, char_bounds.X);
2767 expectf(0.0, char_bounds.Y);
2768 ok(char_bounds.Width > 0, "got %0.2f\n", bounds.Width);
2769 ok(char_bounds.Height > 0, "got %0.2f\n", bounds.Height);
2770 expect(1, codepointsfitted);
2771 expect(1, linesfilled);
2773 status = GdipMeasureString(graphics, teststring, 2, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2774 expect(Ok, status);
2775 expectf(0.0, bounds.X);
2776 expectf(0.0, bounds.Y);
2777 ok(bounds.Width > char_bounds.Width, "got %0.2f, expected at least %0.2f\n", bounds.Width, char_bounds.Width);
2778 expectf(char_bounds.Height, bounds.Height);
2779 expect(2, codepointsfitted);
2780 expect(1, linesfilled);
2781 char_width = bounds.Width - char_bounds.Width;
2783 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2784 expect(Ok, status);
2785 expectf(0.0, bounds.X);
2786 expectf(0.0, bounds.Y);
2787 ok(bounds.Width > char_bounds.Width + char_width * 2, "got %0.2f, expected at least %0.2f\n",
2788 bounds.Width, char_bounds.Width + char_width * 2);
2789 ok(bounds.Height > char_bounds.Height, "got %0.2f, expected at least %0.2f\n", bounds.Height, char_bounds.Height);
2790 expect(6, codepointsfitted);
2791 expect(2, linesfilled);
2792 char_height = bounds.Height - char_bounds.Height;
2794 /* Cut off everything after the first space. */
2795 rc.Width = char_bounds.Width + char_width * 2.1;
2797 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2798 expect(Ok, status);
2799 expectf(0.0, bounds.X);
2800 expectf(0.0, bounds.Y);
2801 expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
2802 expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
2803 expect(6, codepointsfitted);
2804 expect(3, linesfilled);
2806 /* Cut off everything including the first space. */
2807 rc.Width = char_bounds.Width + char_width * 1.5;
2809 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2810 expect(Ok, status);
2811 expectf(0.0, bounds.X);
2812 expectf(0.0, bounds.Y);
2813 expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
2814 expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
2815 expect(6, codepointsfitted);
2816 expect(3, linesfilled);
2818 /* Cut off everything after the first character. */
2819 rc.Width = char_bounds.Width + char_width * 0.5;
2821 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2822 expect(Ok, status);
2823 expectf(0.0, bounds.X);
2824 expectf(0.0, bounds.Y);
2825 expectf_(char_bounds.Width, bounds.Width, 0.01);
2826 todo_wine expectf_(char_bounds.Height + char_height * 3, bounds.Height, 0.05);
2827 expect(6, codepointsfitted);
2828 todo_wine expect(4, linesfilled);
2830 status = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges);
2831 expect(Ok, status);
2833 rc.Width = 100.0;
2835 for (i=0; i<4; i++)
2837 status = GdipCreateRegion(&regions[i]);
2838 expect(Ok, status);
2841 status = GdipMeasureCharacterRanges(NULL, teststring, 6, font, &rc, format, 3, regions);
2842 expect(InvalidParameter, status);
2844 status = GdipMeasureCharacterRanges(graphics, NULL, 6, font, &rc, format, 3, regions);
2845 expect(InvalidParameter, status);
2847 status = GdipMeasureCharacterRanges(graphics, teststring, 6, NULL, &rc, format, 3, regions);
2848 expect(InvalidParameter, status);
2850 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, NULL, format, 3, regions);
2851 expect(InvalidParameter, status);
2853 if (0)
2855 /* Crashes on Windows XP */
2856 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, NULL, 3, regions);
2857 expect(InvalidParameter, status);
2860 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, NULL);
2861 expect(InvalidParameter, status);
2863 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 2, regions);
2864 expect(InvalidParameter, status);
2866 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 4, regions);
2867 expect(Ok, status);
2869 for (i=0; i<4; i++)
2871 status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
2872 expect(Ok, status);
2875 ok(!region_isempty[0], "region shouldn't be empty\n");
2876 ok(!region_isempty[1], "region shouldn't be empty\n");
2877 ok(!region_isempty[2], "region shouldn't be empty\n");
2878 ok(!region_isempty[3], "region shouldn't be empty\n");
2880 /* Cut off everything after the first space, and the second line. */
2881 rc.Width = char_bounds.Width + char_width * 2.1;
2882 rc.Height = char_bounds.Height + char_height * 0.5;
2884 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
2885 expect(Ok, status);
2887 for (i=0; i<4; i++)
2889 status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
2890 expect(Ok, status);
2893 ok(!region_isempty[0], "region shouldn't be empty\n");
2894 ok(!region_isempty[1], "region shouldn't be empty\n");
2895 ok(region_isempty[2], "region should be empty\n");
2896 ok(!region_isempty[3], "region shouldn't be empty\n");
2898 for (i=0; i<4; i++)
2899 GdipDeleteRegion(regions[i]);
2901 GdipDeleteStringFormat(format);
2902 GdipDeleteBrush(brush);
2903 GdipDeleteFont(font);
2904 GdipDeleteFontFamily(family);
2905 GdipDeleteGraphics(graphics);
2907 ReleaseDC(hwnd, hdc);
2910 START_TEST(graphics)
2912 struct GdiplusStartupInput gdiplusStartupInput;
2913 ULONG_PTR gdiplusToken;
2914 WNDCLASSA class;
2916 memset( &class, 0, sizeof(class) );
2917 class.lpszClassName = "gdiplus_test";
2918 class.style = CS_HREDRAW | CS_VREDRAW;
2919 class.lpfnWndProc = DefWindowProcA;
2920 class.hInstance = GetModuleHandleA(0);
2921 class.hIcon = LoadIcon(0, IDI_APPLICATION);
2922 class.hCursor = LoadCursor(NULL, IDC_ARROW);
2923 class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2924 RegisterClassA( &class );
2925 hwnd = CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
2926 CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
2927 ok(hwnd != NULL, "Expected window to be created\n");
2929 gdiplusStartupInput.GdiplusVersion = 1;
2930 gdiplusStartupInput.DebugEventCallback = NULL;
2931 gdiplusStartupInput.SuppressBackgroundThread = 0;
2932 gdiplusStartupInput.SuppressExternalCodecs = 0;
2934 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2936 test_constructor_destructor();
2937 test_save_restore();
2938 test_GdipFillClosedCurve2();
2939 test_GdipFillClosedCurve2I();
2940 test_GdipDrawBezierI();
2941 test_GdipDrawArc();
2942 test_GdipDrawArcI();
2943 test_GdipDrawCurve();
2944 test_GdipDrawCurveI();
2945 test_GdipDrawCurve2();
2946 test_GdipDrawCurve2I();
2947 test_GdipDrawCurve3();
2948 test_GdipDrawCurve3I();
2949 test_GdipDrawLineI();
2950 test_GdipDrawLinesI();
2951 test_GdipFillClosedCurve();
2952 test_GdipFillClosedCurveI();
2953 test_GdipDrawString();
2954 test_GdipGetNearestColor();
2955 test_GdipGetVisibleClipBounds();
2956 test_GdipIsVisiblePoint();
2957 test_GdipIsVisibleRect();
2958 test_Get_Release_DC();
2959 test_BeginContainer2();
2960 test_transformpoints();
2961 test_get_set_clip();
2962 test_isempty();
2963 test_clear();
2964 test_textcontrast();
2965 test_fromMemoryBitmap();
2966 test_string_functions();
2968 GdiplusShutdown(gdiplusToken);
2969 DestroyWindow( hwnd );