push 6e61d6ca5bcaf95ac09a664b4ba4f88238c927be
[wine/hacks.git] / dlls / gdiplus / tests / graphics.c
blobb2dc9b299fb9221cbaa30a550f2f76ad7a5bced5
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) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
29 #define TABLE_LEN (23)
31 static void test_constructor_destructor(void)
33 GpStatus stat;
34 GpGraphics *graphics = NULL;
35 HDC hdc = GetDC(0);
37 stat = GdipCreateFromHDC(NULL, &graphics);
38 expect(OutOfMemory, stat);
39 stat = GdipDeleteGraphics(graphics);
40 expect(InvalidParameter, stat);
42 stat = GdipCreateFromHDC(hdc, &graphics);
43 expect(Ok, stat);
44 stat = GdipDeleteGraphics(graphics);
45 expect(Ok, stat);
47 stat = GdipCreateFromHWND(NULL, &graphics);
48 expect(Ok, stat);
49 stat = GdipDeleteGraphics(graphics);
50 expect(Ok, stat);
52 stat = GdipCreateFromHWNDICM(NULL, &graphics);
53 expect(Ok, stat);
54 stat = GdipDeleteGraphics(graphics);
55 expect(Ok, stat);
57 stat = GdipDeleteGraphics(NULL);
58 expect(InvalidParameter, stat);
59 ReleaseDC(0, hdc);
62 typedef struct node{
63 GraphicsState data;
64 struct node * next;
65 } node;
67 /* Linked list prepend function. */
68 static void log_state(GraphicsState data, node ** log)
70 node * new_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(node));
72 new_entry->data = data;
73 new_entry->next = *log;
74 *log = new_entry;
77 /* Checks if there are duplicates in the list, and frees it. */
78 static void check_no_duplicates(node * log)
80 INT dups = 0;
81 node * temp = NULL;
82 node * temp2 = NULL;
83 node * orig = log;
85 if(!log)
86 goto end;
88 do{
89 temp = log;
90 while((temp = temp->next)){
91 if(log->data == temp->data){
92 dups++;
93 break;
95 if(dups > 0)
96 break;
98 }while((log = log->next));
100 temp = orig;
102 temp2 = temp->next;
103 HeapFree(GetProcessHeap(), 0, temp);
104 temp = temp2;
105 }while(temp);
107 end:
108 expect(0, dups);
111 static void test_save_restore(void)
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;
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);
129 log_state(state_a, &state_log);
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);
143 log_state(state_a, &state_log);
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);
162 log_state(state_a, &state_log);
163 log_state(state_b, &state_log);
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);
185 log_state(state_a, &state_log);
186 log_state(state_b, &state_log);
187 log_state(state_c, &state_log);
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);
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);
221 log_state(state_a, &state_log);
223 /* The same state value should never be returned twice. */
224 todo_wine
225 check_no_duplicates(state_log);
227 ReleaseDC(0, hdc);
230 static void test_GdipDrawArc(void)
232 GpStatus status;
233 GpGraphics *graphics = NULL;
234 GpPen *pen = NULL;
235 HDC hdc = GetDC(0);
237 /* make a graphics object and pen object */
238 ok(hdc != NULL, "Expected HDC to be initialized\n");
240 status = GdipCreateFromHDC(hdc, &graphics);
241 expect(Ok, status);
242 ok(graphics != NULL, "Expected graphics to be initialized\n");
244 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
245 expect(Ok, status);
246 ok(pen != NULL, "Expected pen to be initialized\n");
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);
252 status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
253 expect(InvalidParameter, status);
255 status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
256 expect(InvalidParameter, status);
258 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
259 expect(InvalidParameter, status);
261 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
262 expect(InvalidParameter, status);
264 /* successful case */
265 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
266 expect(Ok, status);
268 GdipDeletePen(pen);
269 GdipDeleteGraphics(graphics);
271 ReleaseDC(0, hdc);
274 static void test_GdipDrawArcI(void)
276 GpStatus status;
277 GpGraphics *graphics = NULL;
278 GpPen *pen = NULL;
279 HDC hdc = GetDC(0);
281 /* make a graphics object and pen object */
282 ok(hdc != NULL, "Expected HDC to be initialized\n");
284 status = GdipCreateFromHDC(hdc, &graphics);
285 expect(Ok, status);
286 ok(graphics != NULL, "Expected graphics to be initialized\n");
288 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
289 expect(Ok, status);
290 ok(pen != NULL, "Expected pen to be initialized\n");
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);
296 status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
297 expect(InvalidParameter, status);
299 status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
300 expect(InvalidParameter, status);
302 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
303 expect(InvalidParameter, status);
305 status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
306 expect(InvalidParameter, status);
308 /* successful case */
309 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
310 expect(Ok, status);
312 GdipDeletePen(pen);
313 GdipDeleteGraphics(graphics);
315 ReleaseDC(0, hdc);
318 static void test_BeginContainer2(void)
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;
335 GpStatus status;
336 GpGraphics *graphics = NULL;
337 HDC hdc = GetDC(0);
339 ok(hdc != NULL, "Expected HDC to be initialized\n");
341 status = GdipCreateFromHDC(hdc, &graphics);
342 expect(Ok, status);
343 ok(graphics != NULL, "Expected graphics to be initialized\n");
345 /* null graphics, null container */
346 status = GdipBeginContainer2(NULL, &cont1);
347 expect(InvalidParameter, status);
349 status = GdipBeginContainer2(graphics, NULL);
350 expect(InvalidParameter, status);
352 status = GdipEndContainer(NULL, cont1);
353 expect(InvalidParameter, status);
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);
366 status = GdipBeginContainer2(graphics, &cont1);
367 expect(Ok, status);
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);
379 status = GdipEndContainer(graphics, cont1);
380 expect(Ok, status);
382 GdipGetCompositingMode(graphics, &compmode);
383 ok(defCompmode == compmode, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode, compmode);
385 GdipGetCompositingQuality(graphics, &compqual);
386 ok(defCompqual == compqual, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual, compqual);
388 GdipGetInterpolationMode(graphics, &interp);
389 ok(defInterp == interp, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp, interp);
391 GdipGetPageScale(graphics, &scale);
392 ok(fabs(defScale - scale) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale, scale);
394 GdipGetPageUnit(graphics, &unit);
395 ok(defUnit == unit, "Expected Page Unit to be restored to %d, got %d\n", defUnit, unit);
397 GdipGetPixelOffsetMode(graphics, &offsetmode);
398 ok(defOffsetmode == offsetmode, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode, offsetmode);
400 GdipGetSmoothingMode(graphics, &smoothmode);
401 ok(defSmoothmode == smoothmode, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode, smoothmode);
403 GdipGetTextContrast(graphics, &contrast);
404 ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
406 GdipGetTextRenderingHint(graphics, &texthint);
407 ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
409 /* test world transform */
410 status = GdipBeginContainer2(graphics, &cont1);
411 expect(Ok, status);
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;
419 status = GdipBeginContainer2(graphics, &cont2);
420 expect(Ok, status);
422 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
423 GdipSetWorldTransform(graphics, transform);
424 GdipDeleteMatrix(transform);
425 transform = NULL;
427 status = GdipEndContainer(graphics, cont2);
428 expect(Ok, status);
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;
445 status = GdipEndContainer(graphics, cont1);
446 expect(Ok, status);
448 /* test clipping */
449 status = GdipBeginContainer2(graphics, &cont1);
450 expect(Ok, status);
452 GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace);
454 status = GdipBeginContainer2(graphics, &cont2);
455 expect(Ok, status);
457 GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
459 status = GdipEndContainer(graphics, cont2);
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);
470 status = GdipEndContainer(graphics, cont1);
472 /* nesting */
473 status = GdipBeginContainer2(graphics, &cont1);
474 expect(Ok, status);
476 status = GdipBeginContainer2(graphics, &cont2);
477 expect(Ok, status);
479 status = GdipBeginContainer2(graphics, &cont3);
480 expect(Ok, status);
482 status = GdipEndContainer(graphics, cont3);
483 expect(Ok, status);
485 status = GdipBeginContainer2(graphics, &cont4);
486 expect(Ok, status);
488 status = GdipEndContainer(graphics, cont4);
489 expect(Ok, status);
491 /* skip cont2 */
492 status = GdipEndContainer(graphics, cont1);
493 expect(Ok, status);
495 /* end an already-ended container */
496 status = GdipEndContainer(graphics, cont1);
497 expect(Ok, status);
499 GdipDeleteGraphics(graphics);
500 ReleaseDC(0, hdc);
503 static void test_GdipDrawBezierI(void)
505 GpStatus status;
506 GpGraphics *graphics = NULL;
507 GpPen *pen = NULL;
508 HDC hdc = GetDC(0);
510 /* make a graphics object and pen object */
511 ok(hdc != NULL, "Expected HDC to be initialized\n");
513 status = GdipCreateFromHDC(hdc, &graphics);
514 expect(Ok, status);
515 ok(graphics != NULL, "Expected graphics to be initialized\n");
517 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
518 expect(Ok, status);
519 ok(pen != NULL, "Expected pen to be initialized\n");
521 /* InvalidParameter cases: null graphics, null pen */
522 status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
523 expect(InvalidParameter, status);
525 status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
526 expect(InvalidParameter, status);
528 status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
529 expect(InvalidParameter, status);
531 /* successful case */
532 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
533 expect(Ok, status);
535 GdipDeletePen(pen);
536 GdipDeleteGraphics(graphics);
538 ReleaseDC(0, hdc);
541 static void test_GdipDrawCurve3(void)
543 GpStatus status;
544 GpGraphics *graphics = NULL;
545 GpPen *pen = NULL;
546 HDC hdc = GetDC(0);
547 GpPointF points[3];
549 points[0].X = 0;
550 points[0].Y = 0;
552 points[1].X = 40;
553 points[1].Y = 20;
555 points[2].X = 10;
556 points[2].Y = 40;
558 /* make a graphics object and pen object */
559 ok(hdc != NULL, "Expected HDC to be initialized\n");
561 status = GdipCreateFromHDC(hdc, &graphics);
562 expect(Ok, status);
563 ok(graphics != NULL, "Expected graphics to be initialized\n");
565 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
566 expect(Ok, status);
567 ok(pen != NULL, "Expected pen to be initialized\n");
569 /* InvalidParameter cases: null graphics, null pen */
570 status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1);
571 expect(InvalidParameter, status);
573 status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1);
574 expect(InvalidParameter, status);
576 status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1);
577 expect(InvalidParameter, status);
579 /* InvalidParameter cases: invalid count */
580 status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1);
581 expect(InvalidParameter, status);
583 status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1);
584 expect(InvalidParameter, status);
586 status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1);
587 expect(InvalidParameter, status);
589 status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1);
590 expect(InvalidParameter, status);
592 /* InvalidParameter cases: invalid number of segments */
593 status = GdipDrawCurve3(graphics, pen, points, 3, 0, -1, 1);
594 expect(InvalidParameter, status);
596 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 2, 1);
597 expect(InvalidParameter, status);
599 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 2, 1);
600 expect(InvalidParameter, status);
602 /* Valid test cases */
603 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, 1);
604 expect(Ok, status);
606 status = GdipDrawCurve3(graphics, pen, points, 3, 0, 2, 2);
607 expect(Ok, status);
609 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, -2);
610 expect(Ok, status);
612 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 1, 0);
613 expect(Ok, status);
615 GdipDeletePen(pen);
616 GdipDeleteGraphics(graphics);
618 ReleaseDC(0, hdc);
621 static void test_GdipDrawCurve3I(void)
623 GpStatus status;
624 GpGraphics *graphics = NULL;
625 GpPen *pen = NULL;
626 HDC hdc = GetDC(0);
627 GpPoint points[3];
629 points[0].X = 0;
630 points[0].Y = 0;
632 points[1].X = 40;
633 points[1].Y = 20;
635 points[2].X = 10;
636 points[2].Y = 40;
638 /* make a graphics object and pen object */
639 ok(hdc != NULL, "Expected HDC to be initialized\n");
641 status = GdipCreateFromHDC(hdc, &graphics);
642 expect(Ok, status);
643 ok(graphics != NULL, "Expected graphics to be initialized\n");
645 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
646 expect(Ok, status);
647 ok(pen != NULL, "Expected pen to be initialized\n");
649 /* InvalidParameter cases: null graphics, null pen */
650 status = GdipDrawCurve3I(NULL, NULL, points, 3, 0, 2, 1);
651 expect(InvalidParameter, status);
653 status = GdipDrawCurve3I(graphics, NULL, points, 3, 0, 2, 1);
654 expect(InvalidParameter, status);
656 status = GdipDrawCurve3I(NULL, pen, points, 3, 0, 2, 1);
657 expect(InvalidParameter, status);
659 /* InvalidParameter cases: invalid count */
660 status = GdipDrawCurve3I(graphics, pen, points, -1, -1, -1, 1);
661 expect(OutOfMemory, status);
663 status = GdipDrawCurve3I(graphics, pen, points, 0, 0, 2, 1);
664 expect(InvalidParameter, status);
666 status = GdipDrawCurve3I(graphics, pen, points, 1, 0, 0, 1);
667 expect(InvalidParameter, status);
669 status = GdipDrawCurve3I(graphics, pen, points, 3, 4, 2, 1);
670 expect(InvalidParameter, status);
672 /* InvalidParameter cases: invalid number of segments */
673 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, -1, 1);
674 expect(InvalidParameter, status);
676 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 2, 1);
677 expect(InvalidParameter, status);
679 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 2, 1);
680 expect(InvalidParameter, status);
682 /* Valid test cases */
683 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, 1);
684 expect(Ok, status);
686 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, 2, 2);
687 expect(Ok, status);
689 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, -2);
690 expect(Ok, status);
692 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 1, 0);
693 expect(Ok, status);
695 GdipDeletePen(pen);
696 GdipDeleteGraphics(graphics);
698 ReleaseDC(0, hdc);
701 static void test_GdipDrawCurve2(void)
703 GpStatus status;
704 GpGraphics *graphics = NULL;
705 GpPen *pen = NULL;
706 HDC hdc = GetDC(0);
707 GpPointF points[3];
709 points[0].X = 0;
710 points[0].Y = 0;
712 points[1].X = 40;
713 points[1].Y = 20;
715 points[2].X = 10;
716 points[2].Y = 40;
718 /* make a graphics object and pen object */
719 ok(hdc != NULL, "Expected HDC to be initialized\n");
721 status = GdipCreateFromHDC(hdc, &graphics);
722 expect(Ok, status);
723 ok(graphics != NULL, "Expected graphics to be initialized\n");
725 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
726 expect(Ok, status);
727 ok(pen != NULL, "Expected pen to be initialized\n");
729 /* InvalidParameter cases: null graphics, null pen */
730 status = GdipDrawCurve2(NULL, NULL, points, 3, 1);
731 expect(InvalidParameter, status);
733 status = GdipDrawCurve2(graphics, NULL, points, 3, 1);
734 expect(InvalidParameter, status);
736 status = GdipDrawCurve2(NULL, pen, points, 3, 1);
737 expect(InvalidParameter, status);
739 /* InvalidParameter cases: invalid count */
740 status = GdipDrawCurve2(graphics, pen, points, -1, 1);
741 expect(InvalidParameter, status);
743 status = GdipDrawCurve2(graphics, pen, points, 0, 1);
744 expect(InvalidParameter, status);
746 status = GdipDrawCurve2(graphics, pen, points, 1, 1);
747 expect(InvalidParameter, status);
749 /* Valid test cases */
750 status = GdipDrawCurve2(graphics, pen, points, 2, 1);
751 expect(Ok, status);
753 status = GdipDrawCurve2(graphics, pen, points, 3, 2);
754 expect(Ok, status);
756 status = GdipDrawCurve2(graphics, pen, points, 3, -2);
757 expect(Ok, status);
759 status = GdipDrawCurve2(graphics, pen, points, 3, 0);
760 expect(Ok, status);
762 GdipDeletePen(pen);
763 GdipDeleteGraphics(graphics);
765 ReleaseDC(0, hdc);
768 static void test_GdipDrawCurve2I(void)
770 GpStatus status;
771 GpGraphics *graphics = NULL;
772 GpPen *pen = NULL;
773 HDC hdc = GetDC(0);
774 GpPoint points[3];
776 points[0].X = 0;
777 points[0].Y = 0;
779 points[1].X = 40;
780 points[1].Y = 20;
782 points[2].X = 10;
783 points[2].Y = 40;
785 /* make a graphics object and pen object */
786 ok(hdc != NULL, "Expected HDC to be initialized\n");
788 status = GdipCreateFromHDC(hdc, &graphics);
789 expect(Ok, status);
790 ok(graphics != NULL, "Expected graphics to be initialized\n");
792 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
793 expect(Ok, status);
794 ok(pen != NULL, "Expected pen to be initialized\n");
796 /* InvalidParameter cases: null graphics, null pen */
797 status = GdipDrawCurve2I(NULL, NULL, points, 3, 1);
798 expect(InvalidParameter, status);
800 status = GdipDrawCurve2I(graphics, NULL, points, 3, 1);
801 expect(InvalidParameter, status);
803 status = GdipDrawCurve2I(NULL, pen, points, 3, 1);
804 expect(InvalidParameter, status);
806 /* InvalidParameter cases: invalid count */
807 status = GdipDrawCurve2I(graphics, pen, points, -1, 1);
808 expect(OutOfMemory, status);
810 status = GdipDrawCurve2I(graphics, pen, points, 0, 1);
811 expect(InvalidParameter, status);
813 status = GdipDrawCurve2I(graphics, pen, points, 1, 1);
814 expect(InvalidParameter, status);
816 /* Valid test cases */
817 status = GdipDrawCurve2I(graphics, pen, points, 2, 1);
818 expect(Ok, status);
820 status = GdipDrawCurve2I(graphics, pen, points, 3, 2);
821 expect(Ok, status);
823 status = GdipDrawCurve2I(graphics, pen, points, 3, -2);
824 expect(Ok, status);
826 status = GdipDrawCurve2I(graphics, pen, points, 3, 0);
827 expect(Ok, status);
829 GdipDeletePen(pen);
830 GdipDeleteGraphics(graphics);
832 ReleaseDC(0, hdc);
835 static void test_GdipDrawCurve(void)
837 GpStatus status;
838 GpGraphics *graphics = NULL;
839 GpPen *pen = NULL;
840 HDC hdc = GetDC(0);
841 GpPointF points[3];
843 points[0].X = 0;
844 points[0].Y = 0;
846 points[1].X = 40;
847 points[1].Y = 20;
849 points[2].X = 10;
850 points[2].Y = 40;
852 /* make a graphics object and pen object */
853 ok(hdc != NULL, "Expected HDC to be initialized\n");
855 status = GdipCreateFromHDC(hdc, &graphics);
856 expect(Ok, status);
857 ok(graphics != NULL, "Expected graphics to be initialized\n");
859 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
860 expect(Ok, status);
861 ok(pen != NULL, "Expected pen to be initialized\n");
863 /* InvalidParameter cases: null graphics, null pen */
864 status = GdipDrawCurve(NULL, NULL, points, 3);
865 expect(InvalidParameter, status);
867 status = GdipDrawCurve(graphics, NULL, points, 3);
868 expect(InvalidParameter, status);
870 status = GdipDrawCurve(NULL, pen, points, 3);
871 expect(InvalidParameter, status);
873 /* InvalidParameter cases: invalid count */
874 status = GdipDrawCurve(graphics, pen, points, -1);
875 expect(InvalidParameter, status);
877 status = GdipDrawCurve(graphics, pen, points, 0);
878 expect(InvalidParameter, status);
880 status = GdipDrawCurve(graphics, pen, points, 1);
881 expect(InvalidParameter, status);
883 /* Valid test cases */
884 status = GdipDrawCurve(graphics, pen, points, 2);
885 expect(Ok, status);
887 status = GdipDrawCurve(graphics, pen, points, 3);
888 expect(Ok, status);
890 GdipDeletePen(pen);
891 GdipDeleteGraphics(graphics);
893 ReleaseDC(0, hdc);
896 static void test_GdipDrawCurveI(void)
898 GpStatus status;
899 GpGraphics *graphics = NULL;
900 GpPen *pen = NULL;
901 HDC hdc = GetDC(0);
902 GpPoint points[3];
904 points[0].X = 0;
905 points[0].Y = 0;
907 points[1].X = 40;
908 points[1].Y = 20;
910 points[2].X = 10;
911 points[2].Y = 40;
913 /* make a graphics object and pen object */
914 ok(hdc != NULL, "Expected HDC to be initialized\n");
916 status = GdipCreateFromHDC(hdc, &graphics);
917 expect(Ok, status);
918 ok(graphics != NULL, "Expected graphics to be initialized\n");
920 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
921 expect(Ok, status);
922 ok(pen != NULL, "Expected pen to be initialized\n");
924 /* InvalidParameter cases: null graphics, null pen */
925 status = GdipDrawCurveI(NULL, NULL, points, 3);
926 expect(InvalidParameter, status);
928 status = GdipDrawCurveI(graphics, NULL, points, 3);
929 expect(InvalidParameter, status);
931 status = GdipDrawCurveI(NULL, pen, points, 3);
932 expect(InvalidParameter, status);
934 /* InvalidParameter cases: invalid count */
935 status = GdipDrawCurveI(graphics, pen, points, -1);
936 expect(OutOfMemory, status);
938 status = GdipDrawCurveI(graphics, pen, points, 0);
939 expect(InvalidParameter, status);
941 status = GdipDrawCurveI(graphics, pen, points, 1);
942 expect(InvalidParameter, status);
944 /* Valid test cases */
945 status = GdipDrawCurveI(graphics, pen, points, 2);
946 expect(Ok, status);
948 status = GdipDrawCurveI(graphics, pen, points, 3);
949 expect(Ok, status);
951 GdipDeletePen(pen);
952 GdipDeleteGraphics(graphics);
954 ReleaseDC(0, hdc);
957 static void test_GdipDrawLineI(void)
959 GpStatus status;
960 GpGraphics *graphics = NULL;
961 GpPen *pen = NULL;
962 HDC hdc = GetDC(0);
964 /* make a graphics object and pen object */
965 ok(hdc != NULL, "Expected HDC to be initialized\n");
967 status = GdipCreateFromHDC(hdc, &graphics);
968 expect(Ok, status);
969 ok(graphics != NULL, "Expected graphics to be initialized\n");
971 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
972 expect(Ok, status);
973 ok(pen != NULL, "Expected pen to be initialized\n");
975 /* InvalidParameter cases: null graphics, null pen */
976 status = GdipDrawLineI(NULL, NULL, 0, 0, 0, 0);
977 expect(InvalidParameter, status);
979 status = GdipDrawLineI(graphics, NULL, 0, 0, 0, 0);
980 expect(InvalidParameter, status);
982 status = GdipDrawLineI(NULL, pen, 0, 0, 0, 0);
983 expect(InvalidParameter, status);
985 /* successful case */
986 status = GdipDrawLineI(graphics, pen, 0, 0, 0, 0);
987 expect(Ok, status);
989 GdipDeletePen(pen);
990 GdipDeleteGraphics(graphics);
992 ReleaseDC(0, hdc);
995 static void test_GdipDrawLinesI(void)
997 GpStatus status;
998 GpGraphics *graphics = NULL;
999 GpPen *pen = NULL;
1000 GpPoint *ptf = NULL;
1001 HDC hdc = GetDC(0);
1003 /* make a graphics object and pen object */
1004 ok(hdc != NULL, "Expected HDC to be initialized\n");
1006 status = GdipCreateFromHDC(hdc, &graphics);
1007 expect(Ok, status);
1008 ok(graphics != NULL, "Expected graphics to be initialized\n");
1010 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1011 expect(Ok, status);
1012 ok(pen != NULL, "Expected pen to be initialized\n");
1014 /* make some arbitrary valid points*/
1015 ptf = GdipAlloc(2 * sizeof(GpPointF));
1017 ptf[0].X = 1;
1018 ptf[0].Y = 1;
1020 ptf[1].X = 2;
1021 ptf[1].Y = 2;
1023 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1024 status = GdipDrawLinesI(NULL, NULL, NULL, 0);
1025 expect(InvalidParameter, status);
1027 status = GdipDrawLinesI(graphics, pen, ptf, 0);
1028 expect(InvalidParameter, status);
1030 status = GdipDrawLinesI(graphics, NULL, ptf, 2);
1031 expect(InvalidParameter, status);
1033 status = GdipDrawLinesI(NULL, pen, ptf, 2);
1034 expect(InvalidParameter, status);
1036 /* successful case */
1037 status = GdipDrawLinesI(graphics, pen, ptf, 2);
1038 expect(Ok, status);
1040 GdipFree(ptf);
1041 GdipDeletePen(pen);
1042 GdipDeleteGraphics(graphics);
1044 ReleaseDC(0, hdc);
1047 static void test_Get_Release_DC(void)
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);
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;
1087 for(i = 0; i < 5;i++){
1088 ptf[i].X = (REAL)pt[i].X;
1089 ptf[i].Y = (REAL)pt[i].Y;
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;
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;
1108 GdipCreateMatrix(&m);
1109 GdipCreateRegion(&region);
1110 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1111 GdipCreatePath(FillModeAlternate, &path);
1112 GdipCreateRegion(&clip);
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);
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);
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);
1135 /* Release without Get */
1136 status = GdipReleaseDC(graphics, hdc);
1137 expect(InvalidParameter, status);
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);
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);
1335 status = GdipReleaseDC(graphics, retdc);
1336 expect(Ok, status);
1338 GdipDeletePen(pen);
1339 GdipDeleteGraphics(graphics);
1341 GdipDeleteRegion(clip);
1342 GdipDeletePath(path);
1343 GdipDeleteBrush((GpBrush*)brush);
1344 GdipDeleteRegion(region);
1345 GdipDeleteMatrix(m);
1346 DeleteObject(hrgn);
1348 ReleaseDC(0, hdc);
1351 static void test_transformpoints(void)
1353 GpStatus status;
1354 GpGraphics *graphics = NULL;
1355 HDC hdc = GetDC(0);
1356 GpPointF ptf[2];
1357 GpPoint pt[2];
1359 status = GdipCreateFromHDC(hdc, &graphics);
1360 expect(Ok, status);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
1467 GdipDeleteGraphics(graphics);
1468 ReleaseDC(0, hdc);
1471 static void test_get_set_clip(void)
1473 GpStatus status;
1474 GpGraphics *graphics = NULL;
1475 HDC hdc = GetDC(0);
1476 GpRegion *clip;
1477 GpRectF rect;
1478 BOOL res;
1480 status = GdipCreateFromHDC(hdc, &graphics);
1481 expect(Ok, status);
1483 rect.X = rect.Y = 0.0;
1484 rect.Height = rect.Width = 100.0;
1486 status = GdipCreateRegionRect(&rect, &clip);
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);
1496 status = GdipSetClipRegion(NULL, NULL, CombineModeReplace);
1497 expect(InvalidParameter, status);
1498 status = GdipSetClipRegion(graphics, NULL, CombineModeReplace);
1499 expect(InvalidParameter, status);
1501 status = GdipSetClipPath(NULL, NULL, CombineModeReplace);
1502 expect(InvalidParameter, status);
1503 status = GdipSetClipPath(graphics, NULL, CombineModeReplace);
1504 expect(InvalidParameter, status);
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);
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);
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);
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);
1544 GdipDeleteRegion(clip);
1546 GdipDeleteGraphics(graphics);
1547 ReleaseDC(0, hdc);
1550 static void test_isempty(void)
1552 GpStatus status;
1553 GpGraphics *graphics = NULL;
1554 HDC hdc = GetDC(0);
1555 GpRegion *clip;
1556 BOOL res;
1558 status = GdipCreateFromHDC(hdc, &graphics);
1559 expect(Ok, status);
1561 status = GdipCreateRegion(&clip);
1562 expect(Ok, status);
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);
1572 /* default is infinite */
1573 res = TRUE;
1574 status = GdipIsClipEmpty(graphics, &res);
1575 expect(Ok, status);
1576 expect(FALSE, res);
1578 GdipDeleteRegion(clip);
1580 GdipDeleteGraphics(graphics);
1581 ReleaseDC(0, hdc);
1584 static void test_clear(void)
1586 GpStatus status;
1588 status = GdipGraphicsClear(NULL, 0xdeadbeef);
1589 expect(InvalidParameter, status);
1592 static void test_textcontrast(void)
1594 GpStatus status;
1595 HDC hdc = GetDC(0);
1596 GpGraphics *graphics;
1597 UINT contrast;
1599 status = GdipGetTextContrast(NULL, NULL);
1600 expect(InvalidParameter, status);
1602 status = GdipCreateFromHDC(hdc, &graphics);
1603 expect(Ok, status);
1605 status = GdipGetTextContrast(graphics, NULL);
1606 expect(InvalidParameter, status);
1607 status = GdipGetTextContrast(graphics, &contrast);
1608 expect(4, contrast);
1610 GdipDeleteGraphics(graphics);
1611 ReleaseDC(0, hdc);
1614 static void test_GdipDrawString(void)
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};
1626 memset(&logfont,0,sizeof(logfont));
1627 strcpy(logfont.lfFaceName,"Arial");
1628 logfont.lfHeight = 12;
1629 logfont.lfCharSet = DEFAULT_CHARSET;
1631 status = GdipCreateFromHDC(hdc, &graphics);
1632 expect(Ok, status);
1634 status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
1635 if (status == FileNotFound)
1637 skip("Arial not installed.\n");
1638 return;
1640 expect(Ok, status);
1642 status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
1643 expect(Ok, status);
1645 status = GdipCreateStringFormat(0,0,&format);
1646 expect(Ok, status);
1648 rect.X = 0;
1649 rect.Y = 0;
1650 rect.Width = 0;
1651 rect.Height = 12;
1653 status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
1654 expect(Ok, status);
1656 GdipDeleteGraphics(graphics);
1657 GdipDeleteBrush(brush);
1658 GdipDeleteFont(fnt);
1659 GdipDeleteStringFormat(format);
1661 ReleaseDC(0, hdc);
1664 static void test_GdipGetVisibleClipBounds_screen(void)
1666 GpStatus status;
1667 GpGraphics *graphics = NULL;
1668 HDC hdc = GetDC(0);
1669 GpRectF rectf, exp, clipr;
1670 GpRect recti;
1672 ok(hdc != NULL, "Expected HDC to be initialized\n");
1674 status = GdipCreateFromHDC(hdc, &graphics);
1675 expect(Ok, status);
1676 ok(graphics != NULL, "Expected graphics to be initialized\n");
1678 /* no clipping rect */
1679 exp.X = 0;
1680 exp.Y = 0;
1681 exp.Width = GetDeviceCaps(hdc, HORZRES);
1682 exp.Height = GetDeviceCaps(hdc, VERTRES);
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);
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;
1701 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1702 expect(Ok, status);
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);
1715 /* clipping rect partially outside of screen */
1716 clipr.X = -10;
1717 clipr.Y = -12;
1718 clipr.Width = 20;
1719 clipr.Height = 24;
1721 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1722 expect(Ok, status);
1724 exp.X = 0;
1725 exp.Y = 0;
1726 exp.Width = 10;
1727 exp.Height = 12;
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);
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);
1751 GdipDeleteGraphics(graphics);
1752 ReleaseDC(0, hdc);
1755 static void test_GdipGetVisibleClipBounds_window(void)
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;
1768 window.X = 0;
1769 window.Y = 0;
1770 window.Width = 200;
1771 window.Height = 300;
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);
1785 hwnd = CreateWindow(class.lpszClassName, "ClipboundsTest",
1786 WS_OVERLAPPEDWINDOW, window.X, window.Y, window.Width, window.Height,
1787 NULL, NULL, hInstance, NULL);
1789 ok(hwnd != NULL, "Expected window to be created\n");
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;
1798 hdc = BeginPaint(hwnd, &ps);
1800 status = GdipCreateFromHDC(hdc, &graphics);
1801 expect(Ok, status);
1802 ok(graphics != NULL, "Expected graphics to be initialized\n");
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);
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;
1821 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1822 expect(Ok, status);
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);
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;
1841 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1842 expect(Ok, status);
1844 exp.X = window.Width - 10;
1845 exp.Y = window.Height - 15;
1846 exp.Width = 10;
1847 exp.Height = 15;
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);
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);
1871 GdipDeleteGraphics(graphics);
1872 EndPaint(hwnd, &ps);
1873 DestroyWindow(hwnd);
1876 static void test_GdipGetVisibleClipBounds(void)
1878 GpGraphics* graphics = NULL;
1879 GpRectF rectf;
1880 GpRect rect;
1881 HDC hdc = GetDC(0);
1882 GpStatus status;
1884 status = GdipCreateFromHDC(hdc, &graphics);
1885 expect(Ok, status);
1886 ok(graphics != NULL, "Expected graphics to be initialized\n");
1888 /* test null parameters */
1889 status = GdipGetVisibleClipBounds(graphics, NULL);
1890 expect(InvalidParameter, status);
1892 status = GdipGetVisibleClipBounds(NULL, &rectf);
1893 expect(InvalidParameter, status);
1895 status = GdipGetVisibleClipBoundsI(graphics, NULL);
1896 expect(InvalidParameter, status);
1898 status = GdipGetVisibleClipBoundsI(NULL, &rect);
1899 expect(InvalidParameter, status);
1901 GdipDeleteGraphics(graphics);
1902 ReleaseDC(0, hdc);
1904 test_GdipGetVisibleClipBounds_screen();
1905 test_GdipGetVisibleClipBounds_window();
1908 static void test_fromMemoryBitmap(void)
1910 GpStatus status;
1911 GpGraphics *graphics = NULL;
1912 GpBitmap *bitmap = NULL;
1913 BYTE bits[48] = {0};
1915 status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, bits, &bitmap);
1916 expect(Ok, status);
1918 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
1919 expect(Ok, status);
1921 status = GdipGraphicsClear(graphics, 0xff686868);
1922 expect(Ok, status);
1924 GdipDeleteGraphics(graphics);
1926 /* drawing writes to the memory provided */
1927 todo_wine expect(0x68, bits[10]);
1929 GdipDisposeImage((GpImage*)bitmap);
1932 static void test_GdipIsVisiblePoint(void)
1934 GpStatus status;
1935 GpGraphics *graphics = NULL;
1936 HDC hdc = GetDC(0);
1937 REAL x, y;
1938 BOOL val;
1940 ok(hdc != NULL, "Expected HDC to be initialized\n");
1942 status = GdipCreateFromHDC(hdc, &graphics);
1943 expect(Ok, status);
1944 ok(graphics != NULL, "Expected graphics to be initialized\n");
1946 /* null parameters */
1947 status = GdipIsVisiblePoint(NULL, 0, 0, &val);
1948 expect(InvalidParameter, status);
1950 status = GdipIsVisiblePoint(graphics, 0, 0, NULL);
1951 expect(InvalidParameter, status);
1953 status = GdipIsVisiblePointI(NULL, 0, 0, &val);
1954 expect(InvalidParameter, status);
1956 status = GdipIsVisiblePointI(graphics, 0, 0, NULL);
1957 expect(InvalidParameter, status);
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);
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);
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);
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);
1983 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
1984 expect(Ok, status);
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);
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);
1998 /* translate into the center of the rect */
1999 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
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);
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);
2013 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
2107 GdipDeleteGraphics(graphics);
2108 ReleaseDC(0, hdc);
2111 static void test_GdipIsVisibleRect(void)
2113 GpStatus status;
2114 GpGraphics *graphics = NULL;
2115 HDC hdc = GetDC(0);
2116 REAL x, y, width, height;
2117 BOOL val;
2119 ok(hdc != NULL, "Expected HDC to be initialized\n");
2121 status = GdipCreateFromHDC(hdc, &graphics);
2122 expect(Ok, status);
2123 ok(graphics != NULL, "Expected graphics to be initialized\n");
2125 status = GdipIsVisibleRect(NULL, 0, 0, 0, 0, &val);
2126 expect(InvalidParameter, status);
2128 status = GdipIsVisibleRect(graphics, 0, 0, 0, 0, NULL);
2129 expect(InvalidParameter, status);
2131 status = GdipIsVisibleRectI(NULL, 0, 0, 0, 0, &val);
2132 expect(InvalidParameter, status);
2134 status = GdipIsVisibleRectI(graphics, 0, 0, 0, 0, NULL);
2135 expect(InvalidParameter, status);
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);
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);
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);
2158 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2159 expect(Ok, status);
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);
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);
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);
2182 /* translate into center of clipping rect */
2183 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
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);
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);
2197 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
2269 GdipDeleteGraphics(graphics);
2270 ReleaseDC(0, hdc);
2273 static void test_GdipGetNearestColor(void)
2275 GpStatus status;
2276 GpGraphics *graphics;
2277 GpBitmap *bitmap;
2278 ARGB color = 0xdeadbeef;
2279 HDC hdc = GetDC(0);
2281 /* create a graphics object */
2282 ok(hdc != NULL, "Expected HDC to be initialized\n");
2284 status = GdipCreateFromHDC(hdc, &graphics);
2285 expect(Ok, status);
2286 ok(graphics != NULL, "Expected graphics to be initialized\n");
2288 status = GdipGetNearestColor(graphics, NULL);
2289 expect(InvalidParameter, status);
2291 status = GdipGetNearestColor(NULL, &color);
2292 expect(InvalidParameter, status);
2293 GdipDeleteGraphics(graphics);
2295 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed, NULL, &bitmap);
2296 expect(Ok, status);
2297 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2298 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2299 if (status == Ok)
2301 status = GdipGetNearestColor(graphics, &color);
2302 expect(Ok, status);
2303 expect(0xdeadbeef, color);
2304 GdipDeleteGraphics(graphics);
2306 GdipDisposeImage((GpImage*)bitmap);
2308 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed, NULL, &bitmap);
2309 expect(Ok, status);
2310 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2311 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2312 if (status == Ok)
2314 status = GdipGetNearestColor(graphics, &color);
2315 expect(Ok, status);
2316 expect(0xdeadbeef, color);
2317 GdipDeleteGraphics(graphics);
2319 GdipDisposeImage((GpImage*)bitmap);
2321 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed, NULL, &bitmap);
2322 expect(Ok, status);
2323 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2324 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2325 if (status == Ok)
2327 status = GdipGetNearestColor(graphics, &color);
2328 expect(Ok, status);
2329 expect(0xdeadbeef, color);
2330 GdipDeleteGraphics(graphics);
2332 GdipDisposeImage((GpImage*)bitmap);
2334 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale, NULL, &bitmap);
2335 expect(Ok, status);
2336 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2337 todo_wine expect(OutOfMemory, status);
2338 if (status == Ok)
2339 GdipDeleteGraphics(graphics);
2340 GdipDisposeImage((GpImage*)bitmap);
2342 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bitmap);
2343 expect(Ok, status);
2344 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2345 expect(Ok, status);
2346 status = GdipGetNearestColor(graphics, &color);
2347 expect(Ok, status);
2348 expect(0xdeadbeef, color);
2349 GdipDeleteGraphics(graphics);
2350 GdipDisposeImage((GpImage*)bitmap);
2352 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB, NULL, &bitmap);
2353 expect(Ok, status);
2354 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2355 expect(Ok, status);
2356 status = GdipGetNearestColor(graphics, &color);
2357 expect(Ok, status);
2358 expect(0xdeadbeef, color);
2359 GdipDeleteGraphics(graphics);
2360 GdipDisposeImage((GpImage*)bitmap);
2362 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB, NULL, &bitmap);
2363 expect(Ok, status);
2364 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2365 expect(Ok, status);
2366 status = GdipGetNearestColor(graphics, &color);
2367 expect(Ok, status);
2368 expect(0xdeadbeef, color);
2369 GdipDeleteGraphics(graphics);
2370 GdipDisposeImage((GpImage*)bitmap);
2372 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap);
2373 expect(Ok, status);
2374 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2375 expect(Ok, status);
2376 status = GdipGetNearestColor(graphics, &color);
2377 expect(Ok, status);
2378 expect(0xdeadbeef, color);
2379 GdipDeleteGraphics(graphics);
2380 GdipDisposeImage((GpImage*)bitmap);
2382 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap);
2383 expect(Ok, status);
2384 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2385 expect(Ok, status);
2386 status = GdipGetNearestColor(graphics, &color);
2387 expect(Ok, status);
2388 expect(0xdeadbeef, color);
2389 GdipDeleteGraphics(graphics);
2390 GdipDisposeImage((GpImage*)bitmap);
2392 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap);
2393 expect(Ok, status);
2394 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2395 expect(Ok, status);
2396 status = GdipGetNearestColor(graphics, &color);
2397 expect(Ok, status);
2398 expect(0xdeadbeef, color);
2399 GdipDeleteGraphics(graphics);
2400 GdipDisposeImage((GpImage*)bitmap);
2402 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap);
2403 expect(Ok, status);
2404 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2405 expect(Ok, status);
2406 status = GdipGetNearestColor(graphics, &color);
2407 expect(Ok, status);
2408 todo_wine expect(0xffa8bce8, color);
2409 GdipDeleteGraphics(graphics);
2410 GdipDisposeImage((GpImage*)bitmap);
2412 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555, NULL, &bitmap);
2413 expect(Ok, status);
2414 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2415 expect(Ok, status);
2416 status = GdipGetNearestColor(graphics, &color);
2417 expect(Ok, status);
2418 todo_wine expect(0xffa8b8e8, color);
2419 GdipDeleteGraphics(graphics);
2420 GdipDisposeImage((GpImage*)bitmap);
2422 ReleaseDC(0, hdc);
2425 START_TEST(graphics)
2427 struct GdiplusStartupInput gdiplusStartupInput;
2428 ULONG_PTR gdiplusToken;
2430 gdiplusStartupInput.GdiplusVersion = 1;
2431 gdiplusStartupInput.DebugEventCallback = NULL;
2432 gdiplusStartupInput.SuppressBackgroundThread = 0;
2433 gdiplusStartupInput.SuppressExternalCodecs = 0;
2435 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2437 test_constructor_destructor();
2438 test_save_restore();
2439 test_GdipDrawBezierI();
2440 test_GdipDrawArc();
2441 test_GdipDrawArcI();
2442 test_GdipDrawCurve();
2443 test_GdipDrawCurveI();
2444 test_GdipDrawCurve2();
2445 test_GdipDrawCurve2I();
2446 test_GdipDrawCurve3();
2447 test_GdipDrawCurve3I();
2448 test_GdipDrawLineI();
2449 test_GdipDrawLinesI();
2450 test_GdipDrawString();
2451 test_GdipGetNearestColor();
2452 test_GdipGetVisibleClipBounds();
2453 test_GdipIsVisiblePoint();
2454 test_GdipIsVisibleRect();
2455 test_Get_Release_DC();
2456 test_BeginContainer2();
2457 test_transformpoints();
2458 test_get_set_clip();
2459 test_isempty();
2460 test_clear();
2461 test_textcontrast();
2462 test_fromMemoryBitmap();
2464 GdiplusShutdown(gdiplusToken);