2 * Unit test suite for graphics objects
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
30 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
31 #define expectf(expected, got) expectf_((expected), (got), 0.001)
33 static GpStatus (WINAPI
*pGdipGraphicsSetAbort
)(GpGraphics
*,GdiplusAbort
*);
35 static const REAL mm_per_inch
= 25.4;
36 static const REAL point_per_inch
= 72.0;
39 static void set_rect_empty(RectF
*rc
)
47 /* converts a given unit to its value in pixels */
48 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
56 return units
* dpi
/ point_per_inch
;
60 return units
* dpi
/ 300.0; /* Per MSDN */
62 return units
* dpi
/ mm_per_inch
;
64 ok(0, "Unsupported unit: %d\n", unit
);
69 /* converts value in pixels to a given unit */
70 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
78 return pixels
* point_per_inch
/ dpi
;
82 return pixels
* 300.0 / dpi
;
84 return pixels
* mm_per_inch
/ dpi
;
86 ok(0, "Unsupported unit: %d\n", unit
);
91 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
93 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
94 return pixels_to_units(pixels
, to
, dpi
);
97 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
105 GpGraphics
*graphics
= NULL
;
108 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
111 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
113 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
116 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
120 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
125 status
= GdipGetDpiX(graphics
, &res
);
128 status
= GdipGetDpiY(graphics
, &res
);
132 status
= GdipSetPageUnit(graphics
, unit
);
134 status
= GdipSetPageScale(graphics
, scale
);
140 static void test_constructor_destructor(void)
143 GpGraphics
*graphics
= NULL
;
144 HDC hdc
= GetDC( hwnd
);
146 stat
= GdipCreateFromHDC(NULL
, &graphics
);
147 expect(OutOfMemory
, stat
);
148 stat
= GdipDeleteGraphics(graphics
);
149 expect(InvalidParameter
, stat
);
151 stat
= GdipCreateFromHDC(hdc
, &graphics
);
153 stat
= GdipDeleteGraphics(graphics
);
156 stat
= GdipCreateFromHWND(NULL
, &graphics
);
158 stat
= GdipDeleteGraphics(graphics
);
161 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
163 stat
= GdipDeleteGraphics(graphics
);
166 stat
= GdipDeleteGraphics(NULL
);
167 expect(InvalidParameter
, stat
);
168 ReleaseDC(hwnd
, hdc
);
176 /* Linked list prepend function. */
177 static void log_state(GraphicsState data
, node
** log
)
179 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
181 new_entry
->data
= data
;
182 new_entry
->next
= *log
;
186 /* Checks if there are duplicates in the list, and frees it. */
187 static void check_no_duplicates(node
* log
)
199 while((temp
= temp
->next
)){
200 if(log
->data
== temp
->data
){
207 }while((log
= log
->next
));
212 HeapFree(GetProcessHeap(), 0, temp
);
220 static void test_save_restore(void)
223 GraphicsState state_a
, state_b
, state_c
;
224 InterpolationMode mode
;
225 GpGraphics
*graphics1
, *graphics2
;
226 node
* state_log
= NULL
;
227 HDC hdc
= GetDC( hwnd
);
228 state_a
= state_b
= state_c
= 0xdeadbeef;
230 /* Invalid saving. */
231 GdipCreateFromHDC(hdc
, &graphics1
);
232 stat
= GdipSaveGraphics(graphics1
, NULL
);
233 expect(InvalidParameter
, stat
);
234 stat
= GdipSaveGraphics(NULL
, &state_a
);
235 expect(InvalidParameter
, stat
);
236 GdipDeleteGraphics(graphics1
);
238 log_state(state_a
, &state_log
);
240 /* Basic save/restore. */
241 GdipCreateFromHDC(hdc
, &graphics1
);
242 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
243 stat
= GdipSaveGraphics(graphics1
, &state_a
);
245 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
246 stat
= GdipRestoreGraphics(graphics1
, state_a
);
248 GdipGetInterpolationMode(graphics1
, &mode
);
249 expect(InterpolationModeBilinear
, mode
);
250 GdipDeleteGraphics(graphics1
);
252 log_state(state_a
, &state_log
);
254 /* Restoring garbage doesn't affect saves. */
255 GdipCreateFromHDC(hdc
, &graphics1
);
256 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
257 GdipSaveGraphics(graphics1
, &state_a
);
258 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
259 GdipSaveGraphics(graphics1
, &state_b
);
260 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
261 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
263 GdipRestoreGraphics(graphics1
, state_b
);
264 GdipGetInterpolationMode(graphics1
, &mode
);
265 expect(InterpolationModeBicubic
, mode
);
266 GdipRestoreGraphics(graphics1
, state_a
);
267 GdipGetInterpolationMode(graphics1
, &mode
);
268 expect(InterpolationModeBilinear
, mode
);
269 GdipDeleteGraphics(graphics1
);
271 log_state(state_a
, &state_log
);
272 log_state(state_b
, &state_log
);
274 /* Restoring older state invalidates newer saves (but not older saves). */
275 GdipCreateFromHDC(hdc
, &graphics1
);
276 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
277 GdipSaveGraphics(graphics1
, &state_a
);
278 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
279 GdipSaveGraphics(graphics1
, &state_b
);
280 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
281 GdipSaveGraphics(graphics1
, &state_c
);
282 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
283 GdipRestoreGraphics(graphics1
, state_b
);
284 GdipGetInterpolationMode(graphics1
, &mode
);
285 expect(InterpolationModeBicubic
, mode
);
286 GdipRestoreGraphics(graphics1
, state_c
);
287 GdipGetInterpolationMode(graphics1
, &mode
);
288 expect(InterpolationModeBicubic
, mode
);
289 GdipRestoreGraphics(graphics1
, state_a
);
290 GdipGetInterpolationMode(graphics1
, &mode
);
291 expect(InterpolationModeBilinear
, mode
);
292 GdipDeleteGraphics(graphics1
);
294 log_state(state_a
, &state_log
);
295 log_state(state_b
, &state_log
);
296 log_state(state_c
, &state_log
);
298 /* Restoring older save from one graphics object does not invalidate
299 * newer save from other graphics object. */
300 GdipCreateFromHDC(hdc
, &graphics1
);
301 GdipCreateFromHDC(hdc
, &graphics2
);
302 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
303 GdipSaveGraphics(graphics1
, &state_a
);
304 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
305 GdipSaveGraphics(graphics2
, &state_b
);
306 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
307 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
308 GdipRestoreGraphics(graphics1
, state_a
);
309 GdipGetInterpolationMode(graphics1
, &mode
);
310 expect(InterpolationModeBilinear
, mode
);
311 GdipRestoreGraphics(graphics2
, state_b
);
312 GdipGetInterpolationMode(graphics2
, &mode
);
313 expect(InterpolationModeBicubic
, mode
);
314 GdipDeleteGraphics(graphics1
);
315 GdipDeleteGraphics(graphics2
);
317 /* You can't restore a state to a graphics object that didn't save it. */
318 GdipCreateFromHDC(hdc
, &graphics1
);
319 GdipCreateFromHDC(hdc
, &graphics2
);
320 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
321 GdipSaveGraphics(graphics1
, &state_a
);
322 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
323 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
324 GdipRestoreGraphics(graphics2
, state_a
);
325 GdipGetInterpolationMode(graphics2
, &mode
);
326 expect(InterpolationModeNearestNeighbor
, mode
);
327 GdipDeleteGraphics(graphics1
);
328 GdipDeleteGraphics(graphics2
);
330 log_state(state_a
, &state_log
);
332 /* A state created by SaveGraphics cannot be restored with EndContainer. */
333 GdipCreateFromHDC(hdc
, &graphics1
);
334 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
335 stat
= GdipSaveGraphics(graphics1
, &state_a
);
337 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
338 stat
= GdipEndContainer(graphics1
, state_a
);
340 GdipGetInterpolationMode(graphics1
, &mode
);
341 expect(InterpolationModeBicubic
, mode
);
342 stat
= GdipRestoreGraphics(graphics1
, state_a
);
344 GdipGetInterpolationMode(graphics1
, &mode
);
345 expect(InterpolationModeBilinear
, mode
);
346 GdipDeleteGraphics(graphics1
);
348 log_state(state_a
, &state_log
);
350 /* A state created by BeginContainer cannot be restored with RestoreGraphics. */
351 stat
= GdipCreateFromHDC(hdc
, &graphics1
);
353 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
354 stat
= GdipBeginContainer2(graphics1
, &state_a
);
356 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
357 stat
= GdipRestoreGraphics(graphics1
, state_a
);
359 GdipGetInterpolationMode(graphics1
, &mode
);
360 expect(InterpolationModeBicubic
, mode
);
361 stat
= GdipEndContainer(graphics1
, state_a
);
363 GdipGetInterpolationMode(graphics1
, &mode
);
364 expect(InterpolationModeBilinear
, mode
);
365 GdipDeleteGraphics(graphics1
);
367 log_state(state_a
, &state_log
);
369 /* BeginContainer and SaveGraphics use the same stack. */
370 stat
= GdipCreateFromHDC(hdc
, &graphics1
);
372 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
373 stat
= GdipBeginContainer2(graphics1
, &state_a
);
375 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
376 stat
= GdipSaveGraphics(graphics1
, &state_b
);
378 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
379 stat
= GdipEndContainer(graphics1
, state_a
);
381 GdipGetInterpolationMode(graphics1
, &mode
);
382 expect(InterpolationModeBilinear
, mode
);
383 stat
= GdipRestoreGraphics(graphics1
, state_b
);
385 GdipGetInterpolationMode(graphics1
, &mode
);
386 expect(InterpolationModeBilinear
, mode
);
387 GdipDeleteGraphics(graphics1
);
389 log_state(state_a
, &state_log
);
390 log_state(state_b
, &state_log
);
392 /* The same state value should never be returned twice. */
394 check_no_duplicates(state_log
);
396 ReleaseDC(hwnd
, hdc
);
399 static void test_GdipFillClosedCurve2(void)
402 GpGraphics
*graphics
= NULL
;
403 GpSolidFill
*brush
= NULL
;
404 HDC hdc
= GetDC( hwnd
);
416 /* make a graphics object and brush object */
417 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
419 status
= GdipCreateFromHDC(hdc
, &graphics
);
421 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
423 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
425 /* InvalidParameter cases: null graphics, null brush, null points */
426 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
427 expect(InvalidParameter
, status
);
429 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
430 expect(InvalidParameter
, status
);
432 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
433 expect(InvalidParameter
, status
);
435 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
436 expect(InvalidParameter
, status
);
438 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
439 expect(InvalidParameter
, status
);
441 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
442 expect(InvalidParameter
, status
);
444 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
445 expect(InvalidParameter
, status
);
447 /* InvalidParameter cases: invalid count */
448 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
449 expect(InvalidParameter
, status
);
451 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
452 expect(InvalidParameter
, status
);
454 /* Valid test cases */
455 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
458 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
461 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
464 GdipDeleteGraphics(graphics
);
465 GdipDeleteBrush((GpBrush
*)brush
);
467 ReleaseDC(hwnd
, hdc
);
470 static void test_GdipFillClosedCurve2I(void)
473 GpGraphics
*graphics
= NULL
;
474 GpSolidFill
*brush
= NULL
;
475 HDC hdc
= GetDC( hwnd
);
487 /* make a graphics object and brush object */
488 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
490 status
= GdipCreateFromHDC(hdc
, &graphics
);
492 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
494 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
496 /* InvalidParameter cases: null graphics, null brush */
497 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
498 when points == NULL, so don't test this condition */
499 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
500 expect(InvalidParameter
, status
);
502 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
503 expect(InvalidParameter
, status
);
505 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
506 expect(InvalidParameter
, status
);
508 /* InvalidParameter cases: invalid count */
509 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
510 expect(InvalidParameter
, status
);
512 /* OutOfMemory cases: large (unsigned) int */
513 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
514 expect(OutOfMemory
, status
);
516 /* Valid test cases */
517 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
520 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
523 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
526 GdipDeleteGraphics(graphics
);
527 GdipDeleteBrush((GpBrush
*)brush
);
529 ReleaseDC(hwnd
, hdc
);
532 static void test_GdipDrawArc(void)
535 GpGraphics
*graphics
= NULL
;
537 HDC hdc
= GetDC( hwnd
);
539 /* make a graphics object and pen object */
540 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
542 status
= GdipCreateFromHDC(hdc
, &graphics
);
544 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
546 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
548 ok(pen
!= NULL
, "Expected pen to be initialized\n");
550 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
551 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
552 expect(InvalidParameter
, status
);
554 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
555 expect(InvalidParameter
, status
);
557 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
558 expect(InvalidParameter
, status
);
560 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
561 expect(InvalidParameter
, status
);
563 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
564 expect(InvalidParameter
, status
);
566 /* successful case */
567 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
571 GdipDeleteGraphics(graphics
);
573 ReleaseDC(hwnd
, hdc
);
576 static void test_GdipDrawArcI(void)
579 GpGraphics
*graphics
= NULL
;
581 HDC hdc
= GetDC( hwnd
);
583 /* make a graphics object and pen object */
584 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
586 status
= GdipCreateFromHDC(hdc
, &graphics
);
588 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
590 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
592 ok(pen
!= NULL
, "Expected pen to be initialized\n");
594 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
595 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
596 expect(InvalidParameter
, status
);
598 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
599 expect(InvalidParameter
, status
);
601 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
602 expect(InvalidParameter
, status
);
604 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
605 expect(InvalidParameter
, status
);
607 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
608 expect(InvalidParameter
, status
);
610 /* successful case */
611 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
615 GdipDeleteGraphics(graphics
);
617 ReleaseDC(hwnd
, hdc
);
620 static void test_BeginContainer2(void)
624 REAL defClip
[] = {5, 10, 15, 20};
625 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
626 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
627 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
628 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
629 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
630 REAL scale
, defScale
= 17;
631 GpUnit unit
, defUnit
= UnitPixel
;
632 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
633 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
634 UINT contrast
, defContrast
= 5;
635 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
638 GpGraphics
*graphics
= NULL
;
639 HDC hdc
= GetDC( hwnd
);
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 /* null graphics, null container */
648 status
= GdipBeginContainer2(NULL
, &cont1
);
649 expect(InvalidParameter
, status
);
651 status
= GdipBeginContainer2(graphics
, NULL
);
652 expect(InvalidParameter
, status
);
654 status
= GdipEndContainer(NULL
, cont1
);
655 expect(InvalidParameter
, status
);
657 /* test all quality-related values */
658 GdipSetCompositingMode(graphics
, defCompmode
);
659 GdipSetCompositingQuality(graphics
, defCompqual
);
660 GdipSetInterpolationMode(graphics
, defInterp
);
661 GdipSetPageScale(graphics
, defScale
);
662 GdipSetPageUnit(graphics
, defUnit
);
663 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
664 GdipSetSmoothingMode(graphics
, defSmoothmode
);
665 GdipSetTextContrast(graphics
, defContrast
);
666 GdipSetTextRenderingHint(graphics
, defTexthint
);
668 status
= GdipBeginContainer2(graphics
, &cont1
);
671 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
672 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
673 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
674 GdipSetPageScale(graphics
, 10);
675 GdipSetPageUnit(graphics
, UnitDocument
);
676 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
677 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
678 GdipSetTextContrast(graphics
, 7);
679 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
681 status
= GdipEndContainer(graphics
, cont1
);
684 GdipGetCompositingMode(graphics
, &compmode
);
685 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
687 GdipGetCompositingQuality(graphics
, &compqual
);
688 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
690 GdipGetInterpolationMode(graphics
, &interp
);
691 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
693 GdipGetPageScale(graphics
, &scale
);
694 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
696 GdipGetPageUnit(graphics
, &unit
);
697 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
699 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
700 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
702 GdipGetSmoothingMode(graphics
, &smoothmode
);
703 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
705 GdipGetTextContrast(graphics
, &contrast
);
706 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
708 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
710 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
712 /* test world transform */
713 status
= GdipBeginContainer2(graphics
, &cont1
);
716 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
717 defTrans
[4], defTrans
[5], &transform
);
719 GdipSetWorldTransform(graphics
, transform
);
720 GdipDeleteMatrix(transform
);
723 status
= GdipBeginContainer2(graphics
, &cont2
);
726 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
728 status
= GdipSetWorldTransform(graphics
, transform
);
730 GdipDeleteMatrix(transform
);
733 status
= GdipEndContainer(graphics
, cont2
);
736 status
= GdipCreateMatrix(&transform
);
738 status
= GdipGetWorldTransform(graphics
, transform
);
740 status
= GdipGetMatrixElements(transform
, elems
);
742 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
743 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
744 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
745 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
746 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
747 fabs(defTrans
[5] - elems
[5]) < 0.0001,
748 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
749 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
750 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
751 GdipDeleteMatrix(transform
);
754 status
= GdipEndContainer(graphics
, cont1
);
758 status
= GdipBeginContainer2(graphics
, &cont1
);
761 status
= GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
764 status
= GdipBeginContainer2(graphics
, &cont2
);
767 status
= GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
770 status
= GdipEndContainer(graphics
, cont2
);
773 status
= GdipGetClipBounds(graphics
, &clip
);
776 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
777 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
778 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
779 fabs(defClip
[3] - clip
.Height
) < 0.0001,
780 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
781 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
782 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
784 status
= GdipEndContainer(graphics
, cont1
);
788 status
= GdipBeginContainer2(graphics
, &cont1
);
791 status
= GdipBeginContainer2(graphics
, &cont2
);
794 status
= GdipBeginContainer2(graphics
, &cont3
);
797 status
= GdipEndContainer(graphics
, cont3
);
800 status
= GdipBeginContainer2(graphics
, &cont4
);
803 status
= GdipEndContainer(graphics
, cont4
);
807 status
= GdipEndContainer(graphics
, cont1
);
810 /* end an already-ended container */
811 status
= GdipEndContainer(graphics
, cont1
);
814 GdipDeleteGraphics(graphics
);
815 ReleaseDC(hwnd
, hdc
);
818 static void test_GdipDrawBezierI(void)
821 GpGraphics
*graphics
= NULL
;
823 HDC hdc
= GetDC( hwnd
);
825 /* make a graphics object and pen object */
826 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
828 status
= GdipCreateFromHDC(hdc
, &graphics
);
830 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
832 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
834 ok(pen
!= NULL
, "Expected pen to be initialized\n");
836 /* InvalidParameter cases: null graphics, null pen */
837 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
838 expect(InvalidParameter
, status
);
840 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
841 expect(InvalidParameter
, status
);
843 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
844 expect(InvalidParameter
, status
);
846 /* successful case */
847 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
851 GdipDeleteGraphics(graphics
);
853 ReleaseDC(hwnd
, hdc
);
856 static void test_GdipDrawCurve3(void)
859 GpGraphics
*graphics
= NULL
;
861 HDC hdc
= GetDC( hwnd
);
873 /* make a graphics object and pen object */
874 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
876 status
= GdipCreateFromHDC(hdc
, &graphics
);
878 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
880 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
882 ok(pen
!= NULL
, "Expected pen to be initialized\n");
884 /* InvalidParameter cases: null graphics, null pen */
885 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
886 expect(InvalidParameter
, status
);
888 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
889 expect(InvalidParameter
, status
);
891 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
892 expect(InvalidParameter
, status
);
894 /* InvalidParameter cases: invalid count */
895 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
896 expect(InvalidParameter
, status
);
898 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
899 expect(InvalidParameter
, status
);
901 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
902 expect(InvalidParameter
, status
);
904 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
905 expect(InvalidParameter
, status
);
907 /* InvalidParameter cases: invalid number of segments */
908 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
909 expect(InvalidParameter
, status
);
911 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
912 expect(InvalidParameter
, status
);
914 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
915 expect(InvalidParameter
, status
);
917 /* Valid test cases */
918 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
921 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
924 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
927 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
931 GdipDeleteGraphics(graphics
);
933 ReleaseDC(hwnd
, hdc
);
936 static void test_GdipDrawCurve3I(void)
939 GpGraphics
*graphics
= NULL
;
941 HDC hdc
= GetDC( hwnd
);
953 /* make a graphics object and pen object */
954 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
956 status
= GdipCreateFromHDC(hdc
, &graphics
);
958 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
960 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
962 ok(pen
!= NULL
, "Expected pen to be initialized\n");
964 /* InvalidParameter cases: null graphics, null pen */
965 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
966 expect(InvalidParameter
, status
);
968 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
969 expect(InvalidParameter
, status
);
971 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
972 expect(InvalidParameter
, status
);
974 /* InvalidParameter cases: invalid count */
975 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
976 expect(OutOfMemory
, status
);
978 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
979 expect(InvalidParameter
, status
);
981 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
982 expect(InvalidParameter
, status
);
984 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
985 expect(InvalidParameter
, status
);
987 /* InvalidParameter cases: invalid number of segments */
988 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
989 expect(InvalidParameter
, status
);
991 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
992 expect(InvalidParameter
, status
);
994 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
995 expect(InvalidParameter
, status
);
997 /* Valid test cases */
998 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
1001 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
1004 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
1007 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
1011 GdipDeleteGraphics(graphics
);
1013 ReleaseDC(hwnd
, hdc
);
1016 static void test_GdipDrawCurve2(void)
1019 GpGraphics
*graphics
= NULL
;
1021 HDC hdc
= GetDC( hwnd
);
1033 /* make a graphics object and pen object */
1034 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1036 status
= GdipCreateFromHDC(hdc
, &graphics
);
1038 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1040 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1042 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1044 /* InvalidParameter cases: null graphics, null pen */
1045 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
1046 expect(InvalidParameter
, status
);
1048 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
1049 expect(InvalidParameter
, status
);
1051 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
1052 expect(InvalidParameter
, status
);
1054 /* InvalidParameter cases: invalid count */
1055 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
1056 expect(InvalidParameter
, status
);
1058 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
1059 expect(InvalidParameter
, status
);
1061 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
1062 expect(InvalidParameter
, status
);
1064 /* Valid test cases */
1065 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1068 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1071 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1074 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1078 GdipDeleteGraphics(graphics
);
1080 ReleaseDC(hwnd
, hdc
);
1083 static void test_GdipDrawCurve2I(void)
1086 GpGraphics
*graphics
= NULL
;
1088 HDC hdc
= GetDC( hwnd
);
1100 /* make a graphics object and pen object */
1101 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1103 status
= GdipCreateFromHDC(hdc
, &graphics
);
1105 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1107 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1109 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1111 /* InvalidParameter cases: null graphics, null pen */
1112 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1113 expect(InvalidParameter
, status
);
1115 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1116 expect(InvalidParameter
, status
);
1118 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1119 expect(InvalidParameter
, status
);
1121 /* InvalidParameter cases: invalid count */
1122 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1123 expect(OutOfMemory
, status
);
1125 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1126 expect(InvalidParameter
, status
);
1128 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1129 expect(InvalidParameter
, status
);
1131 /* Valid test cases */
1132 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1135 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1138 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1141 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1145 GdipDeleteGraphics(graphics
);
1147 ReleaseDC(hwnd
, hdc
);
1150 static void test_GdipDrawCurve(void)
1153 GpGraphics
*graphics
= NULL
;
1155 HDC hdc
= GetDC( hwnd
);
1167 /* make a graphics object and pen object */
1168 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1170 status
= GdipCreateFromHDC(hdc
, &graphics
);
1172 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1174 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1176 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1178 /* InvalidParameter cases: null graphics, null pen */
1179 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1180 expect(InvalidParameter
, status
);
1182 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1183 expect(InvalidParameter
, status
);
1185 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1186 expect(InvalidParameter
, status
);
1188 /* InvalidParameter cases: invalid count */
1189 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1190 expect(InvalidParameter
, status
);
1192 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1193 expect(InvalidParameter
, status
);
1195 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1196 expect(InvalidParameter
, status
);
1198 /* Valid test cases */
1199 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1202 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1206 GdipDeleteGraphics(graphics
);
1208 ReleaseDC(hwnd
, hdc
);
1211 static void test_GdipDrawCurveI(void)
1214 GpGraphics
*graphics
= NULL
;
1216 HDC hdc
= GetDC( hwnd
);
1228 /* make a graphics object and pen object */
1229 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1231 status
= GdipCreateFromHDC(hdc
, &graphics
);
1233 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1235 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1237 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1239 /* InvalidParameter cases: null graphics, null pen */
1240 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1241 expect(InvalidParameter
, status
);
1243 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1244 expect(InvalidParameter
, status
);
1246 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1247 expect(InvalidParameter
, status
);
1249 /* InvalidParameter cases: invalid count */
1250 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1251 expect(OutOfMemory
, status
);
1253 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1254 expect(InvalidParameter
, status
);
1256 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1257 expect(InvalidParameter
, status
);
1259 /* Valid test cases */
1260 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1263 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1267 GdipDeleteGraphics(graphics
);
1269 ReleaseDC(hwnd
, hdc
);
1272 static void test_GdipDrawLineI(void)
1275 GpGraphics
*graphics
= NULL
;
1277 HDC hdc
= GetDC( hwnd
);
1279 /* make a graphics object and pen object */
1280 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1282 status
= GdipCreateFromHDC(hdc
, &graphics
);
1284 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1286 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1288 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1290 /* InvalidParameter cases: null graphics, null pen */
1291 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1292 expect(InvalidParameter
, status
);
1294 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1295 expect(InvalidParameter
, status
);
1297 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1298 expect(InvalidParameter
, status
);
1300 /* successful case */
1301 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1305 GdipDeleteGraphics(graphics
);
1307 ReleaseDC(hwnd
, hdc
);
1310 static void test_GdipDrawImagePointsRect(void)
1313 GpGraphics
*graphics
= NULL
;
1315 GpBitmap
*bm
= NULL
;
1317 BITMAPINFOHEADER bmihdr
;
1318 HDC hdc
= GetDC( hwnd
);
1322 memset(&bmihdr
, 0, sizeof(bmihdr
));
1323 bmihdr
.biSize
= sizeof(BITMAPINFOHEADER
);
1324 bmihdr
.biWidth
= 10;
1325 bmihdr
.biHeight
= 10;
1326 bmihdr
.biPlanes
= 1;
1327 bmihdr
.biBitCount
= 32;
1328 bmihdr
.biCompression
= BI_RGB
;
1329 status
= GdipCreateBitmapFromGdiDib((BITMAPINFO
*)&bmihdr
, buff
, &bm
);
1331 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1332 status
= GdipCreateFromHDC(hdc
, &graphics
);
1342 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1343 expect(NotImplemented
, status
);
1344 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 5, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1345 expect(InvalidParameter
, status
);
1346 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1347 expect(InvalidParameter
, status
);
1348 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1350 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1351 expect(InvalidParameter
, status
);
1352 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1353 expect(InvalidParameter
, status
);
1354 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1356 memset(ptf
, 0, sizeof(ptf
));
1357 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1360 GdipDisposeImage((GpImage
*)bm
);
1361 GdipDeleteGraphics(graphics
);
1362 ReleaseDC(hwnd
, hdc
);
1365 static void test_GdipDrawLinesI(void)
1368 GpGraphics
*graphics
= NULL
;
1370 GpPoint
*ptf
= NULL
;
1371 HDC hdc
= GetDC( hwnd
);
1373 /* make a graphics object and pen object */
1374 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1376 status
= GdipCreateFromHDC(hdc
, &graphics
);
1378 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1380 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1382 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1384 /* make some arbitrary valid points*/
1385 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1393 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1394 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1395 expect(InvalidParameter
, status
);
1397 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1398 expect(InvalidParameter
, status
);
1400 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1401 expect(InvalidParameter
, status
);
1403 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1404 expect(InvalidParameter
, status
);
1406 /* successful case */
1407 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1412 GdipDeleteGraphics(graphics
);
1414 ReleaseDC(hwnd
, hdc
);
1417 static void test_GdipFillClosedCurve(void)
1420 GpGraphics
*graphics
= NULL
;
1421 GpSolidFill
*brush
= NULL
;
1422 HDC hdc
= GetDC( hwnd
);
1434 /* make a graphics object and brush object */
1435 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1437 status
= GdipCreateFromHDC(hdc
, &graphics
);
1439 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1441 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1443 /* InvalidParameter cases: null graphics, null brush, null points */
1444 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1445 expect(InvalidParameter
, status
);
1447 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1448 expect(InvalidParameter
, status
);
1450 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1451 expect(InvalidParameter
, status
);
1453 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1454 expect(InvalidParameter
, status
);
1456 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1457 expect(InvalidParameter
, status
);
1459 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1460 expect(InvalidParameter
, status
);
1462 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1463 expect(InvalidParameter
, status
);
1465 /* InvalidParameter cases: invalid count */
1466 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1467 expect(InvalidParameter
, status
);
1469 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1470 expect(InvalidParameter
, status
);
1472 /* Valid test cases */
1473 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1476 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1479 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1482 GdipDeleteGraphics(graphics
);
1483 GdipDeleteBrush((GpBrush
*)brush
);
1485 ReleaseDC(hwnd
, hdc
);
1488 static void test_GdipFillClosedCurveI(void)
1491 GpGraphics
*graphics
= NULL
;
1492 GpSolidFill
*brush
= NULL
;
1493 HDC hdc
= GetDC( hwnd
);
1505 /* make a graphics object and brush object */
1506 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1508 status
= GdipCreateFromHDC(hdc
, &graphics
);
1510 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1512 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1514 /* InvalidParameter cases: null graphics, null brush */
1515 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1516 when points == NULL, so don't test this condition */
1517 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1518 expect(InvalidParameter
, status
);
1520 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1521 expect(InvalidParameter
, status
);
1523 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1524 expect(InvalidParameter
, status
);
1526 /* InvalidParameter cases: invalid count */
1527 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1528 expect(InvalidParameter
, status
);
1530 /* OutOfMemory cases: large (unsigned) int */
1531 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1532 expect(OutOfMemory
, status
);
1534 /* Valid test cases */
1535 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1538 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1541 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1544 GdipDeleteGraphics(graphics
);
1545 GdipDeleteBrush((GpBrush
*)brush
);
1547 ReleaseDC(hwnd
, hdc
);
1550 static void test_GdipFillPath(void)
1553 GpGraphics
*graphics
;
1556 HDC hdc
= GetDC(hwnd
);
1558 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1559 status
= GdipCreateFromHDC(hdc
, &graphics
);
1561 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1562 status
= GdipCreateSolidFill((ARGB
)0xffffffff, &brush
);
1564 ok(brush
!= NULL
, "Expected brush to be initialized\n");
1565 status
= GdipCreatePath(FillModeAlternate
, &path
);
1567 ok(path
!= NULL
, "Expected path to be initialized\n");
1570 GdipResetPath(path
);
1571 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1574 /* Not closed path */
1575 GdipResetPath(path
);
1576 status
= GdipAddPathLineI(path
, 0, 0, 2, 2);
1578 status
= GdipAddPathLineI(path
, 2, 2, 4, 0);
1580 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1584 GdipResetPath(path
);
1585 status
= GdipAddPathRectangle(path
, 0, 0, 4, 4);
1587 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1590 GdipDeletePath(path
);
1591 GdipDeleteBrush((GpBrush
*)brush
);
1592 GdipDeleteGraphics(graphics
);
1593 ReleaseDC(hwnd
, hdc
);
1596 static void test_Get_Release_DC(void)
1599 GpGraphics
*graphics
= NULL
;
1603 HDC hdc
= GetDC( hwnd
);
1606 CompositingQuality quality
;
1607 CompositingMode compmode
;
1608 InterpolationMode intmode
;
1612 PixelOffsetMode offsetmode
;
1613 SmoothingMode smoothmode
;
1614 TextRenderingHint texthint
;
1622 ARGB color
= 0x00000000;
1623 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1636 for(i
= 0; i
< 5;i
++){
1637 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1638 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1644 rect
[0].Height
= 70;
1648 rect
[1].Height
= 20;
1650 for(i
= 0; i
< 2;i
++){
1651 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1652 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1653 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1654 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1657 status
= GdipCreateMatrix(&m
);
1659 status
= GdipCreateRegion(®ion
);
1661 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1662 GdipCreatePath(FillModeAlternate
, &path
);
1663 status
= GdipCreateRegion(&clip
);
1666 status
= GdipCreateFromHDC(hdc
, &graphics
);
1668 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1669 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1672 /* NULL arguments */
1673 status
= GdipGetDC(NULL
, NULL
);
1674 expect(InvalidParameter
, status
);
1675 status
= GdipGetDC(graphics
, NULL
);
1676 expect(InvalidParameter
, status
);
1677 status
= GdipGetDC(NULL
, &retdc
);
1678 expect(InvalidParameter
, status
);
1680 status
= GdipReleaseDC(NULL
, NULL
);
1681 expect(InvalidParameter
, status
);
1682 status
= GdipReleaseDC(graphics
, NULL
);
1683 expect(InvalidParameter
, status
);
1684 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1685 expect(InvalidParameter
, status
);
1687 /* Release without Get */
1688 status
= GdipReleaseDC(graphics
, hdc
);
1689 expect(InvalidParameter
, status
);
1692 status
= GdipGetDC(graphics
, &retdc
);
1694 ok(retdc
== hdc
, "Invalid HDC returned\n");
1695 /* call it once more */
1696 status
= GdipGetDC(graphics
, &retdc
);
1697 expect(ObjectBusy
, status
);
1699 /* try all Graphics calls here */
1700 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1701 expect(ObjectBusy
, status
);
1702 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1703 expect(ObjectBusy
, status
);
1704 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1705 expect(ObjectBusy
, status
);
1706 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1707 expect(ObjectBusy
, status
);
1708 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1709 expect(ObjectBusy
, status
);
1710 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1711 expect(ObjectBusy
, status
);
1712 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1713 expect(ObjectBusy
, status
);
1714 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1715 expect(ObjectBusy
, status
);
1716 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1717 expect(ObjectBusy
, status
);
1718 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1719 expect(ObjectBusy
, status
);
1720 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1721 expect(ObjectBusy
, status
);
1722 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1723 expect(ObjectBusy
, status
);
1724 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1725 expect(ObjectBusy
, status
);
1726 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1727 expect(ObjectBusy
, status
);
1728 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1729 expect(ObjectBusy
, status
);
1730 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1731 expect(ObjectBusy
, status
);
1732 /* GdipDrawImage/GdipDrawImageI */
1733 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1734 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1735 /* GdipDrawImageRect/GdipDrawImageRectI */
1736 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1737 expect(ObjectBusy
, status
);
1738 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1739 expect(ObjectBusy
, status
);
1740 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1741 expect(ObjectBusy
, status
);
1742 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1743 expect(ObjectBusy
, status
);
1744 status
= GdipDrawPath(graphics
, pen
, path
);
1745 expect(ObjectBusy
, status
);
1746 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1747 expect(ObjectBusy
, status
);
1748 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1749 expect(ObjectBusy
, status
);
1750 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1751 expect(ObjectBusy
, status
);
1752 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1753 expect(ObjectBusy
, status
);
1754 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1755 expect(ObjectBusy
, status
);
1756 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1757 expect(ObjectBusy
, status
);
1758 /* GdipDrawString */
1759 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1764 expect(ObjectBusy
, status
);
1765 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1766 expect(ObjectBusy
, status
);
1767 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1768 expect(ObjectBusy
, status
);
1769 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1770 expect(ObjectBusy
, status
);
1771 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1772 expect(ObjectBusy
, status
);
1773 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1774 expect(ObjectBusy
, status
);
1775 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1776 expect(ObjectBusy
, status
);
1777 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1778 expect(ObjectBusy
, status
);
1779 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1780 expect(ObjectBusy
, status
);
1781 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1782 expect(ObjectBusy
, status
);
1783 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1784 expect(ObjectBusy
, status
);
1785 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1786 expect(ObjectBusy
, status
);
1787 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1788 expect(ObjectBusy
, status
);
1789 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1790 expect(ObjectBusy
, status
);
1791 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1792 expect(ObjectBusy
, status
);
1793 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1794 expect(ObjectBusy
, status
);
1795 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1796 expect(ObjectBusy
, status
);
1797 status
= GdipGetClipBounds(graphics
, rectf
);
1798 expect(ObjectBusy
, status
);
1799 status
= GdipGetClipBoundsI(graphics
, rect
);
1800 expect(ObjectBusy
, status
);
1801 status
= GdipGetCompositingMode(graphics
, &compmode
);
1802 expect(ObjectBusy
, status
);
1803 status
= GdipGetCompositingQuality(graphics
, &quality
);
1804 expect(ObjectBusy
, status
);
1805 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1806 expect(ObjectBusy
, status
);
1807 status
= GdipGetNearestColor(graphics
, &color
);
1808 expect(ObjectBusy
, status
);
1809 status
= GdipGetPageScale(graphics
, &r
);
1810 expect(ObjectBusy
, status
);
1811 status
= GdipGetPageUnit(graphics
, &unit
);
1812 expect(ObjectBusy
, status
);
1813 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1814 expect(ObjectBusy
, status
);
1815 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1816 expect(ObjectBusy
, status
);
1817 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1818 expect(ObjectBusy
, status
);
1819 status
= GdipGetWorldTransform(graphics
, m
);
1820 expect(ObjectBusy
, status
);
1821 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1822 expect(ObjectBusy
, status
);
1823 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1824 expect(ObjectBusy
, status
);
1825 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1826 expect(ObjectBusy
, status
);
1827 /* GdipMeasureCharacterRanges */
1828 /* GdipMeasureString */
1829 status
= GdipResetClip(graphics
);
1830 expect(ObjectBusy
, status
);
1831 status
= GdipResetPageTransform(graphics
);
1832 expect(ObjectBusy
, status
);
1833 status
= GdipResetWorldTransform(graphics
);
1834 expect(ObjectBusy
, status
);
1835 /* GdipRestoreGraphics */
1836 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1837 expect(ObjectBusy
, status
);
1838 /* GdipSaveGraphics */
1839 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1840 expect(ObjectBusy
, status
);
1841 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1842 expect(ObjectBusy
, status
);
1843 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1844 expect(ObjectBusy
, status
);
1845 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1846 expect(ObjectBusy
, status
);
1847 status
= GdipSetPageScale(graphics
, 1.0);
1848 expect(ObjectBusy
, status
);
1849 status
= GdipSetPageScale(graphics
, 0.0);
1850 expect(ObjectBusy
, status
);
1851 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1852 expect(ObjectBusy
, status
);
1853 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1854 expect(ObjectBusy
, status
);
1855 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1856 expect(ObjectBusy
, status
);
1857 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1858 expect(ObjectBusy
, status
);
1859 status
= GdipSetWorldTransform(graphics
, m
);
1860 expect(ObjectBusy
, status
);
1861 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1862 expect(ObjectBusy
, status
);
1863 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1864 expect(ObjectBusy
, status
);
1865 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1866 expect(ObjectBusy
, status
);
1867 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1868 expect(ObjectBusy
, status
);
1869 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1870 expect(ObjectBusy
, status
);
1871 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1872 expect(ObjectBusy
, status
);
1873 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1874 expect(ObjectBusy
, status
);
1875 status
= GdipTranslateClipI(graphics
, 0, 0);
1876 expect(ObjectBusy
, status
);
1877 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1878 expect(ObjectBusy
, status
);
1879 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1880 expect(ObjectBusy
, status
);
1881 status
= GdipGetDpiX(graphics
, &r
);
1882 expect(ObjectBusy
, status
);
1883 status
= GdipGetDpiY(graphics
, &r
);
1884 expect(ObjectBusy
, status
);
1885 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1886 expect(ObjectBusy
, status
);
1887 status
= GdipGetClip(graphics
, region
);
1888 expect(ObjectBusy
, status
);
1889 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1890 expect(ObjectBusy
, status
);
1892 /* try to delete before release */
1893 status
= GdipDeleteGraphics(graphics
);
1894 expect(ObjectBusy
, status
);
1896 status
= GdipReleaseDC(graphics
, retdc
);
1900 GdipDeleteGraphics(graphics
);
1902 GdipDeleteRegion(clip
);
1903 GdipDeletePath(path
);
1904 GdipDeleteBrush((GpBrush
*)brush
);
1905 GdipDeleteRegion(region
);
1906 GdipDeleteMatrix(m
);
1909 ReleaseDC(hwnd
, hdc
);
1912 static void test_transformpoints(void)
1915 GpGraphics
*graphics
= NULL
;
1916 HDC hdc
= GetDC( hwnd
);
1920 status
= GdipCreateFromHDC(hdc
, &graphics
);
1923 /* NULL arguments */
1924 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1925 expect(InvalidParameter
, status
);
1926 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1927 expect(InvalidParameter
, status
);
1928 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1929 expect(InvalidParameter
, status
);
1930 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1931 expect(InvalidParameter
, status
);
1933 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
+1, CoordinateSpaceWorld
, ptf
, 2);
1934 expect(InvalidParameter
, status
);
1935 status
= GdipTransformPoints(graphics
, -1, CoordinateSpaceWorld
, ptf
, 2);
1936 expect(InvalidParameter
, status
);
1937 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceDevice
+1, ptf
, 2);
1938 expect(InvalidParameter
, status
);
1939 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, -1, ptf
, 2);
1940 expect(InvalidParameter
, status
);
1946 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1948 expectf(1.0, ptf
[0].X
);
1949 expectf(0.0, ptf
[0].Y
);
1950 expectf(0.0, ptf
[1].X
);
1951 expectf(1.0, ptf
[1].Y
);
1953 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1955 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1957 status
= GdipSetPageScale(graphics
, 3.0);
1964 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1966 expectf(18.0, ptf
[0].X
);
1967 expectf(15.0, ptf
[0].Y
);
1968 expectf(15.0, ptf
[1].X
);
1969 expectf(18.0, ptf
[1].Y
);
1975 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1977 expectf(6.0, ptf
[0].X
);
1978 expectf(5.0, ptf
[0].Y
);
1979 expectf(5.0, ptf
[1].X
);
1980 expectf(6.0, ptf
[1].Y
);
1986 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1988 expectf(3.0, ptf
[0].X
);
1989 expectf(0.0, ptf
[0].Y
);
1990 expectf(0.0, ptf
[1].X
);
1991 expectf(3.0, ptf
[1].Y
);
1997 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1999 expectf(1.0, ptf
[0].X
);
2000 expectf(0.0, ptf
[0].Y
);
2001 expectf(0.0, ptf
[1].X
);
2002 expectf(1.0, ptf
[1].Y
);
2008 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
2010 expectf(1.0, ptf
[0].X
);
2011 expectf(0.0, ptf
[0].Y
);
2012 expectf(0.0, ptf
[1].X
);
2013 expectf(1.0, ptf
[1].Y
);
2019 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
2021 expectf(1.0, ptf
[0].X
);
2022 expectf(0.0, ptf
[0].Y
);
2023 expectf(0.0, ptf
[1].X
);
2024 expectf(1.0, ptf
[1].Y
);
2030 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
2032 expect(18, pt
[0].X
);
2033 expect(15, pt
[0].Y
);
2034 expect(15, pt
[1].X
);
2035 expect(18, pt
[1].Y
);
2037 GdipDeleteGraphics(graphics
);
2038 ReleaseDC(hwnd
, hdc
);
2041 static void test_get_set_clip(void)
2044 GpGraphics
*graphics
= NULL
;
2045 HDC hdc
= GetDC( hwnd
);
2050 status
= GdipCreateFromHDC(hdc
, &graphics
);
2053 rect
.X
= rect
.Y
= 0.0;
2054 rect
.Height
= rect
.Width
= 100.0;
2056 status
= GdipCreateRegionRect(&rect
, &clip
);
2059 /* NULL arguments */
2060 status
= GdipGetClip(NULL
, NULL
);
2061 expect(InvalidParameter
, status
);
2062 status
= GdipGetClip(graphics
, NULL
);
2063 expect(InvalidParameter
, status
);
2064 status
= GdipGetClip(NULL
, clip
);
2065 expect(InvalidParameter
, status
);
2067 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
2068 expect(InvalidParameter
, status
);
2069 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
2070 expect(InvalidParameter
, status
);
2072 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
2073 expect(InvalidParameter
, status
);
2074 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
2075 expect(InvalidParameter
, status
);
2078 status
= GdipGetClip(graphics
, clip
);
2080 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2084 /* remains infinite after reset */
2086 status
= GdipResetClip(graphics
);
2088 status
= GdipGetClip(graphics
, clip
);
2090 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2094 /* set to empty and then reset to infinite */
2095 status
= GdipSetEmpty(clip
);
2097 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
2100 status
= GdipGetClip(graphics
, clip
);
2103 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
2106 status
= GdipResetClip(graphics
);
2108 status
= GdipGetClip(graphics
, clip
);
2111 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2115 GdipDeleteRegion(clip
);
2117 GdipDeleteGraphics(graphics
);
2118 ReleaseDC(hwnd
, hdc
);
2121 static void test_clip_xform(void)
2124 GpGraphics
*graphics
= NULL
;
2125 HDC hdc
= GetDC( hwnd
);
2128 UINT region_data_size
;
2141 status
= GdipCreateFromHDC(hdc
, &graphics
);
2143 status
= GdipCreateRegion(&clip
);
2146 status
= GdipGraphicsClear(graphics
, 0xff000000);
2149 status
= GdipSetClipRect(graphics
, 10, 10, -10, -10, CombineModeReplace
);
2151 status
= GdipGetClip(graphics
, clip
);
2153 status
= GdipGetRegionData(clip
, (BYTE
*)®ion_data
, sizeof(region_data
), ®ion_data_size
);
2155 expect(36, region_data_size
);
2156 expect(28, region_data
.size
);
2157 expect(0, region_data
.num_children
);
2158 expect(0x10000000 /* RegionDataRect */, region_data
.element_type
);
2159 expectf(0.0, region_data
.x
);
2160 expectf(0.0, region_data
.y
);
2161 expectf(10.0, region_data
.width
);
2162 expectf(10.0, region_data
.height
);
2164 /* No effect with negative width/height */
2165 status
= GdipGraphicsClear(graphics
, 0xffff0000);
2167 color
= GetPixel(hdc
, 5, 5);
2170 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderAppend
);
2173 status
= GdipGraphicsClear(graphics
, 0xffff0000);
2175 color
= GetPixel(hdc
, 5, 5);
2178 status
= GdipResetClip(graphics
);
2180 status
= GdipResetWorldTransform(graphics
);
2182 status
= GdipGraphicsClear(graphics
, 0xff000000);
2185 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderAppend
);
2188 status
= GdipSetClipRect(graphics
, 5, 5, -5, -5, CombineModeReplace
);
2190 status
= GdipGetClip(graphics
, clip
);
2192 status
= GdipGetRegionData(clip
, (BYTE
*)®ion_data
, sizeof(region_data
), ®ion_data_size
);
2194 expect(36, region_data_size
);
2195 expect(28, region_data
.size
);
2196 expect(0, region_data
.num_children
);
2197 expect(0x10000000 /* RegionDataRect */, region_data
.element_type
);
2198 expectf(0.0, region_data
.x
);
2199 expectf(0.0, region_data
.y
);
2200 expectf(5.0, region_data
.width
);
2201 expectf(5.0, region_data
.height
);
2203 status
= GdipGraphicsClear(graphics
, 0xffff0000);
2205 color
= GetPixel(hdc
, 5, 5);
2206 expect(0xff, color
);
2208 GdipDeleteGraphics(graphics
);
2209 GdipDeleteRegion(clip
);
2210 ReleaseDC(hwnd
, hdc
);
2213 static void test_isempty(void)
2216 GpGraphics
*graphics
= NULL
;
2217 HDC hdc
= GetDC( hwnd
);
2221 status
= GdipCreateFromHDC(hdc
, &graphics
);
2224 status
= GdipCreateRegion(&clip
);
2228 status
= GdipIsClipEmpty(NULL
, NULL
);
2229 expect(InvalidParameter
, status
);
2230 status
= GdipIsClipEmpty(graphics
, NULL
);
2231 expect(InvalidParameter
, status
);
2232 status
= GdipIsClipEmpty(NULL
, &res
);
2233 expect(InvalidParameter
, status
);
2235 /* default is infinite */
2237 status
= GdipIsClipEmpty(graphics
, &res
);
2241 GdipDeleteRegion(clip
);
2243 GdipDeleteGraphics(graphics
);
2244 ReleaseDC(hwnd
, hdc
);
2247 static void test_clear(void)
2251 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2252 expect(InvalidParameter
, status
);
2255 static void test_textcontrast(void)
2258 HDC hdc
= GetDC( hwnd
);
2259 GpGraphics
*graphics
;
2262 status
= GdipGetTextContrast(NULL
, NULL
);
2263 expect(InvalidParameter
, status
);
2265 status
= GdipCreateFromHDC(hdc
, &graphics
);
2268 status
= GdipGetTextContrast(graphics
, NULL
);
2269 expect(InvalidParameter
, status
);
2270 status
= GdipGetTextContrast(graphics
, &contrast
);
2272 expect(4, contrast
);
2274 GdipDeleteGraphics(graphics
);
2275 ReleaseDC(hwnd
, hdc
);
2278 static void test_GdipDrawString(void)
2281 GpGraphics
*graphics
= NULL
;
2284 GpStringFormat
*format
;
2287 HDC hdc
= GetDC( hwnd
);
2288 static const WCHAR string
[] = L
"Test";
2289 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2292 memset(&logfont
,0,sizeof(logfont
));
2293 strcpy(logfont
.lfFaceName
,"Arial");
2294 logfont
.lfHeight
= 12;
2295 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2297 status
= GdipCreateFromHDC(hdc
, &graphics
);
2300 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2301 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2303 skip("Arial not installed.\n");
2308 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2311 status
= GdipCreateStringFormat(0,0,&format
);
2319 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2322 status
= GdipCreateMatrix(&matrix
);
2325 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2326 expect(InvalidParameter
, status
);
2328 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2329 expect(InvalidParameter
, status
);
2331 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2332 expect(InvalidParameter
, status
);
2334 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2335 expect(InvalidParameter
, status
);
2337 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2338 expect(InvalidParameter
, status
);
2340 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2343 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2346 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2349 GdipDeleteMatrix(matrix
);
2350 GdipDeleteGraphics(graphics
);
2351 GdipDeleteBrush(brush
);
2352 GdipDeleteFont(fnt
);
2353 GdipDeleteStringFormat(format
);
2355 ReleaseDC(hwnd
, hdc
);
2358 static void test_GdipGetVisibleClipBounds_screen(void)
2361 GpGraphics
*graphics
= NULL
;
2363 GpRectF rectf
, exp
, clipr
;
2366 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2368 status
= GdipCreateFromHDC(hdc
, &graphics
);
2370 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2372 /* no clipping rect */
2375 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2376 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2378 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2380 ok(rectf
.X
== exp
.X
&&
2382 rectf
.Width
== exp
.Width
&&
2383 rectf
.Height
== exp
.Height
,
2384 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2385 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2386 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2387 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2389 /* clipping rect entirely within window */
2390 exp
.X
= clipr
.X
= 10;
2391 exp
.Y
= clipr
.Y
= 12;
2392 exp
.Width
= clipr
.Width
= 14;
2393 exp
.Height
= clipr
.Height
= 16;
2395 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2398 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2400 ok(rectf
.X
== exp
.X
&&
2402 rectf
.Width
== exp
.Width
&&
2403 rectf
.Height
== exp
.Height
,
2404 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2405 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2406 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2407 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2409 /* clipping rect partially outside of screen */
2415 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2423 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2425 ok(rectf
.X
== exp
.X
&&
2427 rectf
.Width
== exp
.Width
&&
2428 rectf
.Height
== exp
.Height
,
2429 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2430 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2431 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2432 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2434 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2436 ok(recti
.X
== exp
.X
&&
2438 recti
.Width
== exp
.Width
&&
2439 recti
.Height
== exp
.Height
,
2440 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2441 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2442 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2443 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2445 GdipDeleteGraphics(graphics
);
2449 static void test_GdipGetVisibleClipBounds_window(void)
2452 GpGraphics
*graphics
= NULL
;
2453 GpRectF rectf
, window
, exp
, clipr
;
2459 /* get client area size */
2460 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2461 window
.X
= wnd_rect
.left
;
2462 window
.Y
= wnd_rect
.top
;
2463 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2464 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2466 hdc
= BeginPaint(hwnd
, &ps
);
2468 status
= GdipCreateFromHDC(hdc
, &graphics
);
2470 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2472 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2474 ok(rectf
.X
== window
.X
&&
2475 rectf
.Y
== window
.Y
&&
2476 rectf
.Width
== window
.Width
&&
2477 rectf
.Height
== window
.Height
,
2478 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2479 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2480 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2481 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2483 /* clipping rect entirely within window */
2484 exp
.X
= clipr
.X
= 20;
2485 exp
.Y
= clipr
.Y
= 8;
2486 exp
.Width
= clipr
.Width
= 30;
2487 exp
.Height
= clipr
.Height
= 20;
2489 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2492 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2494 ok(rectf
.X
== exp
.X
&&
2496 rectf
.Width
== exp
.Width
&&
2497 rectf
.Height
== exp
.Height
,
2498 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2499 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2500 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2501 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2503 /* clipping rect partially outside of window */
2504 clipr
.X
= window
.Width
- 10;
2505 clipr
.Y
= window
.Height
- 15;
2509 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2512 exp
.X
= window
.Width
- 10;
2513 exp
.Y
= window
.Height
- 15;
2517 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2519 ok(rectf
.X
== exp
.X
&&
2521 rectf
.Width
== exp
.Width
&&
2522 rectf
.Height
== exp
.Height
,
2523 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2524 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2525 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2526 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2528 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2530 ok(recti
.X
== exp
.X
&&
2532 recti
.Width
== exp
.Width
&&
2533 recti
.Height
== exp
.Height
,
2534 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2535 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2536 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2537 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2539 /* window bounds with transform applied */
2540 status
= GdipResetClip(graphics
);
2543 status
= GdipScaleWorldTransform(graphics
, 0.5, 0.5, MatrixOrderPrepend
);
2546 exp
.X
= window
.X
* 2.0;
2547 exp
.Y
= window
.Y
* 2.0;
2548 exp
.Width
= window
.Width
* 2.0;
2549 exp
.Height
= window
.Height
* 2.0;
2551 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2553 ok(rectf
.X
== exp
.X
&&
2555 rectf
.Width
== exp
.Width
&&
2556 rectf
.Height
== exp
.Height
,
2557 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2558 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2559 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2560 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2562 GdipDeleteGraphics(graphics
);
2563 EndPaint(hwnd
, &ps
);
2566 static void test_GdipGetVisibleClipBounds(void)
2568 GpGraphics
* graphics
= NULL
;
2571 HDC hdc
= GetDC( hwnd
);
2574 status
= GdipCreateFromHDC(hdc
, &graphics
);
2576 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2578 /* test null parameters */
2579 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2580 expect(InvalidParameter
, status
);
2582 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2583 expect(InvalidParameter
, status
);
2585 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2586 expect(InvalidParameter
, status
);
2588 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2589 expect(InvalidParameter
, status
);
2591 GdipDeleteGraphics(graphics
);
2592 ReleaseDC(hwnd
, hdc
);
2594 test_GdipGetVisibleClipBounds_screen();
2595 test_GdipGetVisibleClipBounds_window();
2598 static void test_fromMemoryBitmap(void)
2601 GpGraphics
*graphics
= NULL
;
2602 GpBitmap
*bitmap
= NULL
;
2603 BYTE bits
[48] = {0};
2607 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2610 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2613 status
= GdipGraphicsClear(graphics
, 0xff686868);
2616 GdipDeleteGraphics(graphics
);
2618 /* drawing writes to the memory provided */
2619 expect(0x68, bits
[10]);
2621 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2624 status
= GdipGetDC(graphics
, &hdc
);
2626 ok(hdc
!= NULL
, "got NULL hdc\n");
2628 color
= GetPixel(hdc
, 0, 0);
2629 /* The HDC is write-only, and native fills with a solid color to figure out
2630 * which pixels have changed. */
2631 todo_wine
expect(0x0c0b0d, color
);
2633 SetPixel(hdc
, 0, 0, 0x797979);
2634 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2636 status
= GdipReleaseDC(graphics
, hdc
);
2639 GdipDeleteGraphics(graphics
);
2641 expect(0x79, bits
[0]);
2642 todo_wine
expect(0x68, bits
[3]);
2644 GdipDisposeImage((GpImage
*)bitmap
);
2646 /* We get the same kind of write-only HDC for a "normal" bitmap */
2647 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2650 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2653 status
= GdipGetDC(graphics
, &hdc
);
2655 ok(hdc
!= NULL
, "got NULL hdc\n");
2657 color
= GetPixel(hdc
, 0, 0);
2658 todo_wine
expect(0x0c0b0d, color
);
2660 status
= GdipReleaseDC(graphics
, hdc
);
2663 GdipDeleteGraphics(graphics
);
2665 GdipDisposeImage((GpImage
*)bitmap
);
2667 /* If we don't draw to the HDC, the bits are never accessed */
2668 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2671 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2674 status
= GdipGetDC(graphics
, &hdc
);
2676 ok(hdc
!= NULL
, "got NULL hdc\n");
2678 color
= GetPixel(hdc
, 0, 0);
2679 todo_wine
expect(0x0c0b0d, color
);
2681 status
= GdipReleaseDC(graphics
, hdc
);
2684 GdipDeleteGraphics(graphics
);
2686 GdipDisposeImage((GpImage
*)bitmap
);
2689 static void test_GdipIsVisiblePoint(void)
2692 GpGraphics
*graphics
= NULL
;
2693 HDC hdc
= GetDC( hwnd
);
2697 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2699 status
= GdipCreateFromHDC(hdc
, &graphics
);
2701 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2703 /* null parameters */
2704 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2705 expect(InvalidParameter
, status
);
2707 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2708 expect(InvalidParameter
, status
);
2710 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2711 expect(InvalidParameter
, status
);
2713 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2714 expect(InvalidParameter
, status
);
2718 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2720 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2724 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2726 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2730 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2732 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2736 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2738 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2740 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2745 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2747 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2751 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2753 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2755 /* translate into the center of the rect */
2756 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2760 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2762 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2766 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2768 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2770 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2775 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2777 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2781 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2783 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2787 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2789 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2793 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2795 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2799 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2801 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2805 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2807 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2811 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2813 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2817 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2819 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2823 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2825 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2829 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2831 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2835 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2837 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2841 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2843 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2847 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2849 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2851 /* integer version */
2854 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2856 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2860 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2862 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2864 GdipDeleteGraphics(graphics
);
2865 ReleaseDC(hwnd
, hdc
);
2868 static void test_GdipIsVisibleRect(void)
2871 GpGraphics
*graphics
= NULL
;
2872 HDC hdc
= GetDC( hwnd
);
2873 REAL x
, y
, width
, height
;
2876 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2878 status
= GdipCreateFromHDC(hdc
, &graphics
);
2880 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2882 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2883 expect(InvalidParameter
, status
);
2885 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2886 expect(InvalidParameter
, status
);
2888 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2889 expect(InvalidParameter
, status
);
2891 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2892 expect(InvalidParameter
, status
);
2894 /* entirely within the visible region */
2897 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2899 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2901 /* partially outside */
2902 x
= -10; width
= 20;
2903 y
= -10; height
= 20;
2904 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2906 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2908 /* entirely outside */
2910 y
= -10; height
= 5;
2911 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2913 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2915 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2918 /* entirely within the visible region */
2920 y
= 22; height
= 10;
2921 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2923 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2925 /* partially outside */
2927 y
= 55; height
= 10;
2928 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2930 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2932 /* entirely outside */
2935 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2937 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2939 /* translate into center of clipping rect */
2940 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2944 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2946 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2950 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2952 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2954 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2956 /* corners entirely outside, but some intersections */
2959 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2961 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2965 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2967 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2971 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2973 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2977 y
= 20; height
= 40;
2978 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2980 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2984 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2986 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2989 y
= 20; height
= 40;
2990 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2992 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2995 y
= 60; height
= 10;
2996 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2998 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
3000 /* rounding tests */
3001 x
= 0.4; width
= 10.4;
3002 y
= 20; height
= 40;
3003 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
3005 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3008 y
= 0.4; height
= 20.4;
3009 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
3011 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3013 /* integer version */
3016 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
3018 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3021 y
= 22; height
= 10;
3022 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
3024 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3026 GdipDeleteGraphics(graphics
);
3027 ReleaseDC(hwnd
, hdc
);
3030 static void test_GdipGetNearestColor(void)
3033 GpGraphics
*graphics
;
3035 ARGB color
= 0xdeadbeef;
3036 HDC hdc
= GetDC( hwnd
);
3038 /* create a graphics object */
3039 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3041 status
= GdipCreateFromHDC(hdc
, &graphics
);
3043 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3045 status
= GdipGetNearestColor(graphics
, NULL
);
3046 expect(InvalidParameter
, status
);
3048 status
= GdipGetNearestColor(NULL
, &color
);
3049 expect(InvalidParameter
, status
);
3050 GdipDeleteGraphics(graphics
);
3052 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
3054 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3055 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3058 status
= GdipGetNearestColor(graphics
, &color
);
3060 expect(0xdeadbeef, color
);
3061 GdipDeleteGraphics(graphics
);
3063 GdipDisposeImage((GpImage
*)bitmap
);
3065 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
3067 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3068 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3071 status
= GdipGetNearestColor(graphics
, &color
);
3073 expect(0xdeadbeef, color
);
3074 GdipDeleteGraphics(graphics
);
3076 GdipDisposeImage((GpImage
*)bitmap
);
3078 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
3080 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3081 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3084 status
= GdipGetNearestColor(graphics
, &color
);
3086 expect(0xdeadbeef, color
);
3087 GdipDeleteGraphics(graphics
);
3089 GdipDisposeImage((GpImage
*)bitmap
);
3091 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
3093 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3094 todo_wine
expect(OutOfMemory
, status
);
3096 GdipDeleteGraphics(graphics
);
3097 GdipDisposeImage((GpImage
*)bitmap
);
3099 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
3101 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3103 status
= GdipGetNearestColor(graphics
, &color
);
3105 expect(0xdeadbeef, color
);
3106 GdipDeleteGraphics(graphics
);
3107 GdipDisposeImage((GpImage
*)bitmap
);
3109 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
3111 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3113 status
= GdipGetNearestColor(graphics
, &color
);
3115 expect(0xdeadbeef, color
);
3116 GdipDeleteGraphics(graphics
);
3117 GdipDisposeImage((GpImage
*)bitmap
);
3119 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
3121 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3123 status
= GdipGetNearestColor(graphics
, &color
);
3125 expect(0xdeadbeef, color
);
3126 GdipDeleteGraphics(graphics
);
3127 GdipDisposeImage((GpImage
*)bitmap
);
3129 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
3133 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3135 status
= GdipGetNearestColor(graphics
, &color
);
3137 expect(0xdeadbeef, color
);
3138 GdipDeleteGraphics(graphics
);
3139 GdipDisposeImage((GpImage
*)bitmap
);
3142 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
3146 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3148 status
= GdipGetNearestColor(graphics
, &color
);
3150 expect(0xdeadbeef, color
);
3151 GdipDeleteGraphics(graphics
);
3152 GdipDisposeImage((GpImage
*)bitmap
);
3155 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
3159 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3161 status
= GdipGetNearestColor(graphics
, &color
);
3163 expect(0xdeadbeef, color
);
3164 GdipDeleteGraphics(graphics
);
3165 GdipDisposeImage((GpImage
*)bitmap
);
3168 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
3170 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3172 status
= GdipGetNearestColor(graphics
, &color
);
3174 todo_wine
expect(0xffa8bce8, color
);
3175 GdipDeleteGraphics(graphics
);
3176 GdipDisposeImage((GpImage
*)bitmap
);
3178 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
3180 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3182 status
= GdipGetNearestColor(graphics
, &color
);
3185 ok(color
== 0xffa8b8e8 ||
3186 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
3187 "Expected ffa8b8e8, got %.8lx\n", color
);
3188 GdipDeleteGraphics(graphics
);
3189 GdipDisposeImage((GpImage
*)bitmap
);
3191 ReleaseDC(hwnd
, hdc
);
3194 static void test_string_functions(void)
3197 GpGraphics
*graphics
;
3198 GpFontFamily
*family
;
3200 RectF rc
, char_bounds
, bounds
;
3202 ARGB color
= 0xff000000;
3203 HDC hdc
= GetDC( hwnd
);
3204 const WCHAR teststring
[] = L
"MM M\nM";
3205 const WCHAR teststring2
[] = L
"j";
3206 const WCHAR teststring3
[] = L
"MM M\r\nM\0";
3207 REAL char_width
, char_height
;
3208 INT codepointsfitted
, linesfilled
;
3209 GpStringFormat
*format
;
3210 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
3211 GpRegion
*regions
[4];
3212 BOOL region_isempty
[4];
3214 PointF positions
[8];
3217 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3218 status
= GdipCreateFromHDC(hdc
, &graphics
);
3220 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3222 status
= GdipCreateFontFamilyFromName(L
"Tahoma", NULL
, &family
);
3225 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
3228 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
3231 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3239 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
3240 expect(InvalidParameter
, status
);
3242 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
3243 expect(InvalidParameter
, status
);
3245 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3246 expect(InvalidParameter
, status
);
3248 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3249 expect(InvalidParameter
, status
);
3251 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3252 expect(InvalidParameter
, status
);
3254 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3257 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3258 expect(InvalidParameter
, status
);
3260 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3261 expect(InvalidParameter
, status
);
3263 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3264 expect(InvalidParameter
, status
);
3266 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3267 expect(InvalidParameter
, status
);
3269 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3270 expect(InvalidParameter
, status
);
3272 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3275 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3278 /* new line handling */
3279 status
= GdipMeasureString(graphics
, teststring3
, -1, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3281 expect(7, codepointsfitted
);
3282 expect(2, linesfilled
);
3284 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3286 expectf(0.0, char_bounds
.X
);
3287 expectf(0.0, char_bounds
.Y
);
3288 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3289 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3290 expect(1, codepointsfitted
);
3291 expect(1, linesfilled
);
3293 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3295 expectf(0.0, bounds
.X
);
3296 expectf(0.0, bounds
.Y
);
3297 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3298 expectf(char_bounds
.Height
, bounds
.Height
);
3299 expect(2, codepointsfitted
);
3300 expect(1, linesfilled
);
3301 char_width
= bounds
.Width
- char_bounds
.Width
;
3303 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3305 expectf(0.0, bounds
.X
);
3306 expectf(0.0, bounds
.Y
);
3307 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3308 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3309 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3310 expect(6, codepointsfitted
);
3311 expect(2, linesfilled
);
3312 char_height
= bounds
.Height
- char_bounds
.Height
;
3314 /* Measure the first line. */
3315 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3317 expectf(0.0, bounds
.X
);
3318 expectf(0.0, bounds
.Y
);
3319 expect(4, codepointsfitted
);
3320 expect(1, linesfilled
);
3322 /* Give just enough space to fit the first line. */
3323 rc
.Width
= bounds
.Width
;
3324 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3326 expectf(0.0, bounds
.X
);
3327 expectf(0.0, bounds
.Y
);
3328 todo_wine
expect(5, codepointsfitted
);
3329 todo_wine
expect(1, linesfilled
);
3331 /* Cut off everything after the first space. */
3332 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3334 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3336 expectf(0.0, bounds
.X
);
3337 expectf(0.0, bounds
.Y
);
3338 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3339 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3340 expect(6, codepointsfitted
);
3341 expect(3, linesfilled
);
3343 /* Cut off everything including the first space. */
3344 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3346 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3348 expectf(0.0, bounds
.X
);
3349 expectf(0.0, bounds
.Y
);
3350 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3351 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3352 expect(6, codepointsfitted
);
3353 expect(3, linesfilled
);
3355 /* Cut off everything after the first character. */
3356 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3358 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3360 expectf(0.0, bounds
.X
);
3361 expectf(0.0, bounds
.Y
);
3362 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3363 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3364 expect(6, codepointsfitted
);
3365 todo_wine
expect(4, linesfilled
);
3367 for (i
= 0; i
< 4; i
++)
3368 regions
[i
] = (GpRegion
*)0xdeadbeef;
3370 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3373 for (i
= 0; i
< 4; i
++)
3374 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3376 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3379 for (i
= 0; i
< 4; i
++)
3380 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3382 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3385 set_rect_empty(&rc
);
3389 status
= GdipCreateRegion(®ions
[i
]);
3391 status
= GdipSetEmpty(regions
[i
]);
3395 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3396 expect(InvalidParameter
, status
);
3398 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3399 expect(InvalidParameter
, status
);
3401 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3402 expect(InvalidParameter
, status
);
3404 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3405 expect(InvalidParameter
, status
);
3409 /* Crashes on Windows XP */
3410 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3411 expect(InvalidParameter
, status
);
3414 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3415 expect(InvalidParameter
, status
);
3417 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3418 expect(InvalidParameter
, status
);
3420 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3423 for (i
= 0; i
< 4; i
++)
3425 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3429 ok(region_isempty
[0], "region should be empty\n");
3430 ok(region_isempty
[1], "region should be empty\n");
3431 ok(region_isempty
[2], "region should be empty\n");
3432 ok(region_isempty
[3], "region should be empty\n");
3437 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3442 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3446 ok(!region_isempty
[0], "region shouldn't be empty\n");
3447 ok(!region_isempty
[1], "region shouldn't be empty\n");
3448 ok(!region_isempty
[2], "region shouldn't be empty\n");
3449 ok(region_isempty
[3], "region should be empty\n");
3451 /* Cut off everything after the first space, and the second line. */
3452 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3453 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3455 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3460 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3464 ok(!region_isempty
[0], "region shouldn't be empty\n");
3465 ok(!region_isempty
[1], "region shouldn't be empty\n");
3466 ok(region_isempty
[2], "region should be empty\n");
3467 ok(region_isempty
[3], "region should be empty\n");
3470 GdipDeleteRegion(regions
[i
]);
3472 status
= GdipCreateMatrix(&identity
);
3479 memset(positions
, 0, sizeof(positions
));
3480 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3481 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3483 expect(InvalidParameter
, status
);
3485 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3486 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3488 expect(InvalidParameter
, status
);
3490 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3491 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3493 expect(InvalidParameter
, status
);
3495 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3496 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3498 expect(InvalidParameter
, status
);
3500 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3501 0x100, identity
, &rc
);
3504 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3505 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3509 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3510 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3512 expect(InvalidParameter
, status
);
3518 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3519 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3524 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3525 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3526 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3528 char_width
= rc
.Width
;
3529 char_height
= rc
.Height
;
3535 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3536 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3541 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3542 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3543 expectf(char_height
, rc
.Height
);
3549 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3550 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3555 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3556 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3557 expectf(rc
.Height
, char_height
);
3559 GdipDeleteMatrix(identity
);
3560 GdipDeleteStringFormat(format
);
3561 GdipDeleteBrush(brush
);
3562 GdipDeleteFont(font
);
3563 GdipDeleteFontFamily(family
);
3564 GdipDeleteGraphics(graphics
);
3566 ReleaseDC(hwnd
, hdc
);
3569 static void test_get_set_interpolation(void)
3571 GpGraphics
*graphics
;
3572 HDC hdc
= GetDC( hwnd
);
3574 InterpolationMode mode
;
3576 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3577 status
= GdipCreateFromHDC(hdc
, &graphics
);
3579 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3581 status
= GdipGetInterpolationMode(NULL
, &mode
);
3582 expect(InvalidParameter
, status
);
3586 /* Crashes on Windows XP */
3587 status
= GdipGetInterpolationMode(graphics
, NULL
);
3588 expect(InvalidParameter
, status
);
3591 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3592 expect(InvalidParameter
, status
);
3595 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3596 expect(InvalidParameter
, status
);
3598 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3599 expect(InvalidParameter
, status
);
3601 status
= GdipGetInterpolationMode(graphics
, &mode
);
3603 expect(InterpolationModeBilinear
, mode
);
3605 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3608 status
= GdipGetInterpolationMode(graphics
, &mode
);
3610 expect(InterpolationModeNearestNeighbor
, mode
);
3612 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3615 status
= GdipGetInterpolationMode(graphics
, &mode
);
3617 expect(InterpolationModeBilinear
, mode
);
3619 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3622 status
= GdipGetInterpolationMode(graphics
, &mode
);
3624 expect(InterpolationModeBilinear
, mode
);
3626 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3629 status
= GdipGetInterpolationMode(graphics
, &mode
);
3631 expect(InterpolationModeHighQualityBicubic
, mode
);
3633 GdipDeleteGraphics(graphics
);
3635 ReleaseDC(hwnd
, hdc
);
3638 static void test_get_set_textrenderinghint(void)
3640 GpGraphics
*graphics
;
3641 HDC hdc
= GetDC( hwnd
);
3643 TextRenderingHint hint
;
3645 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3646 status
= GdipCreateFromHDC(hdc
, &graphics
);
3648 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3650 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3651 expect(InvalidParameter
, status
);
3653 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3654 expect(InvalidParameter
, status
);
3656 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3657 expect(InvalidParameter
, status
);
3660 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3661 expect(InvalidParameter
, status
);
3663 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3665 expect(TextRenderingHintSystemDefault
, hint
);
3667 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3670 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3672 expect(TextRenderingHintSystemDefault
, hint
);
3674 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3677 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3679 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3681 GdipDeleteGraphics(graphics
);
3683 ReleaseDC(hwnd
, hdc
);
3686 static void test_getdc_scaled(void)
3689 GpGraphics
*graphics
= NULL
;
3690 GpBitmap
*bitmap
= NULL
;
3692 HBRUSH hbrush
, holdbrush
;
3695 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3698 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3701 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3704 status
= GdipGetDC(graphics
, &hdc
);
3706 ok(hdc
!= NULL
, "got NULL hdc\n");
3708 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3710 holdbrush
= SelectObject(hdc
, hbrush
);
3712 Rectangle(hdc
, 2, 2, 6, 6);
3714 SelectObject(hdc
, holdbrush
);
3716 DeleteObject(hbrush
);
3718 status
= GdipReleaseDC(graphics
, hdc
);
3721 GdipDeleteGraphics(graphics
);
3723 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3725 expect(0xffff0000, color
);
3727 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3729 expect(0xff000000, color
);
3731 GdipDisposeImage((GpImage
*)bitmap
);
3734 static void test_GdipMeasureString(void)
3736 static const struct test_data
3738 REAL res_x
, res_y
, page_scale
;
3742 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3743 { 200.0, 200.0, 2.0, UnitPixel
},
3744 { 200.0, 200.0, 1.0, UnitDisplay
},
3745 { 200.0, 200.0, 2.0, UnitDisplay
},
3746 { 200.0, 200.0, 1.0, UnitInch
},
3747 { 200.0, 200.0, 2.0, UnitInch
},
3748 { 200.0, 600.0, 1.0, UnitPoint
},
3749 { 200.0, 600.0, 2.0, UnitPoint
},
3750 { 200.0, 600.0, 1.0, UnitDocument
},
3751 { 200.0, 600.0, 2.0, UnitDocument
},
3752 { 200.0, 600.0, 1.0, UnitMillimeter
},
3753 { 200.0, 600.0, 2.0, UnitMillimeter
},
3754 { 200.0, 600.0, 1.0, UnitDisplay
},
3755 { 200.0, 600.0, 2.0, UnitDisplay
},
3756 { 200.0, 600.0, 1.0, UnitPixel
},
3757 { 200.0, 600.0, 2.0, UnitPixel
},
3759 static const WCHAR string
[] = L
"1234567";
3761 GpGraphics
*graphics
;
3762 GpFontFamily
*family
;
3764 GpStringFormat
*format
;
3766 REAL base_cx
= 0, base_cy
= 0, height
;
3771 GpUnit font_unit
, unit
;
3773 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3775 status
= GdipCreateFontFamilyFromName(L
"Tahoma", NULL
, &family
);
3778 /* font size in pixels */
3779 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3781 status
= GdipGetFontSize(font
, &font_size
);
3783 expectf(100.0, font_size
);
3784 status
= GdipGetFontUnit(font
, &font_unit
);
3786 expect(UnitPixel
, font_unit
);
3788 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3792 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3794 lf
.lfHeight
= 0xdeadbeef;
3795 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3797 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3798 if (td
[i
].unit
!= UnitDisplay
)
3799 height
*= td
[i
].page_scale
;
3800 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %ld (%f), got %ld\n",
3801 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3803 height
= font_size
+ 2.0 * font_size
/ 6.0;
3805 set_rect_empty(&rc
);
3806 set_rect_empty(&bounds
);
3807 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3812 base_cx
= bounds
.Width
;
3813 base_cy
= bounds
.Height
;
3816 expectf(0.0, bounds
.X
);
3817 expectf(0.0, bounds
.Y
);
3819 expectf_(height
, bounds
.Height
, height
/ 100.0);
3820 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3824 /* make sure it really fits */
3825 bounds
.Width
+= 1.0;
3826 bounds
.Height
+= 1.0;
3830 set_rect_empty(&bounds
);
3831 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3833 expectf(50.0, bounds
.X
);
3834 expectf(50.0, bounds
.Y
);
3836 expectf_(height
, bounds
.Height
, height
/ 100.0);
3837 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3841 status
= GdipDeleteGraphics(graphics
);
3844 status
= GdipDisposeImage(image
);
3848 GdipDeleteFont(font
);
3850 /* font size in logical units */
3851 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3852 for (unit
= 3; unit
<= 6; unit
++)
3854 /* create a font which final height is 100.0 pixels with 200 dpi device */
3855 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3856 height
= pixels_to_units(75.0, unit
, 200.0);
3857 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3859 status
= GdipGetFontSize(font
, &font_size
);
3861 expectf(height
, font_size
);
3862 status
= GdipGetFontUnit(font
, &font_unit
);
3864 expect(unit
, font_unit
);
3866 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3871 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3873 lf
.lfHeight
= 0xdeadbeef;
3874 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3876 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3877 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3879 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3880 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3881 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %ld (%f), got %ld\n",
3882 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3884 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3885 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3887 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3888 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3889 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3890 if (td
[i
].unit
!= UnitDisplay
)
3891 height
/= td
[i
].page_scale
;
3892 /*trace("%u: %.1f font units = %f units with %.1f dpi, page_scale %.1f\n", i, font_size, height, td[i].res_y, td[i].page_scale);*/
3894 set_rect_empty(&rc
);
3895 set_rect_empty(&bounds
);
3896 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3901 base_cx
= bounds
.Width
;
3902 base_cy
= bounds
.Height
;
3905 expectf(0.0, bounds
.X
);
3906 expectf(0.0, bounds
.Y
);
3908 expectf_(height
, bounds
.Height
, height
/ 85.0);
3909 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3913 /* make sure it really fits */
3914 bounds
.Width
+= 1.0;
3915 bounds
.Height
+= 1.0;
3919 set_rect_empty(&bounds
);
3920 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3922 expectf(50.0, bounds
.X
);
3923 expectf(50.0, bounds
.Y
);
3925 expectf_(height
, bounds
.Height
, height
/ 85.0);
3926 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3930 /* verify the result */
3931 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3932 if (td
[i
].unit
!= UnitDisplay
)
3933 height
*= td
[i
].page_scale
;
3934 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3935 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3937 expectf_(100.0, height
, 1.1);
3939 status
= GdipDeleteGraphics(graphics
);
3942 status
= GdipDisposeImage(image
);
3946 GdipDeleteFont(font
);
3949 /* Font with units = UnitWorld */
3950 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3952 GpPointF pt
= {0.0, 100.0};
3954 REAL expected_width
, expected_height
;
3956 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3958 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3961 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3964 status
= GdipGetFontUnit(font
, &font_unit
);
3966 expect(UnitWorld
, font_unit
);
3968 lf
.lfHeight
= 0xdeadbeef;
3969 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3971 ok(lf
.lfHeight
== -100, "%u: expected -100, got %ld\n", i
, lf
.lfHeight
);
3973 set_rect_empty(&rc
);
3974 set_rect_empty(&bounds
);
3975 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3980 base_cx
= bounds
.Width
;
3981 base_cy
= bounds
.Height
;
3987 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3990 /* height is constant in device space, width is proportional to height in world space */
3991 expected_width
= base_cx
* pt
.Y
;
3992 expected_height
= base_cy
* pt
.Y
;
3994 todo_wine_if(td
[i
].unit
!= UnitDisplay
&& td
[i
].unit
!= UnitPixel
)
3995 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3996 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3998 GdipDeleteGraphics(graphics
);
3999 GdipDisposeImage(image
);
4000 GdipDeleteFont(font
);
4003 GdipDeleteFontFamily(family
);
4004 GdipDeleteStringFormat(format
);
4007 static void test_transform(void)
4009 static const struct test_data
4011 REAL res_x
, res_y
, scale
;
4013 GpPointF in
[2], out
[2];
4016 { 96.0, 96.0, 1.0, UnitPixel
,
4017 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4018 { 96.0, 96.0, 1.0, UnitDisplay
,
4019 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4020 { 96.0, 96.0, 1.0, UnitInch
,
4021 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
4022 { 123.0, 456.0, 1.0, UnitPoint
,
4023 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
4024 { 123.0, 456.0, 1.0, UnitDocument
,
4025 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
4026 { 123.0, 456.0, 2.0, UnitMillimeter
,
4027 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
4028 { 196.0, 296.0, 1.0, UnitDisplay
,
4029 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4030 { 196.0, 296.0, 1.0, UnitPixel
,
4031 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4034 GpGraphics
*graphics
;
4039 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
4041 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
4042 ptf
[0].X
= td
[i
].in
[0].X
;
4043 ptf
[0].Y
= td
[i
].in
[0].Y
;
4044 ptf
[1].X
= td
[i
].in
[1].X
;
4045 ptf
[1].Y
= td
[i
].in
[1].Y
;
4046 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
4048 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
4049 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
4050 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
4051 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
4052 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4054 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
4055 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
4056 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
4057 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
4058 status
= GdipDeleteGraphics(graphics
);
4060 status
= GdipDisposeImage(image
);
4065 static void test_set_page_transform(void)
4080 {UnitMillimeter
+ 1, TRUE
},
4082 static const struct {
4094 GpGraphics
*graphics
;
4095 HDC hdc
= GetDC( hwnd
);
4100 status
= GdipCreateFromHDC(hdc
, &graphics
);
4103 for (i
= 0; i
< ARRAY_SIZE(td_unit
); i
++)
4105 winetest_push_context("%u", i
);
4106 status
= GdipSetPageUnit(graphics
, td_unit
[i
].unit
);
4107 todo_wine_if(td_unit
[i
].unit
> UnitMillimeter
)
4108 expect(td_unit
[i
].isInvalid
? InvalidParameter
: Ok
, status
);
4111 status
= GdipGetPageUnit(graphics
, &unit
);
4113 expect(td_unit
[i
].unit
, unit
);
4115 winetest_pop_context();
4118 for (i
= 0; i
< ARRAY_SIZE(td_scale
); i
++)
4120 winetest_push_context("%u", i
);
4121 status
= GdipSetPageScale(graphics
, td_scale
[i
].scale
);
4122 expect(td_scale
[i
].isInvalid
? InvalidParameter
: Ok
, status
);
4125 status
= GdipGetPageScale(graphics
, &scale
);
4127 expectf_(td_scale
[i
].scale
, scale
, 0);
4129 winetest_pop_context();
4132 status
= GdipGetPageUnit(graphics
, &unit
);
4135 expect(UnitMillimeter
, unit
);
4136 status
= GdipGetPageScale(graphics
, &scale
);
4138 expectf_(2.0, scale
, 0);
4139 status
= GdipResetPageTransform(graphics
);
4141 status
= GdipGetPageUnit(graphics
, &unit
);
4143 expect(UnitDisplay
, unit
);
4144 status
= GdipGetPageScale(graphics
, &scale
);
4146 expectf_(1.0, scale
, 0);
4148 GdipDeleteGraphics(graphics
);
4149 ReleaseDC(hwnd
, hdc
);
4152 static void test_pen_thickness(void)
4154 static const struct test_data
4156 REAL res_x
, res_y
, scale
;
4157 GpUnit pen_unit
, page_unit
;
4159 INT cx
, cy
, path_cx
, path_cy
;
4162 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1, 1, 1 },
4163 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.0, 0, 0, 1, 1 },
4164 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.1, 1, 1, 1, 1 },
4165 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2, 2, 2 },
4166 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1, 1, 1 },
4167 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1, 1, 1 },
4168 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 0.0, 1, 1, 1, 1 },
4169 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6, 6, 6 },
4170 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20, 20, 20 },
4174 GpGraphics
*graphics
;
4186 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
4188 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
4191 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
4194 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
4197 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
4200 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
4203 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
4206 corner
.X
= corner
.Y
= 100.0;
4207 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
4210 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4213 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4216 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4222 for (j
=0; j
<100; j
++)
4224 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4231 for (j
=99; j
>=0; j
--)
4233 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4242 ok(size
== td
[i
].cx
|| broken (i
== 1 && size
== 1), "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
4247 for (j
=0; j
<100; j
++)
4249 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4256 for (j
=99; j
>=0; j
--)
4258 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4267 ok(size
== td
[i
].cy
|| broken (i
== 1 && size
== 1), "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
4269 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4272 status
= GdipGraphicsClear(graphics
, 0xff000000);
4275 status
= GdipCreatePath(FillModeAlternate
, &path
);
4278 status
= GdipAddPathLine(path
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4281 status
= GdipClosePathFigure(path
);
4284 status
= GdipAddPathLine(path
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4287 status
= GdipDrawPath(graphics
, pen
, path
);
4290 GdipDeletePath(path
);
4292 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4298 for (j
=0; j
<100; j
++)
4300 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4307 for (j
=99; j
>=0; j
--)
4309 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4318 ok(size
== td
[i
].path_cx
, "%u: expected %d, got %d\n", i
, td
[i
].path_cx
, size
);
4323 for (j
=0; j
<100; j
++)
4325 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4332 for (j
=99; j
>=0; j
--)
4334 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4343 ok(size
== td
[i
].path_cy
, "%u: expected %d, got %d\n", i
, td
[i
].path_cy
, size
);
4345 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4349 GdipDeleteGraphics(graphics
);
4350 GdipDisposeImage(u
.image
);
4354 /* Many people on the net ask why there is so much difference in rendered
4355 * text height between gdiplus and gdi32, this test suggests an answer to
4356 * that question. Important: this test assumes that font dpi == device dpi.
4358 static void test_font_height_scaling(void)
4360 static const WCHAR string
[] = L
"1234567";
4362 GpStringFormat
*format
;
4363 CharacterRange range
= { 0, 7 };
4365 GpGraphics
*graphics
;
4366 GpFontFamily
*family
;
4370 REAL height
, dpi
, scale
;
4372 GpUnit gfx_unit
, font_unit
;
4374 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4376 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4378 status
= GdipCreateRegion(®ion
);
4381 status
= GdipCreateFontFamilyFromName(L
"Tahoma", NULL
, &family
);
4384 hdc
= CreateCompatibleDC(0);
4385 status
= GdipCreateFromHDC(hdc
, &graphics
);
4388 status
= GdipGetDpiY(graphics
, &dpi
);
4391 /* First check if tested functionality works:
4392 * under XP if font and graphics units differ then GdipTransformPoints
4393 * followed by GdipSetPageUnit to change the graphics units breaks region
4394 * scaling in GdipMeasureCharacterRanges called later.
4396 status
= GdipSetPageUnit(graphics
, UnitDocument
);
4401 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4404 status
= GdipSetPageUnit(graphics
, UnitInch
);
4407 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
4410 set_rect_empty(&rect
);
4411 set_rect_empty(&bounds
);
4412 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4414 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4416 set_rect_empty(&rect
);
4417 rect
.Width
= 32000.0;
4418 rect
.Height
= 32000.0;
4419 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4422 set_rect_empty(&rect
);
4423 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4425 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4427 GdipDeleteFont(font
);
4429 scale
= rect
.Height
/ bounds
.Height
;
4430 if (fabs(scale
- 1.0) > 0.1)
4432 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4436 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4439 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4440 /* UnitPixel as a font base unit is not tested because it drastically
4441 differs in behaviour */
4442 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4444 /* create a font for the final text height of 100 pixels */
4445 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4446 status
= GdipSetPageUnit(graphics
, font_unit
);
4450 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4453 /*trace("height %f units\n", height);*/
4454 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4457 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4458 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4460 RectF bounds_1
, bounds_2
;
4461 REAL margin
, margin_y
, font_height
;
4464 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4467 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4468 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4470 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4473 set_rect_empty(&rect
);
4474 set_rect_empty(&bounds
);
4475 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4477 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4479 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4482 ptf
.Y
= bounds
.Height
;
4483 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4485 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4487 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4489 /* verify the result */
4490 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4492 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4494 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4496 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4497 set_rect_empty(&rect
);
4498 set_rect_empty(&bounds_1
);
4499 status
= GdipMeasureString(graphics
, L
"W", 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4501 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4502 set_rect_empty(&rect
);
4503 set_rect_empty(&bounds_2
);
4504 status
= GdipMeasureString(graphics
, L
"WW", 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4507 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4508 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4509 /*trace("margin %f\n", margin);*/
4510 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4512 set_rect_empty(&rect
);
4513 rect
.Width
= 320000.0;
4514 rect
.Height
= 320000.0;
4515 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4517 set_rect_empty(&rect
);
4518 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4520 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4521 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4522 expectf(0.0, rect
.Y
);
4523 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4524 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4525 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4526 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4527 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4528 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4531 GdipDeleteFont(font
);
4535 status
= GdipDeleteGraphics(graphics
);
4539 GdipDeleteFontFamily(family
);
4540 GdipDeleteRegion(region
);
4541 GdipDeleteStringFormat(format
);
4544 static void test_measure_string(void)
4546 static const WCHAR string
[] = L
"A01";
4547 static const WCHAR string2
[] = L
"M MM";
4549 GpStringFormat
*format
, *format_no_wrap
;
4550 CharacterRange range
;
4552 GpGraphics
*graphics
;
4553 GpFontFamily
*family
;
4557 REAL width
, height
, width_1
, width_2
, width_MM
, width_M_M
;
4558 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4561 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4565 status
= GdipCreateRegion(®ion
);
4568 status
= GdipCreateFontFamilyFromName(L
"Tahoma", NULL
, &family
);
4571 hdc
= CreateCompatibleDC(0);
4572 status
= GdipCreateFromHDC(hdc
, &graphics
);
4574 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4577 margin_x
= 20.0 / 6.0;
4578 margin_y
= 20.0 / 8.0;
4580 set_rect_empty(&rect
);
4581 set_rect_empty(&bounds
);
4582 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4586 expectf(0.0, bounds
.X
);
4587 expectf(0.0, bounds
.Y
);
4588 width
= bounds
.Width
;
4589 height
= bounds
.Height
;
4591 set_rect_empty(&rect
);
4592 rect
.Height
= height
/ 2.0;
4593 set_rect_empty(&bounds
);
4594 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4598 expectf(0.0, bounds
.X
);
4599 expectf(0.0, bounds
.Y
);
4600 expectf(width
, bounds
.Width
);
4602 expectf(height
/ 2.0, bounds
.Height
);
4605 range
.Length
= lstrlenW(string
);
4606 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4611 rect
.Width
= 32000.0;
4612 rect
.Height
= 32000.0;
4613 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4615 set_rect_empty(&bounds
);
4616 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4618 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4619 expectf(5.0, bounds
.Y
);
4620 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4622 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4624 width_rgn
= bounds
.Width
;
4625 height_rgn
= bounds
.Height
;
4629 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4632 set_rect_empty(&rect
);
4633 rect
.Width
= 32000.0;
4634 rect
.Height
= 32000.0;
4635 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4637 set_rect_empty(&bounds
);
4638 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4640 expectf_(margin_x
, bounds
.X
, 1.0);
4641 expectf(0.0, bounds
.Y
);
4642 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4643 expectf(height_rgn
, bounds
.Height
);
4644 width_1
= bounds
.Width
;
4647 range
.Length
= lstrlenW(string
);
4648 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4655 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4657 set_rect_empty(&bounds
);
4658 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4660 expectf(0.0, bounds
.X
);
4661 expectf(0.0, bounds
.Y
);
4662 expectf(0.0, bounds
.Width
);
4663 expectf(0.0, bounds
.Height
);
4667 rect
.Width
= width_rgn
/ 2.0;
4668 rect
.Height
= 32000.0;
4669 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4671 set_rect_empty(&bounds
);
4672 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4674 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4675 expectf(5.0, bounds
.Y
);
4676 expectf_(width_1
, bounds
.Width
, 1.0);
4678 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4680 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4686 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4688 set_rect_empty(&bounds
);
4689 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4691 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4692 expectf(5.0, bounds
.Y
);
4693 expectf(width_rgn
, bounds
.Width
);
4694 expectf(height_rgn
, bounds
.Height
);
4698 rect
.Width
= width_rgn
/ 2.0;
4699 rect
.Height
= 32000.0;
4700 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4702 set_rect_empty(&bounds
);
4703 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4705 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4706 expectf(5.0, bounds
.Y
);
4707 expectf_(width_1
, bounds
.Width
, 1.0);
4708 expectf(height_rgn
, bounds
.Height
);
4710 set_rect_empty(&rect
);
4711 rect
.Height
= height
/ 2.0;
4712 set_rect_empty(&bounds
);
4713 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4717 expectf(0.0, bounds
.X
);
4718 expectf(0.0, bounds
.Y
);
4719 expectf_(width
, bounds
.Width
, 0.01);
4721 expectf(height
, bounds
.Height
);
4723 set_rect_empty(&rect
);
4724 set_rect_empty(&bounds
);
4725 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4729 expectf(0.0, bounds
.X
);
4730 expectf(0.0, bounds
.Y
);
4731 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4732 expectf(height
, bounds
.Height
);
4733 width_1
= bounds
.Width
;
4735 set_rect_empty(&rect
);
4736 set_rect_empty(&bounds
);
4737 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4741 expectf(0.0, bounds
.X
);
4742 expectf(0.0, bounds
.Y
);
4743 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4744 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4745 expectf(height
, bounds
.Height
);
4746 width_2
= bounds
.Width
;
4748 set_rect_empty(&rect
);
4749 rect
.Width
= width
/ 2.0;
4750 set_rect_empty(&bounds
);
4751 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4755 expectf(0.0, bounds
.X
);
4756 expectf(0.0, bounds
.Y
);
4757 expectf_(width_1
, bounds
.Width
, 0.01);
4758 expectf(height
, bounds
.Height
);
4760 set_rect_empty(&rect
);
4761 rect
.Height
= height
;
4762 rect
.Width
= width
- 0.05;
4763 set_rect_empty(&bounds
);
4764 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4768 expectf(0.0, bounds
.X
);
4769 expectf(0.0, bounds
.Y
);
4770 expectf_(width_2
, bounds
.Width
, 0.01);
4771 expectf(height
, bounds
.Height
);
4773 set_rect_empty(&rect
);
4774 rect
.Height
= height
;
4775 rect
.Width
= width_2
- 0.05;
4776 set_rect_empty(&bounds
);
4777 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4781 expectf(0.0, bounds
.X
);
4782 expectf(0.0, bounds
.Y
);
4783 expectf_(width_1
, bounds
.Width
, 0.01);
4784 expectf(height
, bounds
.Height
);
4786 /* Default (Near) alignment */
4789 rect
.Width
= width
* 2.0;
4790 rect
.Height
= height
* 2.0;
4791 set_rect_empty(&bounds
);
4792 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4796 expectf(5.0, bounds
.X
);
4797 expectf(5.0, bounds
.Y
);
4798 expectf_(width
, bounds
.Width
, 0.01);
4799 expectf(height
, bounds
.Height
);
4803 rect
.Width
= 32000.0;
4804 rect
.Height
= 32000.0;
4805 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4807 set_rect_empty(&bounds
);
4808 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4810 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4811 expectf(5.0, bounds
.Y
);
4812 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4814 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4816 width_rgn
= bounds
.Width
;
4817 height_rgn
= bounds
.Height
;
4819 /* Center alignment */
4820 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4821 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4825 rect
.Width
= width
* 2.0;
4826 rect
.Height
= height
* 2.0;
4827 set_rect_empty(&bounds
);
4828 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4833 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4835 expectf(5.0 + height
/2.0, bounds
.Y
);
4836 expectf_(width
, bounds
.Width
, 0.01);
4837 expectf(height
, bounds
.Height
);
4843 set_rect_empty(&bounds
);
4844 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4849 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4851 expectf(5.0 - height
/2.0, bounds
.Y
);
4852 expectf_(width
, bounds
.Width
, 0.01);
4853 expectf(height
, bounds
.Height
);
4857 rect
.Width
= width_rgn
* 2.0;
4858 rect
.Height
= height_rgn
* 2.0;
4859 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4861 set_rect_empty(&bounds
);
4862 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4865 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4867 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4868 expectf_(width_rgn
, bounds
.Width
, 1.0);
4869 expectf_(height_rgn
, bounds
.Height
, 1.0);
4875 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4877 set_rect_empty(&bounds
);
4878 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4881 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4883 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4884 expectf_(width_rgn
, bounds
.Width
, 1.0);
4885 expectf_(height_rgn
, bounds
.Height
, 1.0);
4888 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4889 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4893 rect
.Width
= width
* 2.0;
4894 rect
.Height
= height
* 2.0;
4895 set_rect_empty(&bounds
);
4896 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4901 expectf_(5.0 + width
, bounds
.X
, 0.01);
4903 expectf(5.0 + height
, bounds
.Y
);
4904 expectf_(width
, bounds
.Width
, 0.01);
4905 expectf(height
, bounds
.Height
);
4911 set_rect_empty(&bounds
);
4912 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4917 expectf_(5.0 - width
, bounds
.X
, 0.01);
4919 expectf(5.0 - height
, bounds
.Y
);
4920 expectf_(width
, bounds
.Width
, 0.01);
4921 expectf(height
, bounds
.Height
);
4925 rect
.Width
= width_rgn
* 2.0;
4926 rect
.Height
= height_rgn
* 2.0;
4927 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4929 set_rect_empty(&bounds
);
4930 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4933 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4935 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4936 expectf_(width_rgn
, bounds
.Width
, 1.0);
4937 expectf_(height_rgn
, bounds
.Height
, 1.0);
4943 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4945 set_rect_empty(&bounds
);
4946 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4949 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4951 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4952 expectf_(width_rgn
, bounds
.Width
, 1.0);
4953 expectf_(height_rgn
, bounds
.Height
, 1.0);
4958 rect
.Width
= 32000.0;
4959 rect
.Height
= 32000.0;
4960 status
= GdipMeasureString(graphics
, string2
+ 2, 2, font
, &rect
, NULL
, &bounds
, &glyphs
, &lines
);
4964 width_MM
= bounds
.Width
;
4969 rect
.Width
= 32000.0;
4970 rect
.Height
= 32000.0;
4971 status
= GdipMeasureString(graphics
, string2
, 3, font
, &rect
, NULL
, &bounds
, &glyphs
, &lines
);
4975 width_M_M
= bounds
.Width
;
4980 rect
.Width
= width_M_M
;
4981 rect
.Height
= 32000.0;
4982 status
= GdipMeasureString(graphics
, string2
, -1, font
, &rect
, NULL
, &bounds
, &glyphs
, &lines
);
4984 expectf_(width_MM
, bounds
.Width
, 0.1);
4989 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format_no_wrap
);
4994 rect
.Width
= width_M_M
;
4995 rect
.Height
= 32000.0;
4996 status
= GdipMeasureString(graphics
, string2
, -1, font
, &rect
, format_no_wrap
, &bounds
, &glyphs
, &lines
);
4998 expectf_(width_M_M
, bounds
.Width
, 0.1);
5002 status
= GdipDeleteFont(font
);
5005 status
= GdipDeleteGraphics(graphics
);
5009 GdipDeleteFontFamily(family
);
5010 GdipDeleteRegion(region
);
5011 GdipDeleteStringFormat(format
);
5012 GdipDeleteStringFormat(format_no_wrap
);
5015 static void test_measured_extra_space(void)
5017 GpStringFormat
*format
;
5019 GpGraphics
*graphics
;
5020 GpFontFamily
*family
;
5023 GpUnit gfx_unit
, font_unit
;
5024 RectF bounds_1
, bounds_2
, rect
;
5025 REAL margin
, font_size
, dpi
;
5027 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
5030 status
= GdipCreateFontFamilyFromName(L
"Tahoma", NULL
, &family
);
5032 hdc
= CreateCompatibleDC(0);
5033 status
= GdipCreateFromHDC(hdc
, &graphics
);
5036 status
= GdipGetDpiX(graphics
, &dpi
);
5039 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
5040 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
5041 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
5043 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
5046 status
= GdipGetFontSize(font
, &font_size
);
5048 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
5049 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
5051 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
5052 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
5054 status
= GdipSetPageUnit(graphics
, gfx_unit
);
5057 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
5058 set_rect_empty(&rect
);
5059 set_rect_empty(&bounds_1
);
5060 status
= GdipMeasureString(graphics
, L
"W", 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
5062 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
5063 set_rect_empty(&rect
);
5064 set_rect_empty(&bounds_2
);
5065 status
= GdipMeasureString(graphics
, L
"WW", 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
5068 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
5069 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
5070 /*trace("margin %f pixels\n", margin);*/
5071 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
5074 GdipDeleteFont(font
);
5077 GdipDeleteGraphics(graphics
);
5079 GdipDeleteFontFamily(family
);
5080 GdipDeleteStringFormat(format
);
5083 static void test_alpha_hdc(void)
5087 HBITMAP hbm
, old_hbm
;
5088 GpGraphics
*graphics
;
5094 hdc
= CreateCompatibleDC(0);
5095 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
5096 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
5097 bmi
.bmiHeader
.biHeight
= 5;
5098 bmi
.bmiHeader
.biWidth
= 5;
5099 bmi
.bmiHeader
.biBitCount
= 32;
5100 bmi
.bmiHeader
.biPlanes
= 1;
5101 bmi
.bmiHeader
.biCompression
= BI_RGB
;
5102 bmi
.bmiHeader
.biClrUsed
= 0;
5104 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
5105 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
5107 old_hbm
= SelectObject(hdc
, hbm
);
5109 status
= GdipCreateFromHDC(hdc
, &graphics
);
5112 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
5114 expectf(0.0, bounds
.X
);
5115 expectf(0.0, bounds
.Y
);
5116 expectf(5.0, bounds
.Width
);
5117 expectf(5.0, bounds
.Height
);
5119 bits
[0] = 0xdeadbeef;
5121 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
5124 expect(0xffaaaaaa, bits
[0]);
5126 bits
[0] = 0xdeadbeef;
5128 status
= GdipGetDC(graphics
, &gp_hdc
);
5131 colorref
= GetPixel(gp_hdc
, 0, 4);
5132 expect(0xefbead, colorref
);
5134 SetPixel(gp_hdc
, 0, 4, 0xffffff);
5136 expect(0xffffff, bits
[0]);
5138 status
= GdipReleaseDC(graphics
, gp_hdc
);
5141 SelectObject(hdc
, old_hbm
);
5143 bits
[0] = 0xdeadbeef;
5145 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
5148 todo_wine
expect(0xffbbbbbb, bits
[0]);
5150 GdipDeleteGraphics(graphics
);
5156 static void test_bitmapfromgraphics(void)
5159 GpGraphics
*graphics
= NULL
;
5160 HDC hdc
= GetDC( hwnd
);
5161 GpBitmap
*bitmap
= NULL
;
5163 REAL imageres
, graphicsres
;
5166 stat
= GdipCreateFromHDC(hdc
, &graphics
);
5169 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
5170 expect(InvalidParameter
, stat
);
5172 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
5173 expect(InvalidParameter
, stat
);
5175 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
5178 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
5180 expect(PixelFormat32bppPARGB
, format
);
5182 stat
= GdipGetDpiX(graphics
, &graphicsres
);
5185 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
5187 expectf(graphicsres
, imageres
);
5189 stat
= GdipGetDpiY(graphics
, &graphicsres
);
5192 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
5194 expectf(graphicsres
, imageres
);
5196 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
5200 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
5204 GdipDeleteGraphics(graphics
);
5205 GdipDisposeImage((GpImage
*)bitmap
);
5208 static void test_clipping(void)
5212 GpGraphics
*graphics
;
5213 GpRegion
*region
, *region100x100
;
5223 hdc
= CreateCompatibleDC(0);
5224 status
= GdipCreateFromHDC(hdc
, &graphics
);
5227 status
= GdipGetPageUnit(graphics
, &unit
);
5229 expect(UnitDisplay
, unit
);
5231 status
= GdipCreateRegion(®ion
);
5233 status
= GdipSetEmpty(region
);
5236 status
= GdipCreateRegion(®ion100x100
);
5238 status
= GdipSetEmpty(region100x100
);
5241 rect
.X
= rect
.Y
= 100.0;
5242 rect
.Width
= rect
.Height
= 100.0;
5243 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
5245 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
5248 status
= GdipGetClipBounds(graphics
, &rect
);
5250 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5251 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5253 status
= GdipGetClipBoundsI(graphics
, &recti
);
5255 ok(recti
.X
== 100 && recti
.Y
== 100 && recti
.Width
== 100 && recti
.Height
== 100,
5256 "expected 100,100-100,100, got %i,%i-%i,%i\n", recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
);
5258 /* Clip region does not account for changes to gdi32 transform */
5259 SetViewportOrgEx(hdc
, 10, 10, NULL
);
5261 status
= GdipGetClipBounds(graphics
, &rect
);
5263 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5264 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5266 SetViewportOrgEx(hdc
, 0, 0, NULL
);
5268 status
= GdipSetEmpty(region
);
5270 status
= GdipGetClip(graphics
, region
);
5272 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5274 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5275 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5281 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5283 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5284 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5286 status
= GdipCreateMatrix(&matrix
);
5288 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
5290 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
5292 status
= GdipSetWorldTransform(graphics
, matrix
);
5295 status
= GdipGetClipBounds(graphics
, &rect
);
5297 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5298 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5300 status
= GdipGetClipBoundsI(graphics
, &recti
);
5302 ok(recti
.X
== 45 && recti
.Y
== 20 && recti
.Width
== 50 && recti
.Height
== 25,
5303 "expected 45,20-50,25, got %i,%i-%i,%i\n", recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
);
5305 status
= GdipSetEmpty(region
);
5307 status
= GdipGetClip(graphics
, region
);
5309 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5311 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5312 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5314 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5316 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5317 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5319 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5321 ret
= GetRgnBox(hrgn
, &rc
);
5322 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5323 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5324 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5327 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5329 ret
= GetRgnBox(hrgn
, &rc
);
5330 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5331 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5332 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5339 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5341 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5342 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5344 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5346 ret
= GetRgnBox(hrgn
, &rc
);
5347 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5348 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5349 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5352 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5354 ret
= GetRgnBox(hrgn
, &rc
);
5355 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5356 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5357 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5364 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5366 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5367 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5369 status
= GdipSetPageScale(graphics
, 2.0);
5372 status
= GdipGetClipBounds(graphics
, &rect
);
5374 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5375 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5377 status
= GdipSetEmpty(region
);
5379 status
= GdipGetClip(graphics
, region
);
5381 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5383 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5384 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5386 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5388 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5389 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5391 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5393 ret
= GetRgnBox(hrgn
, &rc
);
5394 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5395 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5396 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5399 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5401 ret
= GetRgnBox(hrgn
, &rc
);
5402 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5403 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5404 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5411 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5413 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5414 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5416 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5418 ret
= GetRgnBox(hrgn
, &rc
);
5419 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5420 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5421 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5424 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5426 ret
= GetRgnBox(hrgn
, &rc
);
5427 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5428 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5429 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5436 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5438 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5439 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5441 GdipSetPageUnit(graphics
, UnitPoint
);
5444 status
= GdipGetClipBounds(graphics
, &rect
);
5446 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5447 /* rounding under Wine is slightly different */
5448 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5449 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5450 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5452 status
= GdipSetEmpty(region
);
5454 status
= GdipGetClip(graphics
, region
);
5456 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5458 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5459 /* rounding under Wine is slightly different */
5460 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5461 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5462 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5464 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5466 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5467 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5469 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5471 ret
= GetRgnBox(hrgn
, &rc
);
5472 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5473 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
5474 /* rounding under Wine is slightly different */
5475 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
5476 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
5477 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc
));
5480 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5482 ret
= GetRgnBox(hrgn
, &rc
);
5483 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5484 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5485 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5486 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5493 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5495 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5496 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5497 "expected 13.75,4.375-32.5,13.75, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5499 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5501 ret
= GetRgnBox(hrgn
, &rc
);
5502 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5503 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5504 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5507 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5509 ret
= GetRgnBox(hrgn
, &rc
);
5510 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5511 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5512 /* rounding under Wine is slightly different */
5513 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5514 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc
));
5521 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5523 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5525 expectf(100.0, ptf
[0].X
);
5526 expectf(100.0, ptf
[0].Y
);
5527 expectf(200.125, ptf
[1].X
);
5528 expectf(200.03125, ptf
[1].Y
);
5530 else /* before Win7 */
5532 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5533 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5534 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5535 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5538 status
= GdipTransformRegion(region100x100
, matrix
);
5541 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5543 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5544 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5546 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5548 ret
= GetRgnBox(hrgn
, &rc
);
5549 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5550 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5551 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5554 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5556 ret
= GetRgnBox(hrgn
, &rc
);
5557 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5558 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5559 /* rounding under Wine is slightly different */
5560 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5561 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc
));
5568 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5570 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5572 expectf(210.0625, ptf
[0].X
);
5573 expectf(420.0625, ptf
[0].Y
);
5574 expectf(410.125, ptf
[1].X
);
5575 expectf(820.0, ptf
[1].Y
);
5577 else /* before Win7 */
5579 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5580 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5581 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5582 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5585 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5587 status
= GdipSetWorldTransform(graphics
, matrix
);
5590 status
= GdipGetClipBounds(graphics
, &rect
);
5592 expectf_(20.612978, rect
.X
, 1.0);
5593 expectf_(-6.256012, rect
.Y
, 1.5);
5594 expectf_(25.612978, rect
.Width
, 1.0);
5595 expectf_(12.806489, rect
.Height
, 1.0);
5597 status
= GdipSetEmpty(region
);
5599 status
= GdipGetClip(graphics
, region
);
5601 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5603 /* rounding under Wine is slightly different */
5604 expectf_(20.612978, rect
.X
, 1.0);
5605 expectf_(-6.256012, rect
.Y
, 1.5);
5606 expectf_(25.612978, rect
.Width
, 1.0);
5607 expectf_(12.806489, rect
.Height
, 1.0);
5609 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5611 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5612 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5614 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5616 ret
= GetRgnBox(hrgn
, &rc
);
5617 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5618 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5619 /* rounding under Wine is slightly different */
5620 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5621 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc
));
5624 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5626 ret
= GetRgnBox(hrgn
, &rc
);
5627 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5628 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5629 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5640 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5642 expectf(20.612978, ptf
[0].X
);
5643 expectf(-1.568512, ptf
[0].Y
);
5644 expectf(46.225956, ptf
[1].X
);
5645 expectf(1.862977, ptf
[1].Y
);
5646 expectf(36.850956, ptf
[2].X
);
5647 expectf(-6.256012, ptf
[2].Y
);
5648 expectf(29.987980, ptf
[3].X
);
5649 expectf(6.550478, ptf
[3].Y
);
5651 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5653 ret
= GetRgnBox(hrgn
, &rc
);
5654 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5655 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5656 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5659 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5661 ret
= GetRgnBox(hrgn
, &rc
);
5662 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5663 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5664 /* rounding under Wine is slightly different */
5665 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5666 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc
));
5677 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5679 expectf(-136.190491, ptf
[0].X
);
5680 expectf(520.010742, ptf
[0].Y
);
5681 expectf(756.417175, ptf
[1].X
);
5682 expectf(720.031616, ptf
[1].Y
);
5683 expectf(360.042114, ptf
[2].X
);
5684 expectf(376.760742, ptf
[2].Y
);
5685 expectf(260.184570, ptf
[3].X
);
5686 expectf(863.281616, ptf
[3].Y
);
5688 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5690 status
= GdipSetWorldTransform(graphics
, matrix
);
5693 status
= GdipGetClipBounds(graphics
, &rect
);
5695 expectf_(-28.100956, rect
.X
, 1.0);
5696 expectf_(7.806488, rect
.Y
, 1.5);
5697 expectf_(25.612978, rect
.Width
, 1.0);
5698 expectf_(12.806489, rect
.Height
, 1.0);
5700 status
= GdipSetEmpty(region
);
5702 status
= GdipGetClip(graphics
, region
);
5704 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5706 /* rounding under Wine is slightly different */
5707 expectf_(-28.100956, rect
.X
, 1.0);
5708 expectf_(7.806488, rect
.Y
, 1.5);
5709 expectf_(25.612978, rect
.Width
, 1.0);
5710 expectf_(12.806489, rect
.Height
, 1.0);
5712 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5714 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5715 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5717 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5719 ret
= GetRgnBox(hrgn
, &rc
);
5720 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5721 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5722 /* rounding under Wine is slightly different */
5723 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5724 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc
));
5727 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5729 ret
= GetRgnBox(hrgn
, &rc
);
5730 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5731 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5732 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5743 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5745 expectf(-11.862979, ptf
[0].X
);
5746 expectf(7.806488, ptf
[0].Y
);
5747 expectf(-18.725958, ptf
[1].X
);
5748 expectf(20.612976, ptf
[1].Y
);
5749 expectf(-2.487981, ptf
[2].X
);
5750 expectf(15.925477, ptf
[2].Y
);
5751 expectf(-28.100956, ptf
[3].X
);
5752 expectf(12.493987, ptf
[3].Y
);
5754 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5756 ret
= GetRgnBox(hrgn
, &rc
);
5757 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5758 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5759 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5762 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5764 ret
= GetRgnBox(hrgn
, &rc
);
5765 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5766 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5767 /* rounding under Wine is slightly different */
5768 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5769 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc
));
5780 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5782 expectf(-1055.021484, ptf
[0].X
);
5783 expectf(-70.595329, ptf
[0].Y
);
5784 expectf(-1455.063232, ptf
[1].X
);
5785 expectf(375.708435, ptf
[1].Y
);
5786 expectf(-768.521484, ptf
[2].X
);
5787 expectf(177.520981, ptf
[2].Y
);
5788 expectf(-1741.563110, ptf
[3].X
);
5789 expectf(127.592125, ptf
[3].Y
);
5791 GdipDeleteMatrix(matrix
);
5792 GdipDeleteRegion(region
);
5793 GdipDeleteRegion(region100x100
);
5794 GdipDeleteGraphics(graphics
);
5798 static void test_clipping_2(void)
5803 GpGraphics
*graphics
;
5813 hdc
= CreateCompatibleDC(0);
5814 status
= GdipCreateFromHDC(hdc
, &graphics
);
5817 status
= GdipGetPageUnit(graphics
, &unit
);
5819 expect(UnitDisplay
, unit
);
5821 GdipSetPageUnit(graphics
, UnitInch
);
5823 status
= GdipCreateRegion(®ion
);
5825 status
= GdipSetEmpty(region
);
5827 rect
.X
= rect
.Y
= 100.0;
5828 rect
.Width
= rect
.Height
= 100.0;
5829 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5831 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5834 status
= GdipGetClip(graphics
, region
);
5836 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5838 ret
= GetRgnBox(hrgn
, &rc
);
5839 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5840 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5841 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5843 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5845 ret
= GetRgnBox(hrgn
, &rc
);
5846 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5847 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5848 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5855 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5857 expectf(100.0, ptf
[0].X
);
5858 expectf(100.0, ptf
[0].Y
);
5859 expectf(200.0, ptf
[1].X
);
5860 expectf(200.0, ptf
[1].X
);
5862 GdipSetPageUnit(graphics
, UnitPoint
);
5864 status
= GdipGetClip(graphics
, region
);
5866 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5868 ret
= GetRgnBox(hrgn
, &rc
);
5869 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5870 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5871 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5872 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc
));
5874 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5876 ret
= GetRgnBox(hrgn
, &rc
);
5877 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5878 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5879 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5880 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5887 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5889 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5890 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5891 "expected 7200.0,7200.0-14400.0,14400.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5892 else /* before Win7 */
5894 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5895 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5896 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5897 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5900 GdipDeleteRegion(region
);
5902 GdipSetPageUnit(graphics
, UnitPixel
);
5904 status
= GdipCreateRegion(®ion
);
5906 status
= GdipSetEmpty(region
);
5908 rect
.X
= rect
.Y
= 100.0;
5909 rect
.Width
= rect
.Height
= 100.0;
5910 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5912 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5915 status
= GdipGetClip(graphics
, region
);
5917 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5919 ret
= GetRgnBox(hrgn
, &rc
);
5920 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5921 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5922 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5923 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5925 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5927 ret
= GetRgnBox(hrgn
, &rc
);
5928 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5929 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5930 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5931 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5938 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5940 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5941 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5942 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5943 else /* before Win7 */
5945 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5946 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5947 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5948 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5951 GdipSetPageUnit(graphics
, UnitPoint
);
5953 status
= GdipGetClip(graphics
, region
);
5955 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5957 ret
= GetRgnBox(hrgn
, &rc
);
5958 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5959 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5960 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5961 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc
));
5963 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5965 ret
= GetRgnBox(hrgn
, &rc
);
5966 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5967 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5968 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5969 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5976 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5978 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5979 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5980 "expected 75.0,75.0-150.0,150.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5981 else /* before Win7 */
5983 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5984 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5985 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5986 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5989 status
= GdipCreateMatrix(&matrix
);
5991 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5993 status
= GdipSetWorldTransform(graphics
, matrix
);
5995 GdipDeleteMatrix(matrix
);
5997 status
= GdipGetClip(graphics
, region
);
5999 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6001 ret
= GetRgnBox(hrgn
, &rc
);
6002 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6003 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
6004 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc
));
6006 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6008 ret
= GetRgnBox(hrgn
, &rc
);
6009 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6010 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
6011 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6018 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
6020 expectf(65.0, ptf
[0].X
);
6021 expectf(65.0, ptf
[0].Y
);
6022 expectf(140.0, ptf
[1].X
);
6023 expectf(140.0, ptf
[1].X
);
6025 status
= GdipCreateMatrix(&matrix
);
6027 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
6029 status
= GdipSetWorldTransform(graphics
, matrix
);
6031 GdipDeleteMatrix(matrix
);
6033 status
= GdipGetClip(graphics
, region
);
6035 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6037 ret
= GetRgnBox(hrgn
, &rc
);
6038 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6039 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
6040 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc
));
6042 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6044 ret
= GetRgnBox(hrgn
, &rc
);
6045 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6046 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
6047 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6054 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
6056 expectf(300.0, ptf
[0].X
);
6057 expectf(150.0, ptf
[0].Y
);
6058 expectf(600.0, ptf
[1].X
);
6059 expectf(300.0, ptf
[1].Y
);
6061 status
= GdipSetPageScale(graphics
, 2.0);
6064 status
= GdipGetClip(graphics
, region
);
6066 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6068 ret
= GetRgnBox(hrgn
, &rc
);
6069 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6070 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
6071 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
6072 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc
));
6074 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6076 ret
= GetRgnBox(hrgn
, &rc
);
6077 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6078 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
6079 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
6080 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6087 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
6089 if (fabs(ptf
[0].X
- 150.0) < 0.001)
6091 expectf(150.0, ptf
[0].X
);
6092 expectf(75.0, ptf
[0].Y
);
6093 expectf(300.0, ptf
[1].X
);
6094 expectf(150.0, ptf
[1].Y
);
6096 else /* before Win7 */
6098 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
6099 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
6100 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
6101 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
6104 status
= GdipCreateMatrix(&matrix
);
6106 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
6108 status
= GdipSetWorldTransform(graphics
, matrix
);
6110 GdipDeleteMatrix(matrix
);
6112 status
= GdipGetClip(graphics
, region
);
6114 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6116 ret
= GetRgnBox(hrgn
, &rc
);
6117 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
6118 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
6119 /* rounding under Wine is slightly different */
6120 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
6121 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc
));
6123 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6125 ret
= GetRgnBox(hrgn
, &rc
);
6126 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6127 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
6128 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6139 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
6141 expectf(53.033016, ptf
[0].X
);
6142 expectf(0.0, ptf
[0].Y
);
6143 expectf(106.066032, ptf
[1].X
);
6144 expectf(0.0, ptf
[1].Y
);
6145 expectf(79.549522, ptf
[2].X
);
6146 expectf(-26.516510, ptf
[2].Y
);
6147 expectf(79.549522, ptf
[3].X
);
6148 expectf(26.516508, ptf
[3].Y
);
6150 status
= GdipCreateMatrix(&matrix
);
6152 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
6154 status
= GdipSetWorldTransform(graphics
, matrix
);
6156 GdipDeleteMatrix(matrix
);
6158 status
= GdipGetClip(graphics
, region
);
6160 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6162 ret
= GetRgnBox(hrgn
, &rc
);
6163 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
6164 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
6165 /* rounding under Wine is slightly different */
6166 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
6167 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc
));
6169 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6171 ret
= GetRgnBox(hrgn
, &rc
);
6172 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6173 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
6174 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6185 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
6187 expectf(0.0, ptf
[0].X
);
6188 expectf(53.033005, ptf
[0].Y
);
6189 expectf(0.0, ptf
[1].X
);
6190 expectf(106.066010, ptf
[1].Y
);
6191 expectf(26.516491, ptf
[2].X
);
6192 expectf(79.549507, ptf
[2].Y
);
6193 expectf(-26.516520, ptf
[3].X
);
6194 expectf(79.549500, ptf
[3].Y
);
6196 GdipDeleteRegion(region
);
6197 GdipDeleteGraphics(graphics
);
6202 static void test_GdipFillRectangles(void)
6205 GpGraphics
*graphics
= NULL
;
6206 GpBrush
*brush
= NULL
;
6207 HDC hdc
= GetDC( hwnd
);
6208 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
6210 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
6212 status
= GdipCreateFromHDC(hdc
, &graphics
);
6214 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
6216 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
6218 ok(brush
!= NULL
, "Expected brush to be initialized\n");
6220 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
6221 expect(InvalidParameter
, status
);
6223 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
6224 expect(InvalidParameter
, status
);
6226 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
6227 expect(InvalidParameter
, status
);
6229 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
6230 expect(InvalidParameter
, status
);
6232 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
6233 expect(InvalidParameter
, status
);
6235 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
6238 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
6241 GdipDeleteBrush(brush
);
6242 GdipDeleteGraphics(graphics
);
6244 ReleaseDC(hwnd
, hdc
);
6247 static void test_GdipGetVisibleClipBounds_memoryDC(void)
6256 GpGraphics
* graphics
= NULL
;
6260 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
6261 width
= rect
.right
- rect
.left
;
6262 height
= rect
.bottom
- rect
.top
;
6265 hdc
= CreateCompatibleDC ( dc
);
6266 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
6267 old
= SelectObject (hdc
, bmp
);
6269 /*change the window origin is the key test point*/
6270 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
6272 status
= GdipCreateFromHDC(hdc
, &graphics
);
6275 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
6278 ok(boundRect
.X
==rect
.left
+10 &&
6279 boundRect
.Y
==rect
.top
+10 &&
6280 boundRect
.Width
==width
&&
6281 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
6283 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6286 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
6289 ok(boundRect
.X
==rect
.left
+10 &&
6290 boundRect
.Y
==rect
.top
+10 &&
6291 boundRect
.Width
==width
-10 &&
6292 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
6294 GdipDeleteGraphics(graphics
);
6296 SelectObject (hdc
, old
);
6299 ReleaseDC(hwnd
, dc
);
6302 static void test_container_rects(void)
6305 GpGraphics
*graphics
;
6306 HDC hdc
= GetDC( hwnd
);
6307 GpRectF dstrect
, srcrect
;
6308 GraphicsContainer state
;
6309 static const GpPointF test_points
[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
6313 status
= GdipCreateFromHDC(hdc
, &graphics
);
6318 dstrect
.Width
= 1.0;
6319 dstrect
.Height
= 1.0;
6322 status
= GdipGetDpiX(graphics
, &dpix
);
6325 status
= GdipGetDpiY(graphics
, &dpiy
);
6328 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitWorld
, &state
);
6329 expect(InvalidParameter
, status
);
6331 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitDisplay
, &state
);
6332 expect(InvalidParameter
, status
);
6334 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitMillimeter
+1, &state
);
6335 expect(InvalidParameter
, status
);
6337 status
= GdipBeginContainer(NULL
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6338 expect(InvalidParameter
, status
);
6340 status
= GdipBeginContainer(graphics
, NULL
, &srcrect
, UnitPixel
, &state
);
6341 expect(InvalidParameter
, status
);
6343 status
= GdipBeginContainer(graphics
, &dstrect
, NULL
, UnitPixel
, &state
);
6344 expect(InvalidParameter
, status
);
6346 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, -1, &state
);
6347 expect(InvalidParameter
, status
);
6349 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, NULL
);
6350 expect(InvalidParameter
, status
);
6352 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6355 memcpy(points
, test_points
, sizeof(points
));
6356 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6358 expectf(0.0, points
[0].X
);
6359 expectf(0.0, points
[0].Y
);
6360 expectf(1.0, points
[1].X
);
6361 expectf(0.0, points
[1].Y
);
6362 expectf(0.0, points
[2].X
);
6363 expectf(1.0, points
[2].Y
);
6365 status
= GdipEndContainer(graphics
, state
);
6368 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6371 memcpy(points
, test_points
, sizeof(points
));
6372 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6374 expectf(0.0, points
[0].X
);
6375 expectf(0.0, points
[0].Y
);
6376 expectf(1.0/dpix
, points
[1].X
);
6377 expectf(0.0, points
[1].Y
);
6378 expectf(0.0, points
[2].X
);
6379 expectf(1.0/dpiy
, points
[2].Y
);
6381 status
= GdipEndContainer(graphics
, state
);
6384 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
6388 dstrect
.Height
= 3.0;
6389 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6392 memcpy(points
, test_points
, sizeof(points
));
6393 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6395 expectf(2.0, points
[0].X
);
6396 expectf(0.0, points
[0].Y
);
6397 expectf(4.0, points
[1].X
);
6398 expectf(0.0, points
[1].Y
);
6399 expectf(2.0, points
[2].X
);
6400 expectf(6.0, points
[2].Y
);
6402 status
= GdipEndContainer(graphics
, state
);
6405 memcpy(points
, test_points
, sizeof(points
));
6406 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6408 expectf(0.0, points
[0].X
);
6409 expectf(0.0, points
[0].Y
);
6410 expectf(2.0, points
[1].X
);
6411 expectf(0.0, points
[1].Y
);
6412 expectf(0.0, points
[2].X
);
6413 expectf(2.0, points
[2].Y
);
6415 status
= GdipResetWorldTransform(graphics
);
6418 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6421 memcpy(points
, test_points
, sizeof(points
));
6422 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6424 expectf(1.0, points
[0].X
);
6425 expectf(0.0, points
[0].Y
);
6426 expectf((dpix
+1.0)/dpix
, points
[1].X
);
6427 expectf(0.0, points
[1].Y
);
6428 expectf(1.0, points
[2].X
);
6429 expectf(3.0/dpiy
, points
[2].Y
);
6431 status
= GdipEndContainer(graphics
, state
);
6434 status
= GdipSetPageUnit(graphics
, UnitInch
);
6437 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6440 memcpy(points
, test_points
, sizeof(points
));
6441 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6443 expectf(dpix
, points
[0].X
);
6444 expectf(0.0, points
[0].Y
);
6445 expectf(dpix
*2, points
[1].X
);
6446 expectf(0.0, points
[1].Y
);
6447 expectf(dpix
, points
[2].X
);
6448 expectf(dpiy
*3, points
[2].Y
);
6450 status
= GdipEndContainer(graphics
, state
);
6453 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6456 memcpy(points
, test_points
, sizeof(points
));
6457 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6459 expectf(dpix
, points
[0].X
);
6460 expectf(0.0, points
[0].Y
);
6461 expectf(dpix
+1.0, points
[1].X
);
6462 expectf(0.0, points
[1].Y
);
6463 expectf(dpix
, points
[2].X
);
6464 expectf(3.0, points
[2].Y
);
6466 status
= GdipEndContainer(graphics
, state
);
6469 GdipDeleteGraphics(graphics
);
6471 ReleaseDC(hwnd
, hdc
);
6474 static void test_GdipGraphicsSetAbort(void)
6478 GpGraphics
*graphics
;
6480 if (!pGdipGraphicsSetAbort
)
6482 win_skip("GdipGraphicsSetAbort() is not supported.\n");
6488 status
= GdipCreateFromHDC(hdc
, &graphics
);
6491 status
= pGdipGraphicsSetAbort(NULL
, NULL
);
6492 expect(InvalidParameter
, status
);
6494 status
= pGdipGraphicsSetAbort(graphics
, NULL
);
6497 GdipDeleteGraphics(graphics
);
6499 ReleaseDC(hwnd
, hdc
);
6502 #define BLUE_COLOR (0xff0000ff)
6503 #define is_blue_color(color) ( ((color) & 0x00ffffff) == 0xff )
6504 #define get_bitmap_pixel(x,y) pixel[(y)*(width) + (x)]
6505 static DWORD
* GetBitmapPixelBuffer(HDC hdc
, HBITMAP hbmp
, int width
, int height
)
6507 BITMAPINFOHEADER bi
;
6509 DWORD
*buffer
= (DWORD
*)GdipAlloc(width
*height
*4);
6511 bi
.biSize
= sizeof(BITMAPINFOHEADER
);
6513 bi
.biHeight
= -height
; /*very Important, set negative, indicating a top-down DIB*/
6516 bi
.biCompression
= BI_RGB
;
6518 bi
.biXPelsPerMeter
= 0;
6519 bi
.biYPelsPerMeter
= 0;
6521 bi
.biClrImportant
= 0;
6523 lines
= GetDIBits(hdc
, hbmp
, 0, height
, buffer
, (BITMAPINFO
*)&bi
, DIB_RGB_COLORS
);
6524 ok(lines
== height
, "Expected GetDIBits:%p,%d->%d,%ld\n", buffer
, height
, lines
, GetLastError());
6529 static void test_GdipFillRectanglesOnMemoryDCSolidBrush(void)
6531 ARGB color
[6] = {0,0,0,0,0,0};
6533 RECT rect
= {100, 100, 180, 180};
6534 UINT width
= rect
.right
- rect
.left
;
6535 UINT height
= rect
.bottom
- rect
.top
;
6536 GpStatus status
= 0;
6537 GpSolidFill
*brush
= NULL
;
6538 GpGraphics
*graphics
= NULL
;
6539 HDC dc
= GetDC( hwnd
);
6540 HDC hdc
= CreateCompatibleDC(dc
);
6541 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6542 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6543 DWORD
* pixel
= NULL
;
6545 /*Change the window origin is the key test point*/
6546 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6548 status
= GdipCreateSolidFill(BLUE_COLOR
, &brush
);
6551 status
= GdipCreateFromHDC(hdc
, &graphics
);
6554 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6555 width
, height
, CombineModeReplace
);
6558 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6561 GdipDeleteBrush((GpBrush
*)brush
);
6562 GdipDeleteGraphics(graphics
);
6564 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6567 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6568 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6569 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6570 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6571 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6572 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6575 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6576 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6577 "Expected GdipFillRectangleI take effect!\n" );
6580 SelectObject(hdc
, old
);
6583 ReleaseDC(hwnd
, dc
);
6586 static void test_GdipFillRectanglesOnMemoryDCTextureBrush(void)
6588 ARGB color
[6] = {0,0,0,0,0,0};
6590 RECT rect
= {100, 100, 180, 180};
6591 UINT width
= rect
.right
- rect
.left
;
6592 UINT height
= rect
.bottom
- rect
.top
;
6593 GpStatus status
= 0;
6599 GpTexture
*brush
= NULL
;
6600 GpGraphics
*graphics
= NULL
;
6601 HDC dc
= GetDC( hwnd
);
6602 HDC hdc
= CreateCompatibleDC(dc
);
6603 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6604 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6608 UINT src_img_width
= width
/2;
6609 UINT src_img_height
= height
/2;
6610 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6611 DWORD
*pixel
= (DWORD
*)src_img_data
;
6612 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6614 /*Change the window origin is the key test point*/
6615 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6617 /*build a blue solid image!*/
6618 for(y
= 0; y
< src_img_height
; ++y
)
6620 for(x
= 0; x
< src_img_width
; ++x
)
6622 pixel
[x
] = BLUE_COLOR
;
6625 pixel
+= src_img_width
;
6628 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6629 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6632 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6635 status
= GdipCreateFromHDC(hdc
, &graphics
);
6638 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6639 width
, height
, CombineModeReplace
);
6642 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6645 GdipDisposeImage(src_img
.image
);
6646 GdipDeleteBrush((GpBrush
*)brush
);
6647 GdipDeleteGraphics(graphics
);
6648 GdipFree(src_img_data
);
6650 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6653 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6654 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6655 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6656 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6657 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6658 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6660 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6661 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6662 "Expected GdipFillRectangleI take effect!\n" );
6665 SelectObject(hdc
, old
);
6668 ReleaseDC(hwnd
, dc
);
6671 static void test_GdipFillRectanglesOnBitmapTextureBrush(void)
6673 ARGB color
[6] = {0,0,0,0,0,0};
6676 RECT rect
= {100, 100, 180, 180};
6677 UINT width
= rect
.right
- rect
.left
;
6678 UINT height
= rect
.bottom
- rect
.top
;
6679 UINT src_img_width
= width
/2;
6680 UINT src_img_height
= height
/2;
6682 GpStatus status
= 0;
6694 GpTexture
*brush
= NULL
;
6695 GpGraphics
*graphics
= NULL
;
6696 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6697 DWORD
*pixel
= (DWORD
*)src_img_data
;
6698 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6700 status
= GdipCreateBitmapFromScan0(width
, height
, width
*4,
6701 PixelFormat32bppARGB
, NULL
, &dst_img
.bitmap
);
6704 /*build a blue solid image!*/
6705 for(y
= 0; y
< src_img_height
; ++y
)
6707 for(x
= 0; x
< src_img_width
; ++x
)
6709 pixel
[x
] = BLUE_COLOR
;
6712 pixel
+= src_img_width
;
6715 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6716 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6719 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6722 status
= GdipGetImageGraphicsContext(dst_img
.image
, &graphics
);
6725 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6728 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, width
/2, height
/2);
6731 GdipDeleteBrush((GpBrush
*)brush
);
6732 GdipDeleteGraphics(graphics
);
6734 status
= GdipBitmapGetPixel(dst_img
.bitmap
, 0, 0, &color
[0]);
6736 status
= GdipBitmapGetPixel(dst_img
.bitmap
, 0, 1, &color
[1]);
6738 status
= GdipBitmapGetPixel(dst_img
.bitmap
, 1, 0, &color
[2]);
6740 status
= GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, 0, &color
[3]);
6742 status
= GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, height
/2, &color
[4]);
6744 status
= GdipBitmapGetPixel(dst_img
.bitmap
, 0, height
/2, &color
[5]);
6747 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6748 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6749 "Expected GdipFillRectangleI take effect!\n" );
6751 GdipDisposeImage(src_img
.image
);
6752 GdipDisposeImage(dst_img
.image
);
6753 GdipFree(src_img_data
);
6756 static void test_GdipDrawImagePointsRectOnMemoryDC(void)
6758 ARGB color
[6] = {0,0,0,0,0,0};
6760 RECT rect
= {100, 100, 180, 180};
6761 UINT width
= rect
.right
- rect
.left
;
6762 UINT height
= rect
.bottom
- rect
.top
;
6763 GpStatus status
= 0;
6769 GpGraphics
*graphics
= NULL
;
6770 HDC dc
= GetDC( hwnd
);
6771 HDC hdc
= CreateCompatibleDC(dc
);
6772 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6773 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6777 UINT src_img_width
= width
/2;
6778 UINT src_img_height
= height
/2;
6779 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6780 DWORD
*pixel
= (DWORD
*)src_img_data
;
6781 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6783 /*Change the window origin is the key test point*/
6784 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6786 /*build a blue solid image!*/
6787 for(y
= 0; y
< src_img_height
; ++y
)
6789 for(x
= 0; x
< src_img_width
; ++x
)
6791 pixel
[x
] = BLUE_COLOR
;
6794 pixel
+= src_img_width
;
6797 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6798 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6801 status
= GdipCreateFromHDC(hdc
, &graphics
);
6804 status
= GdipDrawImageRectRectI(graphics
, src_img
.image
,
6805 rect
.left
+width
/2, rect
.top
+height
/2, width
/2, height
/2,
6806 0, 0, src_img_width
, src_img_height
, UnitPixel
, NULL
, NULL
, NULL
);
6809 GdipDisposeImage(src_img
.image
);
6810 GdipDeleteGraphics(graphics
);
6811 GdipFree(src_img_data
);
6813 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6816 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6817 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6818 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6819 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6820 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6821 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6823 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6824 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6825 "Expected GdipDrawImageRectRectI take effect!\n" );
6828 SelectObject(hdc
, old
);
6831 ReleaseDC(hwnd
, dc
);
6834 static void test_cliphrgn_transform(void)
6838 GpGraphics
*graphics
;
6845 SetViewportOrgEx(hdc
, 10, 10, NULL
);
6847 status
= GdipCreateFromHDC(hdc
, &graphics
);
6850 rgn
= CreateRectRgn(0, 0, 100, 100);
6852 status
= GdipSetClipHrgn(graphics
, rgn
, CombineModeReplace
);
6855 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
6857 expectf(-10.0, rectf
.X
);
6858 expectf(-10.0, rectf
.Y
);
6859 expectf(100.0, rectf
.Width
);
6860 expectf(100.0, rectf
.Height
);
6862 status
= GdipIsVisiblePoint(graphics
, 95, 95, &res
);
6866 status
= GdipIsVisiblePoint(graphics
, -5, -5, &res
);
6872 GdipDeleteGraphics(graphics
);
6874 SetViewportOrgEx(hdc
, 0, 0, NULL
);
6876 ReleaseDC(hwnd
, hdc
);
6879 static void test_hdc_caching(void)
6884 GpGraphics
*graphics
;
6890 hdc
= CreateCompatibleDC(0);
6891 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
6892 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
6893 bmi
.bmiHeader
.biHeight
= -5;
6894 bmi
.bmiHeader
.biWidth
= 5;
6895 bmi
.bmiHeader
.biBitCount
= 32;
6896 bmi
.bmiHeader
.biPlanes
= 1;
6897 bmi
.bmiHeader
.biCompression
= BI_RGB
;
6898 bmi
.bmiHeader
.biClrUsed
= 0;
6900 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
6901 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
6903 SelectObject(hdc
, hbm
);
6905 SetViewportOrgEx(hdc
, 1, 1, NULL
);
6907 hrgn
= CreateRectRgn(0, 0, 3, 3);
6908 SelectClipRgn(hdc
, hrgn
);
6911 status
= GdipCreateSolidFill((ARGB
)0xffaaaaaa, (GpSolidFill
**)&brush
);
6914 status
= GdipCreateFromHDC(hdc
, &graphics
);
6917 memset(bits
, 0, sizeof(*bits
) * 25);
6918 status
= GdipFillRectangleI(graphics
, brush
, 0, 0, 4, 4);
6922 expect(0xffaaaaaa, bits
[6]);
6923 expect(0xffaaaaaa, bits
[12]);
6924 expect(0, bits
[18]);
6925 expect(0, bits
[24]);
6927 SetViewportOrgEx(hdc
, 0, 0, NULL
);
6928 OffsetClipRgn(hdc
, 2, 2);
6930 memset(bits
, 0, sizeof(*bits
) * 25);
6931 status
= GdipFillRectangleI(graphics
, brush
, 0, 0, 4, 4);
6935 expect(0xffaaaaaa, bits
[6]);
6936 expect(0xffaaaaaa, bits
[12]);
6937 expect(0, bits
[18]);
6938 expect(0, bits
[24]);
6940 GdipDeleteGraphics(graphics
);
6942 GdipDeleteBrush(brush
);
6948 static void test_gdi_interop_bitmap(void)
6951 GpGraphics
*graphics
;
6952 GpMatrix
*transform
;
6956 HBRUSH hbrush
, holdbrush
;
6959 stat
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB
, NULL
, &bitmap
);
6962 stat
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
6965 stat
= GdipCreateMatrix(&transform
);
6968 stat
= GdipSetMatrixElements(transform
, 1.0, 0.0, 0.0, 1.0, 50.0, 50.0);
6971 /* GDI+: Set world transform. Should not matter to GDI. */
6972 stat
= GdipSetWorldTransform(graphics
, transform
);
6975 stat
= GdipGetDC(graphics
, &hdc
);
6978 hbrush
= CreateSolidBrush(0xff0000);
6980 holdbrush
= SelectObject(hdc
, hbrush
);
6982 /* GDI: Draw a rectangle at physical coords (5, 5) to (12, 10). */
6983 Rectangle(hdc
, 5, 5, 12, 10);
6985 holdbrush
= SelectObject(hdc
, holdbrush
);
6987 /* GDI: Set view port origin. Should not matter to GDI+. */
6988 SetViewportOrgEx(hdc
, 20, 20, NULL
);
6990 GdipReleaseDC(graphics
, hdc
);
6992 stat
= GdipCreateSolidFill((ARGB
)0xff0000ff, (GpSolidFill
**)&brush
);
6995 /* GDI+: Draw a rectangle at physical coords (85, 85) to (88, 95). */
6996 stat
= GdipFillRectangleI(graphics
, brush
, 35, 35, 3, 10);
6999 stat
= GdipDeleteBrush(brush
);
7002 stat
= GdipGetDC(graphics
, &hdc
);
7005 holdbrush
= SelectObject(hdc
, hbrush
);
7007 /* GDI: Draw a rectangle at physical coords (25, 25) to (30, 34).
7008 Updated view port origin should still be in effect. */
7009 Rectangle(hdc
, 5, 5, 10, 14);
7011 SelectObject(hdc
, holdbrush
);
7013 DeleteObject(hbrush
);
7014 stat
= GdipReleaseDC(graphics
, hdc
);
7017 stat
= GdipDeleteMatrix(transform
);
7020 stat
= GdipBitmapGetPixel(bitmap
, 6, 6, &color
);
7022 expect(0xff0000ff, color
);
7024 stat
= GdipBitmapGetPixel(bitmap
, 26, 26, &color
);
7026 expect(0xff0000ff, color
);
7028 stat
= GdipBitmapGetPixel(bitmap
, 86, 86, &color
);
7030 expect(0xff0000ff, color
);
7032 stat
= GdipDeleteGraphics(graphics
);
7035 stat
= GdipDisposeImage((GpImage
*)bitmap
);
7039 static void test_gdi_interop_hdc(void)
7043 GpGraphics
*graphics
;
7044 GpMatrix
*transform
;
7047 HBRUSH hbrush
, holdbrush
;
7051 XFORM xform
= { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
7053 src_hdc
= CreateCompatibleDC(0);
7054 ok(src_hdc
!= NULL
, "CreateCompatibleDC failed\n");
7056 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
7057 bmi
.bmiHeader
.biHeight
= -100;
7058 bmi
.bmiHeader
.biWidth
= 100;
7059 bmi
.bmiHeader
.biBitCount
= 32;
7060 bmi
.bmiHeader
.biPlanes
= 1;
7061 bmi
.bmiHeader
.biCompression
= BI_RGB
;
7062 bmi
.bmiHeader
.biClrUsed
= 0;
7063 bmi
.bmiHeader
.biClrImportant
= 0;
7065 hbm
= CreateDIBSection(src_hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
7066 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
7068 SelectObject(src_hdc
, hbm
);
7070 SetGraphicsMode(src_hdc
, GM_ADVANCED
);
7074 SetWorldTransform(src_hdc
, &xform
);
7076 stat
= GdipCreateFromHDC(src_hdc
, &graphics
);
7079 stat
= GdipCreateMatrix(&transform
);
7082 stat
= GdipSetMatrixElements(transform
, 1.0, 0.0, 0.0, 1.0, 40.0, 40.0);
7085 /* GDI+: Set world transform. Should not matter to GDI. */
7086 stat
= GdipSetWorldTransform(graphics
, transform
);
7089 stat
= GdipGetDC(graphics
, &gdi_hdc
);
7091 ok( gdi_hdc
== src_hdc
, "wrong dc\n" );
7093 /* GDI: Set GDI transform back to (0, 0).
7094 Should not matter to GDI+. */
7097 SetWorldTransform(gdi_hdc
, &xform
);
7099 hbrush
= CreateSolidBrush(0xff00aa);
7101 holdbrush
= SelectObject(gdi_hdc
, hbrush
);
7103 /* GDI: Draw a rectangle at physical coords (5, 5) to (12, 10). */
7104 Rectangle(gdi_hdc
, 5, 5, 12, 10);
7106 holdbrush
= SelectObject(gdi_hdc
, holdbrush
);
7108 /* GDI: Set GDI transform to translate (+20, +20).
7109 Should not matter to GDI+. */
7112 SetWorldTransform(gdi_hdc
, &xform
);
7114 GdipReleaseDC(graphics
, gdi_hdc
);
7116 /* GDI world transform should still be intact, even when back
7118 stat
= GetWorldTransform(src_hdc
, &xform
);
7120 expect(20.0, xform
.eDx
);
7121 expect(20.0, xform
.eDy
);
7123 stat
= GdipCreateSolidFill((ARGB
)0xffaa00ff, (GpSolidFill
**)&brush
);
7126 /* GDI+: Draw a rectangle at physical coords (85, 85) to (88, 95).
7127 The fact that the GDI world transform has been updated should
7128 not influence the GDI+ world transform. GDI+ should still apply
7129 the world transform from the when HDC backed graphics object was
7131 stat
= GdipFillRectangleI(graphics
, brush
, 35, 35, 3, 10);
7134 stat
= GdipDeleteBrush(brush
);
7137 stat
= GdipGetDC(graphics
, &gdi_hdc
);
7140 holdbrush
= SelectObject(gdi_hdc
, hbrush
);
7142 /* GDI: Draw a rectangle at physical coords (25, 25) to (30, 34).
7143 Updated transform should still be in effect. */
7144 Rectangle(gdi_hdc
, 5, 5, 10, 14);
7146 SelectObject(gdi_hdc
, holdbrush
);
7148 stat
= GdipReleaseDC(graphics
, gdi_hdc
);
7151 GdipDeleteGraphics(graphics
);
7152 stat
= GdipDeleteMatrix(transform
);
7155 holdbrush
= SelectObject(src_hdc
, hbrush
);
7157 /* GDI: Draw a rectangle at physical coords (35, 35) to (40, 38).
7158 Updated transform should still be in effect on src_hdc. */
7159 Rectangle(gdi_hdc
, 15, 15, 20, 18);
7161 SelectObject(gdi_hdc
, holdbrush
);
7163 DeleteObject(hbrush
);
7165 expect(0x00aa00ff, bits
[6 * 100 + 6]);
7166 expect(0x00aa00ff, bits
[26 * 100 + 26]);
7167 expect(0x00aa00ff, bits
[36 * 100 + 36]);
7168 expect(0xffaa00ff, bits
[86 * 100 + 86]);
7174 static HDC
create_printer_dc(void)
7178 PRINTER_INFO_2A
*pbuf
= NULL
;
7179 DRIVER_INFO_3A
*dbuf
= NULL
;
7182 HMODULE winspool
= LoadLibraryA("winspool.drv");
7183 BOOL (WINAPI
*pOpenPrinterA
)(LPSTR
, HANDLE
*, LPPRINTER_DEFAULTSA
);
7184 BOOL (WINAPI
*pGetDefaultPrinterA
)(LPSTR
, LPDWORD
);
7185 BOOL (WINAPI
*pGetPrinterA
)(HANDLE
, DWORD
, LPBYTE
, DWORD
, LPDWORD
);
7186 BOOL (WINAPI
*pGetPrinterDriverA
)(HANDLE
, LPSTR
, DWORD
, LPBYTE
, DWORD
, LPDWORD
);
7187 BOOL (WINAPI
*pClosePrinter
)(HANDLE
);
7189 pGetDefaultPrinterA
= (void *)GetProcAddress(winspool
, "GetDefaultPrinterA");
7190 pOpenPrinterA
= (void *)GetProcAddress(winspool
, "OpenPrinterA");
7191 pGetPrinterA
= (void *)GetProcAddress(winspool
, "GetPrinterA");
7192 pGetPrinterDriverA
= (void *)GetProcAddress(winspool
, "GetPrinterDriverA");
7193 pClosePrinter
= (void *)GetProcAddress(winspool
, "ClosePrinter");
7195 if (!pGetDefaultPrinterA
|| !pOpenPrinterA
|| !pGetPrinterA
|| !pGetPrinterDriverA
|| !pClosePrinter
)
7198 len
= sizeof(buffer
);
7199 if (!pGetDefaultPrinterA(buffer
, &len
)) goto done
;
7200 if (!pOpenPrinterA(buffer
, &hprn
, NULL
)) goto done
;
7202 pGetPrinterA(hprn
, 2, NULL
, 0, &len
);
7203 pbuf
= HeapAlloc(GetProcessHeap(), 0, len
);
7204 if (!pGetPrinterA(hprn
, 2, (LPBYTE
)pbuf
, len
, &len
)) goto done
;
7206 pGetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &len
);
7207 dbuf
= HeapAlloc(GetProcessHeap(), 0, len
);
7208 if (!pGetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)dbuf
, len
, &len
)) goto done
;
7210 hdc
= CreateDCA(dbuf
->pDriverPath
, pbuf
->pPrinterName
, pbuf
->pPortName
, pbuf
->pDevMode
);
7211 trace("hdc %p for driver '%s' printer '%s' port '%s'\n", hdc
,
7212 dbuf
->pDriverPath
, pbuf
->pPrinterName
, pbuf
->pPortName
);
7214 HeapFree(GetProcessHeap(), 0, dbuf
);
7215 HeapFree(GetProcessHeap(), 0, pbuf
);
7216 if (hprn
) pClosePrinter(hprn
);
7217 if (winspool
) FreeLibrary(winspool
);
7221 static BOOL
check_rect_pixels(const DWORD
*pixel
, const RectF
*rect
, UINT width
, DWORD expected
, Point
*failed
)
7226 for (y
= (UINT
)rect
->Y
; y
< (UINT
)(rect
->Y
+ rect
->Height
); y
++)
7228 for (x
= (UINT
)rect
->X
; x
< (UINT
)(rect
->X
+ rect
->Width
); x
++)
7230 if (pixel
[x
+ y
* width
] != expected
)
7252 static void test_printer_dc(void)
7254 HDC hdc_printer
, hdc
;
7256 GpGraphics
*graphics
;
7257 REAL dpi_x
, dpi_y
, pixel_per_unit_x
, pixel_per_unit_y
;
7259 UINT width
= 16, height
= 16;
7267 hdc_printer
= create_printer_dc();
7270 skip("could not create a DC for the default printer\n");
7274 hdc
= CreateCompatibleDC(hdc_printer
);
7275 bitmap
= CreateCompatibleBitmap(hdc
, width
, height
);
7276 SelectObject(hdc
, bitmap
);
7278 status
= GdipCreateFromHDC(hdc
, &graphics
);
7281 GdipGetPageUnit(graphics
, &unit
);
7282 expect(UnitDisplay
, unit
);
7284 GdipGetDpiX(graphics
, &dpi_x
);
7285 GdipGetDpiY(graphics
, &dpi_y
);
7286 expectf((REAL
)GetDeviceCaps(hdc
, LOGPIXELSX
), dpi_x
);
7287 expectf((REAL
)GetDeviceCaps(hdc
, LOGPIXELSY
), dpi_y
);
7289 /* For graphics created from printer DC, UnitDisplay specifies that a unit is 1/100 inch */
7290 pixel_per_unit_x
= dpi_x
/ 100.0;
7291 pixel_per_unit_y
= dpi_y
/ 100.0;
7293 status
= GdipCreateSolidFill((ARGB
)0xffffffff, &brush
);
7296 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 1, 1, 1, 1);
7299 pixel
= GetBitmapPixelBuffer(hdc
, bitmap
, width
, height
);
7301 /* pixels at (0, 0) should all be 0 */
7304 rect
.Width
= pixel_per_unit_x
;
7305 rect
.Height
= pixel_per_unit_y
;
7306 match
= check_rect_pixels(pixel
, &rect
, width
, 0, &pt
);
7307 ok(match
, "Expected pixel (%u, %u) to be %08x, got %08lx\n",
7308 pt
.X
, pt
.Y
, 0, pixel
[pt
.X
+ pt
.Y
* width
]);
7310 /* pixels at (1, 1) should all be 0x00ffffff */
7311 rect
.X
= pixel_per_unit_x
;
7312 rect
.Y
= pixel_per_unit_y
;
7313 rect
.Width
= pixel_per_unit_x
;
7314 rect
.Height
= pixel_per_unit_y
;
7315 match
= check_rect_pixels(pixel
, &rect
, width
, 0x00ffffff, &pt
);
7316 ok(match
, "Expected pixel (%u, %u) to be %08x, got %08lx\n",
7317 pt
.X
, pt
.Y
, 0x00ffffff, pixel
[pt
.X
+ pt
.Y
* width
]);
7320 GdipDeleteBrush((GpBrush
*)brush
);
7321 GdipDeleteGraphics(graphics
);
7322 DeleteObject(bitmap
);
7324 DeleteDC(hdc_printer
);
7327 START_TEST(graphics
)
7329 struct GdiplusStartupInput gdiplusStartupInput
;
7330 ULONG_PTR gdiplusToken
;
7332 HMODULE gdiplus_mod
= GetModuleHandleA("gdiplus.dll");
7334 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
7336 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
7337 hmsvcrt
= LoadLibraryA("msvcrt");
7338 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
7339 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
7341 pGdipGraphicsSetAbort
= (void*)GetProcAddress(gdiplus_mod
, "GdipGraphicsSetAbort");
7343 memset( &class, 0, sizeof(class) );
7344 class.lpszClassName
= "gdiplus_test";
7345 class.style
= CS_HREDRAW
| CS_VREDRAW
;
7346 class.lpfnWndProc
= DefWindowProcA
;
7347 class.hInstance
= GetModuleHandleA(0);
7348 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
7349 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
7350 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
7351 RegisterClassA( &class );
7352 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7353 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
7354 ok(hwnd
!= NULL
, "Expected window to be created\n");
7356 gdiplusStartupInput
.GdiplusVersion
= 1;
7357 gdiplusStartupInput
.DebugEventCallback
= NULL
;
7358 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
7359 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
7361 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
7365 test_measured_extra_space();
7366 test_measure_string();
7367 test_font_height_scaling();
7369 test_set_page_transform();
7370 test_pen_thickness();
7371 test_GdipMeasureString();
7372 test_constructor_destructor();
7373 test_save_restore();
7374 test_GdipFillClosedCurve2();
7375 test_GdipFillClosedCurve2I();
7376 test_GdipDrawBezierI();
7378 test_GdipDrawArcI();
7379 test_GdipDrawCurve();
7380 test_GdipDrawCurveI();
7381 test_GdipDrawCurve2();
7382 test_GdipDrawCurve2I();
7383 test_GdipDrawCurve3();
7384 test_GdipDrawCurve3I();
7385 test_GdipDrawLineI();
7386 test_GdipDrawLinesI();
7387 test_GdipDrawImagePointsRect();
7388 test_GdipFillClosedCurve();
7389 test_GdipFillClosedCurveI();
7390 test_GdipFillPath();
7391 test_GdipDrawString();
7392 test_GdipGetNearestColor();
7393 test_GdipGetVisibleClipBounds();
7394 test_GdipIsVisiblePoint();
7395 test_GdipIsVisibleRect();
7396 test_Get_Release_DC();
7397 test_BeginContainer2();
7398 test_transformpoints();
7399 test_get_set_clip();
7403 test_textcontrast();
7404 test_fromMemoryBitmap();
7405 test_string_functions();
7406 test_get_set_interpolation();
7407 test_get_set_textrenderinghint();
7408 test_getdc_scaled();
7410 test_bitmapfromgraphics();
7411 test_GdipFillRectangles();
7412 test_GdipGetVisibleClipBounds_memoryDC();
7413 test_GdipFillRectanglesOnMemoryDCSolidBrush();
7414 test_GdipFillRectanglesOnMemoryDCTextureBrush();
7415 test_GdipFillRectanglesOnBitmapTextureBrush();
7416 test_GdipDrawImagePointsRectOnMemoryDC();
7417 test_container_rects();
7418 test_GdipGraphicsSetAbort();
7419 test_cliphrgn_transform();
7421 test_gdi_interop_bitmap();
7422 test_gdi_interop_hdc();
7425 GdiplusShutdown(gdiplusToken
);
7426 DestroyWindow( hwnd
);