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
24 #define WIN32_NO_STATUS
26 #define COM_NO_WINDOWS_H
28 //#include "windows.h"
29 #include <wine/test.h>
34 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
35 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
36 #define expectf(expected, got) expectf_((expected), (got), 0.001)
38 static const REAL mm_per_inch
= 25.4;
39 static const REAL point_per_inch
= 72.0;
42 static void set_rect_empty(RectF
*rc
)
50 /* converts a given unit to its value in pixels */
51 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
59 return units
* dpi
/ point_per_inch
;
63 return units
* dpi
/ 300.0; /* Per MSDN */
65 return units
* dpi
/ mm_per_inch
;
67 ok(0, "Unsupported unit: %d\n", unit
);
72 /* converts value in pixels to a given unit */
73 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
81 return pixels
* point_per_inch
/ dpi
;
85 return pixels
* 300.0 / dpi
;
87 return pixels
* mm_per_inch
/ dpi
;
89 ok(0, "Unsupported unit: %d\n", unit
);
94 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
96 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
97 return pixels_to_units(pixels
, to
, dpi
);
100 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
108 GpGraphics
*graphics
= NULL
;
111 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
114 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
116 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
119 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
123 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
128 status
= GdipGetDpiX(graphics
, &res
);
131 status
= GdipGetDpiY(graphics
, &res
);
135 status
= GdipSetPageUnit(graphics
, unit
);
137 status
= GdipSetPageScale(graphics
, scale
);
143 static void test_constructor_destructor(void)
146 GpGraphics
*graphics
= NULL
;
147 HDC hdc
= GetDC( hwnd
);
149 stat
= GdipCreateFromHDC(NULL
, &graphics
);
150 expect(OutOfMemory
, stat
);
151 stat
= GdipDeleteGraphics(graphics
);
152 expect(InvalidParameter
, stat
);
154 stat
= GdipCreateFromHDC(hdc
, &graphics
);
156 stat
= GdipDeleteGraphics(graphics
);
159 stat
= GdipCreateFromHWND(NULL
, &graphics
);
161 stat
= GdipDeleteGraphics(graphics
);
164 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
166 stat
= GdipDeleteGraphics(graphics
);
169 stat
= GdipDeleteGraphics(NULL
);
170 expect(InvalidParameter
, stat
);
171 ReleaseDC(hwnd
, hdc
);
179 /* Linked list prepend function. */
180 static void log_state(GraphicsState data
, node
** log
)
182 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
184 new_entry
->data
= data
;
185 new_entry
->next
= *log
;
189 /* Checks if there are duplicates in the list, and frees it. */
190 static void check_no_duplicates(node
* log
)
202 while((temp
= temp
->next
)){
203 if(log
->data
== temp
->data
){
210 }while((log
= log
->next
));
215 HeapFree(GetProcessHeap(), 0, temp
);
223 static void test_save_restore(void)
226 GraphicsState state_a
, state_b
, state_c
;
227 InterpolationMode mode
;
228 GpGraphics
*graphics1
, *graphics2
;
229 node
* state_log
= NULL
;
230 HDC hdc
= GetDC( hwnd
);
231 state_a
= state_b
= state_c
= 0xdeadbeef;
233 /* Invalid saving. */
234 GdipCreateFromHDC(hdc
, &graphics1
);
235 stat
= GdipSaveGraphics(graphics1
, NULL
);
236 expect(InvalidParameter
, stat
);
237 stat
= GdipSaveGraphics(NULL
, &state_a
);
238 expect(InvalidParameter
, stat
);
239 GdipDeleteGraphics(graphics1
);
241 log_state(state_a
, &state_log
);
243 /* Basic save/restore. */
244 GdipCreateFromHDC(hdc
, &graphics1
);
245 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
246 stat
= GdipSaveGraphics(graphics1
, &state_a
);
248 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
249 stat
= GdipRestoreGraphics(graphics1
, state_a
);
251 GdipGetInterpolationMode(graphics1
, &mode
);
252 expect(InterpolationModeBilinear
, mode
);
253 GdipDeleteGraphics(graphics1
);
255 log_state(state_a
, &state_log
);
257 /* Restoring garbage doesn't affect saves. */
258 GdipCreateFromHDC(hdc
, &graphics1
);
259 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
260 GdipSaveGraphics(graphics1
, &state_a
);
261 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
262 GdipSaveGraphics(graphics1
, &state_b
);
263 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
264 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
266 GdipRestoreGraphics(graphics1
, state_b
);
267 GdipGetInterpolationMode(graphics1
, &mode
);
268 expect(InterpolationModeBicubic
, mode
);
269 GdipRestoreGraphics(graphics1
, state_a
);
270 GdipGetInterpolationMode(graphics1
, &mode
);
271 expect(InterpolationModeBilinear
, mode
);
272 GdipDeleteGraphics(graphics1
);
274 log_state(state_a
, &state_log
);
275 log_state(state_b
, &state_log
);
277 /* Restoring older state invalidates newer saves (but not older saves). */
278 GdipCreateFromHDC(hdc
, &graphics1
);
279 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
280 GdipSaveGraphics(graphics1
, &state_a
);
281 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
282 GdipSaveGraphics(graphics1
, &state_b
);
283 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
284 GdipSaveGraphics(graphics1
, &state_c
);
285 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
286 GdipRestoreGraphics(graphics1
, state_b
);
287 GdipGetInterpolationMode(graphics1
, &mode
);
288 expect(InterpolationModeBicubic
, mode
);
289 GdipRestoreGraphics(graphics1
, state_c
);
290 GdipGetInterpolationMode(graphics1
, &mode
);
291 expect(InterpolationModeBicubic
, mode
);
292 GdipRestoreGraphics(graphics1
, state_a
);
293 GdipGetInterpolationMode(graphics1
, &mode
);
294 expect(InterpolationModeBilinear
, mode
);
295 GdipDeleteGraphics(graphics1
);
297 log_state(state_a
, &state_log
);
298 log_state(state_b
, &state_log
);
299 log_state(state_c
, &state_log
);
301 /* Restoring older save from one graphics object does not invalidate
302 * newer save from other graphics object. */
303 GdipCreateFromHDC(hdc
, &graphics1
);
304 GdipCreateFromHDC(hdc
, &graphics2
);
305 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
306 GdipSaveGraphics(graphics1
, &state_a
);
307 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
308 GdipSaveGraphics(graphics2
, &state_b
);
309 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
310 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
311 GdipRestoreGraphics(graphics1
, state_a
);
312 GdipGetInterpolationMode(graphics1
, &mode
);
313 expect(InterpolationModeBilinear
, mode
);
314 GdipRestoreGraphics(graphics2
, state_b
);
315 GdipGetInterpolationMode(graphics2
, &mode
);
316 expect(InterpolationModeBicubic
, mode
);
317 GdipDeleteGraphics(graphics1
);
318 GdipDeleteGraphics(graphics2
);
320 /* You can't restore a state to a graphics object that didn't save it. */
321 GdipCreateFromHDC(hdc
, &graphics1
);
322 GdipCreateFromHDC(hdc
, &graphics2
);
323 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
324 GdipSaveGraphics(graphics1
, &state_a
);
325 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
326 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
327 GdipRestoreGraphics(graphics2
, state_a
);
328 GdipGetInterpolationMode(graphics2
, &mode
);
329 expect(InterpolationModeNearestNeighbor
, mode
);
330 GdipDeleteGraphics(graphics1
);
331 GdipDeleteGraphics(graphics2
);
333 log_state(state_a
, &state_log
);
335 /* The same state value should never be returned twice. */
337 check_no_duplicates(state_log
);
339 ReleaseDC(hwnd
, hdc
);
342 static void test_GdipFillClosedCurve2(void)
345 GpGraphics
*graphics
= NULL
;
346 GpSolidFill
*brush
= NULL
;
347 HDC hdc
= GetDC( hwnd
);
359 /* make a graphics object and brush object */
360 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
362 status
= GdipCreateFromHDC(hdc
, &graphics
);
364 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
366 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
368 /* InvalidParameter cases: null graphics, null brush, null points */
369 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
370 expect(InvalidParameter
, status
);
372 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
373 expect(InvalidParameter
, status
);
375 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
376 expect(InvalidParameter
, status
);
378 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
379 expect(InvalidParameter
, status
);
381 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
382 expect(InvalidParameter
, status
);
384 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
385 expect(InvalidParameter
, status
);
387 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
388 expect(InvalidParameter
, status
);
390 /* InvalidParameter cases: invalid count */
391 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
392 expect(InvalidParameter
, status
);
394 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
395 expect(InvalidParameter
, status
);
397 /* Valid test cases */
398 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
401 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
404 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
407 GdipDeleteGraphics(graphics
);
408 GdipDeleteBrush((GpBrush
*)brush
);
410 ReleaseDC(hwnd
, hdc
);
413 static void test_GdipFillClosedCurve2I(void)
416 GpGraphics
*graphics
= NULL
;
417 GpSolidFill
*brush
= NULL
;
418 HDC hdc
= GetDC( hwnd
);
430 /* make a graphics object and brush object */
431 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
433 status
= GdipCreateFromHDC(hdc
, &graphics
);
435 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
437 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
439 /* InvalidParameter cases: null graphics, null brush */
440 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
441 when points == NULL, so don't test this condition */
442 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
443 expect(InvalidParameter
, status
);
445 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
446 expect(InvalidParameter
, status
);
448 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
449 expect(InvalidParameter
, status
);
451 /* InvalidParameter cases: invalid count */
452 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
453 expect(InvalidParameter
, status
);
455 /* OutOfMemory cases: large (unsigned) int */
456 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
457 expect(OutOfMemory
, status
);
459 /* Valid test cases */
460 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
463 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
466 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
469 GdipDeleteGraphics(graphics
);
470 GdipDeleteBrush((GpBrush
*)brush
);
472 ReleaseDC(hwnd
, hdc
);
475 static void test_GdipDrawArc(void)
478 GpGraphics
*graphics
= NULL
;
480 HDC hdc
= GetDC( hwnd
);
482 /* make a graphics object and pen object */
483 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
485 status
= GdipCreateFromHDC(hdc
, &graphics
);
487 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
489 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
491 ok(pen
!= NULL
, "Expected pen to be initialized\n");
493 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
494 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
495 expect(InvalidParameter
, status
);
497 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
498 expect(InvalidParameter
, status
);
500 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
501 expect(InvalidParameter
, status
);
503 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
504 expect(InvalidParameter
, status
);
506 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
507 expect(InvalidParameter
, status
);
509 /* successful case */
510 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
514 GdipDeleteGraphics(graphics
);
516 ReleaseDC(hwnd
, hdc
);
519 static void test_GdipDrawArcI(void)
522 GpGraphics
*graphics
= NULL
;
524 HDC hdc
= GetDC( hwnd
);
526 /* make a graphics object and pen object */
527 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
529 status
= GdipCreateFromHDC(hdc
, &graphics
);
531 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
533 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
535 ok(pen
!= NULL
, "Expected pen to be initialized\n");
537 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
538 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
539 expect(InvalidParameter
, status
);
541 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
542 expect(InvalidParameter
, status
);
544 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
545 expect(InvalidParameter
, status
);
547 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
548 expect(InvalidParameter
, status
);
550 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
551 expect(InvalidParameter
, status
);
553 /* successful case */
554 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
558 GdipDeleteGraphics(graphics
);
560 ReleaseDC(hwnd
, hdc
);
563 static void test_BeginContainer2(void)
567 REAL defClip
[] = {5, 10, 15, 20};
568 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
569 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
570 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
571 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
572 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
573 REAL scale
, defScale
= 17;
574 GpUnit unit
, defUnit
= UnitPixel
;
575 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
576 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
577 UINT contrast
, defContrast
= 5;
578 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
581 GpGraphics
*graphics
= NULL
;
582 HDC hdc
= GetDC( hwnd
);
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 /* null graphics, null container */
591 status
= GdipBeginContainer2(NULL
, &cont1
);
592 expect(InvalidParameter
, status
);
594 status
= GdipBeginContainer2(graphics
, NULL
);
595 expect(InvalidParameter
, status
);
597 status
= GdipEndContainer(NULL
, cont1
);
598 expect(InvalidParameter
, status
);
600 /* test all quality-related values */
601 GdipSetCompositingMode(graphics
, defCompmode
);
602 GdipSetCompositingQuality(graphics
, defCompqual
);
603 GdipSetInterpolationMode(graphics
, defInterp
);
604 GdipSetPageScale(graphics
, defScale
);
605 GdipSetPageUnit(graphics
, defUnit
);
606 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
607 GdipSetSmoothingMode(graphics
, defSmoothmode
);
608 GdipSetTextContrast(graphics
, defContrast
);
609 GdipSetTextRenderingHint(graphics
, defTexthint
);
611 status
= GdipBeginContainer2(graphics
, &cont1
);
614 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
615 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
616 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
617 GdipSetPageScale(graphics
, 10);
618 GdipSetPageUnit(graphics
, UnitDocument
);
619 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
620 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
621 GdipSetTextContrast(graphics
, 7);
622 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
624 status
= GdipEndContainer(graphics
, cont1
);
627 GdipGetCompositingMode(graphics
, &compmode
);
628 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
630 GdipGetCompositingQuality(graphics
, &compqual
);
631 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
633 GdipGetInterpolationMode(graphics
, &interp
);
634 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
636 GdipGetPageScale(graphics
, &scale
);
637 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
639 GdipGetPageUnit(graphics
, &unit
);
640 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
642 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
643 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
645 GdipGetSmoothingMode(graphics
, &smoothmode
);
646 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
648 GdipGetTextContrast(graphics
, &contrast
);
649 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
651 GdipGetTextRenderingHint(graphics
, &texthint
);
652 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
654 /* test world transform */
655 status
= GdipBeginContainer2(graphics
, &cont1
);
658 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
659 defTrans
[4], defTrans
[5], &transform
);
661 GdipSetWorldTransform(graphics
, transform
);
662 GdipDeleteMatrix(transform
);
665 status
= GdipBeginContainer2(graphics
, &cont2
);
668 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
670 GdipSetWorldTransform(graphics
, transform
);
671 GdipDeleteMatrix(transform
);
674 status
= GdipEndContainer(graphics
, cont2
);
677 status
= GdipCreateMatrix(&transform
);
679 GdipGetWorldTransform(graphics
, transform
);
680 GdipGetMatrixElements(transform
, elems
);
681 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
682 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
683 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
684 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
685 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
686 fabs(defTrans
[5] - elems
[5]) < 0.0001,
687 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
688 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
689 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
690 GdipDeleteMatrix(transform
);
693 status
= GdipEndContainer(graphics
, cont1
);
697 status
= GdipBeginContainer2(graphics
, &cont1
);
700 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
702 status
= GdipBeginContainer2(graphics
, &cont2
);
705 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
707 status
= GdipEndContainer(graphics
, cont2
);
710 status
= GdipGetClipBounds(graphics
, &clip
);
713 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
714 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
715 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
716 fabs(defClip
[3] - clip
.Height
) < 0.0001,
717 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
718 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
719 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
721 status
= GdipEndContainer(graphics
, cont1
);
725 status
= GdipBeginContainer2(graphics
, &cont1
);
728 status
= GdipBeginContainer2(graphics
, &cont2
);
731 status
= GdipBeginContainer2(graphics
, &cont3
);
734 status
= GdipEndContainer(graphics
, cont3
);
737 status
= GdipBeginContainer2(graphics
, &cont4
);
740 status
= GdipEndContainer(graphics
, cont4
);
744 status
= GdipEndContainer(graphics
, cont1
);
747 /* end an already-ended container */
748 status
= GdipEndContainer(graphics
, cont1
);
751 GdipDeleteGraphics(graphics
);
752 ReleaseDC(hwnd
, hdc
);
755 static void test_GdipDrawBezierI(void)
758 GpGraphics
*graphics
= NULL
;
760 HDC hdc
= GetDC( hwnd
);
762 /* make a graphics object and pen object */
763 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
765 status
= GdipCreateFromHDC(hdc
, &graphics
);
767 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
769 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
771 ok(pen
!= NULL
, "Expected pen to be initialized\n");
773 /* InvalidParameter cases: null graphics, null pen */
774 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
775 expect(InvalidParameter
, status
);
777 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
778 expect(InvalidParameter
, status
);
780 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
781 expect(InvalidParameter
, status
);
783 /* successful case */
784 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
788 GdipDeleteGraphics(graphics
);
790 ReleaseDC(hwnd
, hdc
);
793 static void test_GdipDrawCurve3(void)
796 GpGraphics
*graphics
= NULL
;
798 HDC hdc
= GetDC( hwnd
);
810 /* make a graphics object and pen object */
811 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
813 status
= GdipCreateFromHDC(hdc
, &graphics
);
815 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
817 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
819 ok(pen
!= NULL
, "Expected pen to be initialized\n");
821 /* InvalidParameter cases: null graphics, null pen */
822 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
823 expect(InvalidParameter
, status
);
825 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
826 expect(InvalidParameter
, status
);
828 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
829 expect(InvalidParameter
, status
);
831 /* InvalidParameter cases: invalid count */
832 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
833 expect(InvalidParameter
, status
);
835 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
836 expect(InvalidParameter
, status
);
838 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
839 expect(InvalidParameter
, status
);
841 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
842 expect(InvalidParameter
, status
);
844 /* InvalidParameter cases: invalid number of segments */
845 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
846 expect(InvalidParameter
, status
);
848 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
849 expect(InvalidParameter
, status
);
851 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
852 expect(InvalidParameter
, status
);
854 /* Valid test cases */
855 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
858 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
861 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
864 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
868 GdipDeleteGraphics(graphics
);
870 ReleaseDC(hwnd
, hdc
);
873 static void test_GdipDrawCurve3I(void)
876 GpGraphics
*graphics
= NULL
;
878 HDC hdc
= GetDC( hwnd
);
890 /* make a graphics object and pen object */
891 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
893 status
= GdipCreateFromHDC(hdc
, &graphics
);
895 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
897 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
899 ok(pen
!= NULL
, "Expected pen to be initialized\n");
901 /* InvalidParameter cases: null graphics, null pen */
902 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
903 expect(InvalidParameter
, status
);
905 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
906 expect(InvalidParameter
, status
);
908 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
909 expect(InvalidParameter
, status
);
911 /* InvalidParameter cases: invalid count */
912 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
913 expect(OutOfMemory
, status
);
915 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
916 expect(InvalidParameter
, status
);
918 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
919 expect(InvalidParameter
, status
);
921 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
922 expect(InvalidParameter
, status
);
924 /* InvalidParameter cases: invalid number of segments */
925 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
926 expect(InvalidParameter
, status
);
928 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
929 expect(InvalidParameter
, status
);
931 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
932 expect(InvalidParameter
, status
);
934 /* Valid test cases */
935 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
938 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
941 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
944 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
948 GdipDeleteGraphics(graphics
);
950 ReleaseDC(hwnd
, hdc
);
953 static void test_GdipDrawCurve2(void)
956 GpGraphics
*graphics
= NULL
;
958 HDC hdc
= GetDC( hwnd
);
970 /* make a graphics object and pen object */
971 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
973 status
= GdipCreateFromHDC(hdc
, &graphics
);
975 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
977 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
979 ok(pen
!= NULL
, "Expected pen to be initialized\n");
981 /* InvalidParameter cases: null graphics, null pen */
982 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
983 expect(InvalidParameter
, status
);
985 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
986 expect(InvalidParameter
, status
);
988 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
989 expect(InvalidParameter
, status
);
991 /* InvalidParameter cases: invalid count */
992 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
993 expect(InvalidParameter
, status
);
995 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
996 expect(InvalidParameter
, status
);
998 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
999 expect(InvalidParameter
, status
);
1001 /* Valid test cases */
1002 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1005 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1008 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1011 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1015 GdipDeleteGraphics(graphics
);
1017 ReleaseDC(hwnd
, hdc
);
1020 static void test_GdipDrawCurve2I(void)
1023 GpGraphics
*graphics
= NULL
;
1025 HDC hdc
= GetDC( hwnd
);
1037 /* make a graphics object and pen object */
1038 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1040 status
= GdipCreateFromHDC(hdc
, &graphics
);
1042 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1044 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1046 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1048 /* InvalidParameter cases: null graphics, null pen */
1049 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1050 expect(InvalidParameter
, status
);
1052 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1053 expect(InvalidParameter
, status
);
1055 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1056 expect(InvalidParameter
, status
);
1058 /* InvalidParameter cases: invalid count */
1059 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1060 expect(OutOfMemory
, status
);
1062 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1063 expect(InvalidParameter
, status
);
1065 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1066 expect(InvalidParameter
, status
);
1068 /* Valid test cases */
1069 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1072 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1075 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1078 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1082 GdipDeleteGraphics(graphics
);
1084 ReleaseDC(hwnd
, hdc
);
1087 static void test_GdipDrawCurve(void)
1090 GpGraphics
*graphics
= NULL
;
1092 HDC hdc
= GetDC( hwnd
);
1104 /* make a graphics object and pen object */
1105 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1107 status
= GdipCreateFromHDC(hdc
, &graphics
);
1109 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1111 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1113 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1115 /* InvalidParameter cases: null graphics, null pen */
1116 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1117 expect(InvalidParameter
, status
);
1119 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1120 expect(InvalidParameter
, status
);
1122 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1123 expect(InvalidParameter
, status
);
1125 /* InvalidParameter cases: invalid count */
1126 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1127 expect(InvalidParameter
, status
);
1129 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1130 expect(InvalidParameter
, status
);
1132 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1133 expect(InvalidParameter
, status
);
1135 /* Valid test cases */
1136 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1139 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1143 GdipDeleteGraphics(graphics
);
1145 ReleaseDC(hwnd
, hdc
);
1148 static void test_GdipDrawCurveI(void)
1151 GpGraphics
*graphics
= NULL
;
1153 HDC hdc
= GetDC( hwnd
);
1165 /* make a graphics object and pen object */
1166 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1168 status
= GdipCreateFromHDC(hdc
, &graphics
);
1170 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1172 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1174 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1176 /* InvalidParameter cases: null graphics, null pen */
1177 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1178 expect(InvalidParameter
, status
);
1180 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1181 expect(InvalidParameter
, status
);
1183 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1184 expect(InvalidParameter
, status
);
1186 /* InvalidParameter cases: invalid count */
1187 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1188 expect(OutOfMemory
, status
);
1190 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1191 expect(InvalidParameter
, status
);
1193 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1194 expect(InvalidParameter
, status
);
1196 /* Valid test cases */
1197 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1200 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1204 GdipDeleteGraphics(graphics
);
1206 ReleaseDC(hwnd
, hdc
);
1209 static void test_GdipDrawLineI(void)
1212 GpGraphics
*graphics
= NULL
;
1214 HDC hdc
= GetDC( hwnd
);
1216 /* make a graphics object and pen object */
1217 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1219 status
= GdipCreateFromHDC(hdc
, &graphics
);
1221 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1223 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1225 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1227 /* InvalidParameter cases: null graphics, null pen */
1228 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1229 expect(InvalidParameter
, status
);
1231 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1232 expect(InvalidParameter
, status
);
1234 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1235 expect(InvalidParameter
, status
);
1237 /* successful case */
1238 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1242 GdipDeleteGraphics(graphics
);
1244 ReleaseDC(hwnd
, hdc
);
1247 static void test_GdipDrawImagePointsRect(void)
1250 GpGraphics
*graphics
= NULL
;
1252 GpBitmap
*bm
= NULL
;
1253 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1255 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1256 HDC hdc
= GetDC( hwnd
);
1260 memset(rbmi
, 0, sizeof(rbmi
));
1261 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1262 bmi
->bmiHeader
.biWidth
= 10;
1263 bmi
->bmiHeader
.biHeight
= 10;
1264 bmi
->bmiHeader
.biPlanes
= 1;
1265 bmi
->bmiHeader
.biBitCount
= 32;
1266 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1267 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1269 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1270 status
= GdipCreateFromHDC(hdc
, &graphics
);
1280 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1281 expect(NotImplemented
, status
);
1282 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1283 expect(InvalidParameter
, status
);
1284 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1286 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1287 expect(InvalidParameter
, status
);
1288 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1289 expect(InvalidParameter
, status
);
1290 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1292 memset(ptf
, 0, sizeof(ptf
));
1293 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1296 GdipDisposeImage((GpImage
*)bm
);
1297 GdipDeleteGraphics(graphics
);
1298 ReleaseDC(hwnd
, hdc
);
1301 static void test_GdipDrawLinesI(void)
1304 GpGraphics
*graphics
= NULL
;
1306 GpPoint
*ptf
= NULL
;
1307 HDC hdc
= GetDC( hwnd
);
1309 /* make a graphics object and pen object */
1310 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1312 status
= GdipCreateFromHDC(hdc
, &graphics
);
1314 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1316 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1318 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1320 /* make some arbitrary valid points*/
1321 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1329 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1330 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1331 expect(InvalidParameter
, status
);
1333 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1334 expect(InvalidParameter
, status
);
1336 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1337 expect(InvalidParameter
, status
);
1339 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1340 expect(InvalidParameter
, status
);
1342 /* successful case */
1343 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1348 GdipDeleteGraphics(graphics
);
1350 ReleaseDC(hwnd
, hdc
);
1353 static void test_GdipFillClosedCurve(void)
1356 GpGraphics
*graphics
= NULL
;
1357 GpSolidFill
*brush
= NULL
;
1358 HDC hdc
= GetDC( hwnd
);
1370 /* make a graphics object and brush object */
1371 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1373 status
= GdipCreateFromHDC(hdc
, &graphics
);
1375 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1377 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1379 /* InvalidParameter cases: null graphics, null brush, null points */
1380 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1381 expect(InvalidParameter
, status
);
1383 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1384 expect(InvalidParameter
, status
);
1386 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1387 expect(InvalidParameter
, status
);
1389 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1390 expect(InvalidParameter
, status
);
1392 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1393 expect(InvalidParameter
, status
);
1395 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1396 expect(InvalidParameter
, status
);
1398 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1399 expect(InvalidParameter
, status
);
1401 /* InvalidParameter cases: invalid count */
1402 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1403 expect(InvalidParameter
, status
);
1405 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1406 expect(InvalidParameter
, status
);
1408 /* Valid test cases */
1409 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1412 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1415 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1418 GdipDeleteGraphics(graphics
);
1419 GdipDeleteBrush((GpBrush
*)brush
);
1421 ReleaseDC(hwnd
, hdc
);
1424 static void test_GdipFillClosedCurveI(void)
1427 GpGraphics
*graphics
= NULL
;
1428 GpSolidFill
*brush
= NULL
;
1429 HDC hdc
= GetDC( hwnd
);
1441 /* make a graphics object and brush object */
1442 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1444 status
= GdipCreateFromHDC(hdc
, &graphics
);
1446 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1448 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1450 /* InvalidParameter cases: null graphics, null brush */
1451 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1452 when points == NULL, so don't test this condition */
1453 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1454 expect(InvalidParameter
, status
);
1456 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1457 expect(InvalidParameter
, status
);
1459 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1460 expect(InvalidParameter
, status
);
1462 /* InvalidParameter cases: invalid count */
1463 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1464 expect(InvalidParameter
, status
);
1466 /* OutOfMemory cases: large (unsigned) int */
1467 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1468 expect(OutOfMemory
, status
);
1470 /* Valid test cases */
1471 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1474 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1477 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1480 GdipDeleteGraphics(graphics
);
1481 GdipDeleteBrush((GpBrush
*)brush
);
1483 ReleaseDC(hwnd
, hdc
);
1486 static void test_Get_Release_DC(void)
1489 GpGraphics
*graphics
= NULL
;
1493 HDC hdc
= GetDC( hwnd
);
1496 CompositingQuality quality
;
1497 CompositingMode compmode
;
1498 InterpolationMode intmode
;
1502 PixelOffsetMode offsetmode
;
1503 SmoothingMode smoothmode
;
1504 TextRenderingHint texthint
;
1512 ARGB color
= 0x00000000;
1513 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1526 for(i
= 0; i
< 5;i
++){
1527 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1528 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1534 rect
[0].Height
= 70;
1538 rect
[1].Height
= 20;
1540 for(i
= 0; i
< 2;i
++){
1541 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1542 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1543 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1544 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1547 status
= GdipCreateMatrix(&m
);
1549 GdipCreateRegion(®ion
);
1550 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1551 GdipCreatePath(FillModeAlternate
, &path
);
1552 GdipCreateRegion(&clip
);
1554 status
= GdipCreateFromHDC(hdc
, &graphics
);
1556 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1557 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1560 /* NULL arguments */
1561 status
= GdipGetDC(NULL
, NULL
);
1562 expect(InvalidParameter
, status
);
1563 status
= GdipGetDC(graphics
, NULL
);
1564 expect(InvalidParameter
, status
);
1565 status
= GdipGetDC(NULL
, &retdc
);
1566 expect(InvalidParameter
, status
);
1568 status
= GdipReleaseDC(NULL
, NULL
);
1569 expect(InvalidParameter
, status
);
1570 status
= GdipReleaseDC(graphics
, NULL
);
1571 expect(InvalidParameter
, status
);
1572 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1573 expect(InvalidParameter
, status
);
1575 /* Release without Get */
1576 status
= GdipReleaseDC(graphics
, hdc
);
1577 expect(InvalidParameter
, status
);
1580 status
= GdipGetDC(graphics
, &retdc
);
1582 ok(retdc
== hdc
, "Invalid HDC returned\n");
1583 /* call it once more */
1584 status
= GdipGetDC(graphics
, &retdc
);
1585 expect(ObjectBusy
, status
);
1587 /* try all Graphics calls here */
1588 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1589 expect(ObjectBusy
, status
);
1590 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1591 expect(ObjectBusy
, status
);
1592 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1593 expect(ObjectBusy
, status
);
1594 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1595 expect(ObjectBusy
, status
);
1596 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1597 expect(ObjectBusy
, status
);
1598 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1599 expect(ObjectBusy
, status
);
1600 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1601 expect(ObjectBusy
, status
);
1602 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1603 expect(ObjectBusy
, status
);
1604 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1605 expect(ObjectBusy
, status
);
1606 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1607 expect(ObjectBusy
, status
);
1608 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1609 expect(ObjectBusy
, status
);
1610 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1611 expect(ObjectBusy
, status
);
1612 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1613 expect(ObjectBusy
, status
);
1614 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1615 expect(ObjectBusy
, status
);
1616 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1617 expect(ObjectBusy
, status
);
1618 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1619 expect(ObjectBusy
, status
);
1620 /* GdipDrawImage/GdipDrawImageI */
1621 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1622 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1623 /* GdipDrawImageRect/GdipDrawImageRectI */
1624 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1625 expect(ObjectBusy
, status
);
1626 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1627 expect(ObjectBusy
, status
);
1628 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1629 expect(ObjectBusy
, status
);
1630 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1631 expect(ObjectBusy
, status
);
1632 status
= GdipDrawPath(graphics
, pen
, path
);
1633 expect(ObjectBusy
, status
);
1634 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1635 expect(ObjectBusy
, status
);
1636 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1637 expect(ObjectBusy
, status
);
1638 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1639 expect(ObjectBusy
, status
);
1640 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1641 expect(ObjectBusy
, status
);
1642 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1643 expect(ObjectBusy
, status
);
1644 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1645 expect(ObjectBusy
, status
);
1646 /* GdipDrawString */
1647 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1648 expect(ObjectBusy
, status
);
1649 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1650 expect(ObjectBusy
, status
);
1651 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1652 expect(ObjectBusy
, status
);
1653 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1654 expect(ObjectBusy
, status
);
1655 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1656 expect(ObjectBusy
, status
);
1657 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1658 expect(ObjectBusy
, status
);
1659 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1660 expect(ObjectBusy
, status
);
1661 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1662 expect(ObjectBusy
, status
);
1663 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1664 expect(ObjectBusy
, status
);
1665 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1666 expect(ObjectBusy
, status
);
1667 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1668 expect(ObjectBusy
, status
);
1669 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1670 expect(ObjectBusy
, status
);
1671 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1672 expect(ObjectBusy
, status
);
1673 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1674 expect(ObjectBusy
, status
);
1675 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1676 expect(ObjectBusy
, status
);
1677 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1678 expect(ObjectBusy
, status
);
1679 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1680 expect(ObjectBusy
, status
);
1681 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1682 expect(ObjectBusy
, status
);
1683 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1684 expect(ObjectBusy
, status
);
1685 status
= GdipGetClipBounds(graphics
, rectf
);
1686 expect(ObjectBusy
, status
);
1687 status
= GdipGetClipBoundsI(graphics
, rect
);
1688 expect(ObjectBusy
, status
);
1689 status
= GdipGetCompositingMode(graphics
, &compmode
);
1690 expect(ObjectBusy
, status
);
1691 status
= GdipGetCompositingQuality(graphics
, &quality
);
1692 expect(ObjectBusy
, status
);
1693 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1694 expect(ObjectBusy
, status
);
1695 status
= GdipGetNearestColor(graphics
, &color
);
1696 expect(ObjectBusy
, status
);
1697 status
= GdipGetPageScale(graphics
, &r
);
1698 expect(ObjectBusy
, status
);
1699 status
= GdipGetPageUnit(graphics
, &unit
);
1700 expect(ObjectBusy
, status
);
1701 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1702 expect(ObjectBusy
, status
);
1703 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1704 expect(ObjectBusy
, status
);
1705 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1706 expect(ObjectBusy
, status
);
1707 status
= GdipGetWorldTransform(graphics
, m
);
1708 expect(ObjectBusy
, status
);
1709 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1710 expect(ObjectBusy
, status
);
1711 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1712 expect(ObjectBusy
, status
);
1713 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1714 expect(ObjectBusy
, status
);
1715 /* GdipMeasureCharacterRanges */
1716 /* GdipMeasureString */
1717 status
= GdipResetClip(graphics
);
1718 expect(ObjectBusy
, status
);
1719 status
= GdipResetWorldTransform(graphics
);
1720 expect(ObjectBusy
, status
);
1721 /* GdipRestoreGraphics */
1722 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1723 expect(ObjectBusy
, status
);
1724 /* GdipSaveGraphics */
1725 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1726 expect(ObjectBusy
, status
);
1727 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1728 expect(ObjectBusy
, status
);
1729 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1730 expect(ObjectBusy
, status
);
1731 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1732 expect(ObjectBusy
, status
);
1733 status
= GdipSetPageScale(graphics
, 1.0);
1734 expect(ObjectBusy
, status
);
1735 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1736 expect(ObjectBusy
, status
);
1737 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1738 expect(ObjectBusy
, status
);
1739 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1740 expect(ObjectBusy
, status
);
1741 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1742 expect(ObjectBusy
, status
);
1743 status
= GdipSetWorldTransform(graphics
, m
);
1744 expect(ObjectBusy
, status
);
1745 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1746 expect(ObjectBusy
, status
);
1747 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1748 expect(ObjectBusy
, status
);
1749 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1750 expect(ObjectBusy
, status
);
1751 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1752 expect(ObjectBusy
, status
);
1753 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1754 expect(ObjectBusy
, status
);
1755 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1756 expect(ObjectBusy
, status
);
1757 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1758 expect(ObjectBusy
, status
);
1759 status
= GdipTranslateClipI(graphics
, 0, 0);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1764 expect(ObjectBusy
, status
);
1765 status
= GdipGetDpiX(graphics
, &r
);
1766 expect(ObjectBusy
, status
);
1767 status
= GdipGetDpiY(graphics
, &r
);
1768 expect(ObjectBusy
, status
);
1769 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1770 expect(ObjectBusy
, status
);
1771 status
= GdipGetClip(graphics
, region
);
1772 expect(ObjectBusy
, status
);
1773 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1774 expect(ObjectBusy
, status
);
1776 /* try to delete before release */
1777 status
= GdipDeleteGraphics(graphics
);
1778 expect(ObjectBusy
, status
);
1780 status
= GdipReleaseDC(graphics
, retdc
);
1784 GdipDeleteGraphics(graphics
);
1786 GdipDeleteRegion(clip
);
1787 GdipDeletePath(path
);
1788 GdipDeleteBrush((GpBrush
*)brush
);
1789 GdipDeleteRegion(region
);
1790 GdipDeleteMatrix(m
);
1793 ReleaseDC(hwnd
, hdc
);
1796 static void test_transformpoints(void)
1799 GpGraphics
*graphics
= NULL
;
1800 HDC hdc
= GetDC( hwnd
);
1804 status
= GdipCreateFromHDC(hdc
, &graphics
);
1807 /* NULL arguments */
1808 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1809 expect(InvalidParameter
, status
);
1810 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1811 expect(InvalidParameter
, status
);
1812 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1813 expect(InvalidParameter
, status
);
1814 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1815 expect(InvalidParameter
, status
);
1821 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1823 expectf(1.0, ptf
[0].X
);
1824 expectf(0.0, ptf
[0].Y
);
1825 expectf(0.0, ptf
[1].X
);
1826 expectf(1.0, ptf
[1].Y
);
1828 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1830 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1832 status
= GdipSetPageScale(graphics
, 3.0);
1839 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1841 expectf(18.0, ptf
[0].X
);
1842 expectf(15.0, ptf
[0].Y
);
1843 expectf(15.0, ptf
[1].X
);
1844 expectf(18.0, ptf
[1].Y
);
1850 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1852 expectf(6.0, ptf
[0].X
);
1853 expectf(5.0, ptf
[0].Y
);
1854 expectf(5.0, ptf
[1].X
);
1855 expectf(6.0, ptf
[1].Y
);
1861 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1863 expectf(3.0, ptf
[0].X
);
1864 expectf(0.0, ptf
[0].Y
);
1865 expectf(0.0, ptf
[1].X
);
1866 expectf(3.0, ptf
[1].Y
);
1872 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1874 expectf(1.0, ptf
[0].X
);
1875 expectf(0.0, ptf
[0].Y
);
1876 expectf(0.0, ptf
[1].X
);
1877 expectf(1.0, ptf
[1].Y
);
1883 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1885 expectf(1.0, ptf
[0].X
);
1886 expectf(0.0, ptf
[0].Y
);
1887 expectf(0.0, ptf
[1].X
);
1888 expectf(1.0, ptf
[1].Y
);
1894 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1896 expectf(1.0, ptf
[0].X
);
1897 expectf(0.0, ptf
[0].Y
);
1898 expectf(0.0, ptf
[1].X
);
1899 expectf(1.0, ptf
[1].Y
);
1905 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1907 expect(18, pt
[0].X
);
1908 expect(15, pt
[0].Y
);
1909 expect(15, pt
[1].X
);
1910 expect(18, pt
[1].Y
);
1912 GdipDeleteGraphics(graphics
);
1913 ReleaseDC(hwnd
, hdc
);
1916 static void test_get_set_clip(void)
1919 GpGraphics
*graphics
= NULL
;
1920 HDC hdc
= GetDC( hwnd
);
1925 status
= GdipCreateFromHDC(hdc
, &graphics
);
1928 rect
.X
= rect
.Y
= 0.0;
1929 rect
.Height
= rect
.Width
= 100.0;
1931 status
= GdipCreateRegionRect(&rect
, &clip
);
1934 /* NULL arguments */
1935 status
= GdipGetClip(NULL
, NULL
);
1936 expect(InvalidParameter
, status
);
1937 status
= GdipGetClip(graphics
, NULL
);
1938 expect(InvalidParameter
, status
);
1939 status
= GdipGetClip(NULL
, clip
);
1940 expect(InvalidParameter
, status
);
1942 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1943 expect(InvalidParameter
, status
);
1944 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1945 expect(InvalidParameter
, status
);
1947 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1948 expect(InvalidParameter
, status
);
1949 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1950 expect(InvalidParameter
, status
);
1953 status
= GdipGetClip(graphics
, clip
);
1955 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1959 /* remains infinite after reset */
1961 status
= GdipResetClip(graphics
);
1963 status
= GdipGetClip(graphics
, clip
);
1965 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1969 /* set to empty and then reset to infinite */
1970 status
= GdipSetEmpty(clip
);
1972 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1975 status
= GdipGetClip(graphics
, clip
);
1978 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1981 status
= GdipResetClip(graphics
);
1983 status
= GdipGetClip(graphics
, clip
);
1986 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1990 GdipDeleteRegion(clip
);
1992 GdipDeleteGraphics(graphics
);
1993 ReleaseDC(hwnd
, hdc
);
1996 static void test_isempty(void)
1999 GpGraphics
*graphics
= NULL
;
2000 HDC hdc
= GetDC( hwnd
);
2004 status
= GdipCreateFromHDC(hdc
, &graphics
);
2007 status
= GdipCreateRegion(&clip
);
2011 status
= GdipIsClipEmpty(NULL
, NULL
);
2012 expect(InvalidParameter
, status
);
2013 status
= GdipIsClipEmpty(graphics
, NULL
);
2014 expect(InvalidParameter
, status
);
2015 status
= GdipIsClipEmpty(NULL
, &res
);
2016 expect(InvalidParameter
, status
);
2018 /* default is infinite */
2020 status
= GdipIsClipEmpty(graphics
, &res
);
2024 GdipDeleteRegion(clip
);
2026 GdipDeleteGraphics(graphics
);
2027 ReleaseDC(hwnd
, hdc
);
2030 static void test_clear(void)
2034 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2035 expect(InvalidParameter
, status
);
2038 static void test_textcontrast(void)
2041 HDC hdc
= GetDC( hwnd
);
2042 GpGraphics
*graphics
;
2045 status
= GdipGetTextContrast(NULL
, NULL
);
2046 expect(InvalidParameter
, status
);
2048 status
= GdipCreateFromHDC(hdc
, &graphics
);
2051 status
= GdipGetTextContrast(graphics
, NULL
);
2052 expect(InvalidParameter
, status
);
2053 status
= GdipGetTextContrast(graphics
, &contrast
);
2055 expect(4, contrast
);
2057 GdipDeleteGraphics(graphics
);
2058 ReleaseDC(hwnd
, hdc
);
2061 static void test_GdipDrawString(void)
2064 GpGraphics
*graphics
= NULL
;
2067 GpStringFormat
*format
;
2070 HDC hdc
= GetDC( hwnd
);
2071 static const WCHAR string
[] = {'T','e','s','t',0};
2072 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2075 memset(&logfont
,0,sizeof(logfont
));
2076 strcpy(logfont
.lfFaceName
,"Arial");
2077 logfont
.lfHeight
= 12;
2078 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2080 status
= GdipCreateFromHDC(hdc
, &graphics
);
2083 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2084 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2086 skip("Arial not installed.\n");
2091 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2094 status
= GdipCreateStringFormat(0,0,&format
);
2102 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2105 status
= GdipCreateMatrix(&matrix
);
2108 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2109 expect(InvalidParameter
, status
);
2111 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2112 expect(InvalidParameter
, status
);
2114 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2115 expect(InvalidParameter
, status
);
2117 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2118 expect(InvalidParameter
, status
);
2120 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2121 expect(InvalidParameter
, status
);
2123 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2126 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2129 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2132 GdipDeleteMatrix(matrix
);
2133 GdipDeleteGraphics(graphics
);
2134 GdipDeleteBrush(brush
);
2135 GdipDeleteFont(fnt
);
2136 GdipDeleteStringFormat(format
);
2138 ReleaseDC(hwnd
, hdc
);
2141 static void test_GdipGetVisibleClipBounds_screen(void)
2144 GpGraphics
*graphics
= NULL
;
2146 GpRectF rectf
, exp
, clipr
;
2149 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2151 status
= GdipCreateFromHDC(hdc
, &graphics
);
2153 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2155 /* no clipping rect */
2158 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2159 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2161 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2163 ok(rectf
.X
== exp
.X
&&
2165 rectf
.Width
== exp
.Width
&&
2166 rectf
.Height
== exp
.Height
,
2167 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2168 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2169 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2170 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2172 /* clipping rect entirely within window */
2173 exp
.X
= clipr
.X
= 10;
2174 exp
.Y
= clipr
.Y
= 12;
2175 exp
.Width
= clipr
.Width
= 14;
2176 exp
.Height
= clipr
.Height
= 16;
2178 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2181 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2183 ok(rectf
.X
== exp
.X
&&
2185 rectf
.Width
== exp
.Width
&&
2186 rectf
.Height
== exp
.Height
,
2187 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2188 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2189 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2190 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2192 /* clipping rect partially outside of screen */
2198 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2206 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2208 ok(rectf
.X
== exp
.X
&&
2210 rectf
.Width
== exp
.Width
&&
2211 rectf
.Height
== exp
.Height
,
2212 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2213 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2214 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2215 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2217 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2219 ok(recti
.X
== exp
.X
&&
2221 recti
.Width
== exp
.Width
&&
2222 recti
.Height
== exp
.Height
,
2223 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2224 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2225 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2226 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2228 GdipDeleteGraphics(graphics
);
2232 static void test_GdipGetVisibleClipBounds_window(void)
2235 GpGraphics
*graphics
= NULL
;
2236 GpRectF rectf
, window
, exp
, clipr
;
2242 /* get client area size */
2243 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2244 window
.X
= wnd_rect
.left
;
2245 window
.Y
= wnd_rect
.top
;
2246 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2247 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2249 hdc
= BeginPaint(hwnd
, &ps
);
2251 status
= GdipCreateFromHDC(hdc
, &graphics
);
2253 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2255 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2257 ok(rectf
.X
== window
.X
&&
2258 rectf
.Y
== window
.Y
&&
2259 rectf
.Width
== window
.Width
&&
2260 rectf
.Height
== window
.Height
,
2261 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2262 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2263 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2264 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2266 /* clipping rect entirely within window */
2267 exp
.X
= clipr
.X
= 20;
2268 exp
.Y
= clipr
.Y
= 8;
2269 exp
.Width
= clipr
.Width
= 30;
2270 exp
.Height
= clipr
.Height
= 20;
2272 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2275 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2277 ok(rectf
.X
== exp
.X
&&
2279 rectf
.Width
== exp
.Width
&&
2280 rectf
.Height
== exp
.Height
,
2281 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2282 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2283 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2284 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2286 /* clipping rect partially outside of window */
2287 clipr
.X
= window
.Width
- 10;
2288 clipr
.Y
= window
.Height
- 15;
2292 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2295 exp
.X
= window
.Width
- 10;
2296 exp
.Y
= window
.Height
- 15;
2300 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2302 ok(rectf
.X
== exp
.X
&&
2304 rectf
.Width
== exp
.Width
&&
2305 rectf
.Height
== exp
.Height
,
2306 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2307 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2308 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2309 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2311 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2313 ok(recti
.X
== exp
.X
&&
2315 recti
.Width
== exp
.Width
&&
2316 recti
.Height
== exp
.Height
,
2317 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2318 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2319 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2320 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2322 GdipDeleteGraphics(graphics
);
2323 EndPaint(hwnd
, &ps
);
2326 static void test_GdipGetVisibleClipBounds(void)
2328 GpGraphics
* graphics
= NULL
;
2331 HDC hdc
= GetDC( hwnd
);
2334 status
= GdipCreateFromHDC(hdc
, &graphics
);
2336 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2338 /* test null parameters */
2339 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2340 expect(InvalidParameter
, status
);
2342 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2343 expect(InvalidParameter
, status
);
2345 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2346 expect(InvalidParameter
, status
);
2348 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2349 expect(InvalidParameter
, status
);
2351 GdipDeleteGraphics(graphics
);
2352 ReleaseDC(hwnd
, hdc
);
2354 test_GdipGetVisibleClipBounds_screen();
2355 test_GdipGetVisibleClipBounds_window();
2358 static void test_fromMemoryBitmap(void)
2361 GpGraphics
*graphics
= NULL
;
2362 GpBitmap
*bitmap
= NULL
;
2363 BYTE bits
[48] = {0};
2367 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2370 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2373 status
= GdipGraphicsClear(graphics
, 0xff686868);
2376 GdipDeleteGraphics(graphics
);
2378 /* drawing writes to the memory provided */
2379 expect(0x68, bits
[10]);
2381 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2384 status
= GdipGetDC(graphics
, &hdc
);
2386 ok(hdc
!= NULL
, "got NULL hdc\n");
2388 color
= GetPixel(hdc
, 0, 0);
2389 /* The HDC is write-only, and native fills with a solid color to figure out
2390 * which pixels have changed. */
2391 todo_wine
expect(0x0c0b0d, color
);
2393 SetPixel(hdc
, 0, 0, 0x797979);
2394 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2396 status
= GdipReleaseDC(graphics
, hdc
);
2399 GdipDeleteGraphics(graphics
);
2401 expect(0x79, bits
[0]);
2402 todo_wine
expect(0x68, bits
[3]);
2404 GdipDisposeImage((GpImage
*)bitmap
);
2406 /* We get the same kind of write-only HDC for a "normal" bitmap */
2407 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2410 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2413 status
= GdipGetDC(graphics
, &hdc
);
2415 ok(hdc
!= NULL
, "got NULL hdc\n");
2417 color
= GetPixel(hdc
, 0, 0);
2418 todo_wine
expect(0x0c0b0d, color
);
2420 status
= GdipReleaseDC(graphics
, hdc
);
2423 GdipDeleteGraphics(graphics
);
2425 GdipDisposeImage((GpImage
*)bitmap
);
2428 static void test_GdipIsVisiblePoint(void)
2431 GpGraphics
*graphics
= NULL
;
2432 HDC hdc
= GetDC( hwnd
);
2436 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2438 status
= GdipCreateFromHDC(hdc
, &graphics
);
2440 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2442 /* null parameters */
2443 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2444 expect(InvalidParameter
, status
);
2446 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2447 expect(InvalidParameter
, status
);
2449 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2450 expect(InvalidParameter
, status
);
2452 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2453 expect(InvalidParameter
, status
);
2457 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2459 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2463 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2465 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2469 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2471 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2475 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2477 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2479 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2484 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2486 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2490 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2492 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2494 /* translate into the center of the rect */
2495 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2499 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2501 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2505 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2507 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2509 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2514 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2516 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2520 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2522 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2526 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2528 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2532 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2534 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2538 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2540 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2544 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2546 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2550 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2552 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2556 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2558 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2562 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2564 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2568 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2570 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2574 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2576 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2580 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2582 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2586 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2588 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2590 /* integer version */
2593 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2595 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2599 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2601 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2603 GdipDeleteGraphics(graphics
);
2604 ReleaseDC(hwnd
, hdc
);
2607 static void test_GdipIsVisibleRect(void)
2610 GpGraphics
*graphics
= NULL
;
2611 HDC hdc
= GetDC( hwnd
);
2612 REAL x
, y
, width
, height
;
2615 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2617 status
= GdipCreateFromHDC(hdc
, &graphics
);
2619 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2621 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2622 expect(InvalidParameter
, status
);
2624 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2625 expect(InvalidParameter
, status
);
2627 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2628 expect(InvalidParameter
, status
);
2630 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2631 expect(InvalidParameter
, status
);
2633 /* entirely within the visible region */
2636 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2638 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2640 /* partially outside */
2641 x
= -10; width
= 20;
2642 y
= -10; height
= 20;
2643 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2645 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2647 /* entirely outside */
2649 y
= -10; height
= 5;
2650 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2652 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2654 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2657 /* entirely within the visible region */
2659 y
= 22; height
= 10;
2660 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2662 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2664 /* partially outside */
2666 y
= 55; height
= 10;
2667 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2669 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2671 /* entirely outside */
2674 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2676 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2678 /* translate into center of clipping rect */
2679 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2683 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2685 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2689 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2691 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2693 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2695 /* corners entirely outside, but some intersections */
2698 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2700 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2704 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2706 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2710 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2712 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2716 y
= 20; height
= 40;
2717 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2719 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2723 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2725 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2728 y
= 20; height
= 40;
2729 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2731 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2734 y
= 60; height
= 10;
2735 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2737 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2739 /* rounding tests */
2740 x
= 0.4; width
= 10.4;
2741 y
= 20; height
= 40;
2742 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2744 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2747 y
= 0.4; height
= 20.4;
2748 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2750 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2752 /* integer version */
2755 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2757 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2760 y
= 22; height
= 10;
2761 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2763 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2765 GdipDeleteGraphics(graphics
);
2766 ReleaseDC(hwnd
, hdc
);
2769 static void test_GdipGetNearestColor(void)
2772 GpGraphics
*graphics
;
2774 ARGB color
= 0xdeadbeef;
2775 HDC hdc
= GetDC( hwnd
);
2777 /* create a graphics object */
2778 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2780 status
= GdipCreateFromHDC(hdc
, &graphics
);
2782 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2784 status
= GdipGetNearestColor(graphics
, NULL
);
2785 expect(InvalidParameter
, status
);
2787 status
= GdipGetNearestColor(NULL
, &color
);
2788 expect(InvalidParameter
, status
);
2789 GdipDeleteGraphics(graphics
);
2791 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2793 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2794 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2797 status
= GdipGetNearestColor(graphics
, &color
);
2799 expect(0xdeadbeef, color
);
2800 GdipDeleteGraphics(graphics
);
2802 GdipDisposeImage((GpImage
*)bitmap
);
2804 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2806 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2807 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2810 status
= GdipGetNearestColor(graphics
, &color
);
2812 expect(0xdeadbeef, color
);
2813 GdipDeleteGraphics(graphics
);
2815 GdipDisposeImage((GpImage
*)bitmap
);
2817 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2819 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2820 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2823 status
= GdipGetNearestColor(graphics
, &color
);
2825 expect(0xdeadbeef, color
);
2826 GdipDeleteGraphics(graphics
);
2828 GdipDisposeImage((GpImage
*)bitmap
);
2830 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2832 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2833 todo_wine
expect(OutOfMemory
, status
);
2835 GdipDeleteGraphics(graphics
);
2836 GdipDisposeImage((GpImage
*)bitmap
);
2838 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2840 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2842 status
= GdipGetNearestColor(graphics
, &color
);
2844 expect(0xdeadbeef, color
);
2845 GdipDeleteGraphics(graphics
);
2846 GdipDisposeImage((GpImage
*)bitmap
);
2848 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2850 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2852 status
= GdipGetNearestColor(graphics
, &color
);
2854 expect(0xdeadbeef, color
);
2855 GdipDeleteGraphics(graphics
);
2856 GdipDisposeImage((GpImage
*)bitmap
);
2858 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2860 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2862 status
= GdipGetNearestColor(graphics
, &color
);
2864 expect(0xdeadbeef, color
);
2865 GdipDeleteGraphics(graphics
);
2866 GdipDisposeImage((GpImage
*)bitmap
);
2868 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2872 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2874 status
= GdipGetNearestColor(graphics
, &color
);
2876 expect(0xdeadbeef, color
);
2877 GdipDeleteGraphics(graphics
);
2878 GdipDisposeImage((GpImage
*)bitmap
);
2881 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2885 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2887 status
= GdipGetNearestColor(graphics
, &color
);
2889 expect(0xdeadbeef, color
);
2890 GdipDeleteGraphics(graphics
);
2891 GdipDisposeImage((GpImage
*)bitmap
);
2894 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2898 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2900 status
= GdipGetNearestColor(graphics
, &color
);
2902 expect(0xdeadbeef, color
);
2903 GdipDeleteGraphics(graphics
);
2904 GdipDisposeImage((GpImage
*)bitmap
);
2907 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2909 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2911 status
= GdipGetNearestColor(graphics
, &color
);
2913 todo_wine
expect(0xffa8bce8, color
);
2914 GdipDeleteGraphics(graphics
);
2915 GdipDisposeImage((GpImage
*)bitmap
);
2917 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2919 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2921 status
= GdipGetNearestColor(graphics
, &color
);
2924 ok(color
== 0xffa8b8e8 ||
2925 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2926 "Expected ffa8b8e8, got %.8x\n", color
);
2927 GdipDeleteGraphics(graphics
);
2928 GdipDisposeImage((GpImage
*)bitmap
);
2930 ReleaseDC(hwnd
, hdc
);
2933 static void test_string_functions(void)
2936 GpGraphics
*graphics
;
2937 GpFontFamily
*family
;
2939 RectF rc
, char_bounds
, bounds
;
2941 ARGB color
= 0xff000000;
2942 HDC hdc
= GetDC( hwnd
);
2943 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2944 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2945 const WCHAR teststring2
[] = {'j',0};
2946 REAL char_width
, char_height
;
2947 INT codepointsfitted
, linesfilled
;
2948 GpStringFormat
*format
;
2949 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2950 GpRegion
*regions
[4];
2951 BOOL region_isempty
[4];
2953 PointF positions
[8];
2956 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2957 status
= GdipCreateFromHDC(hdc
, &graphics
);
2959 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2961 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2964 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2967 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2970 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2978 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2979 expect(InvalidParameter
, status
);
2981 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2982 expect(InvalidParameter
, status
);
2984 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2985 expect(InvalidParameter
, status
);
2987 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2988 expect(InvalidParameter
, status
);
2990 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2991 expect(InvalidParameter
, status
);
2993 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
2996 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2997 expect(InvalidParameter
, status
);
2999 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3000 expect(InvalidParameter
, status
);
3002 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3003 expect(InvalidParameter
, status
);
3005 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3006 expect(InvalidParameter
, status
);
3008 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3009 expect(InvalidParameter
, status
);
3011 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3014 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3017 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3019 expectf(0.0, char_bounds
.X
);
3020 expectf(0.0, char_bounds
.Y
);
3021 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3022 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3023 expect(1, codepointsfitted
);
3024 expect(1, linesfilled
);
3026 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3028 expectf(0.0, bounds
.X
);
3029 expectf(0.0, bounds
.Y
);
3030 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3031 expectf(char_bounds
.Height
, bounds
.Height
);
3032 expect(2, codepointsfitted
);
3033 expect(1, linesfilled
);
3034 char_width
= bounds
.Width
- char_bounds
.Width
;
3036 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3038 expectf(0.0, bounds
.X
);
3039 expectf(0.0, bounds
.Y
);
3040 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3041 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3042 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3043 expect(6, codepointsfitted
);
3044 expect(2, linesfilled
);
3045 char_height
= bounds
.Height
- char_bounds
.Height
;
3047 /* Measure the first line. */
3048 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3050 expectf(0.0, bounds
.X
);
3051 expectf(0.0, bounds
.Y
);
3052 expect(4, codepointsfitted
);
3053 expect(1, linesfilled
);
3055 /* Give just enough space to fit the first line. */
3056 rc
.Width
= bounds
.Width
;
3057 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3059 expectf(0.0, bounds
.X
);
3060 expectf(0.0, bounds
.Y
);
3061 todo_wine
expect(5, codepointsfitted
);
3062 todo_wine
expect(1, linesfilled
);
3064 /* Cut off everything after the first space. */
3065 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3067 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3069 expectf(0.0, bounds
.X
);
3070 expectf(0.0, bounds
.Y
);
3071 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3072 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3073 expect(6, codepointsfitted
);
3074 expect(3, linesfilled
);
3076 /* Cut off everything including the first space. */
3077 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3079 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3081 expectf(0.0, bounds
.X
);
3082 expectf(0.0, bounds
.Y
);
3083 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3084 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3085 expect(6, codepointsfitted
);
3086 expect(3, linesfilled
);
3088 /* Cut off everything after the first character. */
3089 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3091 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3093 expectf(0.0, bounds
.X
);
3094 expectf(0.0, bounds
.Y
);
3095 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3096 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3097 expect(6, codepointsfitted
);
3098 todo_wine
expect(4, linesfilled
);
3100 for (i
= 0; i
< 4; i
++)
3101 regions
[i
] = (GpRegion
*)0xdeadbeef;
3103 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3106 for (i
= 0; i
< 4; i
++)
3107 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3109 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3112 for (i
= 0; i
< 4; i
++)
3113 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3115 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3118 set_rect_empty(&rc
);
3122 status
= GdipCreateRegion(®ions
[i
]);
3124 status
= GdipSetEmpty(regions
[i
]);
3128 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3129 expect(InvalidParameter
, status
);
3131 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3132 expect(InvalidParameter
, status
);
3134 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3135 expect(InvalidParameter
, status
);
3137 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3138 expect(InvalidParameter
, status
);
3142 /* Crashes on Windows XP */
3143 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3144 expect(InvalidParameter
, status
);
3147 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3148 expect(InvalidParameter
, status
);
3150 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3151 expect(InvalidParameter
, status
);
3153 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3156 for (i
= 0; i
< 4; i
++)
3158 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3162 ok(region_isempty
[0], "region should be empty\n");
3163 ok(region_isempty
[1], "region should be empty\n");
3164 ok(region_isempty
[2], "region should be empty\n");
3165 ok(region_isempty
[3], "region should be empty\n");
3170 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3175 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3179 ok(!region_isempty
[0], "region shouldn't be empty\n");
3180 ok(!region_isempty
[1], "region shouldn't be empty\n");
3181 ok(!region_isempty
[2], "region shouldn't be empty\n");
3182 ok(region_isempty
[3], "region should be empty\n");
3184 /* Cut off everything after the first space, and the second line. */
3185 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3186 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3188 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3193 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3197 ok(!region_isempty
[0], "region shouldn't be empty\n");
3198 ok(!region_isempty
[1], "region shouldn't be empty\n");
3199 ok(region_isempty
[2], "region should be empty\n");
3200 ok(region_isempty
[3], "region should be empty\n");
3203 GdipDeleteRegion(regions
[i
]);
3205 status
= GdipCreateMatrix(&identity
);
3212 memset(positions
, 0, sizeof(positions
));
3213 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3214 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3216 expect(InvalidParameter
, status
);
3218 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3219 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3221 expect(InvalidParameter
, status
);
3223 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3224 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3226 expect(InvalidParameter
, status
);
3228 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3229 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3231 expect(InvalidParameter
, status
);
3233 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3234 0x100, identity
, &rc
);
3237 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3238 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3242 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3243 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3245 expect(InvalidParameter
, status
);
3251 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3252 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3257 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3258 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3259 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3261 char_width
= rc
.Width
;
3262 char_height
= rc
.Height
;
3268 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3269 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3274 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3275 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3276 expectf(char_height
, rc
.Height
);
3282 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3283 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3288 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3289 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3290 expectf(rc
.Height
, char_height
);
3292 GdipDeleteMatrix(identity
);
3293 GdipDeleteStringFormat(format
);
3294 GdipDeleteBrush(brush
);
3295 GdipDeleteFont(font
);
3296 GdipDeleteFontFamily(family
);
3297 GdipDeleteGraphics(graphics
);
3299 ReleaseDC(hwnd
, hdc
);
3302 static void test_get_set_interpolation(void)
3304 GpGraphics
*graphics
;
3305 HDC hdc
= GetDC( hwnd
);
3307 InterpolationMode mode
;
3309 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3310 status
= GdipCreateFromHDC(hdc
, &graphics
);
3312 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3314 status
= GdipGetInterpolationMode(NULL
, &mode
);
3315 expect(InvalidParameter
, status
);
3319 /* Crashes on Windows XP */
3320 status
= GdipGetInterpolationMode(graphics
, NULL
);
3321 expect(InvalidParameter
, status
);
3324 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3325 expect(InvalidParameter
, status
);
3328 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3329 expect(InvalidParameter
, status
);
3331 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3332 expect(InvalidParameter
, status
);
3334 status
= GdipGetInterpolationMode(graphics
, &mode
);
3336 expect(InterpolationModeBilinear
, mode
);
3338 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3341 status
= GdipGetInterpolationMode(graphics
, &mode
);
3343 expect(InterpolationModeNearestNeighbor
, mode
);
3345 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3348 status
= GdipGetInterpolationMode(graphics
, &mode
);
3350 expect(InterpolationModeBilinear
, mode
);
3352 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3355 status
= GdipGetInterpolationMode(graphics
, &mode
);
3357 expect(InterpolationModeBilinear
, mode
);
3359 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3362 status
= GdipGetInterpolationMode(graphics
, &mode
);
3364 expect(InterpolationModeHighQualityBicubic
, mode
);
3366 GdipDeleteGraphics(graphics
);
3368 ReleaseDC(hwnd
, hdc
);
3371 static void test_get_set_textrenderinghint(void)
3373 GpGraphics
*graphics
;
3374 HDC hdc
= GetDC( hwnd
);
3376 TextRenderingHint hint
;
3378 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3379 status
= GdipCreateFromHDC(hdc
, &graphics
);
3381 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3383 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3384 expect(InvalidParameter
, status
);
3386 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3387 expect(InvalidParameter
, status
);
3389 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3390 expect(InvalidParameter
, status
);
3393 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3394 expect(InvalidParameter
, status
);
3396 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3398 expect(TextRenderingHintSystemDefault
, hint
);
3400 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3403 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3405 expect(TextRenderingHintSystemDefault
, hint
);
3407 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3410 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3412 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3414 GdipDeleteGraphics(graphics
);
3416 ReleaseDC(hwnd
, hdc
);
3419 static void test_getdc_scaled(void)
3422 GpGraphics
*graphics
= NULL
;
3423 GpBitmap
*bitmap
= NULL
;
3425 HBRUSH hbrush
, holdbrush
;
3428 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3431 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3434 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3437 status
= GdipGetDC(graphics
, &hdc
);
3439 ok(hdc
!= NULL
, "got NULL hdc\n");
3441 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3443 holdbrush
= SelectObject(hdc
, hbrush
);
3445 Rectangle(hdc
, 2, 2, 6, 6);
3447 SelectObject(hdc
, holdbrush
);
3449 DeleteObject(hbrush
);
3451 status
= GdipReleaseDC(graphics
, hdc
);
3454 GdipDeleteGraphics(graphics
);
3456 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3458 expect(0xffff0000, color
);
3460 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3462 expect(0xff000000, color
);
3464 GdipDisposeImage((GpImage
*)bitmap
);
3467 static void test_GdipMeasureString(void)
3469 static const struct test_data
3471 REAL res_x
, res_y
, page_scale
;
3475 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3476 { 200.0, 200.0, 2.0, UnitPixel
},
3477 { 200.0, 200.0, 1.0, UnitDisplay
},
3478 { 200.0, 200.0, 2.0, UnitDisplay
},
3479 { 200.0, 200.0, 1.0, UnitInch
},
3480 { 200.0, 200.0, 2.0, UnitInch
},
3481 { 200.0, 600.0, 1.0, UnitPoint
},
3482 { 200.0, 600.0, 2.0, UnitPoint
},
3483 { 200.0, 600.0, 1.0, UnitDocument
},
3484 { 200.0, 600.0, 2.0, UnitDocument
},
3485 { 200.0, 600.0, 1.0, UnitMillimeter
},
3486 { 200.0, 600.0, 2.0, UnitMillimeter
},
3487 { 200.0, 600.0, 1.0, UnitDisplay
},
3488 { 200.0, 600.0, 2.0, UnitDisplay
},
3489 { 200.0, 600.0, 1.0, UnitPixel
},
3490 { 200.0, 600.0, 2.0, UnitPixel
},
3492 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3493 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3495 GpGraphics
*graphics
;
3496 GpFontFamily
*family
;
3498 GpStringFormat
*format
;
3500 REAL base_cx
= 0, base_cy
= 0, height
;
3505 GpUnit font_unit
, unit
;
3507 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3509 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3512 /* font size in pixels */
3513 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3515 status
= GdipGetFontSize(font
, &font_size
);
3517 expectf(100.0, font_size
);
3518 status
= GdipGetFontUnit(font
, &font_unit
);
3520 expect(UnitPixel
, font_unit
);
3522 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3526 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3528 lf
.lfHeight
= 0xdeadbeef;
3529 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3531 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3532 if (td
[i
].unit
!= UnitDisplay
)
3533 height
*= td
[i
].page_scale
;
3534 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3535 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3537 height
= font_size
+ 2.0 * font_size
/ 6.0;
3539 set_rect_empty(&rc
);
3540 set_rect_empty(&bounds
);
3541 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3546 base_cx
= bounds
.Width
;
3547 base_cy
= bounds
.Height
;
3550 expectf(0.0, bounds
.X
);
3551 expectf(0.0, bounds
.Y
);
3553 expectf_(height
, bounds
.Height
, height
/ 100.0);
3554 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3558 /* make sure it really fits */
3559 bounds
.Width
+= 1.0;
3560 bounds
.Height
+= 1.0;
3564 set_rect_empty(&bounds
);
3565 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3567 expectf(50.0, bounds
.X
);
3568 expectf(50.0, bounds
.Y
);
3570 expectf_(height
, bounds
.Height
, height
/ 100.0);
3571 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3575 status
= GdipDeleteGraphics(graphics
);
3578 status
= GdipDisposeImage(image
);
3582 GdipDeleteFont(font
);
3584 /* font size in logical units */
3585 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3586 for (unit
= 3; unit
<= 6; unit
++)
3588 /* create a font which final height is 100.0 pixels with 200 dpi device */
3589 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3590 height
= pixels_to_units(75.0, unit
, 200.0);
3591 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3593 status
= GdipGetFontSize(font
, &font_size
);
3595 expectf(height
, font_size
);
3596 status
= GdipGetFontUnit(font
, &font_unit
);
3598 expect(unit
, font_unit
);
3600 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3605 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3607 lf
.lfHeight
= 0xdeadbeef;
3608 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3610 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3611 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3613 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3614 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3615 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3616 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3618 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3619 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3621 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3622 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3623 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3624 if (td
[i
].unit
!= UnitDisplay
)
3625 height
/= td
[i
].page_scale
;
3626 /*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);*/
3628 set_rect_empty(&rc
);
3629 set_rect_empty(&bounds
);
3630 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3635 base_cx
= bounds
.Width
;
3636 base_cy
= bounds
.Height
;
3639 expectf(0.0, bounds
.X
);
3640 expectf(0.0, bounds
.Y
);
3642 expectf_(height
, bounds
.Height
, height
/ 85.0);
3643 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3647 /* make sure it really fits */
3648 bounds
.Width
+= 1.0;
3649 bounds
.Height
+= 1.0;
3653 set_rect_empty(&bounds
);
3654 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3656 expectf(50.0, bounds
.X
);
3657 expectf(50.0, bounds
.Y
);
3659 expectf_(height
, bounds
.Height
, height
/ 85.0);
3660 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3664 /* verify the result */
3665 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3666 if (td
[i
].unit
!= UnitDisplay
)
3667 height
*= td
[i
].page_scale
;
3668 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3669 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3671 expectf_(100.0, height
, 1.1);
3673 status
= GdipDeleteGraphics(graphics
);
3676 status
= GdipDisposeImage(image
);
3680 GdipDeleteFont(font
);
3683 GdipDeleteFontFamily(family
);
3684 GdipDeleteStringFormat(format
);
3687 static void test_transform(void)
3689 static const struct test_data
3691 REAL res_x
, res_y
, scale
;
3693 GpPointF in
[2], out
[2];
3696 { 96.0, 96.0, 1.0, UnitPixel
,
3697 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3698 { 96.0, 96.0, 1.0, UnitDisplay
,
3699 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3700 { 96.0, 96.0, 1.0, UnitInch
,
3701 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3702 { 123.0, 456.0, 1.0, UnitPoint
,
3703 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3704 { 123.0, 456.0, 1.0, UnitDocument
,
3705 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3706 { 123.0, 456.0, 2.0, UnitMillimeter
,
3707 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3708 { 196.0, 296.0, 1.0, UnitDisplay
,
3709 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3710 { 196.0, 296.0, 1.0, UnitPixel
,
3711 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3714 GpGraphics
*graphics
;
3719 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3721 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3722 ptf
[0].X
= td
[i
].in
[0].X
;
3723 ptf
[0].Y
= td
[i
].in
[0].Y
;
3724 ptf
[1].X
= td
[i
].in
[1].X
;
3725 ptf
[1].Y
= td
[i
].in
[1].Y
;
3726 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3728 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3729 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3730 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3731 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3732 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3734 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3735 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3736 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3737 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3738 status
= GdipDeleteGraphics(graphics
);
3740 status
= GdipDisposeImage(image
);
3745 /* Many people on the net ask why there is so much difference in rendered
3746 * text height between gdiplus and gdi32, this test suggests an answer to
3747 * that question. Important: this test assumes that font dpi == device dpi.
3749 static void test_font_height_scaling(void)
3751 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3752 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3754 GpStringFormat
*format
;
3755 CharacterRange range
= { 0, 7 };
3757 GpGraphics
*graphics
;
3758 GpFontFamily
*family
;
3762 REAL height
, dpi
, scale
;
3764 GpUnit gfx_unit
, font_unit
;
3766 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3768 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3770 status
= GdipCreateRegion(®ion
);
3773 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3776 hdc
= CreateCompatibleDC(0);
3777 status
= GdipCreateFromHDC(hdc
, &graphics
);
3780 status
= GdipGetDpiY(graphics
, &dpi
);
3783 /* First check if tested functionality works:
3784 * under XP if font and graphics units differ then GdipTransformPoints
3785 * followed by GdipSetPageUnit to change the graphics units breaks region
3786 * scaling in GdipMeasureCharacterRanges called later.
3788 status
= GdipSetPageUnit(graphics
, UnitDocument
);
3793 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3796 status
= GdipSetPageUnit(graphics
, UnitInch
);
3799 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
3802 set_rect_empty(&rect
);
3803 set_rect_empty(&bounds
);
3804 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3806 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
3808 set_rect_empty(&rect
);
3809 rect
.Width
= 32000.0;
3810 rect
.Height
= 32000.0;
3811 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3814 set_rect_empty(&rect
);
3815 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3817 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
3819 GdipDeleteFont(font
);
3821 scale
= rect
.Height
/ bounds
.Height
;
3822 if (fabs(scale
- 1.0) > 0.1)
3824 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
3828 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
3831 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3832 /* UnitPixel as a font base unit is not tested because it drastically
3833 differs in behaviour */
3834 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
3836 /* create a font for the final text height of 100 pixels */
3837 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3838 status
= GdipSetPageUnit(graphics
, font_unit
);
3842 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3845 /*trace("height %f units\n", height);*/
3846 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
3849 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3850 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
3852 static const WCHAR doubleW
[2] = { 'W','W' };
3853 RectF bounds_1
, bounds_2
;
3854 REAL margin
, margin_y
, font_height
;
3857 status
= GdipSetPageUnit(graphics
, gfx_unit
);
3860 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
3861 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
3863 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
3866 set_rect_empty(&rect
);
3867 set_rect_empty(&bounds
);
3868 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3870 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
3872 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
3875 ptf
.Y
= bounds
.Height
;
3876 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
3878 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3880 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3882 /* verify the result */
3883 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
3885 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3887 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3889 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
3890 set_rect_empty(&rect
);
3891 set_rect_empty(&bounds_1
);
3892 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
3894 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
3895 set_rect_empty(&rect
);
3896 set_rect_empty(&bounds_2
);
3897 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
3900 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
3901 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
3902 /*trace("margin %f\n", margin);*/
3903 ok(margin
> 0.0, "wrong margin %f\n", margin
);
3905 set_rect_empty(&rect
);
3906 rect
.Width
= 320000.0;
3907 rect
.Height
= 320000.0;
3908 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3910 set_rect_empty(&rect
);
3911 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3913 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
3914 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
3915 expectf(0.0, rect
.Y
);
3916 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
3917 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
3918 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
3919 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
3920 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
3921 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
3924 GdipDeleteFont(font
);
3928 status
= GdipDeleteGraphics(graphics
);
3932 GdipDeleteFontFamily(family
);
3933 GdipDeleteRegion(region
);
3934 GdipDeleteStringFormat(format
);
3937 static void test_measure_string(void)
3939 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3940 static const WCHAR string
[] = { 'A','0','1',0 };
3942 GpStringFormat
*format
;
3943 CharacterRange range
;
3945 GpGraphics
*graphics
;
3946 GpFontFamily
*family
;
3950 REAL width
, height
, width_1
, width_2
;
3951 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
3954 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3958 status
= GdipCreateRegion(®ion
);
3961 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3964 hdc
= CreateCompatibleDC(0);
3965 status
= GdipCreateFromHDC(hdc
, &graphics
);
3967 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
3970 margin_x
= 20.0 / 6.0;
3971 margin_y
= 20.0 / 8.0;
3973 set_rect_empty(&rect
);
3974 set_rect_empty(&bounds
);
3975 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3979 expectf(0.0, bounds
.X
);
3980 expectf(0.0, bounds
.Y
);
3981 width
= bounds
.Width
;
3982 height
= bounds
.Height
;
3984 set_rect_empty(&rect
);
3985 rect
.Height
= height
/ 2.0;
3986 set_rect_empty(&bounds
);
3987 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3991 expectf(0.0, bounds
.X
);
3992 expectf(0.0, bounds
.Y
);
3993 expectf(width
, bounds
.Width
);
3995 expectf(height
/ 2.0, bounds
.Height
);
3998 range
.Length
= lstrlenW(string
);
3999 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4004 rect
.Width
= 32000.0;
4005 rect
.Height
= 32000.0;
4006 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4008 set_rect_empty(&bounds
);
4009 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4011 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4012 expectf(5.0, bounds
.Y
);
4013 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4015 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4017 width_rgn
= bounds
.Width
;
4018 height_rgn
= bounds
.Height
;
4022 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4025 set_rect_empty(&rect
);
4026 rect
.Width
= 32000.0;
4027 rect
.Height
= 32000.0;
4028 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4030 set_rect_empty(&bounds
);
4031 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4033 expectf_(margin_x
, bounds
.X
, 1.0);
4034 expectf(0.0, bounds
.Y
);
4035 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4036 expectf(height_rgn
, bounds
.Height
);
4037 width_1
= bounds
.Width
;
4040 range
.Length
= lstrlenW(string
);
4041 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4048 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4050 set_rect_empty(&bounds
);
4051 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4053 expectf(0.0, bounds
.X
);
4054 expectf(0.0, bounds
.Y
);
4055 expectf(0.0, bounds
.Width
);
4056 expectf(0.0, bounds
.Height
);
4060 rect
.Width
= width_rgn
/ 2.0;
4061 rect
.Height
= 32000.0;
4062 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4064 set_rect_empty(&bounds
);
4065 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4067 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4068 expectf(5.0, bounds
.Y
);
4069 expectf_(width_1
, bounds
.Width
, 1.0);
4071 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4073 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4079 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4081 set_rect_empty(&bounds
);
4082 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4084 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4085 expectf(5.0, bounds
.Y
);
4086 expectf(width_rgn
, bounds
.Width
);
4087 expectf(height_rgn
, bounds
.Height
);
4091 rect
.Width
= width_rgn
/ 2.0;
4092 rect
.Height
= 32000.0;
4093 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4095 set_rect_empty(&bounds
);
4096 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4098 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4099 expectf(5.0, bounds
.Y
);
4100 expectf_(width_1
, bounds
.Width
, 1.0);
4101 expectf(height_rgn
, bounds
.Height
);
4103 set_rect_empty(&rect
);
4104 rect
.Height
= height
/ 2.0;
4105 set_rect_empty(&bounds
);
4106 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4110 expectf(0.0, bounds
.X
);
4111 expectf(0.0, bounds
.Y
);
4112 expectf_(width
, bounds
.Width
, 0.01);
4114 expectf(height
, bounds
.Height
);
4116 set_rect_empty(&rect
);
4117 set_rect_empty(&bounds
);
4118 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4122 expectf(0.0, bounds
.X
);
4123 expectf(0.0, bounds
.Y
);
4124 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4125 expectf(height
, bounds
.Height
);
4126 width_1
= bounds
.Width
;
4128 set_rect_empty(&rect
);
4129 set_rect_empty(&bounds
);
4130 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4134 expectf(0.0, bounds
.X
);
4135 expectf(0.0, bounds
.Y
);
4136 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4137 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4138 expectf(height
, bounds
.Height
);
4139 width_2
= bounds
.Width
;
4141 set_rect_empty(&rect
);
4142 rect
.Width
= width
/ 2.0;
4143 set_rect_empty(&bounds
);
4144 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4148 expectf(0.0, bounds
.X
);
4149 expectf(0.0, bounds
.Y
);
4150 expectf_(width_1
, bounds
.Width
, 0.01);
4151 expectf(height
, bounds
.Height
);
4153 set_rect_empty(&rect
);
4154 rect
.Height
= height
;
4155 rect
.Width
= width
- 0.05;
4156 set_rect_empty(&bounds
);
4157 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4161 expectf(0.0, bounds
.X
);
4162 expectf(0.0, bounds
.Y
);
4163 expectf_(width_2
, bounds
.Width
, 0.01);
4164 expectf(height
, bounds
.Height
);
4166 set_rect_empty(&rect
);
4167 rect
.Height
= height
;
4168 rect
.Width
= width_2
- 0.05;
4169 set_rect_empty(&bounds
);
4170 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4174 expectf(0.0, bounds
.X
);
4175 expectf(0.0, bounds
.Y
);
4176 expectf_(width_1
, bounds
.Width
, 0.01);
4177 expectf(height
, bounds
.Height
);
4179 /* Default (Near) alignment */
4182 rect
.Width
= width
* 2.0;
4183 rect
.Height
= height
* 2.0;
4184 set_rect_empty(&bounds
);
4185 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4189 expectf(5.0, bounds
.X
);
4190 expectf(5.0, bounds
.Y
);
4191 expectf_(width
, bounds
.Width
, 0.01);
4192 expectf(height
, bounds
.Height
);
4196 rect
.Width
= 32000.0;
4197 rect
.Height
= 32000.0;
4198 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4200 set_rect_empty(&bounds
);
4201 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4203 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4204 expectf(5.0, bounds
.Y
);
4205 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4207 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4209 width_rgn
= bounds
.Width
;
4210 height_rgn
= bounds
.Height
;
4212 /* Center alignment */
4213 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4214 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4218 rect
.Width
= width
* 2.0;
4219 rect
.Height
= height
* 2.0;
4220 set_rect_empty(&bounds
);
4221 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4226 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4228 expectf(5.0 + height
/2.0, bounds
.Y
);
4229 expectf_(width
, bounds
.Width
, 0.01);
4230 expectf(height
, bounds
.Height
);
4236 set_rect_empty(&bounds
);
4237 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4242 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4244 expectf(5.0 - height
/2.0, bounds
.Y
);
4245 expectf_(width
, bounds
.Width
, 0.01);
4246 expectf(height
, bounds
.Height
);
4250 rect
.Width
= width_rgn
* 2.0;
4251 rect
.Height
= height_rgn
* 2.0;
4252 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4254 set_rect_empty(&bounds
);
4255 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4258 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4260 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4261 expectf_(width_rgn
, bounds
.Width
, 1.0);
4262 expectf_(height_rgn
, bounds
.Height
, 1.0);
4268 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4270 set_rect_empty(&bounds
);
4271 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4274 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4276 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4277 expectf_(width_rgn
, bounds
.Width
, 1.0);
4278 expectf_(height_rgn
, bounds
.Height
, 1.0);
4281 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4282 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4286 rect
.Width
= width
* 2.0;
4287 rect
.Height
= height
* 2.0;
4288 set_rect_empty(&bounds
);
4289 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4294 expectf_(5.0 + width
, bounds
.X
, 0.01);
4296 expectf(5.0 + height
, bounds
.Y
);
4297 expectf_(width
, bounds
.Width
, 0.01);
4298 expectf(height
, bounds
.Height
);
4304 set_rect_empty(&bounds
);
4305 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4310 expectf_(5.0 - width
, bounds
.X
, 0.01);
4312 expectf(5.0 - height
, bounds
.Y
);
4313 expectf_(width
, bounds
.Width
, 0.01);
4314 expectf(height
, bounds
.Height
);
4318 rect
.Width
= width_rgn
* 2.0;
4319 rect
.Height
= height_rgn
* 2.0;
4320 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4322 set_rect_empty(&bounds
);
4323 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4326 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4328 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4329 expectf_(width_rgn
, bounds
.Width
, 1.0);
4330 expectf_(height_rgn
, bounds
.Height
, 1.0);
4336 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4338 set_rect_empty(&bounds
);
4339 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4342 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4344 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4345 expectf_(width_rgn
, bounds
.Width
, 1.0);
4346 expectf_(height_rgn
, bounds
.Height
, 1.0);
4348 status
= GdipDeleteFont(font
);
4351 status
= GdipDeleteGraphics(graphics
);
4355 GdipDeleteFontFamily(family
);
4356 GdipDeleteRegion(region
);
4357 GdipDeleteStringFormat(format
);
4360 static void test_measured_extra_space(void)
4362 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4363 static const WCHAR string
[2] = { 'W','W' };
4364 GpStringFormat
*format
;
4366 GpGraphics
*graphics
;
4367 GpFontFamily
*family
;
4370 GpUnit gfx_unit
, font_unit
;
4371 RectF bounds_1
, bounds_2
, rect
;
4372 REAL margin
, font_size
, dpi
;
4374 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4377 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4379 hdc
= CreateCompatibleDC(0);
4380 status
= GdipCreateFromHDC(hdc
, &graphics
);
4383 status
= GdipGetDpiX(graphics
, &dpi
);
4386 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4387 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4388 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4390 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4393 status
= GdipGetFontSize(font
, &font_size
);
4395 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4396 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4398 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4399 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4401 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4404 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4405 set_rect_empty(&rect
);
4406 set_rect_empty(&bounds_1
);
4407 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4409 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4410 set_rect_empty(&rect
);
4411 set_rect_empty(&bounds_2
);
4412 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4415 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4416 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4417 /*trace("margin %f pixels\n", margin);*/
4418 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4421 GdipDeleteFont(font
);
4424 GdipDeleteGraphics(graphics
);
4426 GdipDeleteFontFamily(family
);
4427 GdipDeleteStringFormat(format
);
4430 static void test_alpha_hdc(void)
4434 HBITMAP hbm
, old_hbm
;
4435 GpGraphics
*graphics
;
4440 hdc
= CreateCompatibleDC(0);
4441 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4442 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4443 bmi
.bmiHeader
.biHeight
= 5;
4444 bmi
.bmiHeader
.biWidth
= 5;
4445 bmi
.bmiHeader
.biBitCount
= 32;
4446 bmi
.bmiHeader
.biPlanes
= 1;
4447 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4448 bmi
.bmiHeader
.biClrUsed
= 0;
4450 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4451 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4453 old_hbm
= SelectObject(hdc
, hbm
);
4455 status
= GdipCreateFromHDC(hdc
, &graphics
);
4458 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4460 expectf(0.0, bounds
.X
);
4461 expectf(0.0, bounds
.Y
);
4462 expectf(5.0, bounds
.Width
);
4463 expectf(5.0, bounds
.Height
);
4465 bits
[0] = 0xdeadbeef;
4467 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4470 expect(0xffaaaaaa, bits
[0]);
4472 SelectObject(hdc
, old_hbm
);
4474 bits
[0] = 0xdeadbeef;
4476 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4479 todo_wine
expect(0xffbbbbbb, bits
[0]);
4481 GdipDeleteGraphics(graphics
);
4487 static void test_bitmapfromgraphics(void)
4490 GpGraphics
*graphics
= NULL
;
4491 HDC hdc
= GetDC( hwnd
);
4492 GpBitmap
*bitmap
= NULL
;
4494 REAL imageres
, graphicsres
;
4497 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4500 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4501 expect(InvalidParameter
, stat
);
4503 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4504 expect(InvalidParameter
, stat
);
4506 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4509 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4511 expect(PixelFormat32bppPARGB
, format
);
4513 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4516 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4518 expectf(graphicsres
, imageres
);
4520 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4523 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4525 expectf(graphicsres
, imageres
);
4527 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4531 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4535 GdipDeleteGraphics(graphics
);
4536 GdipDisposeImage((GpImage
*)bitmap
);
4539 static void test_clipping(void)
4543 GpGraphics
*graphics
;
4544 GpRegion
*region
, *region100x100
;
4553 hdc
= CreateCompatibleDC(0);
4554 status
= GdipCreateFromHDC(hdc
, &graphics
);
4557 status
= GdipGetPageUnit(graphics
, &unit
);
4559 expect(UnitDisplay
, unit
);
4561 status
= GdipCreateRegion(®ion
);
4563 status
= GdipSetEmpty(region
);
4566 status
= GdipCreateRegion(®ion100x100
);
4568 status
= GdipSetEmpty(region100x100
);
4571 rect
.X
= rect
.Y
= 100.0;
4572 rect
.Width
= rect
.Height
= 100.0;
4573 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4575 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4578 status
= GdipGetClipBounds(graphics
, &rect
);
4580 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4581 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4583 status
= GdipSetEmpty(region
);
4585 status
= GdipGetClip(graphics
, region
);
4587 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4589 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4590 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4596 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4598 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4599 "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
);
4601 status
= GdipCreateMatrix(&matrix
);
4603 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4605 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4607 status
= GdipSetWorldTransform(graphics
, matrix
);
4610 status
= GdipGetClipBounds(graphics
, &rect
);
4612 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4613 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4615 status
= GdipSetEmpty(region
);
4617 status
= GdipGetClip(graphics
, region
);
4619 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4621 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4622 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4624 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4626 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4627 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4629 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4631 ret
= GetRgnBox(hrgn
, &rc
);
4632 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4633 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4634 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4637 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4639 ret
= GetRgnBox(hrgn
, &rc
);
4640 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4641 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4642 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4649 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4651 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4652 "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
);
4654 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4656 ret
= GetRgnBox(hrgn
, &rc
);
4657 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4658 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4659 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4662 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4664 ret
= GetRgnBox(hrgn
, &rc
);
4665 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4666 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4667 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4674 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4676 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4677 "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
);
4679 status
= GdipSetPageScale(graphics
, 2.0);
4682 status
= GdipGetClipBounds(graphics
, &rect
);
4684 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4685 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4687 status
= GdipSetEmpty(region
);
4689 status
= GdipGetClip(graphics
, region
);
4691 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4693 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4694 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4696 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4698 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4699 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4701 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4703 ret
= GetRgnBox(hrgn
, &rc
);
4704 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4705 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4706 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4709 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4711 ret
= GetRgnBox(hrgn
, &rc
);
4712 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4713 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4714 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4721 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4723 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4724 "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
);
4726 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4728 ret
= GetRgnBox(hrgn
, &rc
);
4729 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4730 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4731 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4734 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4736 ret
= GetRgnBox(hrgn
, &rc
);
4737 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4738 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4739 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4746 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4748 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4749 "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
);
4751 GdipSetPageUnit(graphics
, UnitPoint
);
4754 status
= GdipGetClipBounds(graphics
, &rect
);
4756 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4757 /* rounding under Wine is slightly different */
4758 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4759 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4760 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4762 status
= GdipSetEmpty(region
);
4764 status
= GdipGetClip(graphics
, region
);
4766 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4768 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4769 /* rounding under Wine is slightly different */
4770 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4771 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4772 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4774 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4776 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4777 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4779 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4781 ret
= GetRgnBox(hrgn
, &rc
);
4782 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4783 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
4784 /* rounding under Wine is slightly different */
4785 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
4786 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
4787 "expected 14,5-33,14, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4790 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4792 ret
= GetRgnBox(hrgn
, &rc
);
4793 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4794 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
4795 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
4796 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4803 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4805 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
4806 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
4807 "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
);
4809 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4811 ret
= GetRgnBox(hrgn
, &rc
);
4812 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4813 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4814 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4817 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4819 ret
= GetRgnBox(hrgn
, &rc
);
4820 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4821 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
4822 /* rounding under Wine is slightly different */
4823 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
4824 "expected 560,1120-1094,2187, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4831 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4833 if (fabs(ptf
[0].X
- 100.0) < 0.001)
4835 expectf(100.0, ptf
[0].X
);
4836 expectf(100.0, ptf
[0].Y
);
4837 expectf(200.125, ptf
[1].X
);
4838 expectf(200.03125, ptf
[1].Y
);
4840 else /* before Win7 */
4842 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
4843 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
4844 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
4845 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
4848 status
= GdipTransformRegion(region100x100
, matrix
);
4851 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4853 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4854 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4856 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4858 ret
= GetRgnBox(hrgn
, &rc
);
4859 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4860 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4861 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4864 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4866 ret
= GetRgnBox(hrgn
, &rc
);
4867 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4868 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
4869 /* rounding under Wine is slightly different */
4870 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
4871 "expected 1147,4534-2214,8800, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4878 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4880 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
4882 expectf(210.0625, ptf
[0].X
);
4883 expectf(420.0625, ptf
[0].Y
);
4884 expectf(410.125, ptf
[1].X
);
4885 expectf(820.0, ptf
[1].Y
);
4887 else /* before Win7 */
4889 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
4890 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
4891 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
4892 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
4895 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
4897 status
= GdipSetWorldTransform(graphics
, matrix
);
4900 status
= GdipGetClipBounds(graphics
, &rect
);
4902 expectf_(20.612978, rect
.X
, 1.0);
4903 expectf_(-6.256012, rect
.Y
, 1.5);
4904 expectf_(25.612978, rect
.Width
, 1.0);
4905 expectf_(12.806489, rect
.Height
, 1.0);
4907 status
= GdipSetEmpty(region
);
4909 status
= GdipGetClip(graphics
, region
);
4911 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4913 /* rounding under Wine is slightly different */
4914 expectf_(20.612978, rect
.X
, 1.0);
4915 expectf_(-6.256012, rect
.Y
, 1.5);
4916 expectf_(25.612978, rect
.Width
, 1.0);
4917 expectf_(12.806489, rect
.Height
, 1.0);
4919 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4921 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4922 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4924 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4926 ret
= GetRgnBox(hrgn
, &rc
);
4927 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4928 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
4929 /* rounding under Wine is slightly different */
4930 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
4931 "expected (22,-6)-(46,7), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4934 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4936 ret
= GetRgnBox(hrgn
, &rc
);
4937 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4938 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4939 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4950 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4952 expectf(20.612978, ptf
[0].X
);
4953 expectf(-1.568512, ptf
[0].Y
);
4954 expectf(46.225956, ptf
[1].X
);
4955 expectf(1.862977, ptf
[1].Y
);
4956 expectf(36.850956, ptf
[2].X
);
4957 expectf(-6.256012, ptf
[2].Y
);
4958 expectf(29.987980, ptf
[3].X
);
4959 expectf(6.550478, ptf
[3].Y
);
4961 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4963 ret
= GetRgnBox(hrgn
, &rc
);
4964 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4965 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4966 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4969 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4971 ret
= GetRgnBox(hrgn
, &rc
);
4972 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4973 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
4974 /* rounding under Wine is slightly different */
4975 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
4976 "expected (-3406,4500)-(-350,8728), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4987 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4989 expectf(-136.190491, ptf
[0].X
);
4990 expectf(520.010742, ptf
[0].Y
);
4991 expectf(756.417175, ptf
[1].X
);
4992 expectf(720.031616, ptf
[1].Y
);
4993 expectf(360.042114, ptf
[2].X
);
4994 expectf(376.760742, ptf
[2].Y
);
4995 expectf(260.184570, ptf
[3].X
);
4996 expectf(863.281616, ptf
[3].Y
);
4998 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5000 status
= GdipSetWorldTransform(graphics
, matrix
);
5003 status
= GdipGetClipBounds(graphics
, &rect
);
5005 expectf_(-28.100956, rect
.X
, 1.0);
5006 expectf_(7.806488, rect
.Y
, 1.5);
5007 expectf_(25.612978, rect
.Width
, 1.0);
5008 expectf_(12.806489, rect
.Height
, 1.0);
5010 status
= GdipSetEmpty(region
);
5012 status
= GdipGetClip(graphics
, region
);
5014 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5016 /* rounding under Wine is slightly different */
5017 expectf_(-28.100956, rect
.X
, 1.0);
5018 expectf_(7.806488, rect
.Y
, 1.5);
5019 expectf_(25.612978, rect
.Width
, 1.0);
5020 expectf_(12.806489, rect
.Height
, 1.0);
5022 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5024 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5025 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5027 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5029 ret
= GetRgnBox(hrgn
, &rc
);
5030 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5031 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5032 /* rounding under Wine is slightly different */
5033 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5034 "expected (-27,8)-(-2,21), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5037 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5039 ret
= GetRgnBox(hrgn
, &rc
);
5040 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5041 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5042 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5053 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5055 expectf(-11.862979, ptf
[0].X
);
5056 expectf(7.806488, ptf
[0].Y
);
5057 expectf(-18.725958, ptf
[1].X
);
5058 expectf(20.612976, ptf
[1].Y
);
5059 expectf(-2.487981, ptf
[2].X
);
5060 expectf(15.925477, ptf
[2].Y
);
5061 expectf(-28.100956, ptf
[3].X
);
5062 expectf(12.493987, ptf
[3].Y
);
5064 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5066 ret
= GetRgnBox(hrgn
, &rc
);
5067 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5068 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5069 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5072 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5074 ret
= GetRgnBox(hrgn
, &rc
);
5075 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5076 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5077 /* rounding under Wine is slightly different */
5078 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5079 "expected (4500,351)-(8728,3407), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5090 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5092 expectf(-1055.021484, ptf
[0].X
);
5093 expectf(-70.595329, ptf
[0].Y
);
5094 expectf(-1455.063232, ptf
[1].X
);
5095 expectf(375.708435, ptf
[1].Y
);
5096 expectf(-768.521484, ptf
[2].X
);
5097 expectf(177.520981, ptf
[2].Y
);
5098 expectf(-1741.563110, ptf
[3].X
);
5099 expectf(127.592125, ptf
[3].Y
);
5101 GdipDeleteMatrix(matrix
);
5102 GdipDeleteRegion(region
);
5103 GdipDeleteRegion(region100x100
);
5104 GdipDeleteGraphics(graphics
);
5108 static void test_clipping_2(void)
5113 GpGraphics
*graphics
;
5123 hdc
= CreateCompatibleDC(0);
5124 status
= GdipCreateFromHDC(hdc
, &graphics
);
5127 status
= GdipGetPageUnit(graphics
, &unit
);
5129 expect(UnitDisplay
, unit
);
5131 GdipSetPageUnit(graphics
, UnitInch
);
5133 status
= GdipCreateRegion(®ion
);
5135 status
= GdipSetEmpty(region
);
5137 rect
.X
= rect
.Y
= 100.0;
5138 rect
.Width
= rect
.Height
= 100.0;
5139 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5141 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5144 status
= GdipGetClip(graphics
, region
);
5146 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5148 ret
= GetRgnBox(hrgn
, &rc
);
5149 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5150 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5151 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5153 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5155 ret
= GetRgnBox(hrgn
, &rc
);
5156 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5157 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5158 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5165 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5167 expectf(100.0, ptf
[0].X
);
5168 expectf(100.0, ptf
[0].Y
);
5169 expectf(200.0, ptf
[1].X
);
5170 expectf(200.0, ptf
[1].X
);
5172 GdipSetPageUnit(graphics
, UnitPoint
);
5174 status
= GdipGetClip(graphics
, region
);
5176 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5178 ret
= GetRgnBox(hrgn
, &rc
);
5179 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5180 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5181 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5182 "expected 7200,7200-14400,14400, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5184 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5186 ret
= GetRgnBox(hrgn
, &rc
);
5187 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5188 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5189 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5190 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5197 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5199 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5200 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5201 "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
);
5202 else /* before Win7 */
5204 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5205 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5206 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5207 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5210 GdipDeleteRegion(region
);
5212 GdipSetPageUnit(graphics
, UnitPixel
);
5214 status
= GdipCreateRegion(®ion
);
5216 status
= GdipSetEmpty(region
);
5218 rect
.X
= rect
.Y
= 100.0;
5219 rect
.Width
= rect
.Height
= 100.0;
5220 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5222 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5225 status
= GdipGetClip(graphics
, region
);
5227 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5229 ret
= GetRgnBox(hrgn
, &rc
);
5230 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5231 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5232 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5233 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5235 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5237 ret
= GetRgnBox(hrgn
, &rc
);
5238 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5239 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5240 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5241 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5248 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5250 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5251 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5252 "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
);
5253 else /* before Win7 */
5255 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5256 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5257 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5258 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5261 GdipSetPageUnit(graphics
, UnitPoint
);
5263 status
= GdipGetClip(graphics
, region
);
5265 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5267 ret
= GetRgnBox(hrgn
, &rc
);
5268 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5269 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5270 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5271 "expected 75,75-150,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5273 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5275 ret
= GetRgnBox(hrgn
, &rc
);
5276 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5277 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5278 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5279 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5286 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5288 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5289 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5290 "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
);
5291 else /* before Win7 */
5293 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5294 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5295 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5296 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5299 status
= GdipCreateMatrix(&matrix
);
5301 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5303 status
= GdipSetWorldTransform(graphics
, matrix
);
5305 GdipDeleteMatrix(matrix
);
5307 status
= GdipGetClip(graphics
, region
);
5309 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5311 ret
= GetRgnBox(hrgn
, &rc
);
5312 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5313 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5314 "expected 65,65-140,140, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5316 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5318 ret
= GetRgnBox(hrgn
, &rc
);
5319 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5320 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5321 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5328 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5330 expectf(65.0, ptf
[0].X
);
5331 expectf(65.0, ptf
[0].Y
);
5332 expectf(140.0, ptf
[1].X
);
5333 expectf(140.0, ptf
[1].X
);
5335 status
= GdipCreateMatrix(&matrix
);
5337 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5339 status
= GdipSetWorldTransform(graphics
, matrix
);
5341 GdipDeleteMatrix(matrix
);
5343 status
= GdipGetClip(graphics
, region
);
5345 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5347 ret
= GetRgnBox(hrgn
, &rc
);
5348 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5349 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5350 "expected 300,150-600,300, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5352 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5354 ret
= GetRgnBox(hrgn
, &rc
);
5355 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5356 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5357 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5364 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5366 expectf(300.0, ptf
[0].X
);
5367 expectf(150.0, ptf
[0].Y
);
5368 expectf(600.0, ptf
[1].X
);
5369 expectf(300.0, ptf
[1].Y
);
5371 status
= GdipSetPageScale(graphics
, 2.0);
5374 status
= GdipGetClip(graphics
, region
);
5376 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5378 ret
= GetRgnBox(hrgn
, &rc
);
5379 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5380 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5381 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5382 "expected 150,75-300,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5384 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5386 ret
= GetRgnBox(hrgn
, &rc
);
5387 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5388 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5389 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5390 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5397 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5399 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5401 expectf(150.0, ptf
[0].X
);
5402 expectf(75.0, ptf
[0].Y
);
5403 expectf(300.0, ptf
[1].X
);
5404 expectf(150.0, ptf
[1].Y
);
5406 else /* before Win7 */
5408 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5409 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5410 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5411 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5414 status
= GdipCreateMatrix(&matrix
);
5416 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5418 status
= GdipSetWorldTransform(graphics
, matrix
);
5420 GdipDeleteMatrix(matrix
);
5422 status
= GdipGetClip(graphics
, region
);
5424 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5426 ret
= GetRgnBox(hrgn
, &rc
);
5427 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5428 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5429 /* rounding under Wine is slightly different */
5430 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5431 "expected 54,-26-107,27, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5433 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5435 ret
= GetRgnBox(hrgn
, &rc
);
5436 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5437 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5438 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5449 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5451 expectf(53.033016, ptf
[0].X
);
5452 expectf(0.0, ptf
[0].Y
);
5453 expectf(106.066032, ptf
[1].X
);
5454 expectf(0.0, ptf
[1].Y
);
5455 expectf(79.549522, ptf
[2].X
);
5456 expectf(-26.516510, ptf
[2].Y
);
5457 expectf(79.549522, ptf
[3].X
);
5458 expectf(26.516508, ptf
[3].Y
);
5460 status
= GdipCreateMatrix(&matrix
);
5462 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5464 status
= GdipSetWorldTransform(graphics
, matrix
);
5466 GdipDeleteMatrix(matrix
);
5468 status
= GdipGetClip(graphics
, region
);
5470 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5472 ret
= GetRgnBox(hrgn
, &rc
);
5473 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5474 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5475 /* rounding under Wine is slightly different */
5476 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5477 "expected -26,54-27,107, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5479 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5481 ret
= GetRgnBox(hrgn
, &rc
);
5482 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5483 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5484 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5495 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5497 expectf(0.0, ptf
[0].X
);
5498 expectf(53.033005, ptf
[0].Y
);
5499 expectf(0.0, ptf
[1].X
);
5500 expectf(106.066010, ptf
[1].Y
);
5501 expectf(26.516491, ptf
[2].X
);
5502 expectf(79.549507, ptf
[2].Y
);
5503 expectf(-26.516520, ptf
[3].X
);
5504 expectf(79.549500, ptf
[3].Y
);
5506 GdipDeleteRegion(region
);
5507 GdipDeleteGraphics(graphics
);
5512 static void test_GdipFillRectangles(void)
5515 GpGraphics
*graphics
= NULL
;
5516 GpBrush
*brush
= NULL
;
5517 HDC hdc
= GetDC( hwnd
);
5518 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5520 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5522 status
= GdipCreateFromHDC(hdc
, &graphics
);
5524 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5526 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5528 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5530 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5531 expect(InvalidParameter
, status
);
5533 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5534 expect(InvalidParameter
, status
);
5536 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5537 expect(InvalidParameter
, status
);
5539 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5540 expect(InvalidParameter
, status
);
5542 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5543 expect(InvalidParameter
, status
);
5545 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5548 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5551 GdipDeleteBrush(brush
);
5552 GdipDeleteGraphics(graphics
);
5554 ReleaseDC(hwnd
, hdc
);
5557 static void test_GdipGetVisibleClipBounds_memoryDC(void)
5566 GpGraphics
* graphics
= NULL
;
5570 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
5571 width
= rect
.right
- rect
.left
;
5572 height
= rect
.bottom
- rect
.top
;
5575 hdc
= CreateCompatibleDC ( dc
);
5576 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
5577 old
= SelectObject (hdc
, bmp
);
5579 /*change the window origin is the key test point*/
5580 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
5582 status
= GdipCreateFromHDC(hdc
, &graphics
);
5585 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5588 ok(boundRect
.X
==rect
.left
+10 &&
5589 boundRect
.Y
==rect
.top
+10 &&
5590 boundRect
.Width
==width
&&
5591 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
5593 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
5596 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5599 ok(boundRect
.X
==rect
.left
+10 &&
5600 boundRect
.Y
==rect
.top
+10 &&
5601 boundRect
.Width
==width
-10 &&
5602 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
5604 GdipDeleteGraphics(graphics
);
5606 SelectObject (hdc
, old
);
5609 ReleaseDC(hwnd
, dc
);
5612 START_TEST(graphics
)
5614 struct GdiplusStartupInput gdiplusStartupInput
;
5615 ULONG_PTR gdiplusToken
;
5618 memset( &class, 0, sizeof(class) );
5619 class.lpszClassName
= "gdiplus_test";
5620 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5621 class.lpfnWndProc
= DefWindowProcA
;
5622 class.hInstance
= GetModuleHandleA(0);
5623 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5624 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5625 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
5626 RegisterClassA( &class );
5627 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5628 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
5629 ok(hwnd
!= NULL
, "Expected window to be created\n");
5631 gdiplusStartupInput
.GdiplusVersion
= 1;
5632 gdiplusStartupInput
.DebugEventCallback
= NULL
;
5633 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
5634 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
5636 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
5640 test_measured_extra_space();
5641 test_measure_string();
5642 test_font_height_scaling();
5644 test_GdipMeasureString();
5645 test_constructor_destructor();
5646 test_save_restore();
5647 test_GdipFillClosedCurve2();
5648 test_GdipFillClosedCurve2I();
5649 test_GdipDrawBezierI();
5651 test_GdipDrawArcI();
5652 test_GdipDrawCurve();
5653 test_GdipDrawCurveI();
5654 test_GdipDrawCurve2();
5655 test_GdipDrawCurve2I();
5656 test_GdipDrawCurve3();
5657 test_GdipDrawCurve3I();
5658 test_GdipDrawLineI();
5659 test_GdipDrawLinesI();
5660 test_GdipDrawImagePointsRect();
5661 test_GdipFillClosedCurve();
5662 test_GdipFillClosedCurveI();
5663 test_GdipDrawString();
5664 test_GdipGetNearestColor();
5665 test_GdipGetVisibleClipBounds();
5666 test_GdipIsVisiblePoint();
5667 test_GdipIsVisibleRect();
5668 test_Get_Release_DC();
5669 test_BeginContainer2();
5670 test_transformpoints();
5671 test_get_set_clip();
5674 test_textcontrast();
5675 test_fromMemoryBitmap();
5676 test_string_functions();
5677 test_get_set_interpolation();
5678 test_get_set_textrenderinghint();
5679 test_getdc_scaled();
5681 test_bitmapfromgraphics();
5682 test_GdipFillRectangles();
5683 test_GdipGetVisibleClipBounds_memoryDC();
5685 GdiplusShutdown(gdiplusToken
);
5686 DestroyWindow( hwnd
);