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
);
597 GdipGetClipBounds(graphics
, &clip
);
598 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
599 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
600 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
601 fabs(defClip
[3] - clip
.Height
) < 0.0001,
602 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
603 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
604 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
606 status
= GdipEndContainer(graphics
, cont1
);
609 status
= GdipBeginContainer2(graphics
, &cont1
);
612 status
= GdipBeginContainer2(graphics
, &cont2
);
615 status
= GdipBeginContainer2(graphics
, &cont3
);
618 status
= GdipEndContainer(graphics
, cont3
);
621 status
= GdipBeginContainer2(graphics
, &cont4
);
624 status
= GdipEndContainer(graphics
, cont4
);
628 status
= GdipEndContainer(graphics
, cont1
);
631 /* end an already-ended container */
632 status
= GdipEndContainer(graphics
, cont1
);
635 GdipDeleteGraphics(graphics
);
636 ReleaseDC(hwnd
, hdc
);
639 static void test_GdipDrawBezierI(void)
642 GpGraphics
*graphics
= NULL
;
644 HDC hdc
= GetDC( hwnd
);
646 /* make a graphics object and pen object */
647 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
649 status
= GdipCreateFromHDC(hdc
, &graphics
);
651 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
653 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
655 ok(pen
!= NULL
, "Expected pen to be initialized\n");
657 /* InvalidParameter cases: null graphics, null pen */
658 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
659 expect(InvalidParameter
, status
);
661 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
662 expect(InvalidParameter
, status
);
664 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
665 expect(InvalidParameter
, status
);
667 /* successful case */
668 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
672 GdipDeleteGraphics(graphics
);
674 ReleaseDC(hwnd
, hdc
);
677 static void test_GdipDrawCurve3(void)
680 GpGraphics
*graphics
= NULL
;
682 HDC hdc
= GetDC( hwnd
);
694 /* make a graphics object and pen object */
695 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
697 status
= GdipCreateFromHDC(hdc
, &graphics
);
699 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
701 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
703 ok(pen
!= NULL
, "Expected pen to be initialized\n");
705 /* InvalidParameter cases: null graphics, null pen */
706 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
707 expect(InvalidParameter
, status
);
709 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
710 expect(InvalidParameter
, status
);
712 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
713 expect(InvalidParameter
, status
);
715 /* InvalidParameter cases: invalid count */
716 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
717 expect(InvalidParameter
, status
);
719 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
720 expect(InvalidParameter
, status
);
722 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
723 expect(InvalidParameter
, status
);
725 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
726 expect(InvalidParameter
, status
);
728 /* InvalidParameter cases: invalid number of segments */
729 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
730 expect(InvalidParameter
, status
);
732 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
733 expect(InvalidParameter
, status
);
735 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
736 expect(InvalidParameter
, status
);
738 /* Valid test cases */
739 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
742 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
745 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
748 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
752 GdipDeleteGraphics(graphics
);
754 ReleaseDC(hwnd
, hdc
);
757 static void test_GdipDrawCurve3I(void)
760 GpGraphics
*graphics
= NULL
;
762 HDC hdc
= GetDC( hwnd
);
774 /* make a graphics object and pen object */
775 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
777 status
= GdipCreateFromHDC(hdc
, &graphics
);
779 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
781 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
783 ok(pen
!= NULL
, "Expected pen to be initialized\n");
785 /* InvalidParameter cases: null graphics, null pen */
786 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
787 expect(InvalidParameter
, status
);
789 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
790 expect(InvalidParameter
, status
);
792 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
793 expect(InvalidParameter
, status
);
795 /* InvalidParameter cases: invalid count */
796 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
797 expect(OutOfMemory
, status
);
799 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
800 expect(InvalidParameter
, status
);
802 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
803 expect(InvalidParameter
, status
);
805 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
806 expect(InvalidParameter
, status
);
808 /* InvalidParameter cases: invalid number of segments */
809 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
810 expect(InvalidParameter
, status
);
812 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
813 expect(InvalidParameter
, status
);
815 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
816 expect(InvalidParameter
, status
);
818 /* Valid test cases */
819 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
822 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
825 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
828 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
832 GdipDeleteGraphics(graphics
);
834 ReleaseDC(hwnd
, hdc
);
837 static void test_GdipDrawCurve2(void)
840 GpGraphics
*graphics
= NULL
;
842 HDC hdc
= GetDC( hwnd
);
854 /* make a graphics object and pen object */
855 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
857 status
= GdipCreateFromHDC(hdc
, &graphics
);
859 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
861 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
863 ok(pen
!= NULL
, "Expected pen to be initialized\n");
865 /* InvalidParameter cases: null graphics, null pen */
866 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
867 expect(InvalidParameter
, status
);
869 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
870 expect(InvalidParameter
, status
);
872 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
873 expect(InvalidParameter
, status
);
875 /* InvalidParameter cases: invalid count */
876 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
877 expect(InvalidParameter
, status
);
879 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
880 expect(InvalidParameter
, status
);
882 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
883 expect(InvalidParameter
, status
);
885 /* Valid test cases */
886 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
889 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
892 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
895 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
899 GdipDeleteGraphics(graphics
);
901 ReleaseDC(hwnd
, hdc
);
904 static void test_GdipDrawCurve2I(void)
907 GpGraphics
*graphics
= NULL
;
909 HDC hdc
= GetDC( hwnd
);
921 /* make a graphics object and pen object */
922 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
924 status
= GdipCreateFromHDC(hdc
, &graphics
);
926 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
928 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
930 ok(pen
!= NULL
, "Expected pen to be initialized\n");
932 /* InvalidParameter cases: null graphics, null pen */
933 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
934 expect(InvalidParameter
, status
);
936 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
937 expect(InvalidParameter
, status
);
939 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
940 expect(InvalidParameter
, status
);
942 /* InvalidParameter cases: invalid count */
943 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
944 expect(OutOfMemory
, status
);
946 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
947 expect(InvalidParameter
, status
);
949 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
950 expect(InvalidParameter
, status
);
952 /* Valid test cases */
953 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
956 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
959 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
962 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
966 GdipDeleteGraphics(graphics
);
968 ReleaseDC(hwnd
, hdc
);
971 static void test_GdipDrawCurve(void)
974 GpGraphics
*graphics
= NULL
;
976 HDC hdc
= GetDC( hwnd
);
988 /* make a graphics object and pen object */
989 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
991 status
= GdipCreateFromHDC(hdc
, &graphics
);
993 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
995 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
997 ok(pen
!= NULL
, "Expected pen to be initialized\n");
999 /* InvalidParameter cases: null graphics, null pen */
1000 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1001 expect(InvalidParameter
, status
);
1003 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1004 expect(InvalidParameter
, status
);
1006 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1007 expect(InvalidParameter
, status
);
1009 /* InvalidParameter cases: invalid count */
1010 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1011 expect(InvalidParameter
, status
);
1013 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1014 expect(InvalidParameter
, status
);
1016 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1017 expect(InvalidParameter
, status
);
1019 /* Valid test cases */
1020 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1023 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1027 GdipDeleteGraphics(graphics
);
1029 ReleaseDC(hwnd
, hdc
);
1032 static void test_GdipDrawCurveI(void)
1035 GpGraphics
*graphics
= NULL
;
1037 HDC hdc
= GetDC( hwnd
);
1049 /* make a graphics object and pen object */
1050 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1052 status
= GdipCreateFromHDC(hdc
, &graphics
);
1054 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1056 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1058 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1060 /* InvalidParameter cases: null graphics, null pen */
1061 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1062 expect(InvalidParameter
, status
);
1064 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1065 expect(InvalidParameter
, status
);
1067 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1068 expect(InvalidParameter
, status
);
1070 /* InvalidParameter cases: invalid count */
1071 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1072 expect(OutOfMemory
, status
);
1074 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1075 expect(InvalidParameter
, status
);
1077 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1078 expect(InvalidParameter
, status
);
1080 /* Valid test cases */
1081 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1084 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1088 GdipDeleteGraphics(graphics
);
1090 ReleaseDC(hwnd
, hdc
);
1093 static void test_GdipDrawLineI(void)
1096 GpGraphics
*graphics
= NULL
;
1098 HDC hdc
= GetDC( hwnd
);
1100 /* make a graphics object and pen object */
1101 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1103 status
= GdipCreateFromHDC(hdc
, &graphics
);
1105 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1107 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1109 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1111 /* InvalidParameter cases: null graphics, null pen */
1112 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1113 expect(InvalidParameter
, status
);
1115 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1116 expect(InvalidParameter
, status
);
1118 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1119 expect(InvalidParameter
, status
);
1121 /* successful case */
1122 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1126 GdipDeleteGraphics(graphics
);
1128 ReleaseDC(hwnd
, hdc
);
1131 static void test_GdipDrawLinesI(void)
1134 GpGraphics
*graphics
= NULL
;
1136 GpPoint
*ptf
= NULL
;
1137 HDC hdc
= GetDC( hwnd
);
1139 /* make a graphics object and pen object */
1140 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1142 status
= GdipCreateFromHDC(hdc
, &graphics
);
1144 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1146 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1148 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1150 /* make some arbitrary valid points*/
1151 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1159 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1160 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1161 expect(InvalidParameter
, status
);
1163 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1164 expect(InvalidParameter
, status
);
1166 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1167 expect(InvalidParameter
, status
);
1169 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1170 expect(InvalidParameter
, status
);
1172 /* successful case */
1173 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1178 GdipDeleteGraphics(graphics
);
1180 ReleaseDC(hwnd
, hdc
);
1183 static void test_GdipFillClosedCurve(void)
1186 GpGraphics
*graphics
= NULL
;
1187 GpSolidFill
*brush
= NULL
;
1188 HDC hdc
= GetDC( hwnd
);
1200 /* make a graphics object and brush object */
1201 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1203 status
= GdipCreateFromHDC(hdc
, &graphics
);
1205 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1207 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1209 /* InvalidParameter cases: null graphics, null brush, null points */
1210 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1211 expect(InvalidParameter
, status
);
1213 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1214 expect(InvalidParameter
, status
);
1216 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1217 expect(InvalidParameter
, status
);
1219 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1220 expect(InvalidParameter
, status
);
1222 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1223 expect(InvalidParameter
, status
);
1225 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1226 expect(InvalidParameter
, status
);
1228 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1229 expect(InvalidParameter
, status
);
1231 /* InvalidParameter cases: invalid count */
1232 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1233 expect(InvalidParameter
, status
);
1235 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1236 expect(InvalidParameter
, status
);
1238 /* Valid test cases */
1239 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1242 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1245 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1248 GdipDeleteGraphics(graphics
);
1249 GdipDeleteBrush((GpBrush
*)brush
);
1251 ReleaseDC(hwnd
, hdc
);
1254 static void test_GdipFillClosedCurveI(void)
1257 GpGraphics
*graphics
= NULL
;
1258 GpSolidFill
*brush
= NULL
;
1259 HDC hdc
= GetDC( hwnd
);
1271 /* make a graphics object and brush object */
1272 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1274 status
= GdipCreateFromHDC(hdc
, &graphics
);
1276 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1278 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1280 /* InvalidParameter cases: null graphics, null brush */
1281 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1282 when points == NULL, so don't test this condition */
1283 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1284 expect(InvalidParameter
, status
);
1286 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1287 expect(InvalidParameter
, status
);
1289 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1290 expect(InvalidParameter
, status
);
1292 /* InvalidParameter cases: invalid count */
1293 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1294 expect(InvalidParameter
, status
);
1296 /* OutOfMemory cases: large (unsigned) int */
1297 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1298 expect(OutOfMemory
, status
);
1300 /* Valid test cases */
1301 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1304 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1307 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1310 GdipDeleteGraphics(graphics
);
1311 GdipDeleteBrush((GpBrush
*)brush
);
1313 ReleaseDC(hwnd
, hdc
);
1316 static void test_Get_Release_DC(void)
1319 GpGraphics
*graphics
= NULL
;
1323 HDC hdc
= GetDC( hwnd
);
1326 CompositingQuality quality
;
1327 CompositingMode compmode
;
1328 InterpolationMode intmode
;
1332 PixelOffsetMode offsetmode
;
1333 SmoothingMode smoothmode
;
1334 TextRenderingHint texthint
;
1342 ARGB color
= 0x00000000;
1343 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1356 for(i
= 0; i
< 5;i
++){
1357 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1358 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1364 rect
[0].Height
= 70;
1368 rect
[1].Height
= 20;
1370 for(i
= 0; i
< 2;i
++){
1371 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1372 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1373 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1374 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1377 GdipCreateMatrix(&m
);
1378 GdipCreateRegion(®ion
);
1379 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1380 GdipCreatePath(FillModeAlternate
, &path
);
1381 GdipCreateRegion(&clip
);
1383 status
= GdipCreateFromHDC(hdc
, &graphics
);
1385 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1386 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1389 /* NULL arguments */
1390 status
= GdipGetDC(NULL
, NULL
);
1391 expect(InvalidParameter
, status
);
1392 status
= GdipGetDC(graphics
, NULL
);
1393 expect(InvalidParameter
, status
);
1394 status
= GdipGetDC(NULL
, &retdc
);
1395 expect(InvalidParameter
, status
);
1397 status
= GdipReleaseDC(NULL
, NULL
);
1398 expect(InvalidParameter
, status
);
1399 status
= GdipReleaseDC(graphics
, NULL
);
1400 expect(InvalidParameter
, status
);
1401 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1402 expect(InvalidParameter
, status
);
1404 /* Release without Get */
1405 status
= GdipReleaseDC(graphics
, hdc
);
1406 expect(InvalidParameter
, status
);
1409 status
= GdipGetDC(graphics
, &retdc
);
1411 ok(retdc
== hdc
, "Invalid HDC returned\n");
1412 /* call it once more */
1413 status
= GdipGetDC(graphics
, &retdc
);
1414 expect(ObjectBusy
, status
);
1416 /* try all Graphics calls here */
1418 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1419 expect(ObjectBusy
, status
); status
= Ok
;
1420 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1421 expect(ObjectBusy
, status
); status
= Ok
;
1422 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1423 expect(ObjectBusy
, status
); status
= Ok
;
1424 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1425 expect(ObjectBusy
, status
); status
= Ok
;
1426 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1427 expect(ObjectBusy
, status
); status
= Ok
;
1428 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1429 expect(ObjectBusy
, status
); status
= Ok
;
1430 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1431 expect(ObjectBusy
, status
); status
= Ok
;
1432 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1433 expect(ObjectBusy
, status
); status
= Ok
;
1434 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1435 expect(ObjectBusy
, status
); status
= Ok
;
1436 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1437 expect(ObjectBusy
, status
); status
= Ok
;
1438 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1439 expect(ObjectBusy
, status
); status
= Ok
;
1440 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1441 expect(ObjectBusy
, status
); status
= Ok
;
1442 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1443 expect(ObjectBusy
, status
); status
= Ok
;
1444 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1445 expect(ObjectBusy
, status
); status
= Ok
;
1446 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1447 expect(ObjectBusy
, status
); status
= Ok
;
1448 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1449 expect(ObjectBusy
, status
); status
= Ok
;
1450 /* GdipDrawImage/GdipDrawImageI */
1451 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1452 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1453 /* GdipDrawImageRect/GdipDrawImageRectI */
1454 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1455 expect(ObjectBusy
, status
); status
= Ok
;
1456 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1457 expect(ObjectBusy
, status
); status
= Ok
;
1458 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1459 expect(ObjectBusy
, status
); status
= Ok
;
1460 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1461 expect(ObjectBusy
, status
); status
= Ok
;
1462 status
= GdipDrawPath(graphics
, pen
, path
);
1463 expect(ObjectBusy
, status
); status
= Ok
;
1464 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1465 expect(ObjectBusy
, status
); status
= Ok
;
1466 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1467 expect(ObjectBusy
, status
); status
= Ok
;
1468 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1469 expect(ObjectBusy
, status
); status
= Ok
;
1470 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1471 expect(ObjectBusy
, status
); status
= Ok
;
1472 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1473 expect(ObjectBusy
, status
); status
= Ok
;
1474 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1475 expect(ObjectBusy
, status
); status
= Ok
;
1476 /* GdipDrawString */
1477 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1478 expect(ObjectBusy
, status
); status
= Ok
;
1479 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1480 expect(ObjectBusy
, status
); status
= Ok
;
1481 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1482 expect(ObjectBusy
, status
); status
= Ok
;
1483 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1484 expect(ObjectBusy
, status
); status
= Ok
;
1485 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1486 expect(ObjectBusy
, status
); status
= Ok
;
1487 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1488 expect(ObjectBusy
, status
); status
= Ok
;
1489 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1490 expect(ObjectBusy
, status
); status
= Ok
;
1491 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1492 expect(ObjectBusy
, status
); status
= Ok
;
1493 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1494 expect(ObjectBusy
, status
); status
= Ok
;
1495 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1496 expect(ObjectBusy
, status
); status
= Ok
;
1497 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1498 expect(ObjectBusy
, status
); status
= Ok
;
1499 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1500 expect(ObjectBusy
, status
); status
= Ok
;
1501 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1502 expect(ObjectBusy
, status
); status
= Ok
;
1503 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1504 expect(ObjectBusy
, status
); status
= Ok
;
1505 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1506 expect(ObjectBusy
, status
); status
= Ok
;
1507 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1508 expect(ObjectBusy
, status
); status
= Ok
;
1509 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1510 expect(ObjectBusy
, status
); status
= Ok
;
1511 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1512 expect(ObjectBusy
, status
); status
= Ok
;
1513 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1514 expect(ObjectBusy
, status
); status
= Ok
;
1515 status
= GdipGetClipBounds(graphics
, rectf
);
1516 expect(ObjectBusy
, status
); status
= Ok
;
1517 status
= GdipGetClipBoundsI(graphics
, rect
);
1518 expect(ObjectBusy
, status
); status
= Ok
;
1519 status
= GdipGetCompositingMode(graphics
, &compmode
);
1520 expect(ObjectBusy
, status
); status
= Ok
;
1521 status
= GdipGetCompositingQuality(graphics
, &quality
);
1522 expect(ObjectBusy
, status
); status
= Ok
;
1523 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1524 expect(ObjectBusy
, status
); status
= Ok
;
1525 status
= GdipGetNearestColor(graphics
, &color
);
1526 expect(ObjectBusy
, status
); status
= Ok
;
1527 status
= GdipGetPageScale(graphics
, &r
);
1528 expect(ObjectBusy
, status
); status
= Ok
;
1529 status
= GdipGetPageUnit(graphics
, &unit
);
1530 expect(ObjectBusy
, status
); status
= Ok
;
1531 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1532 expect(ObjectBusy
, status
); status
= Ok
;
1533 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1534 expect(ObjectBusy
, status
); status
= Ok
;
1535 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1536 expect(ObjectBusy
, status
); status
= Ok
;
1537 status
= GdipGetWorldTransform(graphics
, m
);
1538 expect(ObjectBusy
, status
); status
= Ok
;
1539 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1540 expect(ObjectBusy
, status
); status
= Ok
;
1541 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1542 expect(ObjectBusy
, status
); status
= Ok
;
1543 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1544 expect(ObjectBusy
, status
); status
= Ok
;
1545 /* GdipMeasureCharacterRanges */
1546 /* GdipMeasureString */
1547 status
= GdipResetClip(graphics
);
1548 expect(ObjectBusy
, status
); status
= Ok
;
1549 status
= GdipResetWorldTransform(graphics
);
1550 expect(ObjectBusy
, status
); status
= Ok
;
1551 /* GdipRestoreGraphics */
1552 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1553 expect(ObjectBusy
, status
); status
= Ok
;
1554 /* GdipSaveGraphics */
1555 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1556 expect(ObjectBusy
, status
); status
= Ok
;
1557 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1558 expect(ObjectBusy
, status
); status
= Ok
;
1559 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1560 expect(ObjectBusy
, status
); status
= Ok
;
1561 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1562 expect(ObjectBusy
, status
); status
= Ok
;
1563 status
= GdipSetPageScale(graphics
, 1.0);
1564 expect(ObjectBusy
, status
); status
= Ok
;
1565 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1566 expect(ObjectBusy
, status
); status
= Ok
;
1567 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1568 expect(ObjectBusy
, status
); status
= Ok
;
1569 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1570 expect(ObjectBusy
, status
); status
= Ok
;
1571 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1572 expect(ObjectBusy
, status
); status
= Ok
;
1573 status
= GdipSetWorldTransform(graphics
, m
);
1574 expect(ObjectBusy
, status
); status
= Ok
;
1575 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1576 expect(ObjectBusy
, status
); status
= Ok
;
1577 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1578 expect(ObjectBusy
, status
); status
= Ok
;
1579 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1580 expect(ObjectBusy
, status
); status
= Ok
;
1581 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1582 expect(ObjectBusy
, status
); status
= Ok
;
1583 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1584 expect(ObjectBusy
, status
); status
= Ok
;
1585 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1586 expect(ObjectBusy
, status
); status
= Ok
;
1587 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1588 expect(ObjectBusy
, status
); status
= Ok
;
1589 status
= GdipTranslateClipI(graphics
, 0, 0);
1590 expect(ObjectBusy
, status
); status
= Ok
;
1591 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1592 expect(ObjectBusy
, status
); status
= Ok
;
1593 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1594 expect(ObjectBusy
, status
); status
= Ok
;
1595 status
= GdipGetDpiX(graphics
, &r
);
1596 expect(ObjectBusy
, status
); status
= Ok
;
1597 status
= GdipGetDpiY(graphics
, &r
);
1598 expect(ObjectBusy
, status
); status
= Ok
;
1599 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1600 status
= GdipGetClip(graphics
, region
);
1601 expect(ObjectBusy
, status
); status
= Ok
;
1602 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1603 expect(ObjectBusy
, status
); status
= Ok
;
1604 /* try to delete before release */
1605 status
= GdipDeleteGraphics(graphics
);
1606 expect(ObjectBusy
, status
);
1608 status
= GdipReleaseDC(graphics
, retdc
);
1612 GdipDeleteGraphics(graphics
);
1614 GdipDeleteRegion(clip
);
1615 GdipDeletePath(path
);
1616 GdipDeleteBrush((GpBrush
*)brush
);
1617 GdipDeleteRegion(region
);
1618 GdipDeleteMatrix(m
);
1621 ReleaseDC(hwnd
, hdc
);
1624 static void test_transformpoints(void)
1627 GpGraphics
*graphics
= NULL
;
1628 HDC hdc
= GetDC( hwnd
);
1632 status
= GdipCreateFromHDC(hdc
, &graphics
);
1635 /* NULL arguments */
1636 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1637 expect(InvalidParameter
, status
);
1638 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1639 expect(InvalidParameter
, status
);
1640 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1641 expect(InvalidParameter
, status
);
1642 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1643 expect(InvalidParameter
, status
);
1649 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1651 expectf(1.0, ptf
[0].X
);
1652 expectf(0.0, ptf
[0].Y
);
1653 expectf(0.0, ptf
[1].X
);
1654 expectf(1.0, ptf
[1].Y
);
1656 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1658 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1660 status
= GdipSetPageScale(graphics
, 3.0);
1667 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1669 expectf(18.0, ptf
[0].X
);
1670 expectf(15.0, ptf
[0].Y
);
1671 expectf(15.0, ptf
[1].X
);
1672 expectf(18.0, ptf
[1].Y
);
1678 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1680 expectf(6.0, ptf
[0].X
);
1681 expectf(5.0, ptf
[0].Y
);
1682 expectf(5.0, ptf
[1].X
);
1683 expectf(6.0, ptf
[1].Y
);
1689 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1691 expectf(3.0, ptf
[0].X
);
1692 expectf(0.0, ptf
[0].Y
);
1693 expectf(0.0, ptf
[1].X
);
1694 expectf(3.0, ptf
[1].Y
);
1700 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1702 expectf(1.0, ptf
[0].X
);
1703 expectf(0.0, ptf
[0].Y
);
1704 expectf(0.0, ptf
[1].X
);
1705 expectf(1.0, ptf
[1].Y
);
1711 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1713 expectf(1.0, ptf
[0].X
);
1714 expectf(0.0, ptf
[0].Y
);
1715 expectf(0.0, ptf
[1].X
);
1716 expectf(1.0, ptf
[1].Y
);
1722 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1724 expectf(1.0, ptf
[0].X
);
1725 expectf(0.0, ptf
[0].Y
);
1726 expectf(0.0, ptf
[1].X
);
1727 expectf(1.0, ptf
[1].Y
);
1733 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1735 expect(18, pt
[0].X
);
1736 expect(15, pt
[0].Y
);
1737 expect(15, pt
[1].X
);
1738 expect(18, pt
[1].Y
);
1740 GdipDeleteGraphics(graphics
);
1741 ReleaseDC(hwnd
, hdc
);
1744 static void test_get_set_clip(void)
1747 GpGraphics
*graphics
= NULL
;
1748 HDC hdc
= GetDC( hwnd
);
1753 status
= GdipCreateFromHDC(hdc
, &graphics
);
1756 rect
.X
= rect
.Y
= 0.0;
1757 rect
.Height
= rect
.Width
= 100.0;
1759 status
= GdipCreateRegionRect(&rect
, &clip
);
1761 /* NULL arguments */
1762 status
= GdipGetClip(NULL
, NULL
);
1763 expect(InvalidParameter
, status
);
1764 status
= GdipGetClip(graphics
, NULL
);
1765 expect(InvalidParameter
, status
);
1766 status
= GdipGetClip(NULL
, clip
);
1767 expect(InvalidParameter
, status
);
1769 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1770 expect(InvalidParameter
, status
);
1771 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1772 expect(InvalidParameter
, status
);
1774 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1775 expect(InvalidParameter
, status
);
1776 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1777 expect(InvalidParameter
, status
);
1780 status
= GdipGetClip(graphics
, clip
);
1782 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1786 /* remains infinite after reset */
1788 status
= GdipResetClip(graphics
);
1790 status
= GdipGetClip(graphics
, clip
);
1792 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1796 /* set to empty and then reset to infinite */
1797 status
= GdipSetEmpty(clip
);
1799 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1802 status
= GdipGetClip(graphics
, clip
);
1805 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1808 status
= GdipResetClip(graphics
);
1810 status
= GdipGetClip(graphics
, clip
);
1813 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1817 GdipDeleteRegion(clip
);
1819 GdipDeleteGraphics(graphics
);
1820 ReleaseDC(hwnd
, hdc
);
1823 static void test_isempty(void)
1826 GpGraphics
*graphics
= NULL
;
1827 HDC hdc
= GetDC( hwnd
);
1831 status
= GdipCreateFromHDC(hdc
, &graphics
);
1834 status
= GdipCreateRegion(&clip
);
1838 status
= GdipIsClipEmpty(NULL
, NULL
);
1839 expect(InvalidParameter
, status
);
1840 status
= GdipIsClipEmpty(graphics
, NULL
);
1841 expect(InvalidParameter
, status
);
1842 status
= GdipIsClipEmpty(NULL
, &res
);
1843 expect(InvalidParameter
, status
);
1845 /* default is infinite */
1847 status
= GdipIsClipEmpty(graphics
, &res
);
1851 GdipDeleteRegion(clip
);
1853 GdipDeleteGraphics(graphics
);
1854 ReleaseDC(hwnd
, hdc
);
1857 static void test_clear(void)
1861 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
1862 expect(InvalidParameter
, status
);
1865 static void test_textcontrast(void)
1868 HDC hdc
= GetDC( hwnd
);
1869 GpGraphics
*graphics
;
1872 status
= GdipGetTextContrast(NULL
, NULL
);
1873 expect(InvalidParameter
, status
);
1875 status
= GdipCreateFromHDC(hdc
, &graphics
);
1878 status
= GdipGetTextContrast(graphics
, NULL
);
1879 expect(InvalidParameter
, status
);
1880 status
= GdipGetTextContrast(graphics
, &contrast
);
1881 expect(4, contrast
);
1883 GdipDeleteGraphics(graphics
);
1884 ReleaseDC(hwnd
, hdc
);
1887 static void test_GdipDrawString(void)
1890 GpGraphics
*graphics
= NULL
;
1893 GpStringFormat
*format
;
1896 HDC hdc
= GetDC( hwnd
);
1897 static const WCHAR string
[] = {'T','e','s','t',0};
1899 memset(&logfont
,0,sizeof(logfont
));
1900 strcpy(logfont
.lfFaceName
,"Arial");
1901 logfont
.lfHeight
= 12;
1902 logfont
.lfCharSet
= DEFAULT_CHARSET
;
1904 status
= GdipCreateFromHDC(hdc
, &graphics
);
1907 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
1908 if (status
== FileNotFound
)
1910 skip("Arial not installed.\n");
1915 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
1918 status
= GdipCreateStringFormat(0,0,&format
);
1926 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
1929 GdipDeleteGraphics(graphics
);
1930 GdipDeleteBrush(brush
);
1931 GdipDeleteFont(fnt
);
1932 GdipDeleteStringFormat(format
);
1934 ReleaseDC(hwnd
, hdc
);
1937 static void test_GdipGetVisibleClipBounds_screen(void)
1940 GpGraphics
*graphics
= NULL
;
1942 GpRectF rectf
, exp
, clipr
;
1945 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1947 status
= GdipCreateFromHDC(hdc
, &graphics
);
1949 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1951 /* no clipping rect */
1954 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
1955 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
1957 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1959 ok(rectf
.X
== exp
.X
&&
1961 rectf
.Width
== exp
.Width
&&
1962 rectf
.Height
== exp
.Height
,
1963 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1964 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1965 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1966 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1968 /* clipping rect entirely within window */
1969 exp
.X
= clipr
.X
= 10;
1970 exp
.Y
= clipr
.Y
= 12;
1971 exp
.Width
= clipr
.Width
= 14;
1972 exp
.Height
= clipr
.Height
= 16;
1974 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1977 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1979 ok(rectf
.X
== exp
.X
&&
1981 rectf
.Width
== exp
.Width
&&
1982 rectf
.Height
== exp
.Height
,
1983 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1984 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1985 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1986 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1988 /* clipping rect partially outside of screen */
1994 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2002 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2004 ok(rectf
.X
== exp
.X
&&
2006 rectf
.Width
== exp
.Width
&&
2007 rectf
.Height
== exp
.Height
,
2008 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2009 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2010 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2011 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2013 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2015 ok(recti
.X
== exp
.X
&&
2017 recti
.Width
== exp
.Width
&&
2018 recti
.Height
== exp
.Height
,
2019 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2020 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2021 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2022 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2024 GdipDeleteGraphics(graphics
);
2028 static void test_GdipGetVisibleClipBounds_window(void)
2031 GpGraphics
*graphics
= NULL
;
2032 GpRectF rectf
, window
, exp
, clipr
;
2038 /* get client area size */
2039 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2040 window
.X
= wnd_rect
.left
;
2041 window
.Y
= wnd_rect
.top
;
2042 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2043 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2045 hdc
= BeginPaint(hwnd
, &ps
);
2047 status
= GdipCreateFromHDC(hdc
, &graphics
);
2049 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2051 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2053 ok(rectf
.X
== window
.X
&&
2054 rectf
.Y
== window
.Y
&&
2055 rectf
.Width
== window
.Width
&&
2056 rectf
.Height
== window
.Height
,
2057 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2058 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2059 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2060 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2062 /* clipping rect entirely within window */
2063 exp
.X
= clipr
.X
= 20;
2064 exp
.Y
= clipr
.Y
= 8;
2065 exp
.Width
= clipr
.Width
= 30;
2066 exp
.Height
= clipr
.Height
= 20;
2068 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2071 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2073 ok(rectf
.X
== exp
.X
&&
2075 rectf
.Width
== exp
.Width
&&
2076 rectf
.Height
== exp
.Height
,
2077 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2078 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2079 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2080 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2082 /* clipping rect partially outside of window */
2083 clipr
.X
= window
.Width
- 10;
2084 clipr
.Y
= window
.Height
- 15;
2088 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2091 exp
.X
= window
.Width
- 10;
2092 exp
.Y
= window
.Height
- 15;
2096 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2098 ok(rectf
.X
== exp
.X
&&
2100 rectf
.Width
== exp
.Width
&&
2101 rectf
.Height
== exp
.Height
,
2102 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2103 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2104 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2105 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2107 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2109 ok(recti
.X
== exp
.X
&&
2111 recti
.Width
== exp
.Width
&&
2112 recti
.Height
== exp
.Height
,
2113 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2114 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2115 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2116 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2118 GdipDeleteGraphics(graphics
);
2119 EndPaint(hwnd
, &ps
);
2122 static void test_GdipGetVisibleClipBounds(void)
2124 GpGraphics
* graphics
= NULL
;
2127 HDC hdc
= GetDC( hwnd
);
2130 status
= GdipCreateFromHDC(hdc
, &graphics
);
2132 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2134 /* test null parameters */
2135 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2136 expect(InvalidParameter
, status
);
2138 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2139 expect(InvalidParameter
, status
);
2141 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2142 expect(InvalidParameter
, status
);
2144 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2145 expect(InvalidParameter
, status
);
2147 GdipDeleteGraphics(graphics
);
2148 ReleaseDC(hwnd
, hdc
);
2150 test_GdipGetVisibleClipBounds_screen();
2151 test_GdipGetVisibleClipBounds_window();
2154 static void test_fromMemoryBitmap(void)
2157 GpGraphics
*graphics
= NULL
;
2158 GpBitmap
*bitmap
= NULL
;
2159 BYTE bits
[48] = {0};
2163 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2166 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2169 status
= GdipGraphicsClear(graphics
, 0xff686868);
2172 GdipDeleteGraphics(graphics
);
2174 /* drawing writes to the memory provided */
2175 todo_wine
expect(0x68, bits
[10]);
2177 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2180 status
= GdipGetDC(graphics
, &hdc
);
2182 ok(hdc
!= NULL
, "got NULL hdc\n");
2184 color
= GetPixel(hdc
, 0, 0);
2185 /* The HDC is write-only, and native fills with a solid color to figure out
2186 * which pixels have changed. */
2187 todo_wine
expect(0x0c0b0d, color
);
2189 SetPixel(hdc
, 0, 0, 0x797979);
2190 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2192 status
= GdipReleaseDC(graphics
, hdc
);
2195 GdipDeleteGraphics(graphics
);
2197 todo_wine
expect(0x79, bits
[0]);
2198 todo_wine
expect(0x68, bits
[3]);
2200 GdipDisposeImage((GpImage
*)bitmap
);
2202 /* We get the same kind of write-only HDC for a "normal" bitmap */
2203 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2206 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2209 status
= GdipGetDC(graphics
, &hdc
);
2211 ok(hdc
!= NULL
, "got NULL hdc\n");
2213 color
= GetPixel(hdc
, 0, 0);
2214 todo_wine
expect(0x0c0b0d, color
);
2216 status
= GdipReleaseDC(graphics
, hdc
);
2219 GdipDeleteGraphics(graphics
);
2221 GdipDisposeImage((GpImage
*)bitmap
);
2224 static void test_GdipIsVisiblePoint(void)
2227 GpGraphics
*graphics
= NULL
;
2228 HDC hdc
= GetDC( hwnd
);
2232 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2234 status
= GdipCreateFromHDC(hdc
, &graphics
);
2236 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2238 /* null parameters */
2239 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2240 expect(InvalidParameter
, status
);
2242 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2243 expect(InvalidParameter
, status
);
2245 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2246 expect(InvalidParameter
, status
);
2248 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2249 expect(InvalidParameter
, status
);
2253 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2255 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2259 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2261 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2265 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2267 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2271 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2273 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2275 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2280 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2282 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2286 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2288 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2290 /* translate into the center of the rect */
2291 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2295 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2297 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2301 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2303 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2305 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2310 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2312 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2316 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2318 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2322 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2324 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2328 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2330 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2334 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2336 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2340 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2342 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2346 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2348 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2352 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2354 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2358 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2360 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2364 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2366 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2370 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2372 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2376 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2378 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2382 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2384 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2386 /* integer version */
2389 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2391 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2395 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2397 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2399 GdipDeleteGraphics(graphics
);
2400 ReleaseDC(hwnd
, hdc
);
2403 static void test_GdipIsVisibleRect(void)
2406 GpGraphics
*graphics
= NULL
;
2407 HDC hdc
= GetDC( hwnd
);
2408 REAL x
, y
, width
, height
;
2411 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2413 status
= GdipCreateFromHDC(hdc
, &graphics
);
2415 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2417 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2418 expect(InvalidParameter
, status
);
2420 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2421 expect(InvalidParameter
, status
);
2423 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2424 expect(InvalidParameter
, status
);
2426 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2427 expect(InvalidParameter
, status
);
2429 /* entirely within the visible region */
2432 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2434 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2436 /* partially outside */
2437 x
= -10; width
= 20;
2438 y
= -10; height
= 20;
2439 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2441 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2443 /* entirely outside */
2445 y
= -10; height
= 5;
2446 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2448 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2450 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2453 /* entirely within the visible region */
2455 y
= 22; height
= 10;
2456 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2458 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2460 /* partially outside */
2462 y
= 55; height
= 10;
2463 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2465 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2467 /* entirely outside */
2470 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2472 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2474 /* translate into center of clipping rect */
2475 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2479 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2481 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2485 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2487 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2489 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2491 /* corners entirely outside, but some intersections */
2494 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2496 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2500 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2502 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2506 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2508 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2512 y
= 20; height
= 40;
2513 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2515 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2519 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2521 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2524 y
= 20; height
= 40;
2525 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2527 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2530 y
= 60; height
= 10;
2531 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2533 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2535 /* rounding tests */
2536 x
= 0.4; width
= 10.4;
2537 y
= 20; height
= 40;
2538 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2540 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2543 y
= 0.4; height
= 20.4;
2544 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2546 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2548 /* integer version */
2551 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2553 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2556 y
= 22; height
= 10;
2557 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2559 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2561 GdipDeleteGraphics(graphics
);
2562 ReleaseDC(hwnd
, hdc
);
2565 static void test_GdipGetNearestColor(void)
2568 GpGraphics
*graphics
;
2570 ARGB color
= 0xdeadbeef;
2571 HDC hdc
= GetDC( hwnd
);
2573 /* create a graphics object */
2574 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2576 status
= GdipCreateFromHDC(hdc
, &graphics
);
2578 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2580 status
= GdipGetNearestColor(graphics
, NULL
);
2581 expect(InvalidParameter
, status
);
2583 status
= GdipGetNearestColor(NULL
, &color
);
2584 expect(InvalidParameter
, status
);
2585 GdipDeleteGraphics(graphics
);
2587 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2589 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2590 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2593 status
= GdipGetNearestColor(graphics
, &color
);
2595 expect(0xdeadbeef, color
);
2596 GdipDeleteGraphics(graphics
);
2598 GdipDisposeImage((GpImage
*)bitmap
);
2600 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2602 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2603 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2606 status
= GdipGetNearestColor(graphics
, &color
);
2608 expect(0xdeadbeef, color
);
2609 GdipDeleteGraphics(graphics
);
2611 GdipDisposeImage((GpImage
*)bitmap
);
2613 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2615 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2616 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2619 status
= GdipGetNearestColor(graphics
, &color
);
2621 expect(0xdeadbeef, color
);
2622 GdipDeleteGraphics(graphics
);
2624 GdipDisposeImage((GpImage
*)bitmap
);
2626 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2628 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2629 todo_wine
expect(OutOfMemory
, status
);
2631 GdipDeleteGraphics(graphics
);
2632 GdipDisposeImage((GpImage
*)bitmap
);
2634 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2636 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2638 status
= GdipGetNearestColor(graphics
, &color
);
2640 expect(0xdeadbeef, color
);
2641 GdipDeleteGraphics(graphics
);
2642 GdipDisposeImage((GpImage
*)bitmap
);
2644 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2646 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2648 status
= GdipGetNearestColor(graphics
, &color
);
2650 expect(0xdeadbeef, color
);
2651 GdipDeleteGraphics(graphics
);
2652 GdipDisposeImage((GpImage
*)bitmap
);
2654 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2656 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2658 status
= GdipGetNearestColor(graphics
, &color
);
2660 expect(0xdeadbeef, color
);
2661 GdipDeleteGraphics(graphics
);
2662 GdipDisposeImage((GpImage
*)bitmap
);
2664 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2668 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2670 status
= GdipGetNearestColor(graphics
, &color
);
2672 expect(0xdeadbeef, color
);
2673 GdipDeleteGraphics(graphics
);
2674 GdipDisposeImage((GpImage
*)bitmap
);
2677 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2681 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2683 status
= GdipGetNearestColor(graphics
, &color
);
2685 expect(0xdeadbeef, color
);
2686 GdipDeleteGraphics(graphics
);
2687 GdipDisposeImage((GpImage
*)bitmap
);
2690 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2694 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2696 status
= GdipGetNearestColor(graphics
, &color
);
2698 expect(0xdeadbeef, color
);
2699 GdipDeleteGraphics(graphics
);
2700 GdipDisposeImage((GpImage
*)bitmap
);
2703 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2705 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2707 status
= GdipGetNearestColor(graphics
, &color
);
2709 todo_wine
expect(0xffa8bce8, color
);
2710 GdipDeleteGraphics(graphics
);
2711 GdipDisposeImage((GpImage
*)bitmap
);
2713 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2715 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2717 status
= GdipGetNearestColor(graphics
, &color
);
2720 ok(color
== 0xffa8b8e8 ||
2721 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2722 "Expected ffa8b8e8, got %.8x\n", color
);
2723 GdipDeleteGraphics(graphics
);
2724 GdipDisposeImage((GpImage
*)bitmap
);
2726 ReleaseDC(hwnd
, hdc
);
2729 static void test_string_functions(void)
2732 GpGraphics
*graphics
;
2733 GpFontFamily
*family
;
2735 RectF rc
, char_bounds
, bounds
;
2737 ARGB color
= 0xff000000;
2738 HDC hdc
= GetDC( hwnd
);
2739 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2740 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2741 REAL char_width
, char_height
;
2742 INT codepointsfitted
, linesfilled
;
2743 GpStringFormat
*format
;
2744 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2745 GpRegion
*regions
[4] = {0};
2746 BOOL region_isempty
[4];
2749 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2750 status
= GdipCreateFromHDC(hdc
, &graphics
);
2752 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2754 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2757 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2760 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2763 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2771 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2772 expect(InvalidParameter
, status
);
2774 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2775 expect(InvalidParameter
, status
);
2777 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2778 expect(InvalidParameter
, status
);
2780 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2781 expect(InvalidParameter
, status
);
2783 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2784 expect(InvalidParameter
, status
);
2786 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
2789 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2790 expect(InvalidParameter
, status
);
2792 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2793 expect(InvalidParameter
, status
);
2795 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2796 expect(InvalidParameter
, status
);
2798 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2799 expect(InvalidParameter
, status
);
2801 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
2802 expect(InvalidParameter
, status
);
2804 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
2807 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
2810 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
2812 expectf(0.0, char_bounds
.X
);
2813 expectf(0.0, char_bounds
.Y
);
2814 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
2815 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
2816 expect(1, codepointsfitted
);
2817 expect(1, linesfilled
);
2819 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2821 expectf(0.0, bounds
.X
);
2822 expectf(0.0, bounds
.Y
);
2823 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
2824 expectf(char_bounds
.Height
, bounds
.Height
);
2825 expect(2, codepointsfitted
);
2826 expect(1, linesfilled
);
2827 char_width
= bounds
.Width
- char_bounds
.Width
;
2829 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2831 expectf(0.0, bounds
.X
);
2832 expectf(0.0, bounds
.Y
);
2833 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
2834 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
2835 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
2836 expect(6, codepointsfitted
);
2837 expect(2, linesfilled
);
2838 char_height
= bounds
.Height
- char_bounds
.Height
;
2840 /* Cut off everything after the first space. */
2841 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
2843 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2845 expectf(0.0, bounds
.X
);
2846 expectf(0.0, bounds
.Y
);
2847 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
2848 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
2849 expect(6, codepointsfitted
);
2850 expect(3, linesfilled
);
2852 /* Cut off everything including the first space. */
2853 rc
.Width
= char_bounds
.Width
+ char_width
* 1.5;
2855 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2857 expectf(0.0, bounds
.X
);
2858 expectf(0.0, bounds
.Y
);
2859 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
2860 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
2861 expect(6, codepointsfitted
);
2862 expect(3, linesfilled
);
2864 /* Cut off everything after the first character. */
2865 rc
.Width
= char_bounds
.Width
+ char_width
* 0.5;
2867 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2869 expectf(0.0, bounds
.X
);
2870 expectf(0.0, bounds
.Y
);
2871 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
2872 todo_wine
expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
2873 expect(6, codepointsfitted
);
2874 todo_wine
expect(4, linesfilled
);
2876 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
2883 status
= GdipCreateRegion(®ions
[i
]);
2887 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
2888 expect(InvalidParameter
, status
);
2890 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
2891 expect(InvalidParameter
, status
);
2893 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
2894 expect(InvalidParameter
, status
);
2896 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
2897 expect(InvalidParameter
, status
);
2901 /* Crashes on Windows XP */
2902 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
2903 expect(InvalidParameter
, status
);
2906 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
2907 expect(InvalidParameter
, status
);
2909 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
2910 expect(InvalidParameter
, status
);
2912 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
2917 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
2921 ok(!region_isempty
[0], "region shouldn't be empty\n");
2922 ok(!region_isempty
[1], "region shouldn't be empty\n");
2923 ok(!region_isempty
[2], "region shouldn't be empty\n");
2924 ok(!region_isempty
[3], "region shouldn't be empty\n");
2926 /* Cut off everything after the first space, and the second line. */
2927 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
2928 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
2930 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
2935 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
2939 ok(!region_isempty
[0], "region shouldn't be empty\n");
2940 ok(!region_isempty
[1], "region shouldn't be empty\n");
2941 ok(region_isempty
[2], "region should be empty\n");
2942 ok(!region_isempty
[3], "region shouldn't be empty\n");
2945 GdipDeleteRegion(regions
[i
]);
2947 GdipDeleteStringFormat(format
);
2948 GdipDeleteBrush(brush
);
2949 GdipDeleteFont(font
);
2950 GdipDeleteFontFamily(family
);
2951 GdipDeleteGraphics(graphics
);
2953 ReleaseDC(hwnd
, hdc
);
2956 START_TEST(graphics
)
2958 struct GdiplusStartupInput gdiplusStartupInput
;
2959 ULONG_PTR gdiplusToken
;
2962 memset( &class, 0, sizeof(class) );
2963 class.lpszClassName
= "gdiplus_test";
2964 class.style
= CS_HREDRAW
| CS_VREDRAW
;
2965 class.lpfnWndProc
= DefWindowProcA
;
2966 class.hInstance
= GetModuleHandleA(0);
2967 class.hIcon
= LoadIcon(0, IDI_APPLICATION
);
2968 class.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
2969 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
2970 RegisterClassA( &class );
2971 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
2972 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
2973 ok(hwnd
!= NULL
, "Expected window to be created\n");
2975 gdiplusStartupInput
.GdiplusVersion
= 1;
2976 gdiplusStartupInput
.DebugEventCallback
= NULL
;
2977 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
2978 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2980 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2982 test_constructor_destructor();
2983 test_save_restore();
2984 test_GdipFillClosedCurve2();
2985 test_GdipFillClosedCurve2I();
2986 test_GdipDrawBezierI();
2988 test_GdipDrawArcI();
2989 test_GdipDrawCurve();
2990 test_GdipDrawCurveI();
2991 test_GdipDrawCurve2();
2992 test_GdipDrawCurve2I();
2993 test_GdipDrawCurve3();
2994 test_GdipDrawCurve3I();
2995 test_GdipDrawLineI();
2996 test_GdipDrawLinesI();
2997 test_GdipFillClosedCurve();
2998 test_GdipFillClosedCurveI();
2999 test_GdipDrawString();
3000 test_GdipGetNearestColor();
3001 test_GdipGetVisibleClipBounds();
3002 test_GdipIsVisiblePoint();
3003 test_GdipIsVisibleRect();
3004 test_Get_Release_DC();
3005 test_BeginContainer2();
3006 test_transformpoints();
3007 test_get_set_clip();
3010 test_textcontrast();
3011 test_fromMemoryBitmap();
3012 test_string_functions();
3014 GdiplusShutdown(gdiplusToken
);
3015 DestroyWindow( hwnd
);