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_GdipDrawArc(void)
236 GpGraphics
*graphics
= NULL
;
238 HDC hdc
= GetDC( hwnd
);
240 /* make a graphics object and pen object */
241 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
243 status
= GdipCreateFromHDC(hdc
, &graphics
);
245 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
247 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
249 ok(pen
!= NULL
, "Expected pen to be initialized\n");
251 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
252 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
253 expect(InvalidParameter
, status
);
255 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
256 expect(InvalidParameter
, status
);
258 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
259 expect(InvalidParameter
, status
);
261 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
262 expect(InvalidParameter
, status
);
264 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
265 expect(InvalidParameter
, status
);
267 /* successful case */
268 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
272 GdipDeleteGraphics(graphics
);
274 ReleaseDC(hwnd
, hdc
);
277 static void test_GdipDrawArcI(void)
280 GpGraphics
*graphics
= NULL
;
282 HDC hdc
= GetDC( hwnd
);
284 /* make a graphics object and pen object */
285 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
287 status
= GdipCreateFromHDC(hdc
, &graphics
);
289 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
291 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
293 ok(pen
!= NULL
, "Expected pen to be initialized\n");
295 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
296 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
297 expect(InvalidParameter
, status
);
299 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
300 expect(InvalidParameter
, status
);
302 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
303 expect(InvalidParameter
, status
);
305 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
306 expect(InvalidParameter
, status
);
308 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
309 expect(InvalidParameter
, status
);
311 /* successful case */
312 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
316 GdipDeleteGraphics(graphics
);
318 ReleaseDC(hwnd
, hdc
);
321 static void test_BeginContainer2(void)
325 REAL defClip
[] = {5, 10, 15, 20};
326 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
327 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
328 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
329 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
330 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
331 REAL scale
, defScale
= 17;
332 GpUnit unit
, defUnit
= UnitPixel
;
333 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
334 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
335 UINT contrast
, defContrast
= 5;
336 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
339 GpGraphics
*graphics
= NULL
;
340 HDC hdc
= GetDC( hwnd
);
342 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
344 status
= GdipCreateFromHDC(hdc
, &graphics
);
346 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
348 /* null graphics, null container */
349 status
= GdipBeginContainer2(NULL
, &cont1
);
350 expect(InvalidParameter
, status
);
352 status
= GdipBeginContainer2(graphics
, NULL
);
353 expect(InvalidParameter
, status
);
355 status
= GdipEndContainer(NULL
, cont1
);
356 expect(InvalidParameter
, status
);
358 /* test all quality-related values */
359 GdipSetCompositingMode(graphics
, defCompmode
);
360 GdipSetCompositingQuality(graphics
, defCompqual
);
361 GdipSetInterpolationMode(graphics
, defInterp
);
362 GdipSetPageScale(graphics
, defScale
);
363 GdipSetPageUnit(graphics
, defUnit
);
364 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
365 GdipSetSmoothingMode(graphics
, defSmoothmode
);
366 GdipSetTextContrast(graphics
, defContrast
);
367 GdipSetTextRenderingHint(graphics
, defTexthint
);
369 status
= GdipBeginContainer2(graphics
, &cont1
);
372 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
373 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
374 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
375 GdipSetPageScale(graphics
, 10);
376 GdipSetPageUnit(graphics
, UnitDocument
);
377 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
378 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
379 GdipSetTextContrast(graphics
, 7);
380 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
382 status
= GdipEndContainer(graphics
, cont1
);
385 GdipGetCompositingMode(graphics
, &compmode
);
386 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
388 GdipGetCompositingQuality(graphics
, &compqual
);
389 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
391 GdipGetInterpolationMode(graphics
, &interp
);
392 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
394 GdipGetPageScale(graphics
, &scale
);
395 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
397 GdipGetPageUnit(graphics
, &unit
);
398 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
400 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
401 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
403 GdipGetSmoothingMode(graphics
, &smoothmode
);
404 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
406 GdipGetTextContrast(graphics
, &contrast
);
407 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
409 GdipGetTextRenderingHint(graphics
, &texthint
);
410 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
412 /* test world transform */
413 status
= GdipBeginContainer2(graphics
, &cont1
);
416 GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
417 defTrans
[4], defTrans
[5], &transform
);
418 GdipSetWorldTransform(graphics
, transform
);
419 GdipDeleteMatrix(transform
);
422 status
= GdipBeginContainer2(graphics
, &cont2
);
425 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
426 GdipSetWorldTransform(graphics
, transform
);
427 GdipDeleteMatrix(transform
);
430 status
= GdipEndContainer(graphics
, cont2
);
433 GdipCreateMatrix(&transform
);
434 GdipGetWorldTransform(graphics
, transform
);
435 GdipGetMatrixElements(transform
, elems
);
436 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
437 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
438 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
439 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
440 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
441 fabs(defTrans
[5] - elems
[5]) < 0.0001,
442 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
443 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
444 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
445 GdipDeleteMatrix(transform
);
448 status
= GdipEndContainer(graphics
, cont1
);
452 status
= GdipBeginContainer2(graphics
, &cont1
);
455 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
457 status
= GdipBeginContainer2(graphics
, &cont2
);
460 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
462 status
= GdipEndContainer(graphics
, cont2
);
464 GdipGetClipBounds(graphics
, &clip
);
465 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
466 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
467 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
468 fabs(defClip
[3] - clip
.Height
) < 0.0001,
469 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
470 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
471 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
473 status
= GdipEndContainer(graphics
, cont1
);
476 status
= GdipBeginContainer2(graphics
, &cont1
);
479 status
= GdipBeginContainer2(graphics
, &cont2
);
482 status
= GdipBeginContainer2(graphics
, &cont3
);
485 status
= GdipEndContainer(graphics
, cont3
);
488 status
= GdipBeginContainer2(graphics
, &cont4
);
491 status
= GdipEndContainer(graphics
, cont4
);
495 status
= GdipEndContainer(graphics
, cont1
);
498 /* end an already-ended container */
499 status
= GdipEndContainer(graphics
, cont1
);
502 GdipDeleteGraphics(graphics
);
503 ReleaseDC(hwnd
, hdc
);
506 static void test_GdipDrawBezierI(void)
509 GpGraphics
*graphics
= NULL
;
511 HDC hdc
= GetDC( hwnd
);
513 /* make a graphics object and pen object */
514 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
516 status
= GdipCreateFromHDC(hdc
, &graphics
);
518 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
520 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
522 ok(pen
!= NULL
, "Expected pen to be initialized\n");
524 /* InvalidParameter cases: null graphics, null pen */
525 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
526 expect(InvalidParameter
, status
);
528 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
529 expect(InvalidParameter
, status
);
531 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
532 expect(InvalidParameter
, status
);
534 /* successful case */
535 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
539 GdipDeleteGraphics(graphics
);
541 ReleaseDC(hwnd
, hdc
);
544 static void test_GdipDrawCurve3(void)
547 GpGraphics
*graphics
= NULL
;
549 HDC hdc
= GetDC( hwnd
);
561 /* make a graphics object and pen object */
562 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
564 status
= GdipCreateFromHDC(hdc
, &graphics
);
566 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
568 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
570 ok(pen
!= NULL
, "Expected pen to be initialized\n");
572 /* InvalidParameter cases: null graphics, null pen */
573 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
574 expect(InvalidParameter
, status
);
576 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
577 expect(InvalidParameter
, status
);
579 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
580 expect(InvalidParameter
, status
);
582 /* InvalidParameter cases: invalid count */
583 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
584 expect(InvalidParameter
, status
);
586 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
587 expect(InvalidParameter
, status
);
589 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
590 expect(InvalidParameter
, status
);
592 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
593 expect(InvalidParameter
, status
);
595 /* InvalidParameter cases: invalid number of segments */
596 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
597 expect(InvalidParameter
, status
);
599 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
600 expect(InvalidParameter
, status
);
602 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
603 expect(InvalidParameter
, status
);
605 /* Valid test cases */
606 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
609 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
612 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
615 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
619 GdipDeleteGraphics(graphics
);
621 ReleaseDC(hwnd
, hdc
);
624 static void test_GdipDrawCurve3I(void)
627 GpGraphics
*graphics
= NULL
;
629 HDC hdc
= GetDC( hwnd
);
641 /* make a graphics object and pen object */
642 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
644 status
= GdipCreateFromHDC(hdc
, &graphics
);
646 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
648 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
650 ok(pen
!= NULL
, "Expected pen to be initialized\n");
652 /* InvalidParameter cases: null graphics, null pen */
653 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
654 expect(InvalidParameter
, status
);
656 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
657 expect(InvalidParameter
, status
);
659 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
660 expect(InvalidParameter
, status
);
662 /* InvalidParameter cases: invalid count */
663 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
664 expect(OutOfMemory
, status
);
666 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
667 expect(InvalidParameter
, status
);
669 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
670 expect(InvalidParameter
, status
);
672 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
673 expect(InvalidParameter
, status
);
675 /* InvalidParameter cases: invalid number of segments */
676 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
677 expect(InvalidParameter
, status
);
679 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
680 expect(InvalidParameter
, status
);
682 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
683 expect(InvalidParameter
, status
);
685 /* Valid test cases */
686 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
689 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
692 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
695 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
699 GdipDeleteGraphics(graphics
);
701 ReleaseDC(hwnd
, hdc
);
704 static void test_GdipDrawCurve2(void)
707 GpGraphics
*graphics
= NULL
;
709 HDC hdc
= GetDC( hwnd
);
721 /* make a graphics object and pen object */
722 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
724 status
= GdipCreateFromHDC(hdc
, &graphics
);
726 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
728 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
730 ok(pen
!= NULL
, "Expected pen to be initialized\n");
732 /* InvalidParameter cases: null graphics, null pen */
733 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
734 expect(InvalidParameter
, status
);
736 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
737 expect(InvalidParameter
, status
);
739 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
740 expect(InvalidParameter
, status
);
742 /* InvalidParameter cases: invalid count */
743 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
744 expect(InvalidParameter
, status
);
746 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
747 expect(InvalidParameter
, status
);
749 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
750 expect(InvalidParameter
, status
);
752 /* Valid test cases */
753 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
756 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
759 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
762 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
766 GdipDeleteGraphics(graphics
);
768 ReleaseDC(hwnd
, hdc
);
771 static void test_GdipDrawCurve2I(void)
774 GpGraphics
*graphics
= NULL
;
776 HDC hdc
= GetDC( hwnd
);
788 /* make a graphics object and pen object */
789 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
791 status
= GdipCreateFromHDC(hdc
, &graphics
);
793 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
795 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
797 ok(pen
!= NULL
, "Expected pen to be initialized\n");
799 /* InvalidParameter cases: null graphics, null pen */
800 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
801 expect(InvalidParameter
, status
);
803 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
804 expect(InvalidParameter
, status
);
806 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
807 expect(InvalidParameter
, status
);
809 /* InvalidParameter cases: invalid count */
810 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
811 expect(OutOfMemory
, status
);
813 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
814 expect(InvalidParameter
, status
);
816 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
817 expect(InvalidParameter
, status
);
819 /* Valid test cases */
820 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
823 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
826 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
829 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
833 GdipDeleteGraphics(graphics
);
835 ReleaseDC(hwnd
, hdc
);
838 static void test_GdipDrawCurve(void)
841 GpGraphics
*graphics
= NULL
;
843 HDC hdc
= GetDC( hwnd
);
855 /* make a graphics object and pen object */
856 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
858 status
= GdipCreateFromHDC(hdc
, &graphics
);
860 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
862 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
864 ok(pen
!= NULL
, "Expected pen to be initialized\n");
866 /* InvalidParameter cases: null graphics, null pen */
867 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
868 expect(InvalidParameter
, status
);
870 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
871 expect(InvalidParameter
, status
);
873 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
874 expect(InvalidParameter
, status
);
876 /* InvalidParameter cases: invalid count */
877 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
878 expect(InvalidParameter
, status
);
880 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
881 expect(InvalidParameter
, status
);
883 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
884 expect(InvalidParameter
, status
);
886 /* Valid test cases */
887 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
890 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
894 GdipDeleteGraphics(graphics
);
896 ReleaseDC(hwnd
, hdc
);
899 static void test_GdipDrawCurveI(void)
902 GpGraphics
*graphics
= NULL
;
904 HDC hdc
= GetDC( hwnd
);
916 /* make a graphics object and pen object */
917 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
919 status
= GdipCreateFromHDC(hdc
, &graphics
);
921 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
923 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
925 ok(pen
!= NULL
, "Expected pen to be initialized\n");
927 /* InvalidParameter cases: null graphics, null pen */
928 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
929 expect(InvalidParameter
, status
);
931 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
932 expect(InvalidParameter
, status
);
934 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
935 expect(InvalidParameter
, status
);
937 /* InvalidParameter cases: invalid count */
938 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
939 expect(OutOfMemory
, status
);
941 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
942 expect(InvalidParameter
, status
);
944 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
945 expect(InvalidParameter
, status
);
947 /* Valid test cases */
948 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
951 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
955 GdipDeleteGraphics(graphics
);
957 ReleaseDC(hwnd
, hdc
);
960 static void test_GdipDrawLineI(void)
963 GpGraphics
*graphics
= NULL
;
965 HDC hdc
= GetDC( hwnd
);
967 /* make a graphics object and pen object */
968 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
970 status
= GdipCreateFromHDC(hdc
, &graphics
);
972 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
974 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
976 ok(pen
!= NULL
, "Expected pen to be initialized\n");
978 /* InvalidParameter cases: null graphics, null pen */
979 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
980 expect(InvalidParameter
, status
);
982 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
983 expect(InvalidParameter
, status
);
985 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
986 expect(InvalidParameter
, status
);
988 /* successful case */
989 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
993 GdipDeleteGraphics(graphics
);
995 ReleaseDC(hwnd
, hdc
);
998 static void test_GdipDrawLinesI(void)
1001 GpGraphics
*graphics
= NULL
;
1003 GpPoint
*ptf
= NULL
;
1004 HDC hdc
= GetDC( hwnd
);
1006 /* make a graphics object and pen object */
1007 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1009 status
= GdipCreateFromHDC(hdc
, &graphics
);
1011 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1013 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1015 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1017 /* make some arbitrary valid points*/
1018 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1026 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1027 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1028 expect(InvalidParameter
, status
);
1030 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1031 expect(InvalidParameter
, status
);
1033 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1034 expect(InvalidParameter
, status
);
1036 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1037 expect(InvalidParameter
, status
);
1039 /* successful case */
1040 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1045 GdipDeleteGraphics(graphics
);
1047 ReleaseDC(hwnd
, hdc
);
1050 static void test_Get_Release_DC(void)
1053 GpGraphics
*graphics
= NULL
;
1057 HDC hdc
= GetDC( hwnd
);
1060 CompositingQuality quality
;
1061 CompositingMode compmode
;
1062 InterpolationMode intmode
;
1066 PixelOffsetMode offsetmode
;
1067 SmoothingMode smoothmode
;
1068 TextRenderingHint texthint
;
1076 ARGB color
= 0x00000000;
1077 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1090 for(i
= 0; i
< 5;i
++){
1091 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1092 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1098 rect
[0].Height
= 70;
1102 rect
[1].Height
= 20;
1104 for(i
= 0; i
< 2;i
++){
1105 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1106 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1107 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1108 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1111 GdipCreateMatrix(&m
);
1112 GdipCreateRegion(®ion
);
1113 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1114 GdipCreatePath(FillModeAlternate
, &path
);
1115 GdipCreateRegion(&clip
);
1117 status
= GdipCreateFromHDC(hdc
, &graphics
);
1119 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1120 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1123 /* NULL arguments */
1124 status
= GdipGetDC(NULL
, NULL
);
1125 expect(InvalidParameter
, status
);
1126 status
= GdipGetDC(graphics
, NULL
);
1127 expect(InvalidParameter
, status
);
1128 status
= GdipGetDC(NULL
, &retdc
);
1129 expect(InvalidParameter
, status
);
1131 status
= GdipReleaseDC(NULL
, NULL
);
1132 expect(InvalidParameter
, status
);
1133 status
= GdipReleaseDC(graphics
, NULL
);
1134 expect(InvalidParameter
, status
);
1135 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1136 expect(InvalidParameter
, status
);
1138 /* Release without Get */
1139 status
= GdipReleaseDC(graphics
, hdc
);
1140 expect(InvalidParameter
, status
);
1143 status
= GdipGetDC(graphics
, &retdc
);
1145 ok(retdc
== hdc
, "Invalid HDC returned\n");
1146 /* call it once more */
1147 status
= GdipGetDC(graphics
, &retdc
);
1148 expect(ObjectBusy
, status
);
1150 /* try all Graphics calls here */
1152 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1153 expect(ObjectBusy
, status
); status
= Ok
;
1154 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1155 expect(ObjectBusy
, status
); status
= Ok
;
1156 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1157 expect(ObjectBusy
, status
); status
= Ok
;
1158 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1159 expect(ObjectBusy
, status
); status
= Ok
;
1160 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1161 expect(ObjectBusy
, status
); status
= Ok
;
1162 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1163 expect(ObjectBusy
, status
); status
= Ok
;
1164 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1165 expect(ObjectBusy
, status
); status
= Ok
;
1166 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1167 expect(ObjectBusy
, status
); status
= Ok
;
1168 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1169 expect(ObjectBusy
, status
); status
= Ok
;
1170 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1171 expect(ObjectBusy
, status
); status
= Ok
;
1172 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1173 expect(ObjectBusy
, status
); status
= Ok
;
1174 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1175 expect(ObjectBusy
, status
); status
= Ok
;
1176 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1177 expect(ObjectBusy
, status
); status
= Ok
;
1178 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1179 expect(ObjectBusy
, status
); status
= Ok
;
1180 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1181 expect(ObjectBusy
, status
); status
= Ok
;
1182 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1183 expect(ObjectBusy
, status
); status
= Ok
;
1184 /* GdipDrawImage/GdipDrawImageI */
1185 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1186 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1187 /* GdipDrawImageRect/GdipDrawImageRectI */
1188 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1189 expect(ObjectBusy
, status
); status
= Ok
;
1190 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1191 expect(ObjectBusy
, status
); status
= Ok
;
1192 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1193 expect(ObjectBusy
, status
); status
= Ok
;
1194 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1195 expect(ObjectBusy
, status
); status
= Ok
;
1196 status
= GdipDrawPath(graphics
, pen
, path
);
1197 expect(ObjectBusy
, status
); status
= Ok
;
1198 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1199 expect(ObjectBusy
, status
); status
= Ok
;
1200 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1201 expect(ObjectBusy
, status
); status
= Ok
;
1202 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1203 expect(ObjectBusy
, status
); status
= Ok
;
1204 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1205 expect(ObjectBusy
, status
); status
= Ok
;
1206 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1207 expect(ObjectBusy
, status
); status
= Ok
;
1208 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1209 expect(ObjectBusy
, status
); status
= Ok
;
1210 /* GdipDrawString */
1211 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1212 expect(ObjectBusy
, status
); status
= Ok
;
1213 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1214 expect(ObjectBusy
, status
); status
= Ok
;
1215 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1216 expect(ObjectBusy
, status
); status
= Ok
;
1217 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1218 expect(ObjectBusy
, status
); status
= Ok
;
1219 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1220 expect(ObjectBusy
, status
); status
= Ok
;
1221 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1222 expect(ObjectBusy
, status
); status
= Ok
;
1223 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1224 expect(ObjectBusy
, status
); status
= Ok
;
1225 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1226 expect(ObjectBusy
, status
); status
= Ok
;
1227 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1228 expect(ObjectBusy
, status
); status
= Ok
;
1229 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1230 expect(ObjectBusy
, status
); status
= Ok
;
1231 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1232 expect(ObjectBusy
, status
); status
= Ok
;
1233 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1234 expect(ObjectBusy
, status
); status
= Ok
;
1235 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1236 expect(ObjectBusy
, status
); status
= Ok
;
1237 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1238 expect(ObjectBusy
, status
); status
= Ok
;
1239 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1240 expect(ObjectBusy
, status
); status
= Ok
;
1241 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1242 expect(ObjectBusy
, status
); status
= Ok
;
1243 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1244 expect(ObjectBusy
, status
); status
= Ok
;
1245 status
= GdipGetClipBounds(graphics
, rectf
);
1246 expect(ObjectBusy
, status
); status
= Ok
;
1247 status
= GdipGetClipBoundsI(graphics
, rect
);
1248 expect(ObjectBusy
, status
); status
= Ok
;
1249 status
= GdipGetCompositingMode(graphics
, &compmode
);
1250 expect(ObjectBusy
, status
); status
= Ok
;
1251 status
= GdipGetCompositingQuality(graphics
, &quality
);
1252 expect(ObjectBusy
, status
); status
= Ok
;
1253 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1254 expect(ObjectBusy
, status
); status
= Ok
;
1255 status
= GdipGetNearestColor(graphics
, &color
);
1256 expect(ObjectBusy
, status
); status
= Ok
;
1257 status
= GdipGetPageScale(graphics
, &r
);
1258 expect(ObjectBusy
, status
); status
= Ok
;
1259 status
= GdipGetPageUnit(graphics
, &unit
);
1260 expect(ObjectBusy
, status
); status
= Ok
;
1261 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1262 expect(ObjectBusy
, status
); status
= Ok
;
1263 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1264 expect(ObjectBusy
, status
); status
= Ok
;
1265 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1266 expect(ObjectBusy
, status
); status
= Ok
;
1267 status
= GdipGetWorldTransform(graphics
, m
);
1268 expect(ObjectBusy
, status
); status
= Ok
;
1269 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1270 expect(ObjectBusy
, status
); status
= Ok
;
1271 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1272 expect(ObjectBusy
, status
); status
= Ok
;
1273 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1274 expect(ObjectBusy
, status
); status
= Ok
;
1275 /* GdipMeasureCharacterRanges */
1276 /* GdipMeasureString */
1277 status
= GdipResetClip(graphics
);
1278 expect(ObjectBusy
, status
); status
= Ok
;
1279 status
= GdipResetWorldTransform(graphics
);
1280 expect(ObjectBusy
, status
); status
= Ok
;
1281 /* GdipRestoreGraphics */
1282 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1283 expect(ObjectBusy
, status
); status
= Ok
;
1284 /* GdipSaveGraphics */
1285 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1286 expect(ObjectBusy
, status
); status
= Ok
;
1287 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1288 expect(ObjectBusy
, status
); status
= Ok
;
1289 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1290 expect(ObjectBusy
, status
); status
= Ok
;
1291 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1292 expect(ObjectBusy
, status
); status
= Ok
;
1293 status
= GdipSetPageScale(graphics
, 1.0);
1294 expect(ObjectBusy
, status
); status
= Ok
;
1295 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1296 expect(ObjectBusy
, status
); status
= Ok
;
1297 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1298 expect(ObjectBusy
, status
); status
= Ok
;
1299 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1300 expect(ObjectBusy
, status
); status
= Ok
;
1301 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1302 expect(ObjectBusy
, status
); status
= Ok
;
1303 status
= GdipSetWorldTransform(graphics
, m
);
1304 expect(ObjectBusy
, status
); status
= Ok
;
1305 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1306 expect(ObjectBusy
, status
); status
= Ok
;
1307 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1308 expect(ObjectBusy
, status
); status
= Ok
;
1309 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1310 expect(ObjectBusy
, status
); status
= Ok
;
1311 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1312 expect(ObjectBusy
, status
); status
= Ok
;
1313 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1314 expect(ObjectBusy
, status
); status
= Ok
;
1315 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1316 expect(ObjectBusy
, status
); status
= Ok
;
1317 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1318 expect(ObjectBusy
, status
); status
= Ok
;
1319 status
= GdipTranslateClipI(graphics
, 0, 0);
1320 expect(ObjectBusy
, status
); status
= Ok
;
1321 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1322 expect(ObjectBusy
, status
); status
= Ok
;
1323 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1324 expect(ObjectBusy
, status
); status
= Ok
;
1325 status
= GdipGetDpiX(graphics
, &r
);
1326 expect(ObjectBusy
, status
); status
= Ok
;
1327 status
= GdipGetDpiY(graphics
, &r
);
1328 expect(ObjectBusy
, status
); status
= Ok
;
1329 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1330 status
= GdipGetClip(graphics
, region
);
1331 expect(ObjectBusy
, status
); status
= Ok
;
1332 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1333 expect(ObjectBusy
, status
); status
= Ok
;
1334 /* try to delete before release */
1335 status
= GdipDeleteGraphics(graphics
);
1336 expect(ObjectBusy
, status
);
1338 status
= GdipReleaseDC(graphics
, retdc
);
1342 GdipDeleteGraphics(graphics
);
1344 GdipDeleteRegion(clip
);
1345 GdipDeletePath(path
);
1346 GdipDeleteBrush((GpBrush
*)brush
);
1347 GdipDeleteRegion(region
);
1348 GdipDeleteMatrix(m
);
1351 ReleaseDC(hwnd
, hdc
);
1354 static void test_transformpoints(void)
1357 GpGraphics
*graphics
= NULL
;
1358 HDC hdc
= GetDC( hwnd
);
1362 status
= GdipCreateFromHDC(hdc
, &graphics
);
1365 /* NULL arguments */
1366 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1367 expect(InvalidParameter
, status
);
1368 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1369 expect(InvalidParameter
, status
);
1370 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1371 expect(InvalidParameter
, status
);
1372 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1373 expect(InvalidParameter
, status
);
1379 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1381 expectf(1.0, ptf
[0].X
);
1382 expectf(0.0, ptf
[0].Y
);
1383 expectf(0.0, ptf
[1].X
);
1384 expectf(1.0, ptf
[1].Y
);
1386 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1388 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1390 status
= GdipSetPageScale(graphics
, 3.0);
1397 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1399 expectf(18.0, ptf
[0].X
);
1400 expectf(15.0, ptf
[0].Y
);
1401 expectf(15.0, ptf
[1].X
);
1402 expectf(18.0, ptf
[1].Y
);
1408 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1410 expectf(6.0, ptf
[0].X
);
1411 expectf(5.0, ptf
[0].Y
);
1412 expectf(5.0, ptf
[1].X
);
1413 expectf(6.0, ptf
[1].Y
);
1419 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1421 expectf(3.0, ptf
[0].X
);
1422 expectf(0.0, ptf
[0].Y
);
1423 expectf(0.0, ptf
[1].X
);
1424 expectf(3.0, ptf
[1].Y
);
1430 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1432 expectf(1.0, ptf
[0].X
);
1433 expectf(0.0, ptf
[0].Y
);
1434 expectf(0.0, ptf
[1].X
);
1435 expectf(1.0, ptf
[1].Y
);
1441 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1443 expectf(1.0, ptf
[0].X
);
1444 expectf(0.0, ptf
[0].Y
);
1445 expectf(0.0, ptf
[1].X
);
1446 expectf(1.0, ptf
[1].Y
);
1452 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1454 expectf(1.0, ptf
[0].X
);
1455 expectf(0.0, ptf
[0].Y
);
1456 expectf(0.0, ptf
[1].X
);
1457 expectf(1.0, ptf
[1].Y
);
1463 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1465 expect(18, pt
[0].X
);
1466 expect(15, pt
[0].Y
);
1467 expect(15, pt
[1].X
);
1468 expect(18, pt
[1].Y
);
1470 GdipDeleteGraphics(graphics
);
1471 ReleaseDC(hwnd
, hdc
);
1474 static void test_get_set_clip(void)
1477 GpGraphics
*graphics
= NULL
;
1478 HDC hdc
= GetDC( hwnd
);
1483 status
= GdipCreateFromHDC(hdc
, &graphics
);
1486 rect
.X
= rect
.Y
= 0.0;
1487 rect
.Height
= rect
.Width
= 100.0;
1489 status
= GdipCreateRegionRect(&rect
, &clip
);
1491 /* NULL arguments */
1492 status
= GdipGetClip(NULL
, NULL
);
1493 expect(InvalidParameter
, status
);
1494 status
= GdipGetClip(graphics
, NULL
);
1495 expect(InvalidParameter
, status
);
1496 status
= GdipGetClip(NULL
, clip
);
1497 expect(InvalidParameter
, status
);
1499 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1500 expect(InvalidParameter
, status
);
1501 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1502 expect(InvalidParameter
, status
);
1504 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1505 expect(InvalidParameter
, status
);
1506 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1507 expect(InvalidParameter
, status
);
1510 status
= GdipGetClip(graphics
, clip
);
1512 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1516 /* remains infinite after reset */
1518 status
= GdipResetClip(graphics
);
1520 status
= GdipGetClip(graphics
, clip
);
1522 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1526 /* set to empty and then reset to infinite */
1527 status
= GdipSetEmpty(clip
);
1529 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1532 status
= GdipGetClip(graphics
, clip
);
1535 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1538 status
= GdipResetClip(graphics
);
1540 status
= GdipGetClip(graphics
, clip
);
1543 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1547 GdipDeleteRegion(clip
);
1549 GdipDeleteGraphics(graphics
);
1550 ReleaseDC(hwnd
, hdc
);
1553 static void test_isempty(void)
1556 GpGraphics
*graphics
= NULL
;
1557 HDC hdc
= GetDC( hwnd
);
1561 status
= GdipCreateFromHDC(hdc
, &graphics
);
1564 status
= GdipCreateRegion(&clip
);
1568 status
= GdipIsClipEmpty(NULL
, NULL
);
1569 expect(InvalidParameter
, status
);
1570 status
= GdipIsClipEmpty(graphics
, NULL
);
1571 expect(InvalidParameter
, status
);
1572 status
= GdipIsClipEmpty(NULL
, &res
);
1573 expect(InvalidParameter
, status
);
1575 /* default is infinite */
1577 status
= GdipIsClipEmpty(graphics
, &res
);
1581 GdipDeleteRegion(clip
);
1583 GdipDeleteGraphics(graphics
);
1584 ReleaseDC(hwnd
, hdc
);
1587 static void test_clear(void)
1591 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
1592 expect(InvalidParameter
, status
);
1595 static void test_textcontrast(void)
1598 HDC hdc
= GetDC( hwnd
);
1599 GpGraphics
*graphics
;
1602 status
= GdipGetTextContrast(NULL
, NULL
);
1603 expect(InvalidParameter
, status
);
1605 status
= GdipCreateFromHDC(hdc
, &graphics
);
1608 status
= GdipGetTextContrast(graphics
, NULL
);
1609 expect(InvalidParameter
, status
);
1610 status
= GdipGetTextContrast(graphics
, &contrast
);
1611 expect(4, contrast
);
1613 GdipDeleteGraphics(graphics
);
1614 ReleaseDC(hwnd
, hdc
);
1617 static void test_GdipDrawString(void)
1620 GpGraphics
*graphics
= NULL
;
1623 GpStringFormat
*format
;
1626 HDC hdc
= GetDC( hwnd
);
1627 static const WCHAR string
[] = {'T','e','s','t',0};
1629 memset(&logfont
,0,sizeof(logfont
));
1630 strcpy(logfont
.lfFaceName
,"Arial");
1631 logfont
.lfHeight
= 12;
1632 logfont
.lfCharSet
= DEFAULT_CHARSET
;
1634 status
= GdipCreateFromHDC(hdc
, &graphics
);
1637 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
1638 if (status
== FileNotFound
)
1640 skip("Arial not installed.\n");
1645 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
1648 status
= GdipCreateStringFormat(0,0,&format
);
1656 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
1659 GdipDeleteGraphics(graphics
);
1660 GdipDeleteBrush(brush
);
1661 GdipDeleteFont(fnt
);
1662 GdipDeleteStringFormat(format
);
1664 ReleaseDC(hwnd
, hdc
);
1667 static void test_GdipGetVisibleClipBounds_screen(void)
1670 GpGraphics
*graphics
= NULL
;
1672 GpRectF rectf
, exp
, clipr
;
1675 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1677 status
= GdipCreateFromHDC(hdc
, &graphics
);
1679 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1681 /* no clipping rect */
1684 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
1685 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
1687 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1689 ok(rectf
.X
== exp
.X
&&
1691 rectf
.Width
== exp
.Width
&&
1692 rectf
.Height
== exp
.Height
,
1693 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1694 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1695 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1696 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1698 /* clipping rect entirely within window */
1699 exp
.X
= clipr
.X
= 10;
1700 exp
.Y
= clipr
.Y
= 12;
1701 exp
.Width
= clipr
.Width
= 14;
1702 exp
.Height
= clipr
.Height
= 16;
1704 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1707 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1709 ok(rectf
.X
== exp
.X
&&
1711 rectf
.Width
== exp
.Width
&&
1712 rectf
.Height
== exp
.Height
,
1713 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1714 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1715 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1716 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1718 /* clipping rect partially outside of screen */
1724 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1732 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1734 ok(rectf
.X
== exp
.X
&&
1736 rectf
.Width
== exp
.Width
&&
1737 rectf
.Height
== exp
.Height
,
1738 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1739 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1740 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1741 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1743 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
1745 ok(recti
.X
== exp
.X
&&
1747 recti
.Width
== exp
.Width
&&
1748 recti
.Height
== exp
.Height
,
1749 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1750 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1751 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
1752 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1754 GdipDeleteGraphics(graphics
);
1758 static void test_GdipGetVisibleClipBounds_window(void)
1761 GpGraphics
*graphics
= NULL
;
1762 GpRectF rectf
, window
, exp
, clipr
;
1768 /* get client area size */
1769 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
1770 window
.X
= wnd_rect
.left
;
1771 window
.Y
= wnd_rect
.top
;
1772 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
1773 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
1775 hdc
= BeginPaint(hwnd
, &ps
);
1777 status
= GdipCreateFromHDC(hdc
, &graphics
);
1779 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1781 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1783 ok(rectf
.X
== window
.X
&&
1784 rectf
.Y
== window
.Y
&&
1785 rectf
.Width
== window
.Width
&&
1786 rectf
.Height
== window
.Height
,
1787 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1788 "the window (%0.f, %0.f, %0.f, %0.f)\n",
1789 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1790 window
.X
, window
.Y
, window
.Width
, window
.Height
);
1792 /* clipping rect entirely within window */
1793 exp
.X
= clipr
.X
= 20;
1794 exp
.Y
= clipr
.Y
= 8;
1795 exp
.Width
= clipr
.Width
= 30;
1796 exp
.Height
= clipr
.Height
= 20;
1798 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1801 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1803 ok(rectf
.X
== exp
.X
&&
1805 rectf
.Width
== exp
.Width
&&
1806 rectf
.Height
== exp
.Height
,
1807 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1808 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1809 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1810 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1812 /* clipping rect partially outside of window */
1813 clipr
.X
= window
.Width
- 10;
1814 clipr
.Y
= window
.Height
- 15;
1818 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1821 exp
.X
= window
.Width
- 10;
1822 exp
.Y
= window
.Height
- 15;
1826 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1828 ok(rectf
.X
== exp
.X
&&
1830 rectf
.Width
== exp
.Width
&&
1831 rectf
.Height
== exp
.Height
,
1832 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1833 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1834 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1835 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1837 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
1839 ok(recti
.X
== exp
.X
&&
1841 recti
.Width
== exp
.Width
&&
1842 recti
.Height
== exp
.Height
,
1843 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1844 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1845 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
1846 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1848 GdipDeleteGraphics(graphics
);
1849 EndPaint(hwnd
, &ps
);
1852 static void test_GdipGetVisibleClipBounds(void)
1854 GpGraphics
* graphics
= NULL
;
1857 HDC hdc
= GetDC( hwnd
);
1860 status
= GdipCreateFromHDC(hdc
, &graphics
);
1862 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1864 /* test null parameters */
1865 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
1866 expect(InvalidParameter
, status
);
1868 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
1869 expect(InvalidParameter
, status
);
1871 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
1872 expect(InvalidParameter
, status
);
1874 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
1875 expect(InvalidParameter
, status
);
1877 GdipDeleteGraphics(graphics
);
1878 ReleaseDC(hwnd
, hdc
);
1880 test_GdipGetVisibleClipBounds_screen();
1881 test_GdipGetVisibleClipBounds_window();
1884 static void test_fromMemoryBitmap(void)
1887 GpGraphics
*graphics
= NULL
;
1888 GpBitmap
*bitmap
= NULL
;
1889 BYTE bits
[48] = {0};
1891 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
1894 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1897 status
= GdipGraphicsClear(graphics
, 0xff686868);
1900 GdipDeleteGraphics(graphics
);
1902 /* drawing writes to the memory provided */
1903 todo_wine
expect(0x68, bits
[10]);
1905 GdipDisposeImage((GpImage
*)bitmap
);
1908 static void test_GdipIsVisiblePoint(void)
1911 GpGraphics
*graphics
= NULL
;
1912 HDC hdc
= GetDC( hwnd
);
1916 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1918 status
= GdipCreateFromHDC(hdc
, &graphics
);
1920 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1922 /* null parameters */
1923 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
1924 expect(InvalidParameter
, status
);
1926 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
1927 expect(InvalidParameter
, status
);
1929 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
1930 expect(InvalidParameter
, status
);
1932 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
1933 expect(InvalidParameter
, status
);
1937 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1939 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1943 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1945 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1949 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1951 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1955 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1957 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1959 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
1964 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1966 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
1970 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1972 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
1974 /* translate into the center of the rect */
1975 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
1979 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1981 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1985 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1987 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1989 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
1994 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1996 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2000 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2002 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2006 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2008 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2012 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2014 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2018 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2020 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2024 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2026 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2030 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2032 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2036 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2038 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2042 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2044 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2048 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2050 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2054 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2056 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2060 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2062 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2066 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2068 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2070 /* integer version */
2073 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2075 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2079 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2081 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2083 GdipDeleteGraphics(graphics
);
2084 ReleaseDC(hwnd
, hdc
);
2087 static void test_GdipIsVisibleRect(void)
2090 GpGraphics
*graphics
= NULL
;
2091 HDC hdc
= GetDC( hwnd
);
2092 REAL x
, y
, width
, height
;
2095 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2097 status
= GdipCreateFromHDC(hdc
, &graphics
);
2099 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2101 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2102 expect(InvalidParameter
, status
);
2104 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2105 expect(InvalidParameter
, status
);
2107 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2108 expect(InvalidParameter
, status
);
2110 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2111 expect(InvalidParameter
, status
);
2113 /* entirely within the visible region */
2116 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2118 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2120 /* partially outside */
2121 x
= -10; width
= 20;
2122 y
= -10; height
= 20;
2123 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2125 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2127 /* entirely outside */
2129 y
= -10; height
= 5;
2130 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2132 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2134 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2137 /* entirely within the visible region */
2139 y
= 22; height
= 10;
2140 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2142 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2144 /* partially outside */
2146 y
= 55; height
= 10;
2147 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2149 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2151 /* entirely outside */
2154 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2156 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2158 /* translate into center of clipping rect */
2159 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2163 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2165 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2169 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2171 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2173 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2175 /* corners entirely outside, but some intersections */
2178 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2180 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2184 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2186 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2190 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2192 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2196 y
= 20; height
= 40;
2197 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2199 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2203 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2205 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2208 y
= 20; height
= 40;
2209 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2211 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2214 y
= 60; height
= 10;
2215 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2217 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2219 /* rounding tests */
2220 x
= 0.4; width
= 10.4;
2221 y
= 20; height
= 40;
2222 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2224 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2227 y
= 0.4; height
= 20.4;
2228 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2230 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2232 /* integer version */
2235 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2237 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2240 y
= 22; height
= 10;
2241 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2243 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2245 GdipDeleteGraphics(graphics
);
2246 ReleaseDC(hwnd
, hdc
);
2249 static void test_GdipGetNearestColor(void)
2252 GpGraphics
*graphics
;
2254 ARGB color
= 0xdeadbeef;
2255 HDC hdc
= GetDC( hwnd
);
2257 /* create a graphics object */
2258 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2260 status
= GdipCreateFromHDC(hdc
, &graphics
);
2262 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2264 status
= GdipGetNearestColor(graphics
, NULL
);
2265 expect(InvalidParameter
, status
);
2267 status
= GdipGetNearestColor(NULL
, &color
);
2268 expect(InvalidParameter
, status
);
2269 GdipDeleteGraphics(graphics
);
2271 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2273 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2274 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2277 status
= GdipGetNearestColor(graphics
, &color
);
2279 expect(0xdeadbeef, color
);
2280 GdipDeleteGraphics(graphics
);
2282 GdipDisposeImage((GpImage
*)bitmap
);
2284 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2286 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2287 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2290 status
= GdipGetNearestColor(graphics
, &color
);
2292 expect(0xdeadbeef, color
);
2293 GdipDeleteGraphics(graphics
);
2295 GdipDisposeImage((GpImage
*)bitmap
);
2297 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2299 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2300 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2303 status
= GdipGetNearestColor(graphics
, &color
);
2305 expect(0xdeadbeef, color
);
2306 GdipDeleteGraphics(graphics
);
2308 GdipDisposeImage((GpImage
*)bitmap
);
2310 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2312 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2313 todo_wine
expect(OutOfMemory
, status
);
2315 GdipDeleteGraphics(graphics
);
2316 GdipDisposeImage((GpImage
*)bitmap
);
2318 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2320 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2322 status
= GdipGetNearestColor(graphics
, &color
);
2324 expect(0xdeadbeef, color
);
2325 GdipDeleteGraphics(graphics
);
2326 GdipDisposeImage((GpImage
*)bitmap
);
2328 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2330 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2332 status
= GdipGetNearestColor(graphics
, &color
);
2334 expect(0xdeadbeef, color
);
2335 GdipDeleteGraphics(graphics
);
2336 GdipDisposeImage((GpImage
*)bitmap
);
2338 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2340 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2342 status
= GdipGetNearestColor(graphics
, &color
);
2344 expect(0xdeadbeef, color
);
2345 GdipDeleteGraphics(graphics
);
2346 GdipDisposeImage((GpImage
*)bitmap
);
2348 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2350 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2352 status
= GdipGetNearestColor(graphics
, &color
);
2354 expect(0xdeadbeef, color
);
2355 GdipDeleteGraphics(graphics
);
2356 GdipDisposeImage((GpImage
*)bitmap
);
2358 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2360 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2362 status
= GdipGetNearestColor(graphics
, &color
);
2364 expect(0xdeadbeef, color
);
2365 GdipDeleteGraphics(graphics
);
2366 GdipDisposeImage((GpImage
*)bitmap
);
2368 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2370 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2372 status
= GdipGetNearestColor(graphics
, &color
);
2374 expect(0xdeadbeef, color
);
2375 GdipDeleteGraphics(graphics
);
2376 GdipDisposeImage((GpImage
*)bitmap
);
2378 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2380 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2382 status
= GdipGetNearestColor(graphics
, &color
);
2384 todo_wine
expect(0xffa8bce8, color
);
2385 GdipDeleteGraphics(graphics
);
2386 GdipDisposeImage((GpImage
*)bitmap
);
2388 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2390 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2392 status
= GdipGetNearestColor(graphics
, &color
);
2395 ok(color
== 0xffa8b8e8 ||
2396 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2397 "Expected ffa8b8e8, got %.8x\n", color
);
2398 GdipDeleteGraphics(graphics
);
2399 GdipDisposeImage((GpImage
*)bitmap
);
2401 ReleaseDC(hwnd
, hdc
);
2404 static void test_string_functions(void)
2407 GpGraphics
*graphics
;
2408 GpFontFamily
*family
;
2410 RectF rc
, char_bounds
, bounds
;
2412 ARGB color
= 0xff000000;
2413 HDC hdc
= GetDC( hwnd
);
2414 const WCHAR fontname
[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
2415 const WCHAR fontname2
[] = {'C','o','u','r','i','e','r',0};
2416 const WCHAR teststring
[] = {'o','o',' ','o','\n','o',0};
2417 REAL char_width
, char_height
;
2418 INT codepointsfitted
, linesfilled
;
2419 GpStringFormat
*format
;
2420 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2421 GpRegion
*regions
[4] = {0};
2422 BOOL region_isempty
[4];
2425 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2426 status
= GdipCreateFromHDC(hdc
, &graphics
);
2428 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2430 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2434 /* Wine doesn't have Courier New? */
2435 todo_wine
expect(Ok
, status
);
2436 status
= GdipCreateFontFamilyFromName(fontname2
, NULL
, &family
);
2441 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2444 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2447 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2455 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2456 expect(InvalidParameter
, status
);
2458 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2459 expect(InvalidParameter
, status
);
2461 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2462 expect(InvalidParameter
, status
);
2464 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2465 expect(InvalidParameter
, status
);
2467 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2468 expect(InvalidParameter
, status
);
2470 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
2473 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2474 expect(InvalidParameter
, status
);
2476 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2477 expect(InvalidParameter
, status
);
2479 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2480 expect(InvalidParameter
, status
);
2482 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2483 expect(InvalidParameter
, status
);
2485 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
2486 expect(InvalidParameter
, status
);
2488 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
2491 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
2494 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
2496 expectf(0.0, char_bounds
.X
);
2497 expectf(0.0, char_bounds
.Y
);
2498 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
2499 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
2500 expect(1, codepointsfitted
);
2501 expect(1, linesfilled
);
2503 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2505 expectf(0.0, bounds
.X
);
2506 expectf(0.0, bounds
.Y
);
2507 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
2508 expectf(char_bounds
.Height
, bounds
.Height
);
2509 expect(2, codepointsfitted
);
2510 expect(1, linesfilled
);
2511 char_width
= bounds
.Width
- char_bounds
.Width
;
2513 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2515 expectf(0.0, bounds
.X
);
2516 expectf(0.0, bounds
.Y
);
2517 expectf_(char_bounds
.Width
+ char_width
* 3, bounds
.Width
, 0.01);
2518 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
2519 expect(6, codepointsfitted
);
2520 expect(2, linesfilled
);
2521 char_height
= bounds
.Height
- char_bounds
.Height
;
2523 /* Cut off everything after the first space. */
2524 rc
.Width
= char_bounds
.Width
+ char_width
* 2.5;
2526 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2528 expectf(0.0, bounds
.X
);
2529 expectf(0.0, bounds
.Y
);
2530 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
2531 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
2532 expect(6, codepointsfitted
);
2533 expect(3, linesfilled
);
2535 /* Cut off everything including the first space. */
2536 rc
.Width
= char_bounds
.Width
+ char_width
* 1.5;
2538 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2540 expectf(0.0, bounds
.X
);
2541 expectf(0.0, bounds
.Y
);
2542 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
2543 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
2544 expect(6, codepointsfitted
);
2545 expect(3, linesfilled
);
2547 /* Cut off everything after the first character. */
2548 rc
.Width
= char_bounds
.Width
+ char_width
* 0.5;
2550 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2552 expectf(0.0, bounds
.X
);
2553 expectf(0.0, bounds
.Y
);
2554 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
2555 todo_wine
expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
2556 expect(6, codepointsfitted
);
2557 todo_wine
expect(4, linesfilled
);
2559 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
2566 status
= GdipCreateRegion(®ions
[i
]);
2570 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
2571 expect(InvalidParameter
, status
);
2573 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
2574 expect(InvalidParameter
, status
);
2576 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
2577 expect(InvalidParameter
, status
);
2579 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
2580 expect(InvalidParameter
, status
);
2584 /* Crashes on Windows XP */
2585 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
2586 expect(InvalidParameter
, status
);
2589 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
2590 expect(InvalidParameter
, status
);
2592 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
2593 expect(InvalidParameter
, status
);
2595 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
2600 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
2604 ok(!region_isempty
[0], "region shouldn't be empty\n");
2605 ok(!region_isempty
[1], "region shouldn't be empty\n");
2606 ok(!region_isempty
[2], "region shouldn't be empty\n");
2607 ok(!region_isempty
[3], "region shouldn't be empty\n");
2609 /* Cut off everything after the first space, and the second line. */
2610 rc
.Width
= char_bounds
.Width
+ char_width
* 2.5;
2611 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
2613 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
2618 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
2622 ok(!region_isempty
[0], "region shouldn't be empty\n");
2623 ok(!region_isempty
[1], "region shouldn't be empty\n");
2624 ok(region_isempty
[2], "region should be empty\n");
2625 ok(!region_isempty
[3], "region shouldn't be empty\n");
2628 GdipDeleteRegion(regions
[i
]);
2630 GdipDeleteStringFormat(format
);
2631 GdipDeleteBrush(brush
);
2632 GdipDeleteFont(font
);
2633 GdipDeleteFontFamily(family
);
2634 GdipDeleteGraphics(graphics
);
2636 ReleaseDC(hwnd
, hdc
);
2639 START_TEST(graphics
)
2641 struct GdiplusStartupInput gdiplusStartupInput
;
2642 ULONG_PTR gdiplusToken
;
2645 memset( &class, 0, sizeof(class) );
2646 class.lpszClassName
= "gdiplus_test";
2647 class.style
= CS_HREDRAW
| CS_VREDRAW
;
2648 class.lpfnWndProc
= DefWindowProcA
;
2649 class.hInstance
= GetModuleHandleA(0);
2650 class.hIcon
= LoadIcon(0, IDI_APPLICATION
);
2651 class.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
2652 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
2653 RegisterClassA( &class );
2654 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
2655 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
2656 ok(hwnd
!= NULL
, "Expected window to be created\n");
2658 gdiplusStartupInput
.GdiplusVersion
= 1;
2659 gdiplusStartupInput
.DebugEventCallback
= NULL
;
2660 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
2661 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2663 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2665 test_constructor_destructor();
2666 test_save_restore();
2667 test_GdipDrawBezierI();
2669 test_GdipDrawArcI();
2670 test_GdipDrawCurve();
2671 test_GdipDrawCurveI();
2672 test_GdipDrawCurve2();
2673 test_GdipDrawCurve2I();
2674 test_GdipDrawCurve3();
2675 test_GdipDrawCurve3I();
2676 test_GdipDrawLineI();
2677 test_GdipDrawLinesI();
2678 test_GdipDrawString();
2679 test_GdipGetNearestColor();
2680 test_GdipGetVisibleClipBounds();
2681 test_GdipIsVisiblePoint();
2682 test_GdipIsVisibleRect();
2683 test_Get_Release_DC();
2684 test_BeginContainer2();
2685 test_transformpoints();
2686 test_get_set_clip();
2689 test_textcontrast();
2690 test_fromMemoryBitmap();
2691 test_string_functions();
2693 GdiplusShutdown(gdiplusToken
);
2694 DestroyWindow( hwnd
);