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
24 #include "wine/test.h"
27 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
28 #define expectf_(expected, got, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
29 #define expectf(expected, got) expectf_(expected, got, 0.0001)
30 #define TABLE_LEN (23)
34 static void test_constructor_destructor(void)
37 GpGraphics
*graphics
= NULL
;
38 HDC hdc
= GetDC( hwnd
);
40 stat
= GdipCreateFromHDC(NULL
, &graphics
);
41 expect(OutOfMemory
, stat
);
42 stat
= GdipDeleteGraphics(graphics
);
43 expect(InvalidParameter
, stat
);
45 stat
= GdipCreateFromHDC(hdc
, &graphics
);
47 stat
= GdipDeleteGraphics(graphics
);
50 stat
= GdipCreateFromHWND(NULL
, &graphics
);
52 stat
= GdipDeleteGraphics(graphics
);
55 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
57 stat
= GdipDeleteGraphics(graphics
);
60 stat
= GdipDeleteGraphics(NULL
);
61 expect(InvalidParameter
, stat
);
70 /* Linked list prepend function. */
71 static void log_state(GraphicsState data
, node
** log
)
73 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
75 new_entry
->data
= data
;
76 new_entry
->next
= *log
;
80 /* Checks if there are duplicates in the list, and frees it. */
81 static void check_no_duplicates(node
* log
)
93 while((temp
= temp
->next
)){
94 if(log
->data
== temp
->data
){
101 }while((log
= log
->next
));
106 HeapFree(GetProcessHeap(), 0, temp
);
114 static void test_save_restore(void)
117 GraphicsState state_a
, state_b
, state_c
;
118 InterpolationMode mode
;
119 GpGraphics
*graphics1
, *graphics2
;
120 node
* state_log
= NULL
;
121 HDC hdc
= GetDC( hwnd
);
122 state_a
= state_b
= state_c
= 0xdeadbeef;
124 /* Invalid saving. */
125 GdipCreateFromHDC(hdc
, &graphics1
);
126 stat
= GdipSaveGraphics(graphics1
, NULL
);
127 expect(InvalidParameter
, stat
);
128 stat
= GdipSaveGraphics(NULL
, &state_a
);
129 expect(InvalidParameter
, stat
);
130 GdipDeleteGraphics(graphics1
);
132 log_state(state_a
, &state_log
);
134 /* Basic save/restore. */
135 GdipCreateFromHDC(hdc
, &graphics1
);
136 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
137 stat
= GdipSaveGraphics(graphics1
, &state_a
);
139 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
140 stat
= GdipRestoreGraphics(graphics1
, state_a
);
142 GdipGetInterpolationMode(graphics1
, &mode
);
143 expect(InterpolationModeBilinear
, mode
);
144 GdipDeleteGraphics(graphics1
);
146 log_state(state_a
, &state_log
);
148 /* Restoring garbage doesn't affect saves. */
149 GdipCreateFromHDC(hdc
, &graphics1
);
150 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
151 GdipSaveGraphics(graphics1
, &state_a
);
152 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
153 GdipSaveGraphics(graphics1
, &state_b
);
154 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
155 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
157 GdipRestoreGraphics(graphics1
, state_b
);
158 GdipGetInterpolationMode(graphics1
, &mode
);
159 expect(InterpolationModeBicubic
, mode
);
160 GdipRestoreGraphics(graphics1
, state_a
);
161 GdipGetInterpolationMode(graphics1
, &mode
);
162 expect(InterpolationModeBilinear
, mode
);
163 GdipDeleteGraphics(graphics1
);
165 log_state(state_a
, &state_log
);
166 log_state(state_b
, &state_log
);
168 /* Restoring older state invalidates newer saves (but not older saves). */
169 GdipCreateFromHDC(hdc
, &graphics1
);
170 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
171 GdipSaveGraphics(graphics1
, &state_a
);
172 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
173 GdipSaveGraphics(graphics1
, &state_b
);
174 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
175 GdipSaveGraphics(graphics1
, &state_c
);
176 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
177 GdipRestoreGraphics(graphics1
, state_b
);
178 GdipGetInterpolationMode(graphics1
, &mode
);
179 expect(InterpolationModeBicubic
, mode
);
180 GdipRestoreGraphics(graphics1
, state_c
);
181 GdipGetInterpolationMode(graphics1
, &mode
);
182 expect(InterpolationModeBicubic
, mode
);
183 GdipRestoreGraphics(graphics1
, state_a
);
184 GdipGetInterpolationMode(graphics1
, &mode
);
185 expect(InterpolationModeBilinear
, mode
);
186 GdipDeleteGraphics(graphics1
);
188 log_state(state_a
, &state_log
);
189 log_state(state_b
, &state_log
);
190 log_state(state_c
, &state_log
);
192 /* Restoring older save from one graphics object does not invalidate
193 * newer save from other graphics object. */
194 GdipCreateFromHDC(hdc
, &graphics1
);
195 GdipCreateFromHDC(hdc
, &graphics2
);
196 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
197 GdipSaveGraphics(graphics1
, &state_a
);
198 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
199 GdipSaveGraphics(graphics2
, &state_b
);
200 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
201 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
202 GdipRestoreGraphics(graphics1
, state_a
);
203 GdipGetInterpolationMode(graphics1
, &mode
);
204 expect(InterpolationModeBilinear
, mode
);
205 GdipRestoreGraphics(graphics2
, state_b
);
206 GdipGetInterpolationMode(graphics2
, &mode
);
207 expect(InterpolationModeBicubic
, mode
);
208 GdipDeleteGraphics(graphics1
);
209 GdipDeleteGraphics(graphics2
);
211 /* You can't restore a state to a graphics object that didn't save it. */
212 GdipCreateFromHDC(hdc
, &graphics1
);
213 GdipCreateFromHDC(hdc
, &graphics2
);
214 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
215 GdipSaveGraphics(graphics1
, &state_a
);
216 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
217 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
218 GdipRestoreGraphics(graphics2
, state_a
);
219 GdipGetInterpolationMode(graphics2
, &mode
);
220 expect(InterpolationModeNearestNeighbor
, mode
);
221 GdipDeleteGraphics(graphics1
);
222 GdipDeleteGraphics(graphics2
);
224 log_state(state_a
, &state_log
);
226 /* The same state value should never be returned twice. */
228 check_no_duplicates(state_log
);
230 ReleaseDC(hwnd
, hdc
);
233 static void test_GdipFillClosedCurve2(void)
236 GpGraphics
*graphics
= NULL
;
237 GpSolidFill
*brush
= NULL
;
238 HDC hdc
= GetDC( hwnd
);
250 /* make a graphics object and brush object */
251 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
253 status
= GdipCreateFromHDC(hdc
, &graphics
);
255 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
257 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
259 /* InvalidParameter cases: null graphics, null brush, null points */
260 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
261 expect(InvalidParameter
, status
);
263 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
264 expect(InvalidParameter
, status
);
266 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
267 expect(InvalidParameter
, status
);
269 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
270 expect(InvalidParameter
, status
);
272 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
273 expect(InvalidParameter
, status
);
275 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
276 expect(InvalidParameter
, status
);
278 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
279 expect(InvalidParameter
, status
);
281 /* InvalidParameter cases: invalid count */
282 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
283 expect(InvalidParameter
, status
);
285 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
286 expect(InvalidParameter
, status
);
288 /* Valid test cases */
289 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
292 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
295 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
298 GdipDeleteGraphics(graphics
);
299 GdipDeleteBrush((GpBrush
*)brush
);
301 ReleaseDC(hwnd
, hdc
);
304 static void test_GdipFillClosedCurve2I(void)
307 GpGraphics
*graphics
= NULL
;
308 GpSolidFill
*brush
= NULL
;
309 HDC hdc
= GetDC( hwnd
);
321 /* make a graphics object and brush object */
322 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
324 status
= GdipCreateFromHDC(hdc
, &graphics
);
326 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
328 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
330 /* InvalidParameter cases: null graphics, null brush */
331 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
332 when points == NULL, so don't test this condition */
333 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
334 expect(InvalidParameter
, status
);
336 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
337 expect(InvalidParameter
, status
);
339 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
340 expect(InvalidParameter
, status
);
342 /* InvalidParameter cases: invalid count */
343 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
344 expect(InvalidParameter
, status
);
346 /* OutOfMemory cases: large (unsigned) int */
347 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
348 expect(OutOfMemory
, status
);
350 /* Valid test cases */
351 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
354 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
357 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
360 GdipDeleteGraphics(graphics
);
361 GdipDeleteBrush((GpBrush
*)brush
);
363 ReleaseDC(hwnd
, hdc
);
366 static void test_GdipDrawArc(void)
369 GpGraphics
*graphics
= NULL
;
371 HDC hdc
= GetDC( hwnd
);
373 /* make a graphics object and pen object */
374 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
376 status
= GdipCreateFromHDC(hdc
, &graphics
);
378 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
380 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
382 ok(pen
!= NULL
, "Expected pen to be initialized\n");
384 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
385 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
386 expect(InvalidParameter
, status
);
388 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
389 expect(InvalidParameter
, status
);
391 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
392 expect(InvalidParameter
, status
);
394 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
395 expect(InvalidParameter
, status
);
397 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
398 expect(InvalidParameter
, status
);
400 /* successful case */
401 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
405 GdipDeleteGraphics(graphics
);
407 ReleaseDC(hwnd
, hdc
);
410 static void test_GdipDrawArcI(void)
413 GpGraphics
*graphics
= NULL
;
415 HDC hdc
= GetDC( hwnd
);
417 /* make a graphics object and pen object */
418 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
420 status
= GdipCreateFromHDC(hdc
, &graphics
);
422 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
424 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
426 ok(pen
!= NULL
, "Expected pen to be initialized\n");
428 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
429 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
430 expect(InvalidParameter
, status
);
432 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
433 expect(InvalidParameter
, status
);
435 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
436 expect(InvalidParameter
, status
);
438 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
439 expect(InvalidParameter
, status
);
441 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
442 expect(InvalidParameter
, status
);
444 /* successful case */
445 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
449 GdipDeleteGraphics(graphics
);
451 ReleaseDC(hwnd
, hdc
);
454 static void test_BeginContainer2(void)
458 REAL defClip
[] = {5, 10, 15, 20};
459 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
460 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
461 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
462 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
463 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
464 REAL scale
, defScale
= 17;
465 GpUnit unit
, defUnit
= UnitPixel
;
466 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
467 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
468 UINT contrast
, defContrast
= 5;
469 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
472 GpGraphics
*graphics
= NULL
;
473 HDC hdc
= GetDC( hwnd
);
475 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
477 status
= GdipCreateFromHDC(hdc
, &graphics
);
479 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
481 /* null graphics, null container */
482 status
= GdipBeginContainer2(NULL
, &cont1
);
483 expect(InvalidParameter
, status
);
485 status
= GdipBeginContainer2(graphics
, NULL
);
486 expect(InvalidParameter
, status
);
488 status
= GdipEndContainer(NULL
, cont1
);
489 expect(InvalidParameter
, status
);
491 /* test all quality-related values */
492 GdipSetCompositingMode(graphics
, defCompmode
);
493 GdipSetCompositingQuality(graphics
, defCompqual
);
494 GdipSetInterpolationMode(graphics
, defInterp
);
495 GdipSetPageScale(graphics
, defScale
);
496 GdipSetPageUnit(graphics
, defUnit
);
497 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
498 GdipSetSmoothingMode(graphics
, defSmoothmode
);
499 GdipSetTextContrast(graphics
, defContrast
);
500 GdipSetTextRenderingHint(graphics
, defTexthint
);
502 status
= GdipBeginContainer2(graphics
, &cont1
);
505 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
506 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
507 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
508 GdipSetPageScale(graphics
, 10);
509 GdipSetPageUnit(graphics
, UnitDocument
);
510 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
511 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
512 GdipSetTextContrast(graphics
, 7);
513 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
515 status
= GdipEndContainer(graphics
, cont1
);
518 GdipGetCompositingMode(graphics
, &compmode
);
519 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
521 GdipGetCompositingQuality(graphics
, &compqual
);
522 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
524 GdipGetInterpolationMode(graphics
, &interp
);
525 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
527 GdipGetPageScale(graphics
, &scale
);
528 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
530 GdipGetPageUnit(graphics
, &unit
);
531 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
533 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
534 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
536 GdipGetSmoothingMode(graphics
, &smoothmode
);
537 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
539 GdipGetTextContrast(graphics
, &contrast
);
540 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
542 GdipGetTextRenderingHint(graphics
, &texthint
);
543 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
545 /* test world transform */
546 status
= GdipBeginContainer2(graphics
, &cont1
);
549 GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
550 defTrans
[4], defTrans
[5], &transform
);
551 GdipSetWorldTransform(graphics
, transform
);
552 GdipDeleteMatrix(transform
);
555 status
= GdipBeginContainer2(graphics
, &cont2
);
558 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
559 GdipSetWorldTransform(graphics
, transform
);
560 GdipDeleteMatrix(transform
);
563 status
= GdipEndContainer(graphics
, cont2
);
566 GdipCreateMatrix(&transform
);
567 GdipGetWorldTransform(graphics
, transform
);
568 GdipGetMatrixElements(transform
, elems
);
569 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
570 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
571 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
572 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
573 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
574 fabs(defTrans
[5] - elems
[5]) < 0.0001,
575 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
576 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
577 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
578 GdipDeleteMatrix(transform
);
581 status
= GdipEndContainer(graphics
, cont1
);
585 status
= GdipBeginContainer2(graphics
, &cont1
);
588 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
590 status
= GdipBeginContainer2(graphics
, &cont2
);
593 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
595 status
= GdipEndContainer(graphics
, cont2
);
598 GdipGetClipBounds(graphics
, &clip
);
599 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
600 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
601 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
602 fabs(defClip
[3] - clip
.Height
) < 0.0001,
603 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
604 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
605 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
607 status
= GdipEndContainer(graphics
, cont1
);
611 status
= GdipBeginContainer2(graphics
, &cont1
);
614 status
= GdipBeginContainer2(graphics
, &cont2
);
617 status
= GdipBeginContainer2(graphics
, &cont3
);
620 status
= GdipEndContainer(graphics
, cont3
);
623 status
= GdipBeginContainer2(graphics
, &cont4
);
626 status
= GdipEndContainer(graphics
, cont4
);
630 status
= GdipEndContainer(graphics
, cont1
);
633 /* end an already-ended container */
634 status
= GdipEndContainer(graphics
, cont1
);
637 GdipDeleteGraphics(graphics
);
638 ReleaseDC(hwnd
, hdc
);
641 static void test_GdipDrawBezierI(void)
644 GpGraphics
*graphics
= NULL
;
646 HDC hdc
= GetDC( hwnd
);
648 /* make a graphics object and pen object */
649 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
651 status
= GdipCreateFromHDC(hdc
, &graphics
);
653 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
655 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
657 ok(pen
!= NULL
, "Expected pen to be initialized\n");
659 /* InvalidParameter cases: null graphics, null pen */
660 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
661 expect(InvalidParameter
, status
);
663 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
664 expect(InvalidParameter
, status
);
666 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
667 expect(InvalidParameter
, status
);
669 /* successful case */
670 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
674 GdipDeleteGraphics(graphics
);
676 ReleaseDC(hwnd
, hdc
);
679 static void test_GdipDrawCurve3(void)
682 GpGraphics
*graphics
= NULL
;
684 HDC hdc
= GetDC( hwnd
);
696 /* make a graphics object and pen object */
697 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
699 status
= GdipCreateFromHDC(hdc
, &graphics
);
701 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
703 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
705 ok(pen
!= NULL
, "Expected pen to be initialized\n");
707 /* InvalidParameter cases: null graphics, null pen */
708 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
709 expect(InvalidParameter
, status
);
711 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
712 expect(InvalidParameter
, status
);
714 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
715 expect(InvalidParameter
, status
);
717 /* InvalidParameter cases: invalid count */
718 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
719 expect(InvalidParameter
, status
);
721 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
722 expect(InvalidParameter
, status
);
724 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
725 expect(InvalidParameter
, status
);
727 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
728 expect(InvalidParameter
, status
);
730 /* InvalidParameter cases: invalid number of segments */
731 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
732 expect(InvalidParameter
, status
);
734 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
735 expect(InvalidParameter
, status
);
737 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
738 expect(InvalidParameter
, status
);
740 /* Valid test cases */
741 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
744 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
747 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
750 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
754 GdipDeleteGraphics(graphics
);
756 ReleaseDC(hwnd
, hdc
);
759 static void test_GdipDrawCurve3I(void)
762 GpGraphics
*graphics
= NULL
;
764 HDC hdc
= GetDC( hwnd
);
776 /* make a graphics object and pen object */
777 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
779 status
= GdipCreateFromHDC(hdc
, &graphics
);
781 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
783 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
785 ok(pen
!= NULL
, "Expected pen to be initialized\n");
787 /* InvalidParameter cases: null graphics, null pen */
788 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
789 expect(InvalidParameter
, status
);
791 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
792 expect(InvalidParameter
, status
);
794 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
795 expect(InvalidParameter
, status
);
797 /* InvalidParameter cases: invalid count */
798 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
799 expect(OutOfMemory
, status
);
801 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
802 expect(InvalidParameter
, status
);
804 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
805 expect(InvalidParameter
, status
);
807 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
808 expect(InvalidParameter
, status
);
810 /* InvalidParameter cases: invalid number of segments */
811 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
812 expect(InvalidParameter
, status
);
814 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
815 expect(InvalidParameter
, status
);
817 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
818 expect(InvalidParameter
, status
);
820 /* Valid test cases */
821 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
824 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
827 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
830 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
834 GdipDeleteGraphics(graphics
);
836 ReleaseDC(hwnd
, hdc
);
839 static void test_GdipDrawCurve2(void)
842 GpGraphics
*graphics
= NULL
;
844 HDC hdc
= GetDC( hwnd
);
856 /* make a graphics object and pen object */
857 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
859 status
= GdipCreateFromHDC(hdc
, &graphics
);
861 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
863 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
865 ok(pen
!= NULL
, "Expected pen to be initialized\n");
867 /* InvalidParameter cases: null graphics, null pen */
868 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
869 expect(InvalidParameter
, status
);
871 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
872 expect(InvalidParameter
, status
);
874 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
875 expect(InvalidParameter
, status
);
877 /* InvalidParameter cases: invalid count */
878 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
879 expect(InvalidParameter
, status
);
881 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
882 expect(InvalidParameter
, status
);
884 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
885 expect(InvalidParameter
, status
);
887 /* Valid test cases */
888 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
891 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
894 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
897 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
901 GdipDeleteGraphics(graphics
);
903 ReleaseDC(hwnd
, hdc
);
906 static void test_GdipDrawCurve2I(void)
909 GpGraphics
*graphics
= NULL
;
911 HDC hdc
= GetDC( hwnd
);
923 /* make a graphics object and pen object */
924 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
926 status
= GdipCreateFromHDC(hdc
, &graphics
);
928 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
930 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
932 ok(pen
!= NULL
, "Expected pen to be initialized\n");
934 /* InvalidParameter cases: null graphics, null pen */
935 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
936 expect(InvalidParameter
, status
);
938 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
939 expect(InvalidParameter
, status
);
941 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
942 expect(InvalidParameter
, status
);
944 /* InvalidParameter cases: invalid count */
945 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
946 expect(OutOfMemory
, status
);
948 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
949 expect(InvalidParameter
, status
);
951 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
952 expect(InvalidParameter
, status
);
954 /* Valid test cases */
955 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
958 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
961 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
964 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
968 GdipDeleteGraphics(graphics
);
970 ReleaseDC(hwnd
, hdc
);
973 static void test_GdipDrawCurve(void)
976 GpGraphics
*graphics
= NULL
;
978 HDC hdc
= GetDC( hwnd
);
990 /* make a graphics object and pen object */
991 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
993 status
= GdipCreateFromHDC(hdc
, &graphics
);
995 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
997 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
999 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1001 /* InvalidParameter cases: null graphics, null pen */
1002 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1003 expect(InvalidParameter
, status
);
1005 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1006 expect(InvalidParameter
, status
);
1008 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1009 expect(InvalidParameter
, status
);
1011 /* InvalidParameter cases: invalid count */
1012 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1013 expect(InvalidParameter
, status
);
1015 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1016 expect(InvalidParameter
, status
);
1018 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1019 expect(InvalidParameter
, status
);
1021 /* Valid test cases */
1022 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1025 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1029 GdipDeleteGraphics(graphics
);
1031 ReleaseDC(hwnd
, hdc
);
1034 static void test_GdipDrawCurveI(void)
1037 GpGraphics
*graphics
= NULL
;
1039 HDC hdc
= GetDC( hwnd
);
1051 /* make a graphics object and pen object */
1052 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1054 status
= GdipCreateFromHDC(hdc
, &graphics
);
1056 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1058 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1060 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1062 /* InvalidParameter cases: null graphics, null pen */
1063 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1064 expect(InvalidParameter
, status
);
1066 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1067 expect(InvalidParameter
, status
);
1069 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1070 expect(InvalidParameter
, status
);
1072 /* InvalidParameter cases: invalid count */
1073 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1074 expect(OutOfMemory
, status
);
1076 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1077 expect(InvalidParameter
, status
);
1079 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1080 expect(InvalidParameter
, status
);
1082 /* Valid test cases */
1083 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1086 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1090 GdipDeleteGraphics(graphics
);
1092 ReleaseDC(hwnd
, hdc
);
1095 static void test_GdipDrawLineI(void)
1098 GpGraphics
*graphics
= NULL
;
1100 HDC hdc
= GetDC( hwnd
);
1102 /* make a graphics object and pen object */
1103 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1105 status
= GdipCreateFromHDC(hdc
, &graphics
);
1107 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1109 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1111 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1113 /* InvalidParameter cases: null graphics, null pen */
1114 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1115 expect(InvalidParameter
, status
);
1117 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1118 expect(InvalidParameter
, status
);
1120 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1121 expect(InvalidParameter
, status
);
1123 /* successful case */
1124 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1128 GdipDeleteGraphics(graphics
);
1130 ReleaseDC(hwnd
, hdc
);
1133 static void test_GdipDrawImagePointsRect(void)
1136 GpGraphics
*graphics
= NULL
;
1138 GpBitmap
*bm
= NULL
;
1139 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1141 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1142 HDC hdc
= GetDC( hwnd
);
1146 memset(rbmi
, 0, sizeof(rbmi
));
1147 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1148 bmi
->bmiHeader
.biWidth
= 10;
1149 bmi
->bmiHeader
.biHeight
= 10;
1150 bmi
->bmiHeader
.biPlanes
= 1;
1151 bmi
->bmiHeader
.biBitCount
= 32;
1152 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1153 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1155 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1156 status
= GdipCreateFromHDC(hdc
, &graphics
);
1166 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1167 expect(NotImplemented
, status
);
1168 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1169 expect(InvalidParameter
, status
);
1170 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1172 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1173 expect(InvalidParameter
, status
);
1174 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1175 expect(InvalidParameter
, status
);
1176 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1178 memset(ptf
, 0, sizeof(ptf
));
1179 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1182 GdipDisposeImage((GpImage
*)bm
);
1183 GdipDeleteGraphics(graphics
);
1184 ReleaseDC(hwnd
, hdc
);
1187 static void test_GdipDrawLinesI(void)
1190 GpGraphics
*graphics
= NULL
;
1192 GpPoint
*ptf
= NULL
;
1193 HDC hdc
= GetDC( hwnd
);
1195 /* make a graphics object and pen object */
1196 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1198 status
= GdipCreateFromHDC(hdc
, &graphics
);
1200 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1202 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1204 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1206 /* make some arbitrary valid points*/
1207 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1215 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1216 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1217 expect(InvalidParameter
, status
);
1219 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1220 expect(InvalidParameter
, status
);
1222 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1223 expect(InvalidParameter
, status
);
1225 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1226 expect(InvalidParameter
, status
);
1228 /* successful case */
1229 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1234 GdipDeleteGraphics(graphics
);
1236 ReleaseDC(hwnd
, hdc
);
1239 static void test_GdipFillClosedCurve(void)
1242 GpGraphics
*graphics
= NULL
;
1243 GpSolidFill
*brush
= NULL
;
1244 HDC hdc
= GetDC( hwnd
);
1256 /* make a graphics object and brush object */
1257 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1259 status
= GdipCreateFromHDC(hdc
, &graphics
);
1261 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1263 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1265 /* InvalidParameter cases: null graphics, null brush, null points */
1266 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1267 expect(InvalidParameter
, status
);
1269 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1270 expect(InvalidParameter
, status
);
1272 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1273 expect(InvalidParameter
, status
);
1275 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1276 expect(InvalidParameter
, status
);
1278 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1279 expect(InvalidParameter
, status
);
1281 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1282 expect(InvalidParameter
, status
);
1284 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1285 expect(InvalidParameter
, status
);
1287 /* InvalidParameter cases: invalid count */
1288 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1289 expect(InvalidParameter
, status
);
1291 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1292 expect(InvalidParameter
, status
);
1294 /* Valid test cases */
1295 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1298 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1301 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1304 GdipDeleteGraphics(graphics
);
1305 GdipDeleteBrush((GpBrush
*)brush
);
1307 ReleaseDC(hwnd
, hdc
);
1310 static void test_GdipFillClosedCurveI(void)
1313 GpGraphics
*graphics
= NULL
;
1314 GpSolidFill
*brush
= NULL
;
1315 HDC hdc
= GetDC( hwnd
);
1327 /* make a graphics object and brush object */
1328 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1330 status
= GdipCreateFromHDC(hdc
, &graphics
);
1332 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1334 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1336 /* InvalidParameter cases: null graphics, null brush */
1337 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1338 when points == NULL, so don't test this condition */
1339 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1340 expect(InvalidParameter
, status
);
1342 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1343 expect(InvalidParameter
, status
);
1345 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1346 expect(InvalidParameter
, status
);
1348 /* InvalidParameter cases: invalid count */
1349 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1350 expect(InvalidParameter
, status
);
1352 /* OutOfMemory cases: large (unsigned) int */
1353 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1354 expect(OutOfMemory
, status
);
1356 /* Valid test cases */
1357 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1360 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1363 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1366 GdipDeleteGraphics(graphics
);
1367 GdipDeleteBrush((GpBrush
*)brush
);
1369 ReleaseDC(hwnd
, hdc
);
1372 static void test_Get_Release_DC(void)
1375 GpGraphics
*graphics
= NULL
;
1379 HDC hdc
= GetDC( hwnd
);
1382 CompositingQuality quality
;
1383 CompositingMode compmode
;
1384 InterpolationMode intmode
;
1388 PixelOffsetMode offsetmode
;
1389 SmoothingMode smoothmode
;
1390 TextRenderingHint texthint
;
1398 ARGB color
= 0x00000000;
1399 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1412 for(i
= 0; i
< 5;i
++){
1413 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1414 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1420 rect
[0].Height
= 70;
1424 rect
[1].Height
= 20;
1426 for(i
= 0; i
< 2;i
++){
1427 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1428 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1429 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1430 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1433 GdipCreateMatrix(&m
);
1434 GdipCreateRegion(®ion
);
1435 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1436 GdipCreatePath(FillModeAlternate
, &path
);
1437 GdipCreateRegion(&clip
);
1439 status
= GdipCreateFromHDC(hdc
, &graphics
);
1441 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1442 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1445 /* NULL arguments */
1446 status
= GdipGetDC(NULL
, NULL
);
1447 expect(InvalidParameter
, status
);
1448 status
= GdipGetDC(graphics
, NULL
);
1449 expect(InvalidParameter
, status
);
1450 status
= GdipGetDC(NULL
, &retdc
);
1451 expect(InvalidParameter
, status
);
1453 status
= GdipReleaseDC(NULL
, NULL
);
1454 expect(InvalidParameter
, status
);
1455 status
= GdipReleaseDC(graphics
, NULL
);
1456 expect(InvalidParameter
, status
);
1457 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1458 expect(InvalidParameter
, status
);
1460 /* Release without Get */
1461 status
= GdipReleaseDC(graphics
, hdc
);
1462 expect(InvalidParameter
, status
);
1465 status
= GdipGetDC(graphics
, &retdc
);
1467 ok(retdc
== hdc
, "Invalid HDC returned\n");
1468 /* call it once more */
1469 status
= GdipGetDC(graphics
, &retdc
);
1470 expect(ObjectBusy
, status
);
1472 /* try all Graphics calls here */
1473 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1474 expect(ObjectBusy
, status
);
1475 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1476 expect(ObjectBusy
, status
);
1477 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1478 expect(ObjectBusy
, status
);
1479 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1480 expect(ObjectBusy
, status
);
1481 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1482 expect(ObjectBusy
, status
);
1483 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1484 expect(ObjectBusy
, status
);
1485 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1486 expect(ObjectBusy
, status
);
1487 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1488 expect(ObjectBusy
, status
);
1489 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1490 expect(ObjectBusy
, status
);
1491 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1492 expect(ObjectBusy
, status
);
1493 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1494 expect(ObjectBusy
, status
);
1495 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1496 expect(ObjectBusy
, status
);
1497 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1498 expect(ObjectBusy
, status
);
1499 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1500 expect(ObjectBusy
, status
);
1501 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1502 expect(ObjectBusy
, status
);
1503 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1504 expect(ObjectBusy
, status
);
1505 /* GdipDrawImage/GdipDrawImageI */
1506 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1507 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1508 /* GdipDrawImageRect/GdipDrawImageRectI */
1509 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1510 expect(ObjectBusy
, status
);
1511 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1512 expect(ObjectBusy
, status
);
1513 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1514 expect(ObjectBusy
, status
);
1515 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1516 expect(ObjectBusy
, status
);
1517 status
= GdipDrawPath(graphics
, pen
, path
);
1518 expect(ObjectBusy
, status
);
1519 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1520 expect(ObjectBusy
, status
);
1521 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1522 expect(ObjectBusy
, status
);
1523 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1524 expect(ObjectBusy
, status
);
1525 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1526 expect(ObjectBusy
, status
);
1527 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1528 expect(ObjectBusy
, status
);
1529 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1530 expect(ObjectBusy
, status
);
1531 /* GdipDrawString */
1532 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1533 expect(ObjectBusy
, status
);
1534 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1535 expect(ObjectBusy
, status
);
1536 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1537 expect(ObjectBusy
, status
);
1538 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1539 expect(ObjectBusy
, status
);
1540 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1541 expect(ObjectBusy
, status
);
1542 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1543 expect(ObjectBusy
, status
);
1544 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1545 expect(ObjectBusy
, status
);
1546 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1547 expect(ObjectBusy
, status
);
1548 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1549 expect(ObjectBusy
, status
);
1550 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1551 expect(ObjectBusy
, status
);
1552 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1553 expect(ObjectBusy
, status
);
1554 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1555 expect(ObjectBusy
, status
);
1556 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1557 expect(ObjectBusy
, status
);
1558 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1559 expect(ObjectBusy
, status
);
1560 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1561 expect(ObjectBusy
, status
);
1562 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1563 expect(ObjectBusy
, status
);
1564 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1565 expect(ObjectBusy
, status
);
1566 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1567 expect(ObjectBusy
, status
);
1568 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1569 expect(ObjectBusy
, status
);
1570 status
= GdipGetClipBounds(graphics
, rectf
);
1571 expect(ObjectBusy
, status
);
1572 status
= GdipGetClipBoundsI(graphics
, rect
);
1573 expect(ObjectBusy
, status
);
1574 status
= GdipGetCompositingMode(graphics
, &compmode
);
1575 expect(ObjectBusy
, status
);
1576 status
= GdipGetCompositingQuality(graphics
, &quality
);
1577 expect(ObjectBusy
, status
);
1578 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1579 expect(ObjectBusy
, status
);
1580 status
= GdipGetNearestColor(graphics
, &color
);
1581 expect(ObjectBusy
, status
);
1582 status
= GdipGetPageScale(graphics
, &r
);
1583 expect(ObjectBusy
, status
);
1584 status
= GdipGetPageUnit(graphics
, &unit
);
1585 expect(ObjectBusy
, status
);
1586 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1587 expect(ObjectBusy
, status
);
1588 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1589 expect(ObjectBusy
, status
);
1590 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1591 expect(ObjectBusy
, status
);
1592 status
= GdipGetWorldTransform(graphics
, m
);
1593 expect(ObjectBusy
, status
);
1594 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1595 expect(ObjectBusy
, status
);
1596 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1597 expect(ObjectBusy
, status
);
1598 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1599 expect(ObjectBusy
, status
);
1600 /* GdipMeasureCharacterRanges */
1601 /* GdipMeasureString */
1602 status
= GdipResetClip(graphics
);
1603 expect(ObjectBusy
, status
);
1604 status
= GdipResetWorldTransform(graphics
);
1605 expect(ObjectBusy
, status
);
1606 /* GdipRestoreGraphics */
1607 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1608 expect(ObjectBusy
, status
);
1609 /* GdipSaveGraphics */
1610 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1611 expect(ObjectBusy
, status
);
1612 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1613 expect(ObjectBusy
, status
);
1614 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1615 expect(ObjectBusy
, status
);
1616 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1617 expect(ObjectBusy
, status
);
1618 status
= GdipSetPageScale(graphics
, 1.0);
1619 expect(ObjectBusy
, status
);
1620 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1621 expect(ObjectBusy
, status
);
1622 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1623 expect(ObjectBusy
, status
);
1624 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1625 expect(ObjectBusy
, status
);
1626 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1627 expect(ObjectBusy
, status
);
1628 status
= GdipSetWorldTransform(graphics
, m
);
1629 expect(ObjectBusy
, status
);
1630 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1631 expect(ObjectBusy
, status
);
1632 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1633 expect(ObjectBusy
, status
);
1634 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1635 expect(ObjectBusy
, status
);
1636 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1637 expect(ObjectBusy
, status
);
1638 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1639 expect(ObjectBusy
, status
);
1640 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1641 expect(ObjectBusy
, status
);
1642 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1643 expect(ObjectBusy
, status
);
1644 status
= GdipTranslateClipI(graphics
, 0, 0);
1645 expect(ObjectBusy
, status
);
1646 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1647 expect(ObjectBusy
, status
);
1648 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1649 expect(ObjectBusy
, status
);
1650 status
= GdipGetDpiX(graphics
, &r
);
1651 expect(ObjectBusy
, status
);
1652 status
= GdipGetDpiY(graphics
, &r
);
1653 expect(ObjectBusy
, status
);
1654 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1655 expect(ObjectBusy
, status
);
1656 status
= GdipGetClip(graphics
, region
);
1657 expect(ObjectBusy
, status
);
1658 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1659 expect(ObjectBusy
, status
);
1661 /* try to delete before release */
1662 status
= GdipDeleteGraphics(graphics
);
1663 expect(ObjectBusy
, status
);
1665 status
= GdipReleaseDC(graphics
, retdc
);
1669 GdipDeleteGraphics(graphics
);
1671 GdipDeleteRegion(clip
);
1672 GdipDeletePath(path
);
1673 GdipDeleteBrush((GpBrush
*)brush
);
1674 GdipDeleteRegion(region
);
1675 GdipDeleteMatrix(m
);
1678 ReleaseDC(hwnd
, hdc
);
1681 static void test_transformpoints(void)
1684 GpGraphics
*graphics
= NULL
;
1685 HDC hdc
= GetDC( hwnd
);
1689 status
= GdipCreateFromHDC(hdc
, &graphics
);
1692 /* NULL arguments */
1693 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1694 expect(InvalidParameter
, status
);
1695 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1696 expect(InvalidParameter
, status
);
1697 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1698 expect(InvalidParameter
, status
);
1699 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1700 expect(InvalidParameter
, status
);
1706 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1708 expectf(1.0, ptf
[0].X
);
1709 expectf(0.0, ptf
[0].Y
);
1710 expectf(0.0, ptf
[1].X
);
1711 expectf(1.0, ptf
[1].Y
);
1713 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1715 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1717 status
= GdipSetPageScale(graphics
, 3.0);
1724 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1726 expectf(18.0, ptf
[0].X
);
1727 expectf(15.0, ptf
[0].Y
);
1728 expectf(15.0, ptf
[1].X
);
1729 expectf(18.0, ptf
[1].Y
);
1735 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1737 expectf(6.0, ptf
[0].X
);
1738 expectf(5.0, ptf
[0].Y
);
1739 expectf(5.0, ptf
[1].X
);
1740 expectf(6.0, ptf
[1].Y
);
1746 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1748 expectf(3.0, ptf
[0].X
);
1749 expectf(0.0, ptf
[0].Y
);
1750 expectf(0.0, ptf
[1].X
);
1751 expectf(3.0, ptf
[1].Y
);
1757 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1759 expectf(1.0, ptf
[0].X
);
1760 expectf(0.0, ptf
[0].Y
);
1761 expectf(0.0, ptf
[1].X
);
1762 expectf(1.0, ptf
[1].Y
);
1768 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1770 expectf(1.0, ptf
[0].X
);
1771 expectf(0.0, ptf
[0].Y
);
1772 expectf(0.0, ptf
[1].X
);
1773 expectf(1.0, ptf
[1].Y
);
1779 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1781 expectf(1.0, ptf
[0].X
);
1782 expectf(0.0, ptf
[0].Y
);
1783 expectf(0.0, ptf
[1].X
);
1784 expectf(1.0, ptf
[1].Y
);
1790 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1792 expect(18, pt
[0].X
);
1793 expect(15, pt
[0].Y
);
1794 expect(15, pt
[1].X
);
1795 expect(18, pt
[1].Y
);
1797 GdipDeleteGraphics(graphics
);
1798 ReleaseDC(hwnd
, hdc
);
1801 static void test_get_set_clip(void)
1804 GpGraphics
*graphics
= NULL
;
1805 HDC hdc
= GetDC( hwnd
);
1810 status
= GdipCreateFromHDC(hdc
, &graphics
);
1813 rect
.X
= rect
.Y
= 0.0;
1814 rect
.Height
= rect
.Width
= 100.0;
1816 status
= GdipCreateRegionRect(&rect
, &clip
);
1819 /* NULL arguments */
1820 status
= GdipGetClip(NULL
, NULL
);
1821 expect(InvalidParameter
, status
);
1822 status
= GdipGetClip(graphics
, NULL
);
1823 expect(InvalidParameter
, status
);
1824 status
= GdipGetClip(NULL
, clip
);
1825 expect(InvalidParameter
, status
);
1827 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1828 expect(InvalidParameter
, status
);
1829 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1830 expect(InvalidParameter
, status
);
1832 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1833 expect(InvalidParameter
, status
);
1834 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1835 expect(InvalidParameter
, status
);
1838 status
= GdipGetClip(graphics
, clip
);
1840 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1844 /* remains infinite after reset */
1846 status
= GdipResetClip(graphics
);
1848 status
= GdipGetClip(graphics
, clip
);
1850 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1854 /* set to empty and then reset to infinite */
1855 status
= GdipSetEmpty(clip
);
1857 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1860 status
= GdipGetClip(graphics
, clip
);
1863 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1866 status
= GdipResetClip(graphics
);
1868 status
= GdipGetClip(graphics
, clip
);
1871 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1875 GdipDeleteRegion(clip
);
1877 GdipDeleteGraphics(graphics
);
1878 ReleaseDC(hwnd
, hdc
);
1881 static void test_isempty(void)
1884 GpGraphics
*graphics
= NULL
;
1885 HDC hdc
= GetDC( hwnd
);
1889 status
= GdipCreateFromHDC(hdc
, &graphics
);
1892 status
= GdipCreateRegion(&clip
);
1896 status
= GdipIsClipEmpty(NULL
, NULL
);
1897 expect(InvalidParameter
, status
);
1898 status
= GdipIsClipEmpty(graphics
, NULL
);
1899 expect(InvalidParameter
, status
);
1900 status
= GdipIsClipEmpty(NULL
, &res
);
1901 expect(InvalidParameter
, status
);
1903 /* default is infinite */
1905 status
= GdipIsClipEmpty(graphics
, &res
);
1909 GdipDeleteRegion(clip
);
1911 GdipDeleteGraphics(graphics
);
1912 ReleaseDC(hwnd
, hdc
);
1915 static void test_clear(void)
1919 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
1920 expect(InvalidParameter
, status
);
1923 static void test_textcontrast(void)
1926 HDC hdc
= GetDC( hwnd
);
1927 GpGraphics
*graphics
;
1930 status
= GdipGetTextContrast(NULL
, NULL
);
1931 expect(InvalidParameter
, status
);
1933 status
= GdipCreateFromHDC(hdc
, &graphics
);
1936 status
= GdipGetTextContrast(graphics
, NULL
);
1937 expect(InvalidParameter
, status
);
1938 status
= GdipGetTextContrast(graphics
, &contrast
);
1940 expect(4, contrast
);
1942 GdipDeleteGraphics(graphics
);
1943 ReleaseDC(hwnd
, hdc
);
1946 static void test_GdipDrawString(void)
1949 GpGraphics
*graphics
= NULL
;
1952 GpStringFormat
*format
;
1955 HDC hdc
= GetDC( hwnd
);
1956 static const WCHAR string
[] = {'T','e','s','t',0};
1957 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
1960 memset(&logfont
,0,sizeof(logfont
));
1961 strcpy(logfont
.lfFaceName
,"Arial");
1962 logfont
.lfHeight
= 12;
1963 logfont
.lfCharSet
= DEFAULT_CHARSET
;
1965 status
= GdipCreateFromHDC(hdc
, &graphics
);
1968 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
1969 if (status
== FileNotFound
)
1971 skip("Arial not installed.\n");
1976 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
1979 status
= GdipCreateStringFormat(0,0,&format
);
1987 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
1990 status
= GdipCreateMatrix(&matrix
);
1993 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
1994 expect(InvalidParameter
, status
);
1996 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
1997 expect(InvalidParameter
, status
);
1999 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2000 expect(InvalidParameter
, status
);
2002 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2003 expect(InvalidParameter
, status
);
2005 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2006 expect(InvalidParameter
, status
);
2008 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2011 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2014 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2017 GdipDeleteMatrix(matrix
);
2018 GdipDeleteGraphics(graphics
);
2019 GdipDeleteBrush(brush
);
2020 GdipDeleteFont(fnt
);
2021 GdipDeleteStringFormat(format
);
2023 ReleaseDC(hwnd
, hdc
);
2026 static void test_GdipGetVisibleClipBounds_screen(void)
2029 GpGraphics
*graphics
= NULL
;
2031 GpRectF rectf
, exp
, clipr
;
2034 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2036 status
= GdipCreateFromHDC(hdc
, &graphics
);
2038 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2040 /* no clipping rect */
2043 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2044 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2046 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2048 ok(rectf
.X
== exp
.X
&&
2050 rectf
.Width
== exp
.Width
&&
2051 rectf
.Height
== exp
.Height
,
2052 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2053 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2054 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2055 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2057 /* clipping rect entirely within window */
2058 exp
.X
= clipr
.X
= 10;
2059 exp
.Y
= clipr
.Y
= 12;
2060 exp
.Width
= clipr
.Width
= 14;
2061 exp
.Height
= clipr
.Height
= 16;
2063 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2066 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2068 ok(rectf
.X
== exp
.X
&&
2070 rectf
.Width
== exp
.Width
&&
2071 rectf
.Height
== exp
.Height
,
2072 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2073 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2074 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2075 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2077 /* clipping rect partially outside of screen */
2083 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2091 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2093 ok(rectf
.X
== exp
.X
&&
2095 rectf
.Width
== exp
.Width
&&
2096 rectf
.Height
== exp
.Height
,
2097 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2098 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2099 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2100 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2102 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2104 ok(recti
.X
== exp
.X
&&
2106 recti
.Width
== exp
.Width
&&
2107 recti
.Height
== exp
.Height
,
2108 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2109 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2110 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2111 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2113 GdipDeleteGraphics(graphics
);
2117 static void test_GdipGetVisibleClipBounds_window(void)
2120 GpGraphics
*graphics
= NULL
;
2121 GpRectF rectf
, window
, exp
, clipr
;
2127 /* get client area size */
2128 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2129 window
.X
= wnd_rect
.left
;
2130 window
.Y
= wnd_rect
.top
;
2131 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2132 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2134 hdc
= BeginPaint(hwnd
, &ps
);
2136 status
= GdipCreateFromHDC(hdc
, &graphics
);
2138 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2140 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2142 ok(rectf
.X
== window
.X
&&
2143 rectf
.Y
== window
.Y
&&
2144 rectf
.Width
== window
.Width
&&
2145 rectf
.Height
== window
.Height
,
2146 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2147 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2148 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2149 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2151 /* clipping rect entirely within window */
2152 exp
.X
= clipr
.X
= 20;
2153 exp
.Y
= clipr
.Y
= 8;
2154 exp
.Width
= clipr
.Width
= 30;
2155 exp
.Height
= clipr
.Height
= 20;
2157 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2160 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2162 ok(rectf
.X
== exp
.X
&&
2164 rectf
.Width
== exp
.Width
&&
2165 rectf
.Height
== exp
.Height
,
2166 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2167 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2168 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2169 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2171 /* clipping rect partially outside of window */
2172 clipr
.X
= window
.Width
- 10;
2173 clipr
.Y
= window
.Height
- 15;
2177 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2180 exp
.X
= window
.Width
- 10;
2181 exp
.Y
= window
.Height
- 15;
2185 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2187 ok(rectf
.X
== exp
.X
&&
2189 rectf
.Width
== exp
.Width
&&
2190 rectf
.Height
== exp
.Height
,
2191 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2192 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2193 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2194 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2196 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2198 ok(recti
.X
== exp
.X
&&
2200 recti
.Width
== exp
.Width
&&
2201 recti
.Height
== exp
.Height
,
2202 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2203 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2204 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2205 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2207 GdipDeleteGraphics(graphics
);
2208 EndPaint(hwnd
, &ps
);
2211 static void test_GdipGetVisibleClipBounds(void)
2213 GpGraphics
* graphics
= NULL
;
2216 HDC hdc
= GetDC( hwnd
);
2219 status
= GdipCreateFromHDC(hdc
, &graphics
);
2221 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2223 /* test null parameters */
2224 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2225 expect(InvalidParameter
, status
);
2227 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2228 expect(InvalidParameter
, status
);
2230 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2231 expect(InvalidParameter
, status
);
2233 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2234 expect(InvalidParameter
, status
);
2236 GdipDeleteGraphics(graphics
);
2237 ReleaseDC(hwnd
, hdc
);
2239 test_GdipGetVisibleClipBounds_screen();
2240 test_GdipGetVisibleClipBounds_window();
2243 static void test_fromMemoryBitmap(void)
2246 GpGraphics
*graphics
= NULL
;
2247 GpBitmap
*bitmap
= NULL
;
2248 BYTE bits
[48] = {0};
2252 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2255 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2258 status
= GdipGraphicsClear(graphics
, 0xff686868);
2261 GdipDeleteGraphics(graphics
);
2263 /* drawing writes to the memory provided */
2264 expect(0x68, bits
[10]);
2266 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2269 status
= GdipGetDC(graphics
, &hdc
);
2271 ok(hdc
!= NULL
, "got NULL hdc\n");
2273 color
= GetPixel(hdc
, 0, 0);
2274 /* The HDC is write-only, and native fills with a solid color to figure out
2275 * which pixels have changed. */
2276 todo_wine
expect(0x0c0b0d, color
);
2278 SetPixel(hdc
, 0, 0, 0x797979);
2279 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2281 status
= GdipReleaseDC(graphics
, hdc
);
2284 GdipDeleteGraphics(graphics
);
2286 expect(0x79, bits
[0]);
2287 todo_wine
expect(0x68, bits
[3]);
2289 GdipDisposeImage((GpImage
*)bitmap
);
2291 /* We get the same kind of write-only HDC for a "normal" bitmap */
2292 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2295 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2298 status
= GdipGetDC(graphics
, &hdc
);
2300 ok(hdc
!= NULL
, "got NULL hdc\n");
2302 color
= GetPixel(hdc
, 0, 0);
2303 todo_wine
expect(0x0c0b0d, color
);
2305 status
= GdipReleaseDC(graphics
, hdc
);
2308 GdipDeleteGraphics(graphics
);
2310 GdipDisposeImage((GpImage
*)bitmap
);
2313 static void test_GdipIsVisiblePoint(void)
2316 GpGraphics
*graphics
= NULL
;
2317 HDC hdc
= GetDC( hwnd
);
2321 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2323 status
= GdipCreateFromHDC(hdc
, &graphics
);
2325 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2327 /* null parameters */
2328 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2329 expect(InvalidParameter
, status
);
2331 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2332 expect(InvalidParameter
, status
);
2334 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2335 expect(InvalidParameter
, status
);
2337 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2338 expect(InvalidParameter
, status
);
2342 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2344 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2348 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2350 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2354 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2356 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2360 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2362 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2364 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2369 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2371 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2375 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2377 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2379 /* translate into the center of the rect */
2380 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2384 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2386 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2390 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2392 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2394 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2399 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2401 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2405 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2407 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2411 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2413 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2417 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2419 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2423 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2425 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2429 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2431 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2435 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2437 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2441 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2443 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2447 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2449 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2453 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2455 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2459 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2461 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2465 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2467 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2471 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2473 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2475 /* integer version */
2478 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2480 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2484 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2486 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2488 GdipDeleteGraphics(graphics
);
2489 ReleaseDC(hwnd
, hdc
);
2492 static void test_GdipIsVisibleRect(void)
2495 GpGraphics
*graphics
= NULL
;
2496 HDC hdc
= GetDC( hwnd
);
2497 REAL x
, y
, width
, height
;
2500 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2502 status
= GdipCreateFromHDC(hdc
, &graphics
);
2504 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2506 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2507 expect(InvalidParameter
, status
);
2509 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2510 expect(InvalidParameter
, status
);
2512 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2513 expect(InvalidParameter
, status
);
2515 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2516 expect(InvalidParameter
, status
);
2518 /* entirely within the visible region */
2521 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2523 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2525 /* partially outside */
2526 x
= -10; width
= 20;
2527 y
= -10; height
= 20;
2528 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2530 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2532 /* entirely outside */
2534 y
= -10; height
= 5;
2535 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2537 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2539 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2542 /* entirely within the visible region */
2544 y
= 22; height
= 10;
2545 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2547 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2549 /* partially outside */
2551 y
= 55; height
= 10;
2552 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2554 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2556 /* entirely outside */
2559 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2561 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2563 /* translate into center of clipping rect */
2564 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2568 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2570 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2574 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2576 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2578 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2580 /* corners entirely outside, but some intersections */
2583 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2585 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2589 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2591 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2595 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2597 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2601 y
= 20; height
= 40;
2602 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2604 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2608 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2610 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2613 y
= 20; height
= 40;
2614 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2616 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2619 y
= 60; height
= 10;
2620 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2622 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2624 /* rounding tests */
2625 x
= 0.4; width
= 10.4;
2626 y
= 20; height
= 40;
2627 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2629 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2632 y
= 0.4; height
= 20.4;
2633 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2635 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2637 /* integer version */
2640 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2642 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2645 y
= 22; height
= 10;
2646 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2648 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2650 GdipDeleteGraphics(graphics
);
2651 ReleaseDC(hwnd
, hdc
);
2654 static void test_GdipGetNearestColor(void)
2657 GpGraphics
*graphics
;
2659 ARGB color
= 0xdeadbeef;
2660 HDC hdc
= GetDC( hwnd
);
2662 /* create a graphics object */
2663 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2665 status
= GdipCreateFromHDC(hdc
, &graphics
);
2667 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2669 status
= GdipGetNearestColor(graphics
, NULL
);
2670 expect(InvalidParameter
, status
);
2672 status
= GdipGetNearestColor(NULL
, &color
);
2673 expect(InvalidParameter
, status
);
2674 GdipDeleteGraphics(graphics
);
2676 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2678 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2679 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2682 status
= GdipGetNearestColor(graphics
, &color
);
2684 expect(0xdeadbeef, color
);
2685 GdipDeleteGraphics(graphics
);
2687 GdipDisposeImage((GpImage
*)bitmap
);
2689 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2691 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2692 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2695 status
= GdipGetNearestColor(graphics
, &color
);
2697 expect(0xdeadbeef, color
);
2698 GdipDeleteGraphics(graphics
);
2700 GdipDisposeImage((GpImage
*)bitmap
);
2702 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2704 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2705 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2708 status
= GdipGetNearestColor(graphics
, &color
);
2710 expect(0xdeadbeef, color
);
2711 GdipDeleteGraphics(graphics
);
2713 GdipDisposeImage((GpImage
*)bitmap
);
2715 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2717 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2718 todo_wine
expect(OutOfMemory
, status
);
2720 GdipDeleteGraphics(graphics
);
2721 GdipDisposeImage((GpImage
*)bitmap
);
2723 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2725 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2727 status
= GdipGetNearestColor(graphics
, &color
);
2729 expect(0xdeadbeef, color
);
2730 GdipDeleteGraphics(graphics
);
2731 GdipDisposeImage((GpImage
*)bitmap
);
2733 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2735 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2737 status
= GdipGetNearestColor(graphics
, &color
);
2739 expect(0xdeadbeef, color
);
2740 GdipDeleteGraphics(graphics
);
2741 GdipDisposeImage((GpImage
*)bitmap
);
2743 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2745 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2747 status
= GdipGetNearestColor(graphics
, &color
);
2749 expect(0xdeadbeef, color
);
2750 GdipDeleteGraphics(graphics
);
2751 GdipDisposeImage((GpImage
*)bitmap
);
2753 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2757 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2759 status
= GdipGetNearestColor(graphics
, &color
);
2761 expect(0xdeadbeef, color
);
2762 GdipDeleteGraphics(graphics
);
2763 GdipDisposeImage((GpImage
*)bitmap
);
2766 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2770 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2772 status
= GdipGetNearestColor(graphics
, &color
);
2774 expect(0xdeadbeef, color
);
2775 GdipDeleteGraphics(graphics
);
2776 GdipDisposeImage((GpImage
*)bitmap
);
2779 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2783 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2785 status
= GdipGetNearestColor(graphics
, &color
);
2787 expect(0xdeadbeef, color
);
2788 GdipDeleteGraphics(graphics
);
2789 GdipDisposeImage((GpImage
*)bitmap
);
2792 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2794 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2796 status
= GdipGetNearestColor(graphics
, &color
);
2798 todo_wine
expect(0xffa8bce8, color
);
2799 GdipDeleteGraphics(graphics
);
2800 GdipDisposeImage((GpImage
*)bitmap
);
2802 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2804 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2806 status
= GdipGetNearestColor(graphics
, &color
);
2809 ok(color
== 0xffa8b8e8 ||
2810 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2811 "Expected ffa8b8e8, got %.8x\n", color
);
2812 GdipDeleteGraphics(graphics
);
2813 GdipDisposeImage((GpImage
*)bitmap
);
2815 ReleaseDC(hwnd
, hdc
);
2818 static void test_string_functions(void)
2821 GpGraphics
*graphics
;
2822 GpFontFamily
*family
;
2824 RectF rc
, char_bounds
, bounds
;
2826 ARGB color
= 0xff000000;
2827 HDC hdc
= GetDC( hwnd
);
2828 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2829 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2830 const WCHAR teststring2
[] = {'j',0};
2831 REAL char_width
, char_height
;
2832 INT codepointsfitted
, linesfilled
;
2833 GpStringFormat
*format
;
2834 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2835 GpRegion
*regions
[4] = {0};
2836 BOOL region_isempty
[4];
2841 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2842 status
= GdipCreateFromHDC(hdc
, &graphics
);
2844 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2846 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2849 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2852 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2855 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2863 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2864 expect(InvalidParameter
, status
);
2866 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2867 expect(InvalidParameter
, status
);
2869 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2870 expect(InvalidParameter
, status
);
2872 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2873 expect(InvalidParameter
, status
);
2875 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2876 expect(InvalidParameter
, status
);
2878 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
2881 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2882 expect(InvalidParameter
, status
);
2884 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2885 expect(InvalidParameter
, status
);
2887 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2888 expect(InvalidParameter
, status
);
2890 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2891 expect(InvalidParameter
, status
);
2893 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
2894 expect(InvalidParameter
, status
);
2896 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
2899 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
2902 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
2904 expectf(0.0, char_bounds
.X
);
2905 expectf(0.0, char_bounds
.Y
);
2906 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
2907 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
2908 expect(1, codepointsfitted
);
2909 expect(1, linesfilled
);
2911 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2913 expectf(0.0, bounds
.X
);
2914 expectf(0.0, bounds
.Y
);
2915 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
2916 expectf(char_bounds
.Height
, bounds
.Height
);
2917 expect(2, codepointsfitted
);
2918 expect(1, linesfilled
);
2919 char_width
= bounds
.Width
- char_bounds
.Width
;
2921 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2923 expectf(0.0, bounds
.X
);
2924 expectf(0.0, bounds
.Y
);
2925 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
2926 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
2927 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
2928 expect(6, codepointsfitted
);
2929 expect(2, linesfilled
);
2930 char_height
= bounds
.Height
- char_bounds
.Height
;
2932 /* Cut off everything after the first space. */
2933 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
2935 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2937 expectf(0.0, bounds
.X
);
2938 expectf(0.0, bounds
.Y
);
2939 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
2940 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
2941 expect(6, codepointsfitted
);
2942 expect(3, linesfilled
);
2944 /* Cut off everything including the first space. */
2945 rc
.Width
= char_bounds
.Width
+ char_width
* 1.5;
2947 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2949 expectf(0.0, bounds
.X
);
2950 expectf(0.0, bounds
.Y
);
2951 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
2952 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
2953 expect(6, codepointsfitted
);
2954 expect(3, linesfilled
);
2956 /* Cut off everything after the first character. */
2957 rc
.Width
= char_bounds
.Width
+ char_width
* 0.5;
2959 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2961 expectf(0.0, bounds
.X
);
2962 expectf(0.0, bounds
.Y
);
2963 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
2964 todo_wine
expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
2965 expect(6, codepointsfitted
);
2966 todo_wine
expect(4, linesfilled
);
2968 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
2975 status
= GdipCreateRegion(®ions
[i
]);
2979 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
2980 expect(InvalidParameter
, status
);
2982 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
2983 expect(InvalidParameter
, status
);
2985 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
2986 expect(InvalidParameter
, status
);
2988 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
2989 expect(InvalidParameter
, status
);
2993 /* Crashes on Windows XP */
2994 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
2995 expect(InvalidParameter
, status
);
2998 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
2999 expect(InvalidParameter
, status
);
3001 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3002 expect(InvalidParameter
, status
);
3004 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3009 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3013 ok(!region_isempty
[0], "region shouldn't be empty\n");
3014 ok(!region_isempty
[1], "region shouldn't be empty\n");
3015 ok(!region_isempty
[2], "region shouldn't be empty\n");
3016 ok(!region_isempty
[3], "region shouldn't be empty\n");
3018 /* Cut off everything after the first space, and the second line. */
3019 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3020 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3022 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3027 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3031 ok(!region_isempty
[0], "region shouldn't be empty\n");
3032 ok(!region_isempty
[1], "region shouldn't be empty\n");
3033 ok(region_isempty
[2], "region should be empty\n");
3034 ok(!region_isempty
[3], "region shouldn't be empty\n");
3037 GdipDeleteRegion(regions
[i
]);
3039 GdipCreateMatrix(&identity
);
3048 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, &position
,
3049 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3051 todo_wine
expect(InvalidParameter
, status
);
3053 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, &position
,
3054 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3056 todo_wine
expect(InvalidParameter
, status
);
3058 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, &position
,
3059 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3061 todo_wine
expect(InvalidParameter
, status
);
3063 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3064 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3066 todo_wine
expect(InvalidParameter
, status
);
3068 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, &position
,
3069 0x100, identity
, &rc
);
3070 todo_wine
expect(Ok
, status
);
3072 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, &position
,
3073 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3075 todo_wine
expect(Ok
, status
);
3077 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, &position
,
3078 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3080 todo_wine
expect(InvalidParameter
, status
);
3086 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, &position
,
3087 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3089 todo_wine
expect(Ok
, status
);
3092 todo_wine
ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3093 todo_wine
ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3094 todo_wine
ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3096 char_width
= rc
.Width
;
3097 char_height
= rc
.Height
;
3103 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, &position
,
3104 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3106 todo_wine
expect(Ok
, status
);
3109 todo_wine
ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3110 todo_wine
ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3111 expectf(char_height
, rc
.Height
);
3117 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, &position
,
3118 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3120 todo_wine
expect(Ok
, status
);
3123 todo_wine
ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3124 todo_wine
ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3125 expectf(rc
.Height
, char_height
);
3127 GdipDeleteMatrix(identity
);
3128 GdipDeleteStringFormat(format
);
3129 GdipDeleteBrush(brush
);
3130 GdipDeleteFont(font
);
3131 GdipDeleteFontFamily(family
);
3132 GdipDeleteGraphics(graphics
);
3134 ReleaseDC(hwnd
, hdc
);
3137 static void test_get_set_interpolation(void)
3139 GpGraphics
*graphics
;
3140 HDC hdc
= GetDC( hwnd
);
3142 InterpolationMode mode
;
3144 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3145 status
= GdipCreateFromHDC(hdc
, &graphics
);
3147 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3149 status
= GdipGetInterpolationMode(NULL
, &mode
);
3150 expect(InvalidParameter
, status
);
3154 /* Crashes on Windows XP */
3155 status
= GdipGetInterpolationMode(graphics
, NULL
);
3156 expect(InvalidParameter
, status
);
3159 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3160 expect(InvalidParameter
, status
);
3163 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3164 expect(InvalidParameter
, status
);
3166 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3167 expect(InvalidParameter
, status
);
3169 status
= GdipGetInterpolationMode(graphics
, &mode
);
3171 expect(InterpolationModeBilinear
, mode
);
3173 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3176 status
= GdipGetInterpolationMode(graphics
, &mode
);
3178 expect(InterpolationModeNearestNeighbor
, mode
);
3180 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3183 status
= GdipGetInterpolationMode(graphics
, &mode
);
3185 expect(InterpolationModeBilinear
, mode
);
3187 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3190 status
= GdipGetInterpolationMode(graphics
, &mode
);
3192 expect(InterpolationModeBilinear
, mode
);
3194 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3197 status
= GdipGetInterpolationMode(graphics
, &mode
);
3199 expect(InterpolationModeHighQualityBicubic
, mode
);
3201 GdipDeleteGraphics(graphics
);
3203 ReleaseDC(hwnd
, hdc
);
3206 static void test_get_set_textrenderinghint(void)
3208 GpGraphics
*graphics
;
3209 HDC hdc
= GetDC( hwnd
);
3211 TextRenderingHint hint
;
3213 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3214 status
= GdipCreateFromHDC(hdc
, &graphics
);
3216 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3218 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3219 expect(InvalidParameter
, status
);
3221 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3222 expect(InvalidParameter
, status
);
3224 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3225 expect(InvalidParameter
, status
);
3228 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3229 expect(InvalidParameter
, status
);
3231 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3233 expect(TextRenderingHintSystemDefault
, hint
);
3235 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3238 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3240 expect(TextRenderingHintSystemDefault
, hint
);
3242 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3245 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3247 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3249 GdipDeleteGraphics(graphics
);
3251 ReleaseDC(hwnd
, hdc
);
3254 START_TEST(graphics
)
3256 struct GdiplusStartupInput gdiplusStartupInput
;
3257 ULONG_PTR gdiplusToken
;
3260 memset( &class, 0, sizeof(class) );
3261 class.lpszClassName
= "gdiplus_test";
3262 class.style
= CS_HREDRAW
| CS_VREDRAW
;
3263 class.lpfnWndProc
= DefWindowProcA
;
3264 class.hInstance
= GetModuleHandleA(0);
3265 class.hIcon
= LoadIcon(0, IDI_APPLICATION
);
3266 class.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
3267 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
3268 RegisterClassA( &class );
3269 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
3270 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
3271 ok(hwnd
!= NULL
, "Expected window to be created\n");
3273 gdiplusStartupInput
.GdiplusVersion
= 1;
3274 gdiplusStartupInput
.DebugEventCallback
= NULL
;
3275 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
3276 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
3278 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
3280 test_constructor_destructor();
3281 test_save_restore();
3282 test_GdipFillClosedCurve2();
3283 test_GdipFillClosedCurve2I();
3284 test_GdipDrawBezierI();
3286 test_GdipDrawArcI();
3287 test_GdipDrawCurve();
3288 test_GdipDrawCurveI();
3289 test_GdipDrawCurve2();
3290 test_GdipDrawCurve2I();
3291 test_GdipDrawCurve3();
3292 test_GdipDrawCurve3I();
3293 test_GdipDrawLineI();
3294 test_GdipDrawLinesI();
3295 test_GdipDrawImagePointsRect();
3296 test_GdipFillClosedCurve();
3297 test_GdipFillClosedCurveI();
3298 test_GdipDrawString();
3299 test_GdipGetNearestColor();
3300 test_GdipGetVisibleClipBounds();
3301 test_GdipIsVisiblePoint();
3302 test_GdipIsVisibleRect();
3303 test_Get_Release_DC();
3304 test_BeginContainer2();
3305 test_transformpoints();
3306 test_get_set_clip();
3309 test_textcontrast();
3310 test_fromMemoryBitmap();
3311 test_string_functions();
3312 test_get_set_interpolation();
3313 test_get_set_textrenderinghint();
3315 GdiplusShutdown(gdiplusToken
);
3316 DestroyWindow( hwnd
);