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) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
29 #define TABLE_LEN (23)
33 static void test_constructor_destructor(void)
36 GpGraphics
*graphics
= NULL
;
37 HDC hdc
= GetDC( hwnd
);
39 stat
= GdipCreateFromHDC(NULL
, &graphics
);
40 expect(OutOfMemory
, stat
);
41 stat
= GdipDeleteGraphics(graphics
);
42 expect(InvalidParameter
, stat
);
44 stat
= GdipCreateFromHDC(hdc
, &graphics
);
46 stat
= GdipDeleteGraphics(graphics
);
49 stat
= GdipCreateFromHWND(NULL
, &graphics
);
51 stat
= GdipDeleteGraphics(graphics
);
54 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
56 stat
= GdipDeleteGraphics(graphics
);
59 stat
= GdipDeleteGraphics(NULL
);
60 expect(InvalidParameter
, stat
);
69 /* Linked list prepend function. */
70 static void log_state(GraphicsState data
, node
** log
)
72 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
74 new_entry
->data
= data
;
75 new_entry
->next
= *log
;
79 /* Checks if there are duplicates in the list, and frees it. */
80 static void check_no_duplicates(node
* log
)
92 while((temp
= temp
->next
)){
93 if(log
->data
== temp
->data
){
100 }while((log
= log
->next
));
105 HeapFree(GetProcessHeap(), 0, temp
);
113 static void test_save_restore(void)
116 GraphicsState state_a
, state_b
, state_c
;
117 InterpolationMode mode
;
118 GpGraphics
*graphics1
, *graphics2
;
119 node
* state_log
= NULL
;
120 HDC hdc
= GetDC( hwnd
);
121 state_a
= state_b
= state_c
= 0xdeadbeef;
123 /* Invalid saving. */
124 GdipCreateFromHDC(hdc
, &graphics1
);
125 stat
= GdipSaveGraphics(graphics1
, NULL
);
126 expect(InvalidParameter
, stat
);
127 stat
= GdipSaveGraphics(NULL
, &state_a
);
128 expect(InvalidParameter
, stat
);
129 GdipDeleteGraphics(graphics1
);
131 log_state(state_a
, &state_log
);
133 /* Basic save/restore. */
134 GdipCreateFromHDC(hdc
, &graphics1
);
135 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
136 stat
= GdipSaveGraphics(graphics1
, &state_a
);
138 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
139 stat
= GdipRestoreGraphics(graphics1
, state_a
);
141 GdipGetInterpolationMode(graphics1
, &mode
);
142 expect(InterpolationModeBilinear
, mode
);
143 GdipDeleteGraphics(graphics1
);
145 log_state(state_a
, &state_log
);
147 /* Restoring garbage doesn't affect saves. */
148 GdipCreateFromHDC(hdc
, &graphics1
);
149 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
150 GdipSaveGraphics(graphics1
, &state_a
);
151 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
152 GdipSaveGraphics(graphics1
, &state_b
);
153 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
154 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
156 GdipRestoreGraphics(graphics1
, state_b
);
157 GdipGetInterpolationMode(graphics1
, &mode
);
158 expect(InterpolationModeBicubic
, mode
);
159 GdipRestoreGraphics(graphics1
, state_a
);
160 GdipGetInterpolationMode(graphics1
, &mode
);
161 expect(InterpolationModeBilinear
, mode
);
162 GdipDeleteGraphics(graphics1
);
164 log_state(state_a
, &state_log
);
165 log_state(state_b
, &state_log
);
167 /* Restoring older state invalidates newer saves (but not older saves). */
168 GdipCreateFromHDC(hdc
, &graphics1
);
169 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
170 GdipSaveGraphics(graphics1
, &state_a
);
171 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
172 GdipSaveGraphics(graphics1
, &state_b
);
173 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
174 GdipSaveGraphics(graphics1
, &state_c
);
175 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
176 GdipRestoreGraphics(graphics1
, state_b
);
177 GdipGetInterpolationMode(graphics1
, &mode
);
178 expect(InterpolationModeBicubic
, mode
);
179 GdipRestoreGraphics(graphics1
, state_c
);
180 GdipGetInterpolationMode(graphics1
, &mode
);
181 expect(InterpolationModeBicubic
, mode
);
182 GdipRestoreGraphics(graphics1
, state_a
);
183 GdipGetInterpolationMode(graphics1
, &mode
);
184 expect(InterpolationModeBilinear
, mode
);
185 GdipDeleteGraphics(graphics1
);
187 log_state(state_a
, &state_log
);
188 log_state(state_b
, &state_log
);
189 log_state(state_c
, &state_log
);
191 /* Restoring older save from one graphics object does not invalidate
192 * newer save from other graphics object. */
193 GdipCreateFromHDC(hdc
, &graphics1
);
194 GdipCreateFromHDC(hdc
, &graphics2
);
195 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
196 GdipSaveGraphics(graphics1
, &state_a
);
197 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
198 GdipSaveGraphics(graphics2
, &state_b
);
199 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
200 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
201 GdipRestoreGraphics(graphics1
, state_a
);
202 GdipGetInterpolationMode(graphics1
, &mode
);
203 expect(InterpolationModeBilinear
, mode
);
204 GdipRestoreGraphics(graphics2
, state_b
);
205 GdipGetInterpolationMode(graphics2
, &mode
);
206 expect(InterpolationModeBicubic
, mode
);
207 GdipDeleteGraphics(graphics1
);
208 GdipDeleteGraphics(graphics2
);
210 /* You can't restore a state to a graphics object that didn't save it. */
211 GdipCreateFromHDC(hdc
, &graphics1
);
212 GdipCreateFromHDC(hdc
, &graphics2
);
213 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
214 GdipSaveGraphics(graphics1
, &state_a
);
215 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
216 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
217 GdipRestoreGraphics(graphics2
, state_a
);
218 GdipGetInterpolationMode(graphics2
, &mode
);
219 expect(InterpolationModeNearestNeighbor
, mode
);
220 GdipDeleteGraphics(graphics1
);
221 GdipDeleteGraphics(graphics2
);
223 log_state(state_a
, &state_log
);
225 /* The same state value should never be returned twice. */
227 check_no_duplicates(state_log
);
229 ReleaseDC(hwnd
, hdc
);
232 static void test_GdipDrawArc(void)
235 GpGraphics
*graphics
= NULL
;
237 HDC hdc
= GetDC( hwnd
);
239 /* make a graphics object and pen object */
240 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
242 status
= GdipCreateFromHDC(hdc
, &graphics
);
244 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
246 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
248 ok(pen
!= NULL
, "Expected pen to be initialized\n");
250 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
251 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
252 expect(InvalidParameter
, status
);
254 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
255 expect(InvalidParameter
, status
);
257 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
258 expect(InvalidParameter
, status
);
260 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
261 expect(InvalidParameter
, status
);
263 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
264 expect(InvalidParameter
, status
);
266 /* successful case */
267 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
271 GdipDeleteGraphics(graphics
);
273 ReleaseDC(hwnd
, hdc
);
276 static void test_GdipDrawArcI(void)
279 GpGraphics
*graphics
= NULL
;
281 HDC hdc
= GetDC( hwnd
);
283 /* make a graphics object and pen object */
284 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
286 status
= GdipCreateFromHDC(hdc
, &graphics
);
288 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
290 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
292 ok(pen
!= NULL
, "Expected pen to be initialized\n");
294 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
295 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
296 expect(InvalidParameter
, status
);
298 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
299 expect(InvalidParameter
, status
);
301 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
302 expect(InvalidParameter
, status
);
304 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
305 expect(InvalidParameter
, status
);
307 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
308 expect(InvalidParameter
, status
);
310 /* successful case */
311 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
315 GdipDeleteGraphics(graphics
);
317 ReleaseDC(hwnd
, hdc
);
320 static void test_BeginContainer2(void)
324 REAL defClip
[] = {5, 10, 15, 20};
325 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
326 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
327 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
328 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
329 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
330 REAL scale
, defScale
= 17;
331 GpUnit unit
, defUnit
= UnitPixel
;
332 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
333 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
334 UINT contrast
, defContrast
= 5;
335 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
338 GpGraphics
*graphics
= NULL
;
339 HDC hdc
= GetDC( hwnd
);
341 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
343 status
= GdipCreateFromHDC(hdc
, &graphics
);
345 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
347 /* null graphics, null container */
348 status
= GdipBeginContainer2(NULL
, &cont1
);
349 expect(InvalidParameter
, status
);
351 status
= GdipBeginContainer2(graphics
, NULL
);
352 expect(InvalidParameter
, status
);
354 status
= GdipEndContainer(NULL
, cont1
);
355 expect(InvalidParameter
, status
);
357 /* test all quality-related values */
358 GdipSetCompositingMode(graphics
, defCompmode
);
359 GdipSetCompositingQuality(graphics
, defCompqual
);
360 GdipSetInterpolationMode(graphics
, defInterp
);
361 GdipSetPageScale(graphics
, defScale
);
362 GdipSetPageUnit(graphics
, defUnit
);
363 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
364 GdipSetSmoothingMode(graphics
, defSmoothmode
);
365 GdipSetTextContrast(graphics
, defContrast
);
366 GdipSetTextRenderingHint(graphics
, defTexthint
);
368 status
= GdipBeginContainer2(graphics
, &cont1
);
371 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
372 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
373 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
374 GdipSetPageScale(graphics
, 10);
375 GdipSetPageUnit(graphics
, UnitDocument
);
376 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
377 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
378 GdipSetTextContrast(graphics
, 7);
379 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
381 status
= GdipEndContainer(graphics
, cont1
);
384 GdipGetCompositingMode(graphics
, &compmode
);
385 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
387 GdipGetCompositingQuality(graphics
, &compqual
);
388 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
390 GdipGetInterpolationMode(graphics
, &interp
);
391 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
393 GdipGetPageScale(graphics
, &scale
);
394 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
396 GdipGetPageUnit(graphics
, &unit
);
397 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
399 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
400 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
402 GdipGetSmoothingMode(graphics
, &smoothmode
);
403 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
405 GdipGetTextContrast(graphics
, &contrast
);
406 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
408 GdipGetTextRenderingHint(graphics
, &texthint
);
409 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
411 /* test world transform */
412 status
= GdipBeginContainer2(graphics
, &cont1
);
415 GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
416 defTrans
[4], defTrans
[5], &transform
);
417 GdipSetWorldTransform(graphics
, transform
);
418 GdipDeleteMatrix(transform
);
421 status
= GdipBeginContainer2(graphics
, &cont2
);
424 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
425 GdipSetWorldTransform(graphics
, transform
);
426 GdipDeleteMatrix(transform
);
429 status
= GdipEndContainer(graphics
, cont2
);
432 GdipCreateMatrix(&transform
);
433 GdipGetWorldTransform(graphics
, transform
);
434 GdipGetMatrixElements(transform
, elems
);
435 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
436 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
437 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
438 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
439 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
440 fabs(defTrans
[5] - elems
[5]) < 0.0001,
441 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
442 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
443 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
444 GdipDeleteMatrix(transform
);
447 status
= GdipEndContainer(graphics
, cont1
);
451 status
= GdipBeginContainer2(graphics
, &cont1
);
454 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
456 status
= GdipBeginContainer2(graphics
, &cont2
);
459 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
461 status
= GdipEndContainer(graphics
, cont2
);
463 GdipGetClipBounds(graphics
, &clip
);
464 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
465 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
466 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
467 fabs(defClip
[3] - clip
.Height
) < 0.0001,
468 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
469 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
470 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
472 status
= GdipEndContainer(graphics
, cont1
);
475 status
= GdipBeginContainer2(graphics
, &cont1
);
478 status
= GdipBeginContainer2(graphics
, &cont2
);
481 status
= GdipBeginContainer2(graphics
, &cont3
);
484 status
= GdipEndContainer(graphics
, cont3
);
487 status
= GdipBeginContainer2(graphics
, &cont4
);
490 status
= GdipEndContainer(graphics
, cont4
);
494 status
= GdipEndContainer(graphics
, cont1
);
497 /* end an already-ended container */
498 status
= GdipEndContainer(graphics
, cont1
);
501 GdipDeleteGraphics(graphics
);
502 ReleaseDC(hwnd
, hdc
);
505 static void test_GdipDrawBezierI(void)
508 GpGraphics
*graphics
= NULL
;
510 HDC hdc
= GetDC( hwnd
);
512 /* make a graphics object and pen object */
513 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
515 status
= GdipCreateFromHDC(hdc
, &graphics
);
517 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
519 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
521 ok(pen
!= NULL
, "Expected pen to be initialized\n");
523 /* InvalidParameter cases: null graphics, null pen */
524 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
525 expect(InvalidParameter
, status
);
527 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
528 expect(InvalidParameter
, status
);
530 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
531 expect(InvalidParameter
, status
);
533 /* successful case */
534 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
538 GdipDeleteGraphics(graphics
);
540 ReleaseDC(hwnd
, hdc
);
543 static void test_GdipDrawCurve3(void)
546 GpGraphics
*graphics
= NULL
;
548 HDC hdc
= GetDC( hwnd
);
560 /* make a graphics object and pen object */
561 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
563 status
= GdipCreateFromHDC(hdc
, &graphics
);
565 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
567 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
569 ok(pen
!= NULL
, "Expected pen to be initialized\n");
571 /* InvalidParameter cases: null graphics, null pen */
572 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
573 expect(InvalidParameter
, status
);
575 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
576 expect(InvalidParameter
, status
);
578 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
579 expect(InvalidParameter
, status
);
581 /* InvalidParameter cases: invalid count */
582 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
583 expect(InvalidParameter
, status
);
585 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
586 expect(InvalidParameter
, status
);
588 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
589 expect(InvalidParameter
, status
);
591 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
592 expect(InvalidParameter
, status
);
594 /* InvalidParameter cases: invalid number of segments */
595 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
596 expect(InvalidParameter
, status
);
598 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
599 expect(InvalidParameter
, status
);
601 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
602 expect(InvalidParameter
, status
);
604 /* Valid test cases */
605 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
608 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
611 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
614 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
618 GdipDeleteGraphics(graphics
);
620 ReleaseDC(hwnd
, hdc
);
623 static void test_GdipDrawCurve3I(void)
626 GpGraphics
*graphics
= NULL
;
628 HDC hdc
= GetDC( hwnd
);
640 /* make a graphics object and pen object */
641 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
643 status
= GdipCreateFromHDC(hdc
, &graphics
);
645 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
647 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
649 ok(pen
!= NULL
, "Expected pen to be initialized\n");
651 /* InvalidParameter cases: null graphics, null pen */
652 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
653 expect(InvalidParameter
, status
);
655 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
656 expect(InvalidParameter
, status
);
658 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
659 expect(InvalidParameter
, status
);
661 /* InvalidParameter cases: invalid count */
662 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
663 expect(OutOfMemory
, status
);
665 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
666 expect(InvalidParameter
, status
);
668 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
669 expect(InvalidParameter
, status
);
671 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
672 expect(InvalidParameter
, status
);
674 /* InvalidParameter cases: invalid number of segments */
675 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
676 expect(InvalidParameter
, status
);
678 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
679 expect(InvalidParameter
, status
);
681 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
682 expect(InvalidParameter
, status
);
684 /* Valid test cases */
685 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
688 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
691 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
694 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
698 GdipDeleteGraphics(graphics
);
700 ReleaseDC(hwnd
, hdc
);
703 static void test_GdipDrawCurve2(void)
706 GpGraphics
*graphics
= NULL
;
708 HDC hdc
= GetDC( hwnd
);
720 /* make a graphics object and pen object */
721 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
723 status
= GdipCreateFromHDC(hdc
, &graphics
);
725 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
727 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
729 ok(pen
!= NULL
, "Expected pen to be initialized\n");
731 /* InvalidParameter cases: null graphics, null pen */
732 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
733 expect(InvalidParameter
, status
);
735 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
736 expect(InvalidParameter
, status
);
738 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
739 expect(InvalidParameter
, status
);
741 /* InvalidParameter cases: invalid count */
742 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
743 expect(InvalidParameter
, status
);
745 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
746 expect(InvalidParameter
, status
);
748 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
749 expect(InvalidParameter
, status
);
751 /* Valid test cases */
752 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
755 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
758 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
761 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
765 GdipDeleteGraphics(graphics
);
767 ReleaseDC(hwnd
, hdc
);
770 static void test_GdipDrawCurve2I(void)
773 GpGraphics
*graphics
= NULL
;
775 HDC hdc
= GetDC( hwnd
);
787 /* make a graphics object and pen object */
788 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
790 status
= GdipCreateFromHDC(hdc
, &graphics
);
792 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
794 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
796 ok(pen
!= NULL
, "Expected pen to be initialized\n");
798 /* InvalidParameter cases: null graphics, null pen */
799 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
800 expect(InvalidParameter
, status
);
802 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
803 expect(InvalidParameter
, status
);
805 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
806 expect(InvalidParameter
, status
);
808 /* InvalidParameter cases: invalid count */
809 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
810 expect(OutOfMemory
, status
);
812 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
813 expect(InvalidParameter
, status
);
815 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
816 expect(InvalidParameter
, status
);
818 /* Valid test cases */
819 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
822 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
825 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
828 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
832 GdipDeleteGraphics(graphics
);
834 ReleaseDC(hwnd
, hdc
);
837 static void test_GdipDrawCurve(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
= GdipDrawCurve(NULL
, NULL
, points
, 3);
867 expect(InvalidParameter
, status
);
869 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
870 expect(InvalidParameter
, status
);
872 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
873 expect(InvalidParameter
, status
);
875 /* InvalidParameter cases: invalid count */
876 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
877 expect(InvalidParameter
, status
);
879 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
880 expect(InvalidParameter
, status
);
882 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
883 expect(InvalidParameter
, status
);
885 /* Valid test cases */
886 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
889 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
893 GdipDeleteGraphics(graphics
);
895 ReleaseDC(hwnd
, hdc
);
898 static void test_GdipDrawCurveI(void)
901 GpGraphics
*graphics
= NULL
;
903 HDC hdc
= GetDC( hwnd
);
915 /* make a graphics object and pen object */
916 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
918 status
= GdipCreateFromHDC(hdc
, &graphics
);
920 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
922 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
924 ok(pen
!= NULL
, "Expected pen to be initialized\n");
926 /* InvalidParameter cases: null graphics, null pen */
927 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
928 expect(InvalidParameter
, status
);
930 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
931 expect(InvalidParameter
, status
);
933 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
934 expect(InvalidParameter
, status
);
936 /* InvalidParameter cases: invalid count */
937 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
938 expect(OutOfMemory
, status
);
940 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
941 expect(InvalidParameter
, status
);
943 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
944 expect(InvalidParameter
, status
);
946 /* Valid test cases */
947 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
950 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
954 GdipDeleteGraphics(graphics
);
956 ReleaseDC(hwnd
, hdc
);
959 static void test_GdipDrawLineI(void)
962 GpGraphics
*graphics
= NULL
;
964 HDC hdc
= GetDC( hwnd
);
966 /* make a graphics object and pen object */
967 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
969 status
= GdipCreateFromHDC(hdc
, &graphics
);
971 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
973 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
975 ok(pen
!= NULL
, "Expected pen to be initialized\n");
977 /* InvalidParameter cases: null graphics, null pen */
978 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
979 expect(InvalidParameter
, status
);
981 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
982 expect(InvalidParameter
, status
);
984 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
985 expect(InvalidParameter
, status
);
987 /* successful case */
988 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
992 GdipDeleteGraphics(graphics
);
994 ReleaseDC(hwnd
, hdc
);
997 static void test_GdipDrawLinesI(void)
1000 GpGraphics
*graphics
= NULL
;
1002 GpPoint
*ptf
= NULL
;
1003 HDC hdc
= GetDC( hwnd
);
1005 /* make a graphics object and pen object */
1006 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1008 status
= GdipCreateFromHDC(hdc
, &graphics
);
1010 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1012 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1014 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1016 /* make some arbitrary valid points*/
1017 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1025 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1026 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1027 expect(InvalidParameter
, status
);
1029 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1030 expect(InvalidParameter
, status
);
1032 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1033 expect(InvalidParameter
, status
);
1035 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1036 expect(InvalidParameter
, status
);
1038 /* successful case */
1039 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1044 GdipDeleteGraphics(graphics
);
1046 ReleaseDC(hwnd
, hdc
);
1049 static void test_Get_Release_DC(void)
1052 GpGraphics
*graphics
= NULL
;
1056 HDC hdc
= GetDC( hwnd
);
1059 CompositingQuality quality
;
1060 CompositingMode compmode
;
1061 InterpolationMode intmode
;
1065 PixelOffsetMode offsetmode
;
1066 SmoothingMode smoothmode
;
1067 TextRenderingHint texthint
;
1075 ARGB color
= 0x00000000;
1076 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1089 for(i
= 0; i
< 5;i
++){
1090 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1091 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1097 rect
[0].Height
= 70;
1101 rect
[1].Height
= 20;
1103 for(i
= 0; i
< 2;i
++){
1104 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1105 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1106 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1107 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1110 GdipCreateMatrix(&m
);
1111 GdipCreateRegion(®ion
);
1112 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1113 GdipCreatePath(FillModeAlternate
, &path
);
1114 GdipCreateRegion(&clip
);
1116 status
= GdipCreateFromHDC(hdc
, &graphics
);
1118 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1119 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1122 /* NULL arguments */
1123 status
= GdipGetDC(NULL
, NULL
);
1124 expect(InvalidParameter
, status
);
1125 status
= GdipGetDC(graphics
, NULL
);
1126 expect(InvalidParameter
, status
);
1127 status
= GdipGetDC(NULL
, &retdc
);
1128 expect(InvalidParameter
, status
);
1130 status
= GdipReleaseDC(NULL
, NULL
);
1131 expect(InvalidParameter
, status
);
1132 status
= GdipReleaseDC(graphics
, NULL
);
1133 expect(InvalidParameter
, status
);
1134 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1135 expect(InvalidParameter
, status
);
1137 /* Release without Get */
1138 status
= GdipReleaseDC(graphics
, hdc
);
1139 expect(InvalidParameter
, status
);
1142 status
= GdipGetDC(graphics
, &retdc
);
1144 ok(retdc
== hdc
, "Invalid HDC returned\n");
1145 /* call it once more */
1146 status
= GdipGetDC(graphics
, &retdc
);
1147 expect(ObjectBusy
, status
);
1149 /* try all Graphics calls here */
1151 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1152 expect(ObjectBusy
, status
); status
= Ok
;
1153 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1154 expect(ObjectBusy
, status
); status
= Ok
;
1155 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1156 expect(ObjectBusy
, status
); status
= Ok
;
1157 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1158 expect(ObjectBusy
, status
); status
= Ok
;
1159 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1160 expect(ObjectBusy
, status
); status
= Ok
;
1161 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1162 expect(ObjectBusy
, status
); status
= Ok
;
1163 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1164 expect(ObjectBusy
, status
); status
= Ok
;
1165 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1166 expect(ObjectBusy
, status
); status
= Ok
;
1167 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1168 expect(ObjectBusy
, status
); status
= Ok
;
1169 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1170 expect(ObjectBusy
, status
); status
= Ok
;
1171 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1172 expect(ObjectBusy
, status
); status
= Ok
;
1173 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1174 expect(ObjectBusy
, status
); status
= Ok
;
1175 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1176 expect(ObjectBusy
, status
); status
= Ok
;
1177 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1178 expect(ObjectBusy
, status
); status
= Ok
;
1179 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1180 expect(ObjectBusy
, status
); status
= Ok
;
1181 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1182 expect(ObjectBusy
, status
); status
= Ok
;
1183 /* GdipDrawImage/GdipDrawImageI */
1184 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1185 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1186 /* GdipDrawImageRect/GdipDrawImageRectI */
1187 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1188 expect(ObjectBusy
, status
); status
= Ok
;
1189 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1190 expect(ObjectBusy
, status
); status
= Ok
;
1191 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1192 expect(ObjectBusy
, status
); status
= Ok
;
1193 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1194 expect(ObjectBusy
, status
); status
= Ok
;
1195 status
= GdipDrawPath(graphics
, pen
, path
);
1196 expect(ObjectBusy
, status
); status
= Ok
;
1197 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1198 expect(ObjectBusy
, status
); status
= Ok
;
1199 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1200 expect(ObjectBusy
, status
); status
= Ok
;
1201 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1202 expect(ObjectBusy
, status
); status
= Ok
;
1203 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1204 expect(ObjectBusy
, status
); status
= Ok
;
1205 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1206 expect(ObjectBusy
, status
); status
= Ok
;
1207 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1208 expect(ObjectBusy
, status
); status
= Ok
;
1209 /* GdipDrawString */
1210 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1211 expect(ObjectBusy
, status
); status
= Ok
;
1212 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1213 expect(ObjectBusy
, status
); status
= Ok
;
1214 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1215 expect(ObjectBusy
, status
); status
= Ok
;
1216 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1217 expect(ObjectBusy
, status
); status
= Ok
;
1218 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1219 expect(ObjectBusy
, status
); status
= Ok
;
1220 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1221 expect(ObjectBusy
, status
); status
= Ok
;
1222 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1223 expect(ObjectBusy
, status
); status
= Ok
;
1224 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1225 expect(ObjectBusy
, status
); status
= Ok
;
1226 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1227 expect(ObjectBusy
, status
); status
= Ok
;
1228 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1229 expect(ObjectBusy
, status
); status
= Ok
;
1230 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1231 expect(ObjectBusy
, status
); status
= Ok
;
1232 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1233 expect(ObjectBusy
, status
); status
= Ok
;
1234 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1235 expect(ObjectBusy
, status
); status
= Ok
;
1236 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1237 expect(ObjectBusy
, status
); status
= Ok
;
1238 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1239 expect(ObjectBusy
, status
); status
= Ok
;
1240 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1241 expect(ObjectBusy
, status
); status
= Ok
;
1242 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1243 expect(ObjectBusy
, status
); status
= Ok
;
1244 status
= GdipGetClipBounds(graphics
, rectf
);
1245 expect(ObjectBusy
, status
); status
= Ok
;
1246 status
= GdipGetClipBoundsI(graphics
, rect
);
1247 expect(ObjectBusy
, status
); status
= Ok
;
1248 status
= GdipGetCompositingMode(graphics
, &compmode
);
1249 expect(ObjectBusy
, status
); status
= Ok
;
1250 status
= GdipGetCompositingQuality(graphics
, &quality
);
1251 expect(ObjectBusy
, status
); status
= Ok
;
1252 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1253 expect(ObjectBusy
, status
); status
= Ok
;
1254 status
= GdipGetNearestColor(graphics
, &color
);
1255 expect(ObjectBusy
, status
); status
= Ok
;
1256 status
= GdipGetPageScale(graphics
, &r
);
1257 expect(ObjectBusy
, status
); status
= Ok
;
1258 status
= GdipGetPageUnit(graphics
, &unit
);
1259 expect(ObjectBusy
, status
); status
= Ok
;
1260 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1261 expect(ObjectBusy
, status
); status
= Ok
;
1262 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1263 expect(ObjectBusy
, status
); status
= Ok
;
1264 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1265 expect(ObjectBusy
, status
); status
= Ok
;
1266 status
= GdipGetWorldTransform(graphics
, m
);
1267 expect(ObjectBusy
, status
); status
= Ok
;
1268 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1269 expect(ObjectBusy
, status
); status
= Ok
;
1270 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1271 expect(ObjectBusy
, status
); status
= Ok
;
1272 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1273 expect(ObjectBusy
, status
); status
= Ok
;
1274 /* GdipMeasureCharacterRanges */
1275 /* GdipMeasureString */
1276 status
= GdipResetClip(graphics
);
1277 expect(ObjectBusy
, status
); status
= Ok
;
1278 status
= GdipResetWorldTransform(graphics
);
1279 expect(ObjectBusy
, status
); status
= Ok
;
1280 /* GdipRestoreGraphics */
1281 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1282 expect(ObjectBusy
, status
); status
= Ok
;
1283 /* GdipSaveGraphics */
1284 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1285 expect(ObjectBusy
, status
); status
= Ok
;
1286 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1287 expect(ObjectBusy
, status
); status
= Ok
;
1288 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1289 expect(ObjectBusy
, status
); status
= Ok
;
1290 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1291 expect(ObjectBusy
, status
); status
= Ok
;
1292 status
= GdipSetPageScale(graphics
, 1.0);
1293 expect(ObjectBusy
, status
); status
= Ok
;
1294 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1295 expect(ObjectBusy
, status
); status
= Ok
;
1296 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1297 expect(ObjectBusy
, status
); status
= Ok
;
1298 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1299 expect(ObjectBusy
, status
); status
= Ok
;
1300 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1301 expect(ObjectBusy
, status
); status
= Ok
;
1302 status
= GdipSetWorldTransform(graphics
, m
);
1303 expect(ObjectBusy
, status
); status
= Ok
;
1304 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1305 expect(ObjectBusy
, status
); status
= Ok
;
1306 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1307 expect(ObjectBusy
, status
); status
= Ok
;
1308 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1309 expect(ObjectBusy
, status
); status
= Ok
;
1310 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1311 expect(ObjectBusy
, status
); status
= Ok
;
1312 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1313 expect(ObjectBusy
, status
); status
= Ok
;
1314 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1315 expect(ObjectBusy
, status
); status
= Ok
;
1316 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1317 expect(ObjectBusy
, status
); status
= Ok
;
1318 status
= GdipTranslateClipI(graphics
, 0, 0);
1319 expect(ObjectBusy
, status
); status
= Ok
;
1320 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1321 expect(ObjectBusy
, status
); status
= Ok
;
1322 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1323 expect(ObjectBusy
, status
); status
= Ok
;
1324 status
= GdipGetDpiX(graphics
, &r
);
1325 expect(ObjectBusy
, status
); status
= Ok
;
1326 status
= GdipGetDpiY(graphics
, &r
);
1327 expect(ObjectBusy
, status
); status
= Ok
;
1328 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1329 status
= GdipGetClip(graphics
, region
);
1330 expect(ObjectBusy
, status
); status
= Ok
;
1331 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1332 expect(ObjectBusy
, status
); status
= Ok
;
1333 /* try to delete before release */
1334 status
= GdipDeleteGraphics(graphics
);
1335 expect(ObjectBusy
, status
);
1337 status
= GdipReleaseDC(graphics
, retdc
);
1341 GdipDeleteGraphics(graphics
);
1343 GdipDeleteRegion(clip
);
1344 GdipDeletePath(path
);
1345 GdipDeleteBrush((GpBrush
*)brush
);
1346 GdipDeleteRegion(region
);
1347 GdipDeleteMatrix(m
);
1350 ReleaseDC(hwnd
, hdc
);
1353 static void test_transformpoints(void)
1356 GpGraphics
*graphics
= NULL
;
1357 HDC hdc
= GetDC( hwnd
);
1361 status
= GdipCreateFromHDC(hdc
, &graphics
);
1364 /* NULL arguments */
1365 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1366 expect(InvalidParameter
, status
);
1367 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1368 expect(InvalidParameter
, status
);
1369 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1370 expect(InvalidParameter
, status
);
1371 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1372 expect(InvalidParameter
, status
);
1378 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1380 expectf(1.0, ptf
[0].X
);
1381 expectf(0.0, ptf
[0].Y
);
1382 expectf(0.0, ptf
[1].X
);
1383 expectf(1.0, ptf
[1].Y
);
1385 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1387 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1389 status
= GdipSetPageScale(graphics
, 3.0);
1396 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1398 expectf(18.0, ptf
[0].X
);
1399 expectf(15.0, ptf
[0].Y
);
1400 expectf(15.0, ptf
[1].X
);
1401 expectf(18.0, ptf
[1].Y
);
1407 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1409 expectf(6.0, ptf
[0].X
);
1410 expectf(5.0, ptf
[0].Y
);
1411 expectf(5.0, ptf
[1].X
);
1412 expectf(6.0, ptf
[1].Y
);
1418 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1420 expectf(3.0, ptf
[0].X
);
1421 expectf(0.0, ptf
[0].Y
);
1422 expectf(0.0, ptf
[1].X
);
1423 expectf(3.0, ptf
[1].Y
);
1429 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1431 expectf(1.0, ptf
[0].X
);
1432 expectf(0.0, ptf
[0].Y
);
1433 expectf(0.0, ptf
[1].X
);
1434 expectf(1.0, ptf
[1].Y
);
1440 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1442 expectf(1.0, ptf
[0].X
);
1443 expectf(0.0, ptf
[0].Y
);
1444 expectf(0.0, ptf
[1].X
);
1445 expectf(1.0, ptf
[1].Y
);
1451 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1453 expectf(1.0, ptf
[0].X
);
1454 expectf(0.0, ptf
[0].Y
);
1455 expectf(0.0, ptf
[1].X
);
1456 expectf(1.0, ptf
[1].Y
);
1462 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1464 expect(18, pt
[0].X
);
1465 expect(15, pt
[0].Y
);
1466 expect(15, pt
[1].X
);
1467 expect(18, pt
[1].Y
);
1469 GdipDeleteGraphics(graphics
);
1470 ReleaseDC(hwnd
, hdc
);
1473 static void test_get_set_clip(void)
1476 GpGraphics
*graphics
= NULL
;
1477 HDC hdc
= GetDC( hwnd
);
1482 status
= GdipCreateFromHDC(hdc
, &graphics
);
1485 rect
.X
= rect
.Y
= 0.0;
1486 rect
.Height
= rect
.Width
= 100.0;
1488 status
= GdipCreateRegionRect(&rect
, &clip
);
1490 /* NULL arguments */
1491 status
= GdipGetClip(NULL
, NULL
);
1492 expect(InvalidParameter
, status
);
1493 status
= GdipGetClip(graphics
, NULL
);
1494 expect(InvalidParameter
, status
);
1495 status
= GdipGetClip(NULL
, clip
);
1496 expect(InvalidParameter
, status
);
1498 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1499 expect(InvalidParameter
, status
);
1500 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1501 expect(InvalidParameter
, status
);
1503 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1504 expect(InvalidParameter
, status
);
1505 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1506 expect(InvalidParameter
, status
);
1509 status
= GdipGetClip(graphics
, clip
);
1511 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1515 /* remains infinite after reset */
1517 status
= GdipResetClip(graphics
);
1519 status
= GdipGetClip(graphics
, clip
);
1521 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1525 /* set to empty and then reset to infinite */
1526 status
= GdipSetEmpty(clip
);
1528 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1531 status
= GdipGetClip(graphics
, clip
);
1534 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1537 status
= GdipResetClip(graphics
);
1539 status
= GdipGetClip(graphics
, clip
);
1542 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1546 GdipDeleteRegion(clip
);
1548 GdipDeleteGraphics(graphics
);
1549 ReleaseDC(hwnd
, hdc
);
1552 static void test_isempty(void)
1555 GpGraphics
*graphics
= NULL
;
1556 HDC hdc
= GetDC( hwnd
);
1560 status
= GdipCreateFromHDC(hdc
, &graphics
);
1563 status
= GdipCreateRegion(&clip
);
1567 status
= GdipIsClipEmpty(NULL
, NULL
);
1568 expect(InvalidParameter
, status
);
1569 status
= GdipIsClipEmpty(graphics
, NULL
);
1570 expect(InvalidParameter
, status
);
1571 status
= GdipIsClipEmpty(NULL
, &res
);
1572 expect(InvalidParameter
, status
);
1574 /* default is infinite */
1576 status
= GdipIsClipEmpty(graphics
, &res
);
1580 GdipDeleteRegion(clip
);
1582 GdipDeleteGraphics(graphics
);
1583 ReleaseDC(hwnd
, hdc
);
1586 static void test_clear(void)
1590 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
1591 expect(InvalidParameter
, status
);
1594 static void test_textcontrast(void)
1597 HDC hdc
= GetDC( hwnd
);
1598 GpGraphics
*graphics
;
1601 status
= GdipGetTextContrast(NULL
, NULL
);
1602 expect(InvalidParameter
, status
);
1604 status
= GdipCreateFromHDC(hdc
, &graphics
);
1607 status
= GdipGetTextContrast(graphics
, NULL
);
1608 expect(InvalidParameter
, status
);
1609 status
= GdipGetTextContrast(graphics
, &contrast
);
1610 expect(4, contrast
);
1612 GdipDeleteGraphics(graphics
);
1613 ReleaseDC(hwnd
, hdc
);
1616 static void test_GdipDrawString(void)
1619 GpGraphics
*graphics
= NULL
;
1622 GpStringFormat
*format
;
1625 HDC hdc
= GetDC( hwnd
);
1626 static const WCHAR string
[] = {'T','e','s','t',0};
1628 memset(&logfont
,0,sizeof(logfont
));
1629 strcpy(logfont
.lfFaceName
,"Arial");
1630 logfont
.lfHeight
= 12;
1631 logfont
.lfCharSet
= DEFAULT_CHARSET
;
1633 status
= GdipCreateFromHDC(hdc
, &graphics
);
1636 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
1637 if (status
== FileNotFound
)
1639 skip("Arial not installed.\n");
1644 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
1647 status
= GdipCreateStringFormat(0,0,&format
);
1655 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
1658 GdipDeleteGraphics(graphics
);
1659 GdipDeleteBrush(brush
);
1660 GdipDeleteFont(fnt
);
1661 GdipDeleteStringFormat(format
);
1663 ReleaseDC(hwnd
, hdc
);
1666 static void test_GdipGetVisibleClipBounds_screen(void)
1669 GpGraphics
*graphics
= NULL
;
1671 GpRectF rectf
, exp
, clipr
;
1674 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1676 status
= GdipCreateFromHDC(hdc
, &graphics
);
1678 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1680 /* no clipping rect */
1683 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
1684 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
1686 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1688 ok(rectf
.X
== exp
.X
&&
1690 rectf
.Width
== exp
.Width
&&
1691 rectf
.Height
== exp
.Height
,
1692 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1693 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1694 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1695 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1697 /* clipping rect entirely within window */
1698 exp
.X
= clipr
.X
= 10;
1699 exp
.Y
= clipr
.Y
= 12;
1700 exp
.Width
= clipr
.Width
= 14;
1701 exp
.Height
= clipr
.Height
= 16;
1703 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1706 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1708 ok(rectf
.X
== exp
.X
&&
1710 rectf
.Width
== exp
.Width
&&
1711 rectf
.Height
== exp
.Height
,
1712 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1713 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1714 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1715 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1717 /* clipping rect partially outside of screen */
1723 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1731 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1733 ok(rectf
.X
== exp
.X
&&
1735 rectf
.Width
== exp
.Width
&&
1736 rectf
.Height
== exp
.Height
,
1737 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1738 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1739 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1740 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1742 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
1744 ok(recti
.X
== exp
.X
&&
1746 recti
.Width
== exp
.Width
&&
1747 recti
.Height
== exp
.Height
,
1748 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1749 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1750 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
1751 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1753 GdipDeleteGraphics(graphics
);
1757 static void test_GdipGetVisibleClipBounds_window(void)
1760 GpGraphics
*graphics
= NULL
;
1761 GpRectF rectf
, window
, exp
, clipr
;
1767 /* get client area size */
1768 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
1769 window
.X
= wnd_rect
.left
;
1770 window
.Y
= wnd_rect
.top
;
1771 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
1772 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
1774 hdc
= BeginPaint(hwnd
, &ps
);
1776 status
= GdipCreateFromHDC(hdc
, &graphics
);
1778 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1780 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1782 ok(rectf
.X
== window
.X
&&
1783 rectf
.Y
== window
.Y
&&
1784 rectf
.Width
== window
.Width
&&
1785 rectf
.Height
== window
.Height
,
1786 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1787 "the window (%0.f, %0.f, %0.f, %0.f)\n",
1788 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1789 window
.X
, window
.Y
, window
.Width
, window
.Height
);
1791 /* clipping rect entirely within window */
1792 exp
.X
= clipr
.X
= 20;
1793 exp
.Y
= clipr
.Y
= 8;
1794 exp
.Width
= clipr
.Width
= 30;
1795 exp
.Height
= clipr
.Height
= 20;
1797 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1800 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1802 ok(rectf
.X
== exp
.X
&&
1804 rectf
.Width
== exp
.Width
&&
1805 rectf
.Height
== exp
.Height
,
1806 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1807 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1808 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1809 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1811 /* clipping rect partially outside of window */
1812 clipr
.X
= window
.Width
- 10;
1813 clipr
.Y
= window
.Height
- 15;
1817 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1820 exp
.X
= window
.Width
- 10;
1821 exp
.Y
= window
.Height
- 15;
1825 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1827 ok(rectf
.X
== exp
.X
&&
1829 rectf
.Width
== exp
.Width
&&
1830 rectf
.Height
== exp
.Height
,
1831 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1832 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1833 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1834 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1836 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
1838 ok(recti
.X
== exp
.X
&&
1840 recti
.Width
== exp
.Width
&&
1841 recti
.Height
== exp
.Height
,
1842 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1843 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1844 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
1845 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1847 GdipDeleteGraphics(graphics
);
1848 EndPaint(hwnd
, &ps
);
1851 static void test_GdipGetVisibleClipBounds(void)
1853 GpGraphics
* graphics
= NULL
;
1856 HDC hdc
= GetDC( hwnd
);
1859 status
= GdipCreateFromHDC(hdc
, &graphics
);
1861 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1863 /* test null parameters */
1864 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
1865 expect(InvalidParameter
, status
);
1867 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
1868 expect(InvalidParameter
, status
);
1870 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
1871 expect(InvalidParameter
, status
);
1873 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
1874 expect(InvalidParameter
, status
);
1876 GdipDeleteGraphics(graphics
);
1877 ReleaseDC(hwnd
, hdc
);
1879 test_GdipGetVisibleClipBounds_screen();
1880 test_GdipGetVisibleClipBounds_window();
1883 static void test_fromMemoryBitmap(void)
1886 GpGraphics
*graphics
= NULL
;
1887 GpBitmap
*bitmap
= NULL
;
1888 BYTE bits
[48] = {0};
1890 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
1893 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1896 status
= GdipGraphicsClear(graphics
, 0xff686868);
1899 GdipDeleteGraphics(graphics
);
1901 /* drawing writes to the memory provided */
1902 todo_wine
expect(0x68, bits
[10]);
1904 GdipDisposeImage((GpImage
*)bitmap
);
1907 static void test_GdipIsVisiblePoint(void)
1910 GpGraphics
*graphics
= NULL
;
1911 HDC hdc
= GetDC( hwnd
);
1915 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1917 status
= GdipCreateFromHDC(hdc
, &graphics
);
1919 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1921 /* null parameters */
1922 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
1923 expect(InvalidParameter
, status
);
1925 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
1926 expect(InvalidParameter
, status
);
1928 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
1929 expect(InvalidParameter
, status
);
1931 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
1932 expect(InvalidParameter
, status
);
1936 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1938 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1942 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1944 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1948 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1950 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1954 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1956 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1958 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
1963 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1965 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
1969 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1971 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
1973 /* translate into the center of the rect */
1974 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
1978 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1980 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1984 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1986 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1988 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
1993 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1995 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
1999 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2001 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2005 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2007 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2011 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2013 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2017 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2019 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2023 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2025 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2029 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2031 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2035 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2037 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2041 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2043 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2047 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2049 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2053 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2055 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2059 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2061 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2065 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2067 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2069 /* integer version */
2072 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2074 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2078 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2080 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2082 GdipDeleteGraphics(graphics
);
2083 ReleaseDC(hwnd
, hdc
);
2086 static void test_GdipIsVisibleRect(void)
2089 GpGraphics
*graphics
= NULL
;
2090 HDC hdc
= GetDC( hwnd
);
2091 REAL x
, y
, width
, height
;
2094 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2096 status
= GdipCreateFromHDC(hdc
, &graphics
);
2098 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2100 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2101 expect(InvalidParameter
, status
);
2103 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2104 expect(InvalidParameter
, status
);
2106 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2107 expect(InvalidParameter
, status
);
2109 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2110 expect(InvalidParameter
, status
);
2112 /* entirely within the visible region */
2115 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2117 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2119 /* partially outside */
2120 x
= -10; width
= 20;
2121 y
= -10; height
= 20;
2122 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2124 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2126 /* entirely outside */
2128 y
= -10; height
= 5;
2129 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2131 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2133 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2136 /* entirely within the visible region */
2138 y
= 22; height
= 10;
2139 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2141 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2143 /* partially outside */
2145 y
= 55; height
= 10;
2146 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2148 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2150 /* entirely outside */
2153 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2155 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2157 /* translate into center of clipping rect */
2158 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2162 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2164 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2168 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2170 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2172 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2174 /* corners entirely outside, but some intersections */
2177 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2179 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2183 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2185 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2189 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2191 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2195 y
= 20; height
= 40;
2196 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2198 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2202 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2204 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2207 y
= 20; height
= 40;
2208 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2210 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2213 y
= 60; height
= 10;
2214 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2216 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2218 /* rounding tests */
2219 x
= 0.4; width
= 10.4;
2220 y
= 20; height
= 40;
2221 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2223 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2226 y
= 0.4; height
= 20.4;
2227 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2229 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2231 /* integer version */
2234 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2236 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2239 y
= 22; height
= 10;
2240 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2242 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2244 GdipDeleteGraphics(graphics
);
2245 ReleaseDC(hwnd
, hdc
);
2248 static void test_GdipGetNearestColor(void)
2251 GpGraphics
*graphics
;
2253 ARGB color
= 0xdeadbeef;
2254 HDC hdc
= GetDC( hwnd
);
2256 /* create a graphics object */
2257 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2259 status
= GdipCreateFromHDC(hdc
, &graphics
);
2261 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2263 status
= GdipGetNearestColor(graphics
, NULL
);
2264 expect(InvalidParameter
, status
);
2266 status
= GdipGetNearestColor(NULL
, &color
);
2267 expect(InvalidParameter
, status
);
2268 GdipDeleteGraphics(graphics
);
2270 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2272 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2273 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2276 status
= GdipGetNearestColor(graphics
, &color
);
2278 expect(0xdeadbeef, color
);
2279 GdipDeleteGraphics(graphics
);
2281 GdipDisposeImage((GpImage
*)bitmap
);
2283 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2285 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2286 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2289 status
= GdipGetNearestColor(graphics
, &color
);
2291 expect(0xdeadbeef, color
);
2292 GdipDeleteGraphics(graphics
);
2294 GdipDisposeImage((GpImage
*)bitmap
);
2296 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2298 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2299 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2302 status
= GdipGetNearestColor(graphics
, &color
);
2304 expect(0xdeadbeef, color
);
2305 GdipDeleteGraphics(graphics
);
2307 GdipDisposeImage((GpImage
*)bitmap
);
2309 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2311 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2312 todo_wine
expect(OutOfMemory
, status
);
2314 GdipDeleteGraphics(graphics
);
2315 GdipDisposeImage((GpImage
*)bitmap
);
2317 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2319 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2321 status
= GdipGetNearestColor(graphics
, &color
);
2323 expect(0xdeadbeef, color
);
2324 GdipDeleteGraphics(graphics
);
2325 GdipDisposeImage((GpImage
*)bitmap
);
2327 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2329 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2331 status
= GdipGetNearestColor(graphics
, &color
);
2333 expect(0xdeadbeef, color
);
2334 GdipDeleteGraphics(graphics
);
2335 GdipDisposeImage((GpImage
*)bitmap
);
2337 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2339 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2341 status
= GdipGetNearestColor(graphics
, &color
);
2343 expect(0xdeadbeef, color
);
2344 GdipDeleteGraphics(graphics
);
2345 GdipDisposeImage((GpImage
*)bitmap
);
2347 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2349 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2351 status
= GdipGetNearestColor(graphics
, &color
);
2353 expect(0xdeadbeef, color
);
2354 GdipDeleteGraphics(graphics
);
2355 GdipDisposeImage((GpImage
*)bitmap
);
2357 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2359 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2361 status
= GdipGetNearestColor(graphics
, &color
);
2363 expect(0xdeadbeef, color
);
2364 GdipDeleteGraphics(graphics
);
2365 GdipDisposeImage((GpImage
*)bitmap
);
2367 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2369 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2371 status
= GdipGetNearestColor(graphics
, &color
);
2373 expect(0xdeadbeef, color
);
2374 GdipDeleteGraphics(graphics
);
2375 GdipDisposeImage((GpImage
*)bitmap
);
2377 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2379 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2381 status
= GdipGetNearestColor(graphics
, &color
);
2383 todo_wine
expect(0xffa8bce8, color
);
2384 GdipDeleteGraphics(graphics
);
2385 GdipDisposeImage((GpImage
*)bitmap
);
2387 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2389 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2391 status
= GdipGetNearestColor(graphics
, &color
);
2394 ok(color
== 0xffa8b8e8 ||
2395 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2396 "Expected ffa8b8e8, got %.8x\n", color
);
2397 GdipDeleteGraphics(graphics
);
2398 GdipDisposeImage((GpImage
*)bitmap
);
2400 ReleaseDC(hwnd
, hdc
);
2403 START_TEST(graphics
)
2405 struct GdiplusStartupInput gdiplusStartupInput
;
2406 ULONG_PTR gdiplusToken
;
2409 memset( &class, 0, sizeof(class) );
2410 class.lpszClassName
= "gdiplus_test";
2411 class.style
= CS_HREDRAW
| CS_VREDRAW
;
2412 class.lpfnWndProc
= DefWindowProcA
;
2413 class.hInstance
= GetModuleHandleA(0);
2414 class.hIcon
= LoadIcon(0, IDI_APPLICATION
);
2415 class.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
2416 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
2417 RegisterClassA( &class );
2418 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
2419 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
2420 ok(hwnd
!= NULL
, "Expected window to be created\n");
2422 gdiplusStartupInput
.GdiplusVersion
= 1;
2423 gdiplusStartupInput
.DebugEventCallback
= NULL
;
2424 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
2425 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2427 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2429 test_constructor_destructor();
2430 test_save_restore();
2431 test_GdipDrawBezierI();
2433 test_GdipDrawArcI();
2434 test_GdipDrawCurve();
2435 test_GdipDrawCurveI();
2436 test_GdipDrawCurve2();
2437 test_GdipDrawCurve2I();
2438 test_GdipDrawCurve3();
2439 test_GdipDrawCurve3I();
2440 test_GdipDrawLineI();
2441 test_GdipDrawLinesI();
2442 test_GdipDrawString();
2443 test_GdipGetNearestColor();
2444 test_GdipGetVisibleClipBounds();
2445 test_GdipIsVisiblePoint();
2446 test_GdipIsVisibleRect();
2447 test_Get_Release_DC();
2448 test_BeginContainer2();
2449 test_transformpoints();
2450 test_get_set_clip();
2453 test_textcontrast();
2454 test_fromMemoryBitmap();
2456 GdiplusShutdown(gdiplusToken
);
2457 DestroyWindow( hwnd
);