[gdiplus_winetest]
[reactos.git] / rostests / winetests / gdiplus / graphics.c
1 /*
2 * Unit test suite for graphics objects
3 *
4 * Copyright (C) 2007 Google (Evan Stade)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "windows.h"
22 #include "gdiplus.h"
23 #include "wingdi.h"
24 #include "wine/test.h"
25 #include <math.h>
26
27 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
28 #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
29 #define TABLE_LEN (23)
30
31 static void test_constructor_destructor(void)
32 {
33 GpStatus stat;
34 GpGraphics *graphics = NULL;
35 HDC hdc = GetDC(0);
36
37 stat = GdipCreateFromHDC(NULL, &graphics);
38 expect(OutOfMemory, stat);
39 stat = GdipDeleteGraphics(graphics);
40 expect(InvalidParameter, stat);
41
42 stat = GdipCreateFromHDC(hdc, &graphics);
43 expect(Ok, stat);
44 stat = GdipDeleteGraphics(graphics);
45 expect(Ok, stat);
46
47 stat = GdipCreateFromHWND(NULL, &graphics);
48 expect(Ok, stat);
49 stat = GdipDeleteGraphics(graphics);
50 expect(Ok, stat);
51
52 stat = GdipCreateFromHWNDICM(NULL, &graphics);
53 expect(Ok, stat);
54 stat = GdipDeleteGraphics(graphics);
55 expect(Ok, stat);
56
57 stat = GdipDeleteGraphics(NULL);
58 expect(InvalidParameter, stat);
59 ReleaseDC(0, hdc);
60 }
61
62 typedef struct node{
63 GraphicsState data;
64 struct node * next;
65 } node;
66
67 /* Linked list prepend function. */
68 static void log_state(GraphicsState data, node ** log)
69 {
70 node * new_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(node));
71
72 new_entry->data = data;
73 new_entry->next = *log;
74 *log = new_entry;
75 }
76
77 /* Checks if there are duplicates in the list, and frees it. */
78 static void check_no_duplicates(node * log)
79 {
80 INT dups = 0;
81 node * temp = NULL;
82 node * temp2 = NULL;
83 node * orig = log;
84
85 if(!log)
86 goto end;
87
88 do{
89 temp = log;
90 while((temp = temp->next)){
91 if(log->data == temp->data){
92 dups++;
93 break;
94 }
95 if(dups > 0)
96 break;
97 }
98 }while((log = log->next));
99
100 temp = orig;
101 do{
102 temp2 = temp->next;
103 HeapFree(GetProcessHeap(), 0, temp);
104 temp = temp2;
105 }while(temp);
106
107 end:
108 expect(0, dups);
109 }
110
111 static void test_save_restore(void)
112 {
113 GpStatus stat;
114 GraphicsState state_a, state_b, state_c;
115 InterpolationMode mode;
116 GpGraphics *graphics1, *graphics2;
117 node * state_log = NULL;
118 HDC hdc = GetDC(0);
119 state_a = state_b = state_c = 0xdeadbeef;
120
121 /* Invalid saving. */
122 GdipCreateFromHDC(hdc, &graphics1);
123 stat = GdipSaveGraphics(graphics1, NULL);
124 expect(InvalidParameter, stat);
125 stat = GdipSaveGraphics(NULL, &state_a);
126 expect(InvalidParameter, stat);
127 GdipDeleteGraphics(graphics1);
128
129 log_state(state_a, &state_log);
130
131 /* Basic save/restore. */
132 GdipCreateFromHDC(hdc, &graphics1);
133 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
134 stat = GdipSaveGraphics(graphics1, &state_a);
135 expect(Ok, stat);
136 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
137 stat = GdipRestoreGraphics(graphics1, state_a);
138 expect(Ok, stat);
139 GdipGetInterpolationMode(graphics1, &mode);
140 expect(InterpolationModeBilinear, mode);
141 GdipDeleteGraphics(graphics1);
142
143 log_state(state_a, &state_log);
144
145 /* Restoring garbage doesn't affect saves. */
146 GdipCreateFromHDC(hdc, &graphics1);
147 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
148 GdipSaveGraphics(graphics1, &state_a);
149 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
150 GdipSaveGraphics(graphics1, &state_b);
151 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
152 stat = GdipRestoreGraphics(graphics1, 0xdeadbeef);
153 expect(Ok, stat);
154 GdipRestoreGraphics(graphics1, state_b);
155 GdipGetInterpolationMode(graphics1, &mode);
156 expect(InterpolationModeBicubic, mode);
157 GdipRestoreGraphics(graphics1, state_a);
158 GdipGetInterpolationMode(graphics1, &mode);
159 expect(InterpolationModeBilinear, mode);
160 GdipDeleteGraphics(graphics1);
161
162 log_state(state_a, &state_log);
163 log_state(state_b, &state_log);
164
165 /* Restoring older state invalidates newer saves (but not older saves). */
166 GdipCreateFromHDC(hdc, &graphics1);
167 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
168 GdipSaveGraphics(graphics1, &state_a);
169 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
170 GdipSaveGraphics(graphics1, &state_b);
171 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
172 GdipSaveGraphics(graphics1, &state_c);
173 GdipSetInterpolationMode(graphics1, InterpolationModeHighQualityBilinear);
174 GdipRestoreGraphics(graphics1, state_b);
175 GdipGetInterpolationMode(graphics1, &mode);
176 expect(InterpolationModeBicubic, mode);
177 GdipRestoreGraphics(graphics1, state_c);
178 GdipGetInterpolationMode(graphics1, &mode);
179 expect(InterpolationModeBicubic, mode);
180 GdipRestoreGraphics(graphics1, state_a);
181 GdipGetInterpolationMode(graphics1, &mode);
182 expect(InterpolationModeBilinear, mode);
183 GdipDeleteGraphics(graphics1);
184
185 log_state(state_a, &state_log);
186 log_state(state_b, &state_log);
187 log_state(state_c, &state_log);
188
189 /* Restoring older save from one graphics object does not invalidate
190 * newer save from other graphics object. */
191 GdipCreateFromHDC(hdc, &graphics1);
192 GdipCreateFromHDC(hdc, &graphics2);
193 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
194 GdipSaveGraphics(graphics1, &state_a);
195 GdipSetInterpolationMode(graphics2, InterpolationModeBicubic);
196 GdipSaveGraphics(graphics2, &state_b);
197 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
198 GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
199 GdipRestoreGraphics(graphics1, state_a);
200 GdipGetInterpolationMode(graphics1, &mode);
201 expect(InterpolationModeBilinear, mode);
202 GdipRestoreGraphics(graphics2, state_b);
203 GdipGetInterpolationMode(graphics2, &mode);
204 expect(InterpolationModeBicubic, mode);
205 GdipDeleteGraphics(graphics1);
206 GdipDeleteGraphics(graphics2);
207
208 /* You can't restore a state to a graphics object that didn't save it. */
209 GdipCreateFromHDC(hdc, &graphics1);
210 GdipCreateFromHDC(hdc, &graphics2);
211 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
212 GdipSaveGraphics(graphics1, &state_a);
213 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
214 GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
215 GdipRestoreGraphics(graphics2, state_a);
216 GdipGetInterpolationMode(graphics2, &mode);
217 expect(InterpolationModeNearestNeighbor, mode);
218 GdipDeleteGraphics(graphics1);
219 GdipDeleteGraphics(graphics2);
220
221 log_state(state_a, &state_log);
222
223 /* The same state value should never be returned twice. */
224 todo_wine
225 check_no_duplicates(state_log);
226
227 ReleaseDC(0, hdc);
228 }
229
230 static void test_GdipDrawArc(void)
231 {
232 GpStatus status;
233 GpGraphics *graphics = NULL;
234 GpPen *pen = NULL;
235 HDC hdc = GetDC(0);
236
237 /* make a graphics object and pen object */
238 ok(hdc != NULL, "Expected HDC to be initialized\n");
239
240 status = GdipCreateFromHDC(hdc, &graphics);
241 expect(Ok, status);
242 ok(graphics != NULL, "Expected graphics to be initialized\n");
243
244 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
245 expect(Ok, status);
246 ok(pen != NULL, "Expected pen to be initialized\n");
247
248 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
249 status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
250 expect(InvalidParameter, status);
251
252 status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
253 expect(InvalidParameter, status);
254
255 status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
256 expect(InvalidParameter, status);
257
258 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
259 expect(InvalidParameter, status);
260
261 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
262 expect(InvalidParameter, status);
263
264 /* successful case */
265 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
266 expect(Ok, status);
267
268 GdipDeletePen(pen);
269 GdipDeleteGraphics(graphics);
270
271 ReleaseDC(0, hdc);
272 }
273
274 static void test_GdipDrawArcI(void)
275 {
276 GpStatus status;
277 GpGraphics *graphics = NULL;
278 GpPen *pen = NULL;
279 HDC hdc = GetDC(0);
280
281 /* make a graphics object and pen object */
282 ok(hdc != NULL, "Expected HDC to be initialized\n");
283
284 status = GdipCreateFromHDC(hdc, &graphics);
285 expect(Ok, status);
286 ok(graphics != NULL, "Expected graphics to be initialized\n");
287
288 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
289 expect(Ok, status);
290 ok(pen != NULL, "Expected pen to be initialized\n");
291
292 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
293 status = GdipDrawArcI(NULL, NULL, 0, 0, 0, 0, 0, 0);
294 expect(InvalidParameter, status);
295
296 status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
297 expect(InvalidParameter, status);
298
299 status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
300 expect(InvalidParameter, status);
301
302 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
303 expect(InvalidParameter, status);
304
305 status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
306 expect(InvalidParameter, status);
307
308 /* successful case */
309 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
310 expect(Ok, status);
311
312 GdipDeletePen(pen);
313 GdipDeleteGraphics(graphics);
314
315 ReleaseDC(0, hdc);
316 }
317
318 static void test_BeginContainer2(void)
319 {
320 GpMatrix *transform;
321 GpRectF clip;
322 REAL defClip[] = {5, 10, 15, 20};
323 REAL elems[6], defTrans[] = {1, 2, 3, 4, 5, 6};
324 GraphicsContainer cont1, cont2, cont3, cont4;
325 CompositingQuality compqual, defCompqual = CompositingQualityHighSpeed;
326 CompositingMode compmode, defCompmode = CompositingModeSourceOver;
327 InterpolationMode interp, defInterp = InterpolationModeHighQualityBicubic;
328 REAL scale, defScale = 17;
329 GpUnit unit, defUnit = UnitPixel;
330 PixelOffsetMode offsetmode, defOffsetmode = PixelOffsetModeHighSpeed;
331 SmoothingMode smoothmode, defSmoothmode = SmoothingModeAntiAlias;
332 UINT contrast, defContrast = 5;
333 TextRenderingHint texthint, defTexthint = TextRenderingHintAntiAlias;
334
335 GpStatus status;
336 GpGraphics *graphics = NULL;
337 HDC hdc = GetDC(0);
338
339 ok(hdc != NULL, "Expected HDC to be initialized\n");
340
341 status = GdipCreateFromHDC(hdc, &graphics);
342 expect(Ok, status);
343 ok(graphics != NULL, "Expected graphics to be initialized\n");
344
345 /* null graphics, null container */
346 status = GdipBeginContainer2(NULL, &cont1);
347 expect(InvalidParameter, status);
348
349 status = GdipBeginContainer2(graphics, NULL);
350 expect(InvalidParameter, status);
351
352 status = GdipEndContainer(NULL, cont1);
353 expect(InvalidParameter, status);
354
355 /* test all quality-related values */
356 GdipSetCompositingMode(graphics, defCompmode);
357 GdipSetCompositingQuality(graphics, defCompqual);
358 GdipSetInterpolationMode(graphics, defInterp);
359 GdipSetPageScale(graphics, defScale);
360 GdipSetPageUnit(graphics, defUnit);
361 GdipSetPixelOffsetMode(graphics, defOffsetmode);
362 GdipSetSmoothingMode(graphics, defSmoothmode);
363 GdipSetTextContrast(graphics, defContrast);
364 GdipSetTextRenderingHint(graphics, defTexthint);
365
366 status = GdipBeginContainer2(graphics, &cont1);
367 expect(Ok, status);
368
369 GdipSetCompositingMode(graphics, CompositingModeSourceCopy);
370 GdipSetCompositingQuality(graphics, CompositingQualityHighQuality);
371 GdipSetInterpolationMode(graphics, InterpolationModeBilinear);
372 GdipSetPageScale(graphics, 10);
373 GdipSetPageUnit(graphics, UnitDocument);
374 GdipSetPixelOffsetMode(graphics, PixelOffsetModeHalf);
375 GdipSetSmoothingMode(graphics, SmoothingModeNone);
376 GdipSetTextContrast(graphics, 7);
377 GdipSetTextRenderingHint(graphics, TextRenderingHintClearTypeGridFit);
378
379 status = GdipEndContainer(graphics, cont1);
380 expect(Ok, status);
381
382 GdipGetCompositingMode(graphics, &compmode);
383 ok(defCompmode == compmode, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode, compmode);
384
385 GdipGetCompositingQuality(graphics, &compqual);
386 ok(defCompqual == compqual, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual, compqual);
387
388 GdipGetInterpolationMode(graphics, &interp);
389 ok(defInterp == interp, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp, interp);
390
391 GdipGetPageScale(graphics, &scale);
392 ok(fabs(defScale - scale) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale, scale);
393
394 GdipGetPageUnit(graphics, &unit);
395 ok(defUnit == unit, "Expected Page Unit to be restored to %d, got %d\n", defUnit, unit);
396
397 GdipGetPixelOffsetMode(graphics, &offsetmode);
398 ok(defOffsetmode == offsetmode, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode, offsetmode);
399
400 GdipGetSmoothingMode(graphics, &smoothmode);
401 ok(defSmoothmode == smoothmode, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode, smoothmode);
402
403 GdipGetTextContrast(graphics, &contrast);
404 ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
405
406 GdipGetTextRenderingHint(graphics, &texthint);
407 ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
408
409 /* test world transform */
410 status = GdipBeginContainer2(graphics, &cont1);
411 expect(Ok, status);
412
413 GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
414 defTrans[4], defTrans[5], &transform);
415 GdipSetWorldTransform(graphics, transform);
416 GdipDeleteMatrix(transform);
417 transform = NULL;
418
419 status = GdipBeginContainer2(graphics, &cont2);
420 expect(Ok, status);
421
422 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
423 GdipSetWorldTransform(graphics, transform);
424 GdipDeleteMatrix(transform);
425 transform = NULL;
426
427 status = GdipEndContainer(graphics, cont2);
428 expect(Ok, status);
429
430 GdipCreateMatrix(&transform);
431 GdipGetWorldTransform(graphics, transform);
432 GdipGetMatrixElements(transform, elems);
433 ok(fabs(defTrans[0] - elems[0]) < 0.0001 &&
434 fabs(defTrans[1] - elems[1]) < 0.0001 &&
435 fabs(defTrans[2] - elems[2]) < 0.0001 &&
436 fabs(defTrans[3] - elems[3]) < 0.0001 &&
437 fabs(defTrans[4] - elems[4]) < 0.0001 &&
438 fabs(defTrans[5] - elems[5]) < 0.0001,
439 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
440 defTrans[0], defTrans[1], defTrans[2], defTrans[3], defTrans[4], defTrans[5],
441 elems[0], elems[1], elems[2], elems[3], elems[4], elems[5]);
442 GdipDeleteMatrix(transform);
443 transform = NULL;
444
445 status = GdipEndContainer(graphics, cont1);
446 expect(Ok, status);
447
448 /* test clipping */
449 status = GdipBeginContainer2(graphics, &cont1);
450 expect(Ok, status);
451
452 GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace);
453
454 status = GdipBeginContainer2(graphics, &cont2);
455 expect(Ok, status);
456
457 GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
458
459 status = GdipEndContainer(graphics, cont2);
460
461 GdipGetClipBounds(graphics, &clip);
462 ok(fabs(defClip[0] - clip.X) < 0.0001 &&
463 fabs(defClip[1] - clip.Y) < 0.0001 &&
464 fabs(defClip[2] - clip.Width) < 0.0001 &&
465 fabs(defClip[3] - clip.Height) < 0.0001,
466 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
467 defClip[0], defClip[1], defClip[2], defClip[3],
468 clip.X, clip.Y, clip.Width, clip.Height);
469
470 status = GdipEndContainer(graphics, cont1);
471
472 /* nesting */
473 status = GdipBeginContainer2(graphics, &cont1);
474 expect(Ok, status);
475
476 status = GdipBeginContainer2(graphics, &cont2);
477 expect(Ok, status);
478
479 status = GdipBeginContainer2(graphics, &cont3);
480 expect(Ok, status);
481
482 status = GdipEndContainer(graphics, cont3);
483 expect(Ok, status);
484
485 status = GdipBeginContainer2(graphics, &cont4);
486 expect(Ok, status);
487
488 status = GdipEndContainer(graphics, cont4);
489 expect(Ok, status);
490
491 /* skip cont2 */
492 status = GdipEndContainer(graphics, cont1);
493 expect(Ok, status);
494
495 /* end an already-ended container */
496 status = GdipEndContainer(graphics, cont1);
497 expect(Ok, status);
498
499 GdipDeleteGraphics(graphics);
500 ReleaseDC(0, hdc);
501 }
502
503 static void test_GdipDrawBezierI(void)
504 {
505 GpStatus status;
506 GpGraphics *graphics = NULL;
507 GpPen *pen = NULL;
508 HDC hdc = GetDC(0);
509
510 /* make a graphics object and pen object */
511 ok(hdc != NULL, "Expected HDC to be initialized\n");
512
513 status = GdipCreateFromHDC(hdc, &graphics);
514 expect(Ok, status);
515 ok(graphics != NULL, "Expected graphics to be initialized\n");
516
517 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
518 expect(Ok, status);
519 ok(pen != NULL, "Expected pen to be initialized\n");
520
521 /* InvalidParameter cases: null graphics, null pen */
522 status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
523 expect(InvalidParameter, status);
524
525 status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
526 expect(InvalidParameter, status);
527
528 status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
529 expect(InvalidParameter, status);
530
531 /* successful case */
532 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
533 expect(Ok, status);
534
535 GdipDeletePen(pen);
536 GdipDeleteGraphics(graphics);
537
538 ReleaseDC(0, hdc);
539 }
540
541 static void test_GdipDrawCurve3(void)
542 {
543 GpStatus status;
544 GpGraphics *graphics = NULL;
545 GpPen *pen = NULL;
546 HDC hdc = GetDC(0);
547 GpPointF points[3];
548
549 points[0].X = 0;
550 points[0].Y = 0;
551
552 points[1].X = 40;
553 points[1].Y = 20;
554
555 points[2].X = 10;
556 points[2].Y = 40;
557
558 /* make a graphics object and pen object */
559 ok(hdc != NULL, "Expected HDC to be initialized\n");
560
561 status = GdipCreateFromHDC(hdc, &graphics);
562 expect(Ok, status);
563 ok(graphics != NULL, "Expected graphics to be initialized\n");
564
565 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
566 expect(Ok, status);
567 ok(pen != NULL, "Expected pen to be initialized\n");
568
569 /* InvalidParameter cases: null graphics, null pen */
570 status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1);
571 expect(InvalidParameter, status);
572
573 status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1);
574 expect(InvalidParameter, status);
575
576 status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1);
577 expect(InvalidParameter, status);
578
579 /* InvalidParameter cases: invalid count */
580 status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1);
581 expect(InvalidParameter, status);
582
583 status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1);
584 expect(InvalidParameter, status);
585
586 status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1);
587 expect(InvalidParameter, status);
588
589 status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1);
590 expect(InvalidParameter, status);
591
592 /* InvalidParameter cases: invalid number of segments */
593 status = GdipDrawCurve3(graphics, pen, points, 3, 0, -1, 1);
594 expect(InvalidParameter, status);
595
596 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 2, 1);
597 expect(InvalidParameter, status);
598
599 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 2, 1);
600 expect(InvalidParameter, status);
601
602 /* Valid test cases */
603 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, 1);
604 expect(Ok, status);
605
606 status = GdipDrawCurve3(graphics, pen, points, 3, 0, 2, 2);
607 expect(Ok, status);
608
609 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, -2);
610 expect(Ok, status);
611
612 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 1, 0);
613 expect(Ok, status);
614
615 GdipDeletePen(pen);
616 GdipDeleteGraphics(graphics);
617
618 ReleaseDC(0, hdc);
619 }
620
621 static void test_GdipDrawCurve3I(void)
622 {
623 GpStatus status;
624 GpGraphics *graphics = NULL;
625 GpPen *pen = NULL;
626 HDC hdc = GetDC(0);
627 GpPoint points[3];
628
629 points[0].X = 0;
630 points[0].Y = 0;
631
632 points[1].X = 40;
633 points[1].Y = 20;
634
635 points[2].X = 10;
636 points[2].Y = 40;
637
638 /* make a graphics object and pen object */
639 ok(hdc != NULL, "Expected HDC to be initialized\n");
640
641 status = GdipCreateFromHDC(hdc, &graphics);
642 expect(Ok, status);
643 ok(graphics != NULL, "Expected graphics to be initialized\n");
644
645 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
646 expect(Ok, status);
647 ok(pen != NULL, "Expected pen to be initialized\n");
648
649 /* InvalidParameter cases: null graphics, null pen */
650 status = GdipDrawCurve3I(NULL, NULL, points, 3, 0, 2, 1);
651 expect(InvalidParameter, status);
652
653 status = GdipDrawCurve3I(graphics, NULL, points, 3, 0, 2, 1);
654 expect(InvalidParameter, status);
655
656 status = GdipDrawCurve3I(NULL, pen, points, 3, 0, 2, 1);
657 expect(InvalidParameter, status);
658
659 /* InvalidParameter cases: invalid count */
660 status = GdipDrawCurve3I(graphics, pen, points, -1, -1, -1, 1);
661 expect(OutOfMemory, status);
662
663 status = GdipDrawCurve3I(graphics, pen, points, 0, 0, 2, 1);
664 expect(InvalidParameter, status);
665
666 status = GdipDrawCurve3I(graphics, pen, points, 1, 0, 0, 1);
667 expect(InvalidParameter, status);
668
669 status = GdipDrawCurve3I(graphics, pen, points, 3, 4, 2, 1);
670 expect(InvalidParameter, status);
671
672 /* InvalidParameter cases: invalid number of segments */
673 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, -1, 1);
674 expect(InvalidParameter, status);
675
676 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 2, 1);
677 expect(InvalidParameter, status);
678
679 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 2, 1);
680 expect(InvalidParameter, status);
681
682 /* Valid test cases */
683 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, 1);
684 expect(Ok, status);
685
686 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, 2, 2);
687 expect(Ok, status);
688
689 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, -2);
690 expect(Ok, status);
691
692 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 1, 0);
693 expect(Ok, status);
694
695 GdipDeletePen(pen);
696 GdipDeleteGraphics(graphics);
697
698 ReleaseDC(0, hdc);
699 }
700
701 static void test_GdipDrawCurve2(void)
702 {
703 GpStatus status;
704 GpGraphics *graphics = NULL;
705 GpPen *pen = NULL;
706 HDC hdc = GetDC(0);
707 GpPointF points[3];
708
709 points[0].X = 0;
710 points[0].Y = 0;
711
712 points[1].X = 40;
713 points[1].Y = 20;
714
715 points[2].X = 10;
716 points[2].Y = 40;
717
718 /* make a graphics object and pen object */
719 ok(hdc != NULL, "Expected HDC to be initialized\n");
720
721 status = GdipCreateFromHDC(hdc, &graphics);
722 expect(Ok, status);
723 ok(graphics != NULL, "Expected graphics to be initialized\n");
724
725 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
726 expect(Ok, status);
727 ok(pen != NULL, "Expected pen to be initialized\n");
728
729 /* InvalidParameter cases: null graphics, null pen */
730 status = GdipDrawCurve2(NULL, NULL, points, 3, 1);
731 expect(InvalidParameter, status);
732
733 status = GdipDrawCurve2(graphics, NULL, points, 3, 1);
734 expect(InvalidParameter, status);
735
736 status = GdipDrawCurve2(NULL, pen, points, 3, 1);
737 expect(InvalidParameter, status);
738
739 /* InvalidParameter cases: invalid count */
740 status = GdipDrawCurve2(graphics, pen, points, -1, 1);
741 expect(InvalidParameter, status);
742
743 status = GdipDrawCurve2(graphics, pen, points, 0, 1);
744 expect(InvalidParameter, status);
745
746 status = GdipDrawCurve2(graphics, pen, points, 1, 1);
747 expect(InvalidParameter, status);
748
749 /* Valid test cases */
750 status = GdipDrawCurve2(graphics, pen, points, 2, 1);
751 expect(Ok, status);
752
753 status = GdipDrawCurve2(graphics, pen, points, 3, 2);
754 expect(Ok, status);
755
756 status = GdipDrawCurve2(graphics, pen, points, 3, -2);
757 expect(Ok, status);
758
759 status = GdipDrawCurve2(graphics, pen, points, 3, 0);
760 expect(Ok, status);
761
762 GdipDeletePen(pen);
763 GdipDeleteGraphics(graphics);
764
765 ReleaseDC(0, hdc);
766 }
767
768 static void test_GdipDrawCurve2I(void)
769 {
770 GpStatus status;
771 GpGraphics *graphics = NULL;
772 GpPen *pen = NULL;
773 HDC hdc = GetDC(0);
774 GpPoint points[3];
775
776 points[0].X = 0;
777 points[0].Y = 0;
778
779 points[1].X = 40;
780 points[1].Y = 20;
781
782 points[2].X = 10;
783 points[2].Y = 40;
784
785 /* make a graphics object and pen object */
786 ok(hdc != NULL, "Expected HDC to be initialized\n");
787
788 status = GdipCreateFromHDC(hdc, &graphics);
789 expect(Ok, status);
790 ok(graphics != NULL, "Expected graphics to be initialized\n");
791
792 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
793 expect(Ok, status);
794 ok(pen != NULL, "Expected pen to be initialized\n");
795
796 /* InvalidParameter cases: null graphics, null pen */
797 status = GdipDrawCurve2I(NULL, NULL, points, 3, 1);
798 expect(InvalidParameter, status);
799
800 status = GdipDrawCurve2I(graphics, NULL, points, 3, 1);
801 expect(InvalidParameter, status);
802
803 status = GdipDrawCurve2I(NULL, pen, points, 3, 1);
804 expect(InvalidParameter, status);
805
806 /* InvalidParameter cases: invalid count */
807 status = GdipDrawCurve2I(graphics, pen, points, -1, 1);
808 expect(OutOfMemory, status);
809
810 status = GdipDrawCurve2I(graphics, pen, points, 0, 1);
811 expect(InvalidParameter, status);
812
813 status = GdipDrawCurve2I(graphics, pen, points, 1, 1);
814 expect(InvalidParameter, status);
815
816 /* Valid test cases */
817 status = GdipDrawCurve2I(graphics, pen, points, 2, 1);
818 expect(Ok, status);
819
820 status = GdipDrawCurve2I(graphics, pen, points, 3, 2);
821 expect(Ok, status);
822
823 status = GdipDrawCurve2I(graphics, pen, points, 3, -2);
824 expect(Ok, status);
825
826 status = GdipDrawCurve2I(graphics, pen, points, 3, 0);
827 expect(Ok, status);
828
829 GdipDeletePen(pen);
830 GdipDeleteGraphics(graphics);
831
832 ReleaseDC(0, hdc);
833 }
834
835 static void test_GdipDrawCurve(void)
836 {
837 GpStatus status;
838 GpGraphics *graphics = NULL;
839 GpPen *pen = NULL;
840 HDC hdc = GetDC(0);
841 GpPointF points[3];
842
843 points[0].X = 0;
844 points[0].Y = 0;
845
846 points[1].X = 40;
847 points[1].Y = 20;
848
849 points[2].X = 10;
850 points[2].Y = 40;
851
852 /* make a graphics object and pen object */
853 ok(hdc != NULL, "Expected HDC to be initialized\n");
854
855 status = GdipCreateFromHDC(hdc, &graphics);
856 expect(Ok, status);
857 ok(graphics != NULL, "Expected graphics to be initialized\n");
858
859 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
860 expect(Ok, status);
861 ok(pen != NULL, "Expected pen to be initialized\n");
862
863 /* InvalidParameter cases: null graphics, null pen */
864 status = GdipDrawCurve(NULL, NULL, points, 3);
865 expect(InvalidParameter, status);
866
867 status = GdipDrawCurve(graphics, NULL, points, 3);
868 expect(InvalidParameter, status);
869
870 status = GdipDrawCurve(NULL, pen, points, 3);
871 expect(InvalidParameter, status);
872
873 /* InvalidParameter cases: invalid count */
874 status = GdipDrawCurve(graphics, pen, points, -1);
875 expect(InvalidParameter, status);
876
877 status = GdipDrawCurve(graphics, pen, points, 0);
878 expect(InvalidParameter, status);
879
880 status = GdipDrawCurve(graphics, pen, points, 1);
881 expect(InvalidParameter, status);
882
883 /* Valid test cases */
884 status = GdipDrawCurve(graphics, pen, points, 2);
885 expect(Ok, status);
886
887 status = GdipDrawCurve(graphics, pen, points, 3);
888 expect(Ok, status);
889
890 GdipDeletePen(pen);
891 GdipDeleteGraphics(graphics);
892
893 ReleaseDC(0, hdc);
894 }
895
896 static void test_GdipDrawCurveI(void)
897 {
898 GpStatus status;
899 GpGraphics *graphics = NULL;
900 GpPen *pen = NULL;
901 HDC hdc = GetDC(0);
902 GpPoint points[3];
903
904 points[0].X = 0;
905 points[0].Y = 0;
906
907 points[1].X = 40;
908 points[1].Y = 20;
909
910 points[2].X = 10;
911 points[2].Y = 40;
912
913 /* make a graphics object and pen object */
914 ok(hdc != NULL, "Expected HDC to be initialized\n");
915
916 status = GdipCreateFromHDC(hdc, &graphics);
917 expect(Ok, status);
918 ok(graphics != NULL, "Expected graphics to be initialized\n");
919
920 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
921 expect(Ok, status);
922 ok(pen != NULL, "Expected pen to be initialized\n");
923
924 /* InvalidParameter cases: null graphics, null pen */
925 status = GdipDrawCurveI(NULL, NULL, points, 3);
926 expect(InvalidParameter, status);
927
928 status = GdipDrawCurveI(graphics, NULL, points, 3);
929 expect(InvalidParameter, status);
930
931 status = GdipDrawCurveI(NULL, pen, points, 3);
932 expect(InvalidParameter, status);
933
934 /* InvalidParameter cases: invalid count */
935 status = GdipDrawCurveI(graphics, pen, points, -1);
936 expect(OutOfMemory, status);
937
938 status = GdipDrawCurveI(graphics, pen, points, 0);
939 expect(InvalidParameter, status);
940
941 status = GdipDrawCurveI(graphics, pen, points, 1);
942 expect(InvalidParameter, status);
943
944 /* Valid test cases */
945 status = GdipDrawCurveI(graphics, pen, points, 2);
946 expect(Ok, status);
947
948 status = GdipDrawCurveI(graphics, pen, points, 3);
949 expect(Ok, status);
950
951 GdipDeletePen(pen);
952 GdipDeleteGraphics(graphics);
953
954 ReleaseDC(0, hdc);
955 }
956
957 static void test_GdipDrawLineI(void)
958 {
959 GpStatus status;
960 GpGraphics *graphics = NULL;
961 GpPen *pen = NULL;
962 HDC hdc = GetDC(0);
963
964 /* make a graphics object and pen object */
965 ok(hdc != NULL, "Expected HDC to be initialized\n");
966
967 status = GdipCreateFromHDC(hdc, &graphics);
968 expect(Ok, status);
969 ok(graphics != NULL, "Expected graphics to be initialized\n");
970
971 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
972 expect(Ok, status);
973 ok(pen != NULL, "Expected pen to be initialized\n");
974
975 /* InvalidParameter cases: null graphics, null pen */
976 status = GdipDrawLineI(NULL, NULL, 0, 0, 0, 0);
977 expect(InvalidParameter, status);
978
979 status = GdipDrawLineI(graphics, NULL, 0, 0, 0, 0);
980 expect(InvalidParameter, status);
981
982 status = GdipDrawLineI(NULL, pen, 0, 0, 0, 0);
983 expect(InvalidParameter, status);
984
985 /* successful case */
986 status = GdipDrawLineI(graphics, pen, 0, 0, 0, 0);
987 expect(Ok, status);
988
989 GdipDeletePen(pen);
990 GdipDeleteGraphics(graphics);
991
992 ReleaseDC(0, hdc);
993 }
994
995 static void test_GdipDrawLinesI(void)
996 {
997 GpStatus status;
998 GpGraphics *graphics = NULL;
999 GpPen *pen = NULL;
1000 GpPoint *ptf = NULL;
1001 HDC hdc = GetDC(0);
1002
1003 /* make a graphics object and pen object */
1004 ok(hdc != NULL, "Expected HDC to be initialized\n");
1005
1006 status = GdipCreateFromHDC(hdc, &graphics);
1007 expect(Ok, status);
1008 ok(graphics != NULL, "Expected graphics to be initialized\n");
1009
1010 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1011 expect(Ok, status);
1012 ok(pen != NULL, "Expected pen to be initialized\n");
1013
1014 /* make some arbitrary valid points*/
1015 ptf = GdipAlloc(2 * sizeof(GpPointF));
1016
1017 ptf[0].X = 1;
1018 ptf[0].Y = 1;
1019
1020 ptf[1].X = 2;
1021 ptf[1].Y = 2;
1022
1023 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1024 status = GdipDrawLinesI(NULL, NULL, NULL, 0);
1025 expect(InvalidParameter, status);
1026
1027 status = GdipDrawLinesI(graphics, pen, ptf, 0);
1028 expect(InvalidParameter, status);
1029
1030 status = GdipDrawLinesI(graphics, NULL, ptf, 2);
1031 expect(InvalidParameter, status);
1032
1033 status = GdipDrawLinesI(NULL, pen, ptf, 2);
1034 expect(InvalidParameter, status);
1035
1036 /* successful case */
1037 status = GdipDrawLinesI(graphics, pen, ptf, 2);
1038 expect(Ok, status);
1039
1040 GdipFree(ptf);
1041 GdipDeletePen(pen);
1042 GdipDeleteGraphics(graphics);
1043
1044 ReleaseDC(0, hdc);
1045 }
1046
1047 static void test_Get_Release_DC(void)
1048 {
1049 GpStatus status;
1050 GpGraphics *graphics = NULL;
1051 GpPen *pen;
1052 GpSolidFill *brush;
1053 GpPath *path;
1054 HDC hdc = GetDC(0);
1055 HDC retdc;
1056 REAL r;
1057 CompositingQuality quality;
1058 CompositingMode compmode;
1059 InterpolationMode intmode;
1060 GpMatrix *m;
1061 GpRegion *region;
1062 GpUnit unit;
1063 PixelOffsetMode offsetmode;
1064 SmoothingMode smoothmode;
1065 TextRenderingHint texthint;
1066 GpPointF ptf[5];
1067 GpPoint pt[5];
1068 GpRectF rectf[2];
1069 GpRect rect[2];
1070 GpRegion *clip;
1071 INT i;
1072 BOOL res;
1073 ARGB color = 0x00000000;
1074 HRGN hrgn = CreateRectRgn(0, 0, 10, 10);
1075
1076 pt[0].X = 10;
1077 pt[0].Y = 10;
1078 pt[1].X = 20;
1079 pt[1].Y = 15;
1080 pt[2].X = 40;
1081 pt[2].Y = 80;
1082 pt[3].X = -20;
1083 pt[3].Y = 20;
1084 pt[4].X = 50;
1085 pt[4].Y = 110;
1086
1087 for(i = 0; i < 5;i++){
1088 ptf[i].X = (REAL)pt[i].X;
1089 ptf[i].Y = (REAL)pt[i].Y;
1090 }
1091
1092 rect[0].X = 0;
1093 rect[0].Y = 0;
1094 rect[0].Width = 50;
1095 rect[0].Height = 70;
1096 rect[1].X = 0;
1097 rect[1].Y = 0;
1098 rect[1].Width = 10;
1099 rect[1].Height = 20;
1100
1101 for(i = 0; i < 2;i++){
1102 rectf[i].X = (REAL)rect[i].X;
1103 rectf[i].Y = (REAL)rect[i].Y;
1104 rectf[i].Height = (REAL)rect[i].Height;
1105 rectf[i].Width = (REAL)rect[i].Width;
1106 }
1107
1108 GdipCreateMatrix(&m);
1109 GdipCreateRegion(&region);
1110 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1111 GdipCreatePath(FillModeAlternate, &path);
1112 GdipCreateRegion(&clip);
1113
1114 status = GdipCreateFromHDC(hdc, &graphics);
1115 expect(Ok, status);
1116 ok(graphics != NULL, "Expected graphics to be initialized\n");
1117 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1118 expect(Ok, status);
1119
1120 /* NULL arguments */
1121 status = GdipGetDC(NULL, NULL);
1122 expect(InvalidParameter, status);
1123 status = GdipGetDC(graphics, NULL);
1124 expect(InvalidParameter, status);
1125 status = GdipGetDC(NULL, &retdc);
1126 expect(InvalidParameter, status);
1127
1128 status = GdipReleaseDC(NULL, NULL);
1129 expect(InvalidParameter, status);
1130 status = GdipReleaseDC(graphics, NULL);
1131 expect(InvalidParameter, status);
1132 status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
1133 expect(InvalidParameter, status);
1134
1135 /* Release without Get */
1136 status = GdipReleaseDC(graphics, hdc);
1137 expect(InvalidParameter, status);
1138
1139 retdc = NULL;
1140 status = GdipGetDC(graphics, &retdc);
1141 expect(Ok, status);
1142 ok(retdc == hdc, "Invalid HDC returned\n");
1143 /* call it once more */
1144 status = GdipGetDC(graphics, &retdc);
1145 expect(ObjectBusy, status);
1146
1147 /* try all Graphics calls here */
1148 status = Ok;
1149 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1150 expect(ObjectBusy, status); status = Ok;
1151 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
1152 expect(ObjectBusy, status); status = Ok;
1153 status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1154 expect(ObjectBusy, status); status = Ok;
1155 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
1156 expect(ObjectBusy, status); status = Ok;
1157 status = GdipDrawBeziers(graphics, pen, ptf, 5);
1158 expect(ObjectBusy, status); status = Ok;
1159 status = GdipDrawBeziersI(graphics, pen, pt, 5);
1160 expect(ObjectBusy, status); status = Ok;
1161 status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
1162 expect(ObjectBusy, status); status = Ok;
1163 status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
1164 expect(ObjectBusy, status); status = Ok;
1165 status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
1166 expect(ObjectBusy, status); status = Ok;
1167 status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
1168 expect(ObjectBusy, status); status = Ok;
1169 status = GdipDrawCurve(graphics, pen, ptf, 5);
1170 expect(ObjectBusy, status); status = Ok;
1171 status = GdipDrawCurveI(graphics, pen, pt, 5);
1172 expect(ObjectBusy, status); status = Ok;
1173 status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
1174 expect(ObjectBusy, status); status = Ok;
1175 status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
1176 expect(ObjectBusy, status); status = Ok;
1177 status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
1178 expect(ObjectBusy, status); status = Ok;
1179 status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
1180 expect(ObjectBusy, status); status = Ok;
1181 /* GdipDrawImage/GdipDrawImageI */
1182 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1183 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1184 /* GdipDrawImageRect/GdipDrawImageRectI */
1185 status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
1186 expect(ObjectBusy, status); status = Ok;
1187 status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
1188 expect(ObjectBusy, status); status = Ok;
1189 status = GdipDrawLines(graphics, pen, ptf, 5);
1190 expect(ObjectBusy, status); status = Ok;
1191 status = GdipDrawLinesI(graphics, pen, pt, 5);
1192 expect(ObjectBusy, status); status = Ok;
1193 status = GdipDrawPath(graphics, pen, path);
1194 expect(ObjectBusy, status); status = Ok;
1195 status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1196 expect(ObjectBusy, status); status = Ok;
1197 status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
1198 expect(ObjectBusy, status); status = Ok;
1199 status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
1200 expect(ObjectBusy, status); status = Ok;
1201 status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
1202 expect(ObjectBusy, status); status = Ok;
1203 status = GdipDrawRectangles(graphics, pen, rectf, 2);
1204 expect(ObjectBusy, status); status = Ok;
1205 status = GdipDrawRectanglesI(graphics, pen, rect, 2);
1206 expect(ObjectBusy, status); status = Ok;
1207 /* GdipDrawString */
1208 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0, FillModeAlternate);
1209 expect(ObjectBusy, status); status = Ok;
1210 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0, FillModeAlternate);
1211 expect(ObjectBusy, status); status = Ok;
1212 status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1213 expect(ObjectBusy, status); status = Ok;
1214 status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1215 expect(ObjectBusy, status); status = Ok;
1216 status = GdipFillPath(graphics, (GpBrush*)brush, path);
1217 expect(ObjectBusy, status); status = Ok;
1218 status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1219 expect(ObjectBusy, status); status = Ok;
1220 status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
1221 expect(ObjectBusy, status); status = Ok;
1222 status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
1223 expect(ObjectBusy, status); status = Ok;
1224 status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
1225 expect(ObjectBusy, status); status = Ok;
1226 status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
1227 expect(ObjectBusy, status); status = Ok;
1228 status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
1229 expect(ObjectBusy, status); status = Ok;
1230 status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1231 expect(ObjectBusy, status); status = Ok;
1232 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1233 expect(ObjectBusy, status); status = Ok;
1234 status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
1235 expect(ObjectBusy, status); status = Ok;
1236 status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
1237 expect(ObjectBusy, status); status = Ok;
1238 status = GdipFillRegion(graphics, (GpBrush*)brush, region);
1239 expect(ObjectBusy, status); status = Ok;
1240 status = GdipFlush(graphics, FlushIntentionFlush);
1241 expect(ObjectBusy, status); status = Ok;
1242 status = GdipGetClipBounds(graphics, rectf);
1243 expect(ObjectBusy, status); status = Ok;
1244 status = GdipGetClipBoundsI(graphics, rect);
1245 expect(ObjectBusy, status); status = Ok;
1246 status = GdipGetCompositingMode(graphics, &compmode);
1247 expect(ObjectBusy, status); status = Ok;
1248 status = GdipGetCompositingQuality(graphics, &quality);
1249 expect(ObjectBusy, status); status = Ok;
1250 status = GdipGetInterpolationMode(graphics, &intmode);
1251 expect(ObjectBusy, status); status = Ok;
1252 status = GdipGetNearestColor(graphics, &color);
1253 expect(ObjectBusy, status); status = Ok;
1254 status = GdipGetPageScale(graphics, &r);
1255 expect(ObjectBusy, status); status = Ok;
1256 status = GdipGetPageUnit(graphics, &unit);
1257 expect(ObjectBusy, status); status = Ok;
1258 status = GdipGetPixelOffsetMode(graphics, &offsetmode);
1259 expect(ObjectBusy, status); status = Ok;
1260 status = GdipGetSmoothingMode(graphics, &smoothmode);
1261 expect(ObjectBusy, status); status = Ok;
1262 status = GdipGetTextRenderingHint(graphics, &texthint);
1263 expect(ObjectBusy, status); status = Ok;
1264 status = GdipGetWorldTransform(graphics, m);
1265 expect(ObjectBusy, status); status = Ok;
1266 status = GdipGraphicsClear(graphics, 0xdeadbeef);
1267 expect(ObjectBusy, status); status = Ok;
1268 status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
1269 expect(ObjectBusy, status); status = Ok;
1270 status = GdipIsVisiblePointI(graphics, 0, 0, &res);
1271 expect(ObjectBusy, status); status = Ok;
1272 /* GdipMeasureCharacterRanges */
1273 /* GdipMeasureString */
1274 status = GdipResetClip(graphics);
1275 expect(ObjectBusy, status); status = Ok;
1276 status = GdipResetWorldTransform(graphics);
1277 expect(ObjectBusy, status); status = Ok;
1278 /* GdipRestoreGraphics */
1279 status = GdipRotateWorldTransform(graphics, 15.0, MatrixOrderPrepend);
1280 expect(ObjectBusy, status); status = Ok;
1281 /* GdipSaveGraphics */
1282 status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
1283 expect(ObjectBusy, status); status = Ok;
1284 status = GdipSetCompositingMode(graphics, CompositingModeSourceOver);
1285 expect(ObjectBusy, status); status = Ok;
1286 status = GdipSetCompositingQuality(graphics, CompositingQualityDefault);
1287 expect(ObjectBusy, status); status = Ok;
1288 status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
1289 expect(ObjectBusy, status); status = Ok;
1290 status = GdipSetPageScale(graphics, 1.0);
1291 expect(ObjectBusy, status); status = Ok;
1292 status = GdipSetPageUnit(graphics, UnitWorld);
1293 expect(ObjectBusy, status); status = Ok;
1294 status = GdipSetPixelOffsetMode(graphics, PixelOffsetModeDefault);
1295 expect(ObjectBusy, status); status = Ok;
1296 status = GdipSetSmoothingMode(graphics, SmoothingModeDefault);
1297 expect(ObjectBusy, status); status = Ok;
1298 status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
1299 expect(ObjectBusy, status); status = Ok;
1300 status = GdipSetWorldTransform(graphics, m);
1301 expect(ObjectBusy, status); status = Ok;
1302 status = GdipTranslateWorldTransform(graphics, 0.0, 0.0, MatrixOrderPrepend);
1303 expect(ObjectBusy, status); status = Ok;
1304 status = GdipSetClipHrgn(graphics, hrgn, CombineModeReplace);
1305 expect(ObjectBusy, status); status = Ok;
1306 status = GdipSetClipPath(graphics, path, CombineModeReplace);
1307 expect(ObjectBusy, status); status = Ok;
1308 status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
1309 expect(ObjectBusy, status); status = Ok;
1310 status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
1311 expect(ObjectBusy, status); status = Ok;
1312 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1313 expect(ObjectBusy, status); status = Ok;
1314 status = GdipTranslateClip(graphics, 0.0, 0.0);
1315 expect(ObjectBusy, status); status = Ok;
1316 status = GdipTranslateClipI(graphics, 0, 0);
1317 expect(ObjectBusy, status); status = Ok;
1318 status = GdipDrawPolygon(graphics, pen, ptf, 5);
1319 expect(ObjectBusy, status); status = Ok;
1320 status = GdipDrawPolygonI(graphics, pen, pt, 5);
1321 expect(ObjectBusy, status); status = Ok;
1322 status = GdipGetDpiX(graphics, &r);
1323 expect(ObjectBusy, status); status = Ok;
1324 status = GdipGetDpiY(graphics, &r);
1325 expect(ObjectBusy, status); status = Ok;
1326 status = GdipMultiplyWorldTransform(graphics, m, MatrixOrderPrepend);
1327 status = GdipGetClip(graphics, region);
1328 expect(ObjectBusy, status); status = Ok;
1329 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
1330 expect(ObjectBusy, status); status = Ok;
1331 /* try to delete before release */
1332 status = GdipDeleteGraphics(graphics);
1333 expect(ObjectBusy, status);
1334
1335 status = GdipReleaseDC(graphics, retdc);
1336 expect(Ok, status);
1337
1338 GdipDeletePen(pen);
1339 GdipDeleteGraphics(graphics);
1340
1341 GdipDeleteRegion(clip);
1342 GdipDeletePath(path);
1343 GdipDeleteBrush((GpBrush*)brush);
1344 GdipDeleteRegion(region);
1345 GdipDeleteMatrix(m);
1346 DeleteObject(hrgn);
1347
1348 ReleaseDC(0, hdc);
1349 }
1350
1351 static void test_transformpoints(void)
1352 {
1353 GpStatus status;
1354 GpGraphics *graphics = NULL;
1355 HDC hdc = GetDC(0);
1356 GpPointF ptf[2];
1357 GpPoint pt[2];
1358
1359 status = GdipCreateFromHDC(hdc, &graphics);
1360 expect(Ok, status);
1361
1362 /* NULL arguments */
1363 status = GdipTransformPoints(NULL, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
1364 expect(InvalidParameter, status);
1365 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
1366 expect(InvalidParameter, status);
1367 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 0);
1368 expect(InvalidParameter, status);
1369 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, -1);
1370 expect(InvalidParameter, status);
1371
1372 ptf[0].X = 1.0;
1373 ptf[0].Y = 0.0;
1374 ptf[1].X = 0.0;
1375 ptf[1].Y = 1.0;
1376 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
1377 expect(Ok, status);
1378 expectf(1.0, ptf[0].X);
1379 expectf(0.0, ptf[0].Y);
1380 expectf(0.0, ptf[1].X);
1381 expectf(1.0, ptf[1].Y);
1382
1383 status = GdipTranslateWorldTransform(graphics, 5.0, 5.0, MatrixOrderAppend);
1384 expect(Ok, status);
1385 status = GdipSetPageUnit(graphics, UnitPixel);
1386 expect(Ok, status);
1387 status = GdipSetPageScale(graphics, 3.0);
1388 expect(Ok, status);
1389
1390 ptf[0].X = 1.0;
1391 ptf[0].Y = 0.0;
1392 ptf[1].X = 0.0;
1393 ptf[1].Y = 1.0;
1394 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
1395 expect(Ok, status);
1396 expectf(18.0, ptf[0].X);
1397 expectf(15.0, ptf[0].Y);
1398 expectf(15.0, ptf[1].X);
1399 expectf(18.0, ptf[1].Y);
1400
1401 ptf[0].X = 1.0;
1402 ptf[0].Y = 0.0;
1403 ptf[1].X = 0.0;
1404 ptf[1].Y = 1.0;
1405 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 2);
1406 expect(Ok, status);
1407 expectf(6.0, ptf[0].X);
1408 expectf(5.0, ptf[0].Y);
1409 expectf(5.0, ptf[1].X);
1410 expectf(6.0, ptf[1].Y);
1411
1412 ptf[0].X = 1.0;
1413 ptf[0].Y = 0.0;
1414 ptf[1].X = 0.0;
1415 ptf[1].Y = 1.0;
1416 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpacePage, ptf, 2);
1417 expect(Ok, status);
1418 expectf(3.0, ptf[0].X);
1419 expectf(0.0, ptf[0].Y);
1420 expectf(0.0, ptf[1].X);
1421 expectf(3.0, ptf[1].Y);
1422
1423 ptf[0].X = 18.0;
1424 ptf[0].Y = 15.0;
1425 ptf[1].X = 15.0;
1426 ptf[1].Y = 18.0;
1427 status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, ptf, 2);
1428 expect(Ok, status);
1429 expectf(1.0, ptf[0].X);
1430 expectf(0.0, ptf[0].Y);
1431 expectf(0.0, ptf[1].X);
1432 expectf(1.0, ptf[1].Y);
1433
1434 ptf[0].X = 6.0;
1435 ptf[0].Y = 5.0;
1436 ptf[1].X = 5.0;
1437 ptf[1].Y = 6.0;
1438 status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpacePage, ptf, 2);
1439 expect(Ok, status);
1440 expectf(1.0, ptf[0].X);
1441 expectf(0.0, ptf[0].Y);
1442 expectf(0.0, ptf[1].X);
1443 expectf(1.0, ptf[1].Y);
1444
1445 ptf[0].X = 3.0;
1446 ptf[0].Y = 0.0;
1447 ptf[1].X = 0.0;
1448 ptf[1].Y = 3.0;
1449 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceDevice, ptf, 2);
1450 expect(Ok, status);
1451 expectf(1.0, ptf[0].X);
1452 expectf(0.0, ptf[0].Y);
1453 expectf(0.0, ptf[1].X);
1454 expectf(1.0, ptf[1].Y);
1455
1456 pt[0].X = 1;
1457 pt[0].Y = 0;
1458 pt[1].X = 0;
1459 pt[1].Y = 1;
1460 status = GdipTransformPointsI(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, pt, 2);
1461 expect(Ok, status);
1462 expect(18, pt[0].X);
1463 expect(15, pt[0].Y);
1464 expect(15, pt[1].X);
1465 expect(18, pt[1].Y);
1466
1467 GdipDeleteGraphics(graphics);
1468 ReleaseDC(0, hdc);
1469 }
1470
1471 static void test_get_set_clip(void)
1472 {
1473 GpStatus status;
1474 GpGraphics *graphics = NULL;
1475 HDC hdc = GetDC(0);
1476 GpRegion *clip;
1477 GpRectF rect;
1478 BOOL res;
1479
1480 status = GdipCreateFromHDC(hdc, &graphics);
1481 expect(Ok, status);
1482
1483 rect.X = rect.Y = 0.0;
1484 rect.Height = rect.Width = 100.0;
1485
1486 status = GdipCreateRegionRect(&rect, &clip);
1487
1488 /* NULL arguments */
1489 status = GdipGetClip(NULL, NULL);
1490 expect(InvalidParameter, status);
1491 status = GdipGetClip(graphics, NULL);
1492 expect(InvalidParameter, status);
1493 status = GdipGetClip(NULL, clip);
1494 expect(InvalidParameter, status);
1495
1496 status = GdipSetClipRegion(NULL, NULL, CombineModeReplace);
1497 expect(InvalidParameter, status);
1498 status = GdipSetClipRegion(graphics, NULL, CombineModeReplace);
1499 expect(InvalidParameter, status);
1500
1501 status = GdipSetClipPath(NULL, NULL, CombineModeReplace);
1502 expect(InvalidParameter, status);
1503 status = GdipSetClipPath(graphics, NULL, CombineModeReplace);
1504 expect(InvalidParameter, status);
1505
1506 res = FALSE;
1507 status = GdipGetClip(graphics, clip);
1508 expect(Ok, status);
1509 status = GdipIsInfiniteRegion(clip, graphics, &res);
1510 expect(Ok, status);
1511 expect(TRUE, res);
1512
1513 /* remains infinite after reset */
1514 res = FALSE;
1515 status = GdipResetClip(graphics);
1516 expect(Ok, status);
1517 status = GdipGetClip(graphics, clip);
1518 expect(Ok, status);
1519 status = GdipIsInfiniteRegion(clip, graphics, &res);
1520 expect(Ok, status);
1521 expect(TRUE, res);
1522
1523 /* set to empty and then reset to infinite */
1524 status = GdipSetEmpty(clip);
1525 expect(Ok, status);
1526 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1527 expect(Ok, status);
1528
1529 status = GdipGetClip(graphics, clip);
1530 expect(Ok, status);
1531 res = FALSE;
1532 status = GdipIsEmptyRegion(clip, graphics, &res);
1533 expect(Ok, status);
1534 expect(TRUE, res);
1535 status = GdipResetClip(graphics);
1536 expect(Ok, status);
1537 status = GdipGetClip(graphics, clip);
1538 expect(Ok, status);
1539 res = FALSE;
1540 status = GdipIsInfiniteRegion(clip, graphics, &res);
1541 expect(Ok, status);
1542 expect(TRUE, res);
1543
1544 GdipDeleteRegion(clip);
1545
1546 GdipDeleteGraphics(graphics);
1547 ReleaseDC(0, hdc);
1548 }
1549
1550 static void test_isempty(void)
1551 {
1552 GpStatus status;
1553 GpGraphics *graphics = NULL;
1554 HDC hdc = GetDC(0);
1555 GpRegion *clip;
1556 BOOL res;
1557
1558 status = GdipCreateFromHDC(hdc, &graphics);
1559 expect(Ok, status);
1560
1561 status = GdipCreateRegion(&clip);
1562 expect(Ok, status);
1563
1564 /* NULL */
1565 status = GdipIsClipEmpty(NULL, NULL);
1566 expect(InvalidParameter, status);
1567 status = GdipIsClipEmpty(graphics, NULL);
1568 expect(InvalidParameter, status);
1569 status = GdipIsClipEmpty(NULL, &res);
1570 expect(InvalidParameter, status);
1571
1572 /* default is infinite */
1573 res = TRUE;
1574 status = GdipIsClipEmpty(graphics, &res);
1575 expect(Ok, status);
1576 expect(FALSE, res);
1577
1578 GdipDeleteRegion(clip);
1579
1580 GdipDeleteGraphics(graphics);
1581 ReleaseDC(0, hdc);
1582 }
1583
1584 static void test_clear(void)
1585 {
1586 GpStatus status;
1587
1588 status = GdipGraphicsClear(NULL, 0xdeadbeef);
1589 expect(InvalidParameter, status);
1590 }
1591
1592 static void test_textcontrast(void)
1593 {
1594 GpStatus status;
1595 HDC hdc = GetDC(0);
1596 GpGraphics *graphics;
1597 UINT contrast;
1598
1599 status = GdipGetTextContrast(NULL, NULL);
1600 expect(InvalidParameter, status);
1601
1602 status = GdipCreateFromHDC(hdc, &graphics);
1603 expect(Ok, status);
1604
1605 status = GdipGetTextContrast(graphics, NULL);
1606 expect(InvalidParameter, status);
1607 status = GdipGetTextContrast(graphics, &contrast);
1608 expect(4, contrast);
1609
1610 GdipDeleteGraphics(graphics);
1611 ReleaseDC(0, hdc);
1612 }
1613
1614 static void test_GdipDrawString(void)
1615 {
1616 GpStatus status;
1617 GpGraphics *graphics = NULL;
1618 GpFont *fnt = NULL;
1619 RectF rect;
1620 GpStringFormat *format;
1621 GpBrush *brush;
1622 LOGFONTA logfont;
1623 HDC hdc = GetDC(0);
1624 static const WCHAR string[] = {'T','e','s','t',0};
1625
1626 memset(&logfont,0,sizeof(logfont));
1627 strcpy(logfont.lfFaceName,"Arial");
1628 logfont.lfHeight = 12;
1629 logfont.lfCharSet = DEFAULT_CHARSET;
1630
1631 status = GdipCreateFromHDC(hdc, &graphics);
1632 expect(Ok, status);
1633
1634 status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
1635 if (status == FileNotFound)
1636 {
1637 skip("Arial not installed.\n");
1638 return;
1639 }
1640 expect(Ok, status);
1641
1642 status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
1643 expect(Ok, status);
1644
1645 status = GdipCreateStringFormat(0,0,&format);
1646 expect(Ok, status);
1647
1648 rect.X = 0;
1649 rect.Y = 0;
1650 rect.Width = 0;
1651 rect.Height = 12;
1652
1653 status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
1654 expect(Ok, status);
1655
1656 GdipDeleteGraphics(graphics);
1657 GdipDeleteBrush(brush);
1658 GdipDeleteFont(fnt);
1659 GdipDeleteStringFormat(format);
1660
1661 ReleaseDC(0, hdc);
1662 }
1663
1664 static void test_GdipGetVisibleClipBounds_screen(void)
1665 {
1666 GpStatus status;
1667 GpGraphics *graphics = NULL;
1668 HDC hdc = GetDC(0);
1669 GpRectF rectf, exp, clipr;
1670 GpRect recti;
1671
1672 ok(hdc != NULL, "Expected HDC to be initialized\n");
1673
1674 status = GdipCreateFromHDC(hdc, &graphics);
1675 expect(Ok, status);
1676 ok(graphics != NULL, "Expected graphics to be initialized\n");
1677
1678 /* no clipping rect */
1679 exp.X = 0;
1680 exp.Y = 0;
1681 exp.Width = GetDeviceCaps(hdc, HORZRES);
1682 exp.Height = GetDeviceCaps(hdc, VERTRES);
1683
1684 status = GdipGetVisibleClipBounds(graphics, &rectf);
1685 expect(Ok, status);
1686 ok(rectf.X == exp.X &&
1687 rectf.Y == exp.Y &&
1688 rectf.Width == exp.Width &&
1689 rectf.Height == exp.Height,
1690 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1691 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1692 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1693 exp.X, exp.Y, exp.Width, exp.Height);
1694
1695 /* clipping rect entirely within window */
1696 exp.X = clipr.X = 10;
1697 exp.Y = clipr.Y = 12;
1698 exp.Width = clipr.Width = 14;
1699 exp.Height = clipr.Height = 16;
1700
1701 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1702 expect(Ok, status);
1703
1704 status = GdipGetVisibleClipBounds(graphics, &rectf);
1705 expect(Ok, status);
1706 ok(rectf.X == exp.X &&
1707 rectf.Y == exp.Y &&
1708 rectf.Width == exp.Width &&
1709 rectf.Height == exp.Height,
1710 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1711 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1712 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1713 exp.X, exp.Y, exp.Width, exp.Height);
1714
1715 /* clipping rect partially outside of screen */
1716 clipr.X = -10;
1717 clipr.Y = -12;
1718 clipr.Width = 20;
1719 clipr.Height = 24;
1720
1721 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1722 expect(Ok, status);
1723
1724 exp.X = 0;
1725 exp.Y = 0;
1726 exp.Width = 10;
1727 exp.Height = 12;
1728
1729 status = GdipGetVisibleClipBounds(graphics, &rectf);
1730 expect(Ok, status);
1731 ok(rectf.X == exp.X &&
1732 rectf.Y == exp.Y &&
1733 rectf.Width == exp.Width &&
1734 rectf.Height == exp.Height,
1735 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1736 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1737 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1738 exp.X, exp.Y, exp.Width, exp.Height);
1739
1740 status = GdipGetVisibleClipBoundsI(graphics, &recti);
1741 expect(Ok, status);
1742 ok(recti.X == exp.X &&
1743 recti.Y == exp.Y &&
1744 recti.Width == exp.Width &&
1745 recti.Height == exp.Height,
1746 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1747 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1748 recti.X, recti.Y, recti.Width, recti.Height,
1749 exp.X, exp.Y, exp.Width, exp.Height);
1750
1751 GdipDeleteGraphics(graphics);
1752 ReleaseDC(0, hdc);
1753 }
1754
1755 static void test_GdipGetVisibleClipBounds_window(void)
1756 {
1757 GpStatus status;
1758 GpGraphics *graphics = NULL;
1759 GpRectF rectf, window, exp, clipr;
1760 GpRect recti;
1761 HWND hwnd;
1762 WNDCLASSA class;
1763 HDC hdc;
1764 PAINTSTRUCT ps;
1765 HINSTANCE hInstance = GetModuleHandle(NULL);
1766 RECT wnd_rect;
1767
1768 window.X = 0;
1769 window.Y = 0;
1770 window.Width = 200;
1771 window.Height = 300;
1772
1773 class.lpszClassName = "ClipBoundsTestClass";
1774 class.style = CS_HREDRAW | CS_VREDRAW;
1775 class.lpfnWndProc = DefWindowProcA;
1776 class.hInstance = hInstance;
1777 class.hIcon = LoadIcon(0, IDI_APPLICATION);
1778 class.hCursor = LoadCursor(NULL, IDC_ARROW);
1779 class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1780 class.lpszMenuName = 0;
1781 class.cbClsExtra = 0;
1782 class.cbWndExtra = 0;
1783 RegisterClass(&class);
1784
1785 hwnd = CreateWindow(class.lpszClassName, "ClipboundsTest",
1786 WS_OVERLAPPEDWINDOW, window.X, window.Y, window.Width, window.Height,
1787 NULL, NULL, hInstance, NULL);
1788
1789 ok(hwnd != NULL, "Expected window to be created\n");
1790
1791 /* get client area size */
1792 ok(GetClientRect(hwnd, &wnd_rect), "GetClientRect should have succeeded\n");
1793 window.X = wnd_rect.left;
1794 window.Y = wnd_rect.top;
1795 window.Width = wnd_rect.right - wnd_rect.left;
1796 window.Height = wnd_rect.bottom - wnd_rect.top;
1797
1798 hdc = BeginPaint(hwnd, &ps);
1799
1800 status = GdipCreateFromHDC(hdc, &graphics);
1801 expect(Ok, status);
1802 ok(graphics != NULL, "Expected graphics to be initialized\n");
1803
1804 status = GdipGetVisibleClipBounds(graphics, &rectf);
1805 expect(Ok, status);
1806 ok(rectf.X == window.X &&
1807 rectf.Y == window.Y &&
1808 rectf.Width == window.Width &&
1809 rectf.Height == window.Height,
1810 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1811 "the window (%0.f, %0.f, %0.f, %0.f)\n",
1812 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1813 window.X, window.Y, window.Width, window.Height);
1814
1815 /* clipping rect entirely within window */
1816 exp.X = clipr.X = 20;
1817 exp.Y = clipr.Y = 8;
1818 exp.Width = clipr.Width = 30;
1819 exp.Height = clipr.Height = 20;
1820
1821 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1822 expect(Ok, status);
1823
1824 status = GdipGetVisibleClipBounds(graphics, &rectf);
1825 expect(Ok, status);
1826 ok(rectf.X == exp.X &&
1827 rectf.Y == exp.Y &&
1828 rectf.Width == exp.Width &&
1829 rectf.Height == exp.Height,
1830 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1831 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1832 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1833 exp.X, exp.Y, exp.Width, exp.Height);
1834
1835 /* clipping rect partially outside of window */
1836 clipr.X = window.Width - 10;
1837 clipr.Y = window.Height - 15;
1838 clipr.Width = 20;
1839 clipr.Height = 30;
1840
1841 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1842 expect(Ok, status);
1843
1844 exp.X = window.Width - 10;
1845 exp.Y = window.Height - 15;
1846 exp.Width = 10;
1847 exp.Height = 15;
1848
1849 status = GdipGetVisibleClipBounds(graphics, &rectf);
1850 expect(Ok, status);
1851 ok(rectf.X == exp.X &&
1852 rectf.Y == exp.Y &&
1853 rectf.Width == exp.Width &&
1854 rectf.Height == exp.Height,
1855 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1856 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1857 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1858 exp.X, exp.Y, exp.Width, exp.Height);
1859
1860 status = GdipGetVisibleClipBoundsI(graphics, &recti);
1861 expect(Ok, status);
1862 ok(recti.X == exp.X &&
1863 recti.Y == exp.Y &&
1864 recti.Width == exp.Width &&
1865 recti.Height == exp.Height,
1866 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1867 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1868 recti.X, recti.Y, recti.Width, recti.Height,
1869 exp.X, exp.Y, exp.Width, exp.Height);
1870
1871 GdipDeleteGraphics(graphics);
1872 EndPaint(hwnd, &ps);
1873 DestroyWindow(hwnd);
1874 }
1875
1876 static void test_GdipGetVisibleClipBounds(void)
1877 {
1878 GpGraphics* graphics = NULL;
1879 GpRectF rectf;
1880 GpRect rect;
1881 HDC hdc = GetDC(0);
1882 GpStatus status;
1883
1884 status = GdipCreateFromHDC(hdc, &graphics);
1885 expect(Ok, status);
1886 ok(graphics != NULL, "Expected graphics to be initialized\n");
1887
1888 /* test null parameters */
1889 status = GdipGetVisibleClipBounds(graphics, NULL);
1890 expect(InvalidParameter, status);
1891
1892 status = GdipGetVisibleClipBounds(NULL, &rectf);
1893 expect(InvalidParameter, status);
1894
1895 status = GdipGetVisibleClipBoundsI(graphics, NULL);
1896 expect(InvalidParameter, status);
1897
1898 status = GdipGetVisibleClipBoundsI(NULL, &rect);
1899 expect(InvalidParameter, status);
1900
1901 GdipDeleteGraphics(graphics);
1902 ReleaseDC(0, hdc);
1903
1904 test_GdipGetVisibleClipBounds_screen();
1905 test_GdipGetVisibleClipBounds_window();
1906 }
1907
1908 static void test_fromMemoryBitmap(void)
1909 {
1910 GpStatus status;
1911 GpGraphics *graphics = NULL;
1912 GpBitmap *bitmap = NULL;
1913 BYTE bits[48] = {0};
1914
1915 status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, bits, &bitmap);
1916 expect(Ok, status);
1917
1918 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
1919 expect(Ok, status);
1920
1921 status = GdipGraphicsClear(graphics, 0xff686868);
1922 expect(Ok, status);
1923
1924 GdipDeleteGraphics(graphics);
1925
1926 /* drawing writes to the memory provided */
1927 todo_wine expect(0x68, bits[10]);
1928
1929 GdipDisposeImage((GpImage*)bitmap);
1930 }
1931
1932 static void test_GdipIsVisiblePoint(void)
1933 {
1934 GpStatus status;
1935 GpGraphics *graphics = NULL;
1936 HDC hdc = GetDC(0);
1937 REAL x, y;
1938 BOOL val;
1939
1940 ok(hdc != NULL, "Expected HDC to be initialized\n");
1941
1942 status = GdipCreateFromHDC(hdc, &graphics);
1943 expect(Ok, status);
1944 ok(graphics != NULL, "Expected graphics to be initialized\n");
1945
1946 /* null parameters */
1947 status = GdipIsVisiblePoint(NULL, 0, 0, &val);
1948 expect(InvalidParameter, status);
1949
1950 status = GdipIsVisiblePoint(graphics, 0, 0, NULL);
1951 expect(InvalidParameter, status);
1952
1953 status = GdipIsVisiblePointI(NULL, 0, 0, &val);
1954 expect(InvalidParameter, status);
1955
1956 status = GdipIsVisiblePointI(graphics, 0, 0, NULL);
1957 expect(InvalidParameter, status);
1958
1959 x = 0;
1960 y = 0;
1961 status = GdipIsVisiblePoint(graphics, x, y, &val);
1962 expect(Ok, status);
1963 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1964
1965 x = -10;
1966 y = 0;
1967 status = GdipIsVisiblePoint(graphics, x, y, &val);
1968 expect(Ok, status);
1969 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1970
1971 x = 0;
1972 y = -5;
1973 status = GdipIsVisiblePoint(graphics, x, y, &val);
1974 expect(Ok, status);
1975 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1976
1977 x = 1;
1978 y = 1;
1979 status = GdipIsVisiblePoint(graphics, x, y, &val);
1980 expect(Ok, status);
1981 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1982
1983 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
1984 expect(Ok, status);
1985
1986 x = 1;
1987 y = 1;
1988 status = GdipIsVisiblePoint(graphics, x, y, &val);
1989 expect(Ok, status);
1990 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
1991
1992 x = 15.5;
1993 y = 40.5;
1994 status = GdipIsVisiblePoint(graphics, x, y, &val);
1995 expect(Ok, status);
1996 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
1997
1998 /* translate into the center of the rect */
1999 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2000
2001 x = 0;
2002 y = 0;
2003 status = GdipIsVisiblePoint(graphics, x, y, &val);
2004 expect(Ok, status);
2005 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2006
2007 x = 25;
2008 y = 40;
2009 status = GdipIsVisiblePoint(graphics, x, y, &val);
2010 expect(Ok, status);
2011 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2012
2013 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2014
2015 /* corner cases */
2016 x = 9;
2017 y = 19;
2018 status = GdipIsVisiblePoint(graphics, x, y, &val);
2019 expect(Ok, status);
2020 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2021
2022 x = 9.25;
2023 y = 19.25;
2024 status = GdipIsVisiblePoint(graphics, x, y, &val);
2025 expect(Ok, status);
2026 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2027
2028 x = 9.5;
2029 y = 19.5;
2030 status = GdipIsVisiblePoint(graphics, x, y, &val);
2031 expect(Ok, status);
2032 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2033
2034 x = 9.75;
2035 y = 19.75;
2036 status = GdipIsVisiblePoint(graphics, x, y, &val);
2037 expect(Ok, status);
2038 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2039
2040 x = 10;
2041 y = 20;
2042 status = GdipIsVisiblePoint(graphics, x, y, &val);
2043 expect(Ok, status);
2044 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2045
2046 x = 40;
2047 y = 20;
2048 status = GdipIsVisiblePoint(graphics, x, y, &val);
2049 expect(Ok, status);
2050 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2051
2052 x = 39;
2053 y = 59;
2054 status = GdipIsVisiblePoint(graphics, x, y, &val);
2055 expect(Ok, status);
2056 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2057
2058 x = 39.25;
2059 y = 59.25;
2060 status = GdipIsVisiblePoint(graphics, x, y, &val);
2061 expect(Ok, status);
2062 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2063
2064 x = 39.5;
2065 y = 39.5;
2066 status = GdipIsVisiblePoint(graphics, x, y, &val);
2067 expect(Ok, status);
2068 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2069
2070 x = 39.75;
2071 y = 59.75;
2072 status = GdipIsVisiblePoint(graphics, x, y, &val);
2073 expect(Ok, status);
2074 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2075
2076 x = 40;
2077 y = 60;
2078 status = GdipIsVisiblePoint(graphics, x, y, &val);
2079 expect(Ok, status);
2080 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2081
2082 x = 40.15;
2083 y = 60.15;
2084 status = GdipIsVisiblePoint(graphics, x, y, &val);
2085 expect(Ok, status);
2086 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2087
2088 x = 10;
2089 y = 60;
2090 status = GdipIsVisiblePoint(graphics, x, y, &val);
2091 expect(Ok, status);
2092 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2093
2094 /* integer version */
2095 x = 25;
2096 y = 30;
2097 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2098 expect(Ok, status);
2099 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2100
2101 x = 50;
2102 y = 100;
2103 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2104 expect(Ok, status);
2105 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2106
2107 GdipDeleteGraphics(graphics);
2108 ReleaseDC(0, hdc);
2109 }
2110
2111 static void test_GdipIsVisibleRect(void)
2112 {
2113 GpStatus status;
2114 GpGraphics *graphics = NULL;
2115 HDC hdc = GetDC(0);
2116 REAL x, y, width, height;
2117 BOOL val;
2118
2119 ok(hdc != NULL, "Expected HDC to be initialized\n");
2120
2121 status = GdipCreateFromHDC(hdc, &graphics);
2122 expect(Ok, status);
2123 ok(graphics != NULL, "Expected graphics to be initialized\n");
2124
2125 status = GdipIsVisibleRect(NULL, 0, 0, 0, 0, &val);
2126 expect(InvalidParameter, status);
2127
2128 status = GdipIsVisibleRect(graphics, 0, 0, 0, 0, NULL);
2129 expect(InvalidParameter, status);
2130
2131 status = GdipIsVisibleRectI(NULL, 0, 0, 0, 0, &val);
2132 expect(InvalidParameter, status);
2133
2134 status = GdipIsVisibleRectI(graphics, 0, 0, 0, 0, NULL);
2135 expect(InvalidParameter, status);
2136
2137 /* entirely within the visible region */
2138 x = 0; width = 10;
2139 y = 0; height = 10;
2140 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2141 expect(Ok, status);
2142 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2143
2144 /* partially outside */
2145 x = -10; width = 20;
2146 y = -10; height = 20;
2147 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2148 expect(Ok, status);
2149 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2150
2151 /* entirely outside */
2152 x = -10; width = 5;
2153 y = -10; height = 5;
2154 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2155 expect(Ok, status);
2156 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2157
2158 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2159 expect(Ok, status);
2160
2161 /* entirely within the visible region */
2162 x = 12; width = 10;
2163 y = 22; height = 10;
2164 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2165 expect(Ok, status);
2166 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2167
2168 /* partially outside */
2169 x = 35; width = 10;
2170 y = 55; height = 10;
2171 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2172 expect(Ok, status);
2173 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2174
2175 /* entirely outside */
2176 x = 45; width = 5;
2177 y = 65; height = 5;
2178 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2179 expect(Ok, status);
2180 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2181
2182 /* translate into center of clipping rect */
2183 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2184
2185 x = 0; width = 10;
2186 y = 0; height = 10;
2187 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2188 expect(Ok, status);
2189 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2190
2191 x = 25; width = 5;
2192 y = 40; height = 5;
2193 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2194 expect(Ok, status);
2195 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2196
2197 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2198
2199 /* corners entirely outside, but some intersections */
2200 x = 0; width = 70;
2201 y = 0; height = 90;
2202 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2203 expect(Ok, status);
2204 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2205
2206 x = 0; width = 70;
2207 y = 0; height = 30;
2208 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2209 expect(Ok, status);
2210 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2211
2212 x = 0; width = 30;
2213 y = 0; height = 90;
2214 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2215 expect(Ok, status);
2216 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2217
2218 /* edge cases */
2219 x = 0; width = 10;
2220 y = 20; height = 40;
2221 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2222 expect(Ok, status);
2223 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2224
2225 x = 10; width = 30;
2226 y = 0; height = 20;
2227 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2228 expect(Ok, status);
2229 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2230
2231 x = 40; width = 10;
2232 y = 20; height = 40;
2233 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2234 expect(Ok, status);
2235 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2236
2237 x = 10; width = 30;
2238 y = 60; height = 10;
2239 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2240 expect(Ok, status);
2241 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2242
2243 /* rounding tests */
2244 x = 0.4; width = 10.4;
2245 y = 20; height = 40;
2246 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2247 expect(Ok, status);
2248 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2249
2250 x = 10; width = 30;
2251 y = 0.4; height = 20.4;
2252 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2253 expect(Ok, status);
2254 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2255
2256 /* integer version */
2257 x = 0; width = 30;
2258 y = 0; height = 90;
2259 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
2260 expect(Ok, status);
2261 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2262
2263 x = 12; width = 10;
2264 y = 22; height = 10;
2265 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
2266 expect(Ok, status);
2267 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2268
2269 GdipDeleteGraphics(graphics);
2270 ReleaseDC(0, hdc);
2271 }
2272
2273 START_TEST(graphics)
2274 {
2275 struct GdiplusStartupInput gdiplusStartupInput;
2276 ULONG_PTR gdiplusToken;
2277
2278 gdiplusStartupInput.GdiplusVersion = 1;
2279 gdiplusStartupInput.DebugEventCallback = NULL;
2280 gdiplusStartupInput.SuppressBackgroundThread = 0;
2281 gdiplusStartupInput.SuppressExternalCodecs = 0;
2282
2283 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2284
2285 test_constructor_destructor();
2286 test_save_restore();
2287 test_GdipDrawBezierI();
2288 test_GdipDrawArc();
2289 test_GdipDrawArcI();
2290 test_GdipDrawCurve();
2291 test_GdipDrawCurveI();
2292 test_GdipDrawCurve2();
2293 test_GdipDrawCurve2I();
2294 test_GdipDrawCurve3();
2295 test_GdipDrawCurve3I();
2296 test_GdipDrawLineI();
2297 test_GdipDrawLinesI();
2298 test_GdipDrawString();
2299 test_GdipGetVisibleClipBounds();
2300 test_GdipIsVisiblePoint();
2301 test_GdipIsVisibleRect();
2302 test_Get_Release_DC();
2303 test_BeginContainer2();
2304 test_transformpoints();
2305 test_get_set_clip();
2306 test_isempty();
2307 test_clear();
2308 test_textcontrast();
2309 test_fromMemoryBitmap();
2310
2311 GdiplusShutdown(gdiplusToken);
2312 }