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
26 #include "wine/test.h"
28 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
29 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
30 #define expectf(expected, got) expectf_((expected), (got), 0.001)
31 #define TABLE_LEN (23)
33 static const REAL mm_per_inch
= 25.4;
34 static const REAL point_per_inch
= 72.0;
37 static void set_rect_empty(RectF
*rc
)
45 /* converts a given unit to its value in pixels */
46 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
54 return units
* dpi
/ point_per_inch
;
58 return units
* dpi
/ 300.0; /* Per MSDN */
60 return units
* dpi
/ mm_per_inch
;
62 ok(0, "Unsupported unit: %d\n", unit
);
67 /* converts value in pixels to a given unit */
68 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
76 return pixels
* point_per_inch
/ dpi
;
80 return pixels
* 300.0 / dpi
;
82 return pixels
* mm_per_inch
/ dpi
;
84 ok(0, "Unsupported unit: %d\n", unit
);
89 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
91 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
92 return pixels_to_units(pixels
, to
, dpi
);
95 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
103 GpGraphics
*graphics
= NULL
;
106 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
109 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
111 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
114 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
118 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
123 status
= GdipGetDpiX(graphics
, &res
);
126 status
= GdipGetDpiY(graphics
, &res
);
130 status
= GdipSetPageUnit(graphics
, unit
);
132 status
= GdipSetPageScale(graphics
, scale
);
138 static void test_constructor_destructor(void)
141 GpGraphics
*graphics
= NULL
;
142 HDC hdc
= GetDC( hwnd
);
144 stat
= GdipCreateFromHDC(NULL
, &graphics
);
145 expect(OutOfMemory
, stat
);
146 stat
= GdipDeleteGraphics(graphics
);
147 expect(InvalidParameter
, stat
);
149 stat
= GdipCreateFromHDC(hdc
, &graphics
);
151 stat
= GdipDeleteGraphics(graphics
);
154 stat
= GdipCreateFromHWND(NULL
, &graphics
);
156 stat
= GdipDeleteGraphics(graphics
);
159 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
161 stat
= GdipDeleteGraphics(graphics
);
164 stat
= GdipDeleteGraphics(NULL
);
165 expect(InvalidParameter
, stat
);
166 ReleaseDC(hwnd
, hdc
);
174 /* Linked list prepend function. */
175 static void log_state(GraphicsState data
, node
** log
)
177 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
179 new_entry
->data
= data
;
180 new_entry
->next
= *log
;
184 /* Checks if there are duplicates in the list, and frees it. */
185 static void check_no_duplicates(node
* log
)
197 while((temp
= temp
->next
)){
198 if(log
->data
== temp
->data
){
205 }while((log
= log
->next
));
210 HeapFree(GetProcessHeap(), 0, temp
);
218 static void test_save_restore(void)
221 GraphicsState state_a
, state_b
, state_c
;
222 InterpolationMode mode
;
223 GpGraphics
*graphics1
, *graphics2
;
224 node
* state_log
= NULL
;
225 HDC hdc
= GetDC( hwnd
);
226 state_a
= state_b
= state_c
= 0xdeadbeef;
228 /* Invalid saving. */
229 GdipCreateFromHDC(hdc
, &graphics1
);
230 stat
= GdipSaveGraphics(graphics1
, NULL
);
231 expect(InvalidParameter
, stat
);
232 stat
= GdipSaveGraphics(NULL
, &state_a
);
233 expect(InvalidParameter
, stat
);
234 GdipDeleteGraphics(graphics1
);
236 log_state(state_a
, &state_log
);
238 /* Basic save/restore. */
239 GdipCreateFromHDC(hdc
, &graphics1
);
240 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
241 stat
= GdipSaveGraphics(graphics1
, &state_a
);
243 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
244 stat
= GdipRestoreGraphics(graphics1
, state_a
);
246 GdipGetInterpolationMode(graphics1
, &mode
);
247 expect(InterpolationModeBilinear
, mode
);
248 GdipDeleteGraphics(graphics1
);
250 log_state(state_a
, &state_log
);
252 /* Restoring garbage doesn't affect saves. */
253 GdipCreateFromHDC(hdc
, &graphics1
);
254 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
255 GdipSaveGraphics(graphics1
, &state_a
);
256 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
257 GdipSaveGraphics(graphics1
, &state_b
);
258 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
259 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
261 GdipRestoreGraphics(graphics1
, state_b
);
262 GdipGetInterpolationMode(graphics1
, &mode
);
263 expect(InterpolationModeBicubic
, mode
);
264 GdipRestoreGraphics(graphics1
, state_a
);
265 GdipGetInterpolationMode(graphics1
, &mode
);
266 expect(InterpolationModeBilinear
, mode
);
267 GdipDeleteGraphics(graphics1
);
269 log_state(state_a
, &state_log
);
270 log_state(state_b
, &state_log
);
272 /* Restoring older state invalidates newer saves (but not older saves). */
273 GdipCreateFromHDC(hdc
, &graphics1
);
274 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
275 GdipSaveGraphics(graphics1
, &state_a
);
276 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
277 GdipSaveGraphics(graphics1
, &state_b
);
278 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
279 GdipSaveGraphics(graphics1
, &state_c
);
280 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
281 GdipRestoreGraphics(graphics1
, state_b
);
282 GdipGetInterpolationMode(graphics1
, &mode
);
283 expect(InterpolationModeBicubic
, mode
);
284 GdipRestoreGraphics(graphics1
, state_c
);
285 GdipGetInterpolationMode(graphics1
, &mode
);
286 expect(InterpolationModeBicubic
, mode
);
287 GdipRestoreGraphics(graphics1
, state_a
);
288 GdipGetInterpolationMode(graphics1
, &mode
);
289 expect(InterpolationModeBilinear
, mode
);
290 GdipDeleteGraphics(graphics1
);
292 log_state(state_a
, &state_log
);
293 log_state(state_b
, &state_log
);
294 log_state(state_c
, &state_log
);
296 /* Restoring older save from one graphics object does not invalidate
297 * newer save from other graphics object. */
298 GdipCreateFromHDC(hdc
, &graphics1
);
299 GdipCreateFromHDC(hdc
, &graphics2
);
300 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
301 GdipSaveGraphics(graphics1
, &state_a
);
302 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
303 GdipSaveGraphics(graphics2
, &state_b
);
304 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
305 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
306 GdipRestoreGraphics(graphics1
, state_a
);
307 GdipGetInterpolationMode(graphics1
, &mode
);
308 expect(InterpolationModeBilinear
, mode
);
309 GdipRestoreGraphics(graphics2
, state_b
);
310 GdipGetInterpolationMode(graphics2
, &mode
);
311 expect(InterpolationModeBicubic
, mode
);
312 GdipDeleteGraphics(graphics1
);
313 GdipDeleteGraphics(graphics2
);
315 /* You can't restore a state to a graphics object that didn't save it. */
316 GdipCreateFromHDC(hdc
, &graphics1
);
317 GdipCreateFromHDC(hdc
, &graphics2
);
318 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
319 GdipSaveGraphics(graphics1
, &state_a
);
320 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
321 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
322 GdipRestoreGraphics(graphics2
, state_a
);
323 GdipGetInterpolationMode(graphics2
, &mode
);
324 expect(InterpolationModeNearestNeighbor
, mode
);
325 GdipDeleteGraphics(graphics1
);
326 GdipDeleteGraphics(graphics2
);
328 log_state(state_a
, &state_log
);
330 /* The same state value should never be returned twice. */
332 check_no_duplicates(state_log
);
334 ReleaseDC(hwnd
, hdc
);
337 static void test_GdipFillClosedCurve2(void)
340 GpGraphics
*graphics
= NULL
;
341 GpSolidFill
*brush
= NULL
;
342 HDC hdc
= GetDC( hwnd
);
354 /* make a graphics object and brush object */
355 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
357 status
= GdipCreateFromHDC(hdc
, &graphics
);
359 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
361 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
363 /* InvalidParameter cases: null graphics, null brush, null points */
364 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
365 expect(InvalidParameter
, status
);
367 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
368 expect(InvalidParameter
, status
);
370 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
371 expect(InvalidParameter
, status
);
373 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
374 expect(InvalidParameter
, status
);
376 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
377 expect(InvalidParameter
, status
);
379 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
380 expect(InvalidParameter
, status
);
382 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
383 expect(InvalidParameter
, status
);
385 /* InvalidParameter cases: invalid count */
386 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
387 expect(InvalidParameter
, status
);
389 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
390 expect(InvalidParameter
, status
);
392 /* Valid test cases */
393 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
396 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
399 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
402 GdipDeleteGraphics(graphics
);
403 GdipDeleteBrush((GpBrush
*)brush
);
405 ReleaseDC(hwnd
, hdc
);
408 static void test_GdipFillClosedCurve2I(void)
411 GpGraphics
*graphics
= NULL
;
412 GpSolidFill
*brush
= NULL
;
413 HDC hdc
= GetDC( hwnd
);
425 /* make a graphics object and brush object */
426 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
428 status
= GdipCreateFromHDC(hdc
, &graphics
);
430 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
432 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
434 /* InvalidParameter cases: null graphics, null brush */
435 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
436 when points == NULL, so don't test this condition */
437 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
438 expect(InvalidParameter
, status
);
440 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
441 expect(InvalidParameter
, status
);
443 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
444 expect(InvalidParameter
, status
);
446 /* InvalidParameter cases: invalid count */
447 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
448 expect(InvalidParameter
, status
);
450 /* OutOfMemory cases: large (unsigned) int */
451 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
452 expect(OutOfMemory
, status
);
454 /* Valid test cases */
455 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
458 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
461 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
464 GdipDeleteGraphics(graphics
);
465 GdipDeleteBrush((GpBrush
*)brush
);
467 ReleaseDC(hwnd
, hdc
);
470 static void test_GdipDrawArc(void)
473 GpGraphics
*graphics
= NULL
;
475 HDC hdc
= GetDC( hwnd
);
477 /* make a graphics object and pen object */
478 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
480 status
= GdipCreateFromHDC(hdc
, &graphics
);
482 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
484 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
486 ok(pen
!= NULL
, "Expected pen to be initialized\n");
488 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
489 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
490 expect(InvalidParameter
, status
);
492 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
493 expect(InvalidParameter
, status
);
495 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
496 expect(InvalidParameter
, status
);
498 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
499 expect(InvalidParameter
, status
);
501 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
502 expect(InvalidParameter
, status
);
504 /* successful case */
505 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
509 GdipDeleteGraphics(graphics
);
511 ReleaseDC(hwnd
, hdc
);
514 static void test_GdipDrawArcI(void)
517 GpGraphics
*graphics
= NULL
;
519 HDC hdc
= GetDC( hwnd
);
521 /* make a graphics object and pen object */
522 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
524 status
= GdipCreateFromHDC(hdc
, &graphics
);
526 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
528 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
530 ok(pen
!= NULL
, "Expected pen to be initialized\n");
532 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
533 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
534 expect(InvalidParameter
, status
);
536 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
537 expect(InvalidParameter
, status
);
539 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
540 expect(InvalidParameter
, status
);
542 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
543 expect(InvalidParameter
, status
);
545 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
546 expect(InvalidParameter
, status
);
548 /* successful case */
549 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
553 GdipDeleteGraphics(graphics
);
555 ReleaseDC(hwnd
, hdc
);
558 static void test_BeginContainer2(void)
562 REAL defClip
[] = {5, 10, 15, 20};
563 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
564 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
565 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
566 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
567 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
568 REAL scale
, defScale
= 17;
569 GpUnit unit
, defUnit
= UnitPixel
;
570 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
571 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
572 UINT contrast
, defContrast
= 5;
573 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
576 GpGraphics
*graphics
= NULL
;
577 HDC hdc
= GetDC( hwnd
);
579 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
581 status
= GdipCreateFromHDC(hdc
, &graphics
);
583 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
585 /* null graphics, null container */
586 status
= GdipBeginContainer2(NULL
, &cont1
);
587 expect(InvalidParameter
, status
);
589 status
= GdipBeginContainer2(graphics
, NULL
);
590 expect(InvalidParameter
, status
);
592 status
= GdipEndContainer(NULL
, cont1
);
593 expect(InvalidParameter
, status
);
595 /* test all quality-related values */
596 GdipSetCompositingMode(graphics
, defCompmode
);
597 GdipSetCompositingQuality(graphics
, defCompqual
);
598 GdipSetInterpolationMode(graphics
, defInterp
);
599 GdipSetPageScale(graphics
, defScale
);
600 GdipSetPageUnit(graphics
, defUnit
);
601 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
602 GdipSetSmoothingMode(graphics
, defSmoothmode
);
603 GdipSetTextContrast(graphics
, defContrast
);
604 GdipSetTextRenderingHint(graphics
, defTexthint
);
606 status
= GdipBeginContainer2(graphics
, &cont1
);
609 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
610 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
611 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
612 GdipSetPageScale(graphics
, 10);
613 GdipSetPageUnit(graphics
, UnitDocument
);
614 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
615 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
616 GdipSetTextContrast(graphics
, 7);
617 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
619 status
= GdipEndContainer(graphics
, cont1
);
622 GdipGetCompositingMode(graphics
, &compmode
);
623 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
625 GdipGetCompositingQuality(graphics
, &compqual
);
626 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
628 GdipGetInterpolationMode(graphics
, &interp
);
629 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
631 GdipGetPageScale(graphics
, &scale
);
632 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
634 GdipGetPageUnit(graphics
, &unit
);
635 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
637 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
638 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
640 GdipGetSmoothingMode(graphics
, &smoothmode
);
641 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
643 GdipGetTextContrast(graphics
, &contrast
);
644 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
646 GdipGetTextRenderingHint(graphics
, &texthint
);
647 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
649 /* test world transform */
650 status
= GdipBeginContainer2(graphics
, &cont1
);
653 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
654 defTrans
[4], defTrans
[5], &transform
);
656 GdipSetWorldTransform(graphics
, transform
);
657 GdipDeleteMatrix(transform
);
660 status
= GdipBeginContainer2(graphics
, &cont2
);
663 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
665 GdipSetWorldTransform(graphics
, transform
);
666 GdipDeleteMatrix(transform
);
669 status
= GdipEndContainer(graphics
, cont2
);
672 status
= GdipCreateMatrix(&transform
);
674 GdipGetWorldTransform(graphics
, transform
);
675 GdipGetMatrixElements(transform
, elems
);
676 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
677 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
678 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
679 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
680 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
681 fabs(defTrans
[5] - elems
[5]) < 0.0001,
682 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
683 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
684 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
685 GdipDeleteMatrix(transform
);
688 status
= GdipEndContainer(graphics
, cont1
);
692 status
= GdipBeginContainer2(graphics
, &cont1
);
695 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
697 status
= GdipBeginContainer2(graphics
, &cont2
);
700 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
702 status
= GdipEndContainer(graphics
, cont2
);
705 status
= GdipGetClipBounds(graphics
, &clip
);
708 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
709 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
710 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
711 fabs(defClip
[3] - clip
.Height
) < 0.0001,
712 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
713 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
714 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
716 status
= GdipEndContainer(graphics
, cont1
);
720 status
= GdipBeginContainer2(graphics
, &cont1
);
723 status
= GdipBeginContainer2(graphics
, &cont2
);
726 status
= GdipBeginContainer2(graphics
, &cont3
);
729 status
= GdipEndContainer(graphics
, cont3
);
732 status
= GdipBeginContainer2(graphics
, &cont4
);
735 status
= GdipEndContainer(graphics
, cont4
);
739 status
= GdipEndContainer(graphics
, cont1
);
742 /* end an already-ended container */
743 status
= GdipEndContainer(graphics
, cont1
);
746 GdipDeleteGraphics(graphics
);
747 ReleaseDC(hwnd
, hdc
);
750 static void test_GdipDrawBezierI(void)
753 GpGraphics
*graphics
= NULL
;
755 HDC hdc
= GetDC( hwnd
);
757 /* make a graphics object and pen object */
758 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
760 status
= GdipCreateFromHDC(hdc
, &graphics
);
762 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
764 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
766 ok(pen
!= NULL
, "Expected pen to be initialized\n");
768 /* InvalidParameter cases: null graphics, null pen */
769 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
770 expect(InvalidParameter
, status
);
772 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
773 expect(InvalidParameter
, status
);
775 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
776 expect(InvalidParameter
, status
);
778 /* successful case */
779 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
783 GdipDeleteGraphics(graphics
);
785 ReleaseDC(hwnd
, hdc
);
788 static void test_GdipDrawCurve3(void)
791 GpGraphics
*graphics
= NULL
;
793 HDC hdc
= GetDC( hwnd
);
805 /* make a graphics object and pen object */
806 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
808 status
= GdipCreateFromHDC(hdc
, &graphics
);
810 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
812 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
814 ok(pen
!= NULL
, "Expected pen to be initialized\n");
816 /* InvalidParameter cases: null graphics, null pen */
817 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
818 expect(InvalidParameter
, status
);
820 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
821 expect(InvalidParameter
, status
);
823 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
824 expect(InvalidParameter
, status
);
826 /* InvalidParameter cases: invalid count */
827 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
828 expect(InvalidParameter
, status
);
830 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
831 expect(InvalidParameter
, status
);
833 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
834 expect(InvalidParameter
, status
);
836 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
837 expect(InvalidParameter
, status
);
839 /* InvalidParameter cases: invalid number of segments */
840 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
841 expect(InvalidParameter
, status
);
843 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
844 expect(InvalidParameter
, status
);
846 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
847 expect(InvalidParameter
, status
);
849 /* Valid test cases */
850 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
853 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
856 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
859 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
863 GdipDeleteGraphics(graphics
);
865 ReleaseDC(hwnd
, hdc
);
868 static void test_GdipDrawCurve3I(void)
871 GpGraphics
*graphics
= NULL
;
873 HDC hdc
= GetDC( hwnd
);
885 /* make a graphics object and pen object */
886 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
888 status
= GdipCreateFromHDC(hdc
, &graphics
);
890 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
892 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
894 ok(pen
!= NULL
, "Expected pen to be initialized\n");
896 /* InvalidParameter cases: null graphics, null pen */
897 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
898 expect(InvalidParameter
, status
);
900 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
901 expect(InvalidParameter
, status
);
903 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
904 expect(InvalidParameter
, status
);
906 /* InvalidParameter cases: invalid count */
907 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
908 expect(OutOfMemory
, status
);
910 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
911 expect(InvalidParameter
, status
);
913 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
914 expect(InvalidParameter
, status
);
916 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
917 expect(InvalidParameter
, status
);
919 /* InvalidParameter cases: invalid number of segments */
920 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
921 expect(InvalidParameter
, status
);
923 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
924 expect(InvalidParameter
, status
);
926 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
927 expect(InvalidParameter
, status
);
929 /* Valid test cases */
930 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
933 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
936 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
939 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
943 GdipDeleteGraphics(graphics
);
945 ReleaseDC(hwnd
, hdc
);
948 static void test_GdipDrawCurve2(void)
951 GpGraphics
*graphics
= NULL
;
953 HDC hdc
= GetDC( hwnd
);
965 /* make a graphics object and pen object */
966 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
968 status
= GdipCreateFromHDC(hdc
, &graphics
);
970 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
972 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
974 ok(pen
!= NULL
, "Expected pen to be initialized\n");
976 /* InvalidParameter cases: null graphics, null pen */
977 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
978 expect(InvalidParameter
, status
);
980 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
981 expect(InvalidParameter
, status
);
983 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
984 expect(InvalidParameter
, status
);
986 /* InvalidParameter cases: invalid count */
987 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
988 expect(InvalidParameter
, status
);
990 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
991 expect(InvalidParameter
, status
);
993 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
994 expect(InvalidParameter
, status
);
996 /* Valid test cases */
997 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1000 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1003 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1006 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1010 GdipDeleteGraphics(graphics
);
1012 ReleaseDC(hwnd
, hdc
);
1015 static void test_GdipDrawCurve2I(void)
1018 GpGraphics
*graphics
= NULL
;
1020 HDC hdc
= GetDC( hwnd
);
1032 /* make a graphics object and pen object */
1033 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1035 status
= GdipCreateFromHDC(hdc
, &graphics
);
1037 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1039 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1041 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1043 /* InvalidParameter cases: null graphics, null pen */
1044 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1045 expect(InvalidParameter
, status
);
1047 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1048 expect(InvalidParameter
, status
);
1050 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1051 expect(InvalidParameter
, status
);
1053 /* InvalidParameter cases: invalid count */
1054 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1055 expect(OutOfMemory
, status
);
1057 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1058 expect(InvalidParameter
, status
);
1060 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1061 expect(InvalidParameter
, status
);
1063 /* Valid test cases */
1064 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1067 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1070 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1073 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1077 GdipDeleteGraphics(graphics
);
1079 ReleaseDC(hwnd
, hdc
);
1082 static void test_GdipDrawCurve(void)
1085 GpGraphics
*graphics
= NULL
;
1087 HDC hdc
= GetDC( hwnd
);
1099 /* make a graphics object and pen object */
1100 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1102 status
= GdipCreateFromHDC(hdc
, &graphics
);
1104 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1106 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1108 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1110 /* InvalidParameter cases: null graphics, null pen */
1111 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1112 expect(InvalidParameter
, status
);
1114 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1115 expect(InvalidParameter
, status
);
1117 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1118 expect(InvalidParameter
, status
);
1120 /* InvalidParameter cases: invalid count */
1121 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1122 expect(InvalidParameter
, status
);
1124 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1125 expect(InvalidParameter
, status
);
1127 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1128 expect(InvalidParameter
, status
);
1130 /* Valid test cases */
1131 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1134 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1138 GdipDeleteGraphics(graphics
);
1140 ReleaseDC(hwnd
, hdc
);
1143 static void test_GdipDrawCurveI(void)
1146 GpGraphics
*graphics
= NULL
;
1148 HDC hdc
= GetDC( hwnd
);
1160 /* make a graphics object and pen object */
1161 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1163 status
= GdipCreateFromHDC(hdc
, &graphics
);
1165 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1167 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1169 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1171 /* InvalidParameter cases: null graphics, null pen */
1172 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1173 expect(InvalidParameter
, status
);
1175 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1176 expect(InvalidParameter
, status
);
1178 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1179 expect(InvalidParameter
, status
);
1181 /* InvalidParameter cases: invalid count */
1182 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1183 expect(OutOfMemory
, status
);
1185 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1186 expect(InvalidParameter
, status
);
1188 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1189 expect(InvalidParameter
, status
);
1191 /* Valid test cases */
1192 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1195 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1199 GdipDeleteGraphics(graphics
);
1201 ReleaseDC(hwnd
, hdc
);
1204 static void test_GdipDrawLineI(void)
1207 GpGraphics
*graphics
= NULL
;
1209 HDC hdc
= GetDC( hwnd
);
1211 /* make a graphics object and pen object */
1212 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1214 status
= GdipCreateFromHDC(hdc
, &graphics
);
1216 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1218 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1220 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1222 /* InvalidParameter cases: null graphics, null pen */
1223 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1224 expect(InvalidParameter
, status
);
1226 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1227 expect(InvalidParameter
, status
);
1229 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1230 expect(InvalidParameter
, status
);
1232 /* successful case */
1233 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1237 GdipDeleteGraphics(graphics
);
1239 ReleaseDC(hwnd
, hdc
);
1242 static void test_GdipDrawImagePointsRect(void)
1245 GpGraphics
*graphics
= NULL
;
1247 GpBitmap
*bm
= NULL
;
1248 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1250 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1251 HDC hdc
= GetDC( hwnd
);
1255 memset(rbmi
, 0, sizeof(rbmi
));
1256 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1257 bmi
->bmiHeader
.biWidth
= 10;
1258 bmi
->bmiHeader
.biHeight
= 10;
1259 bmi
->bmiHeader
.biPlanes
= 1;
1260 bmi
->bmiHeader
.biBitCount
= 32;
1261 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1262 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1264 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1265 status
= GdipCreateFromHDC(hdc
, &graphics
);
1275 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1276 expect(NotImplemented
, status
);
1277 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1278 expect(InvalidParameter
, status
);
1279 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1281 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1282 expect(InvalidParameter
, status
);
1283 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1284 expect(InvalidParameter
, status
);
1285 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1287 memset(ptf
, 0, sizeof(ptf
));
1288 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1291 GdipDisposeImage((GpImage
*)bm
);
1292 GdipDeleteGraphics(graphics
);
1293 ReleaseDC(hwnd
, hdc
);
1296 static void test_GdipDrawLinesI(void)
1299 GpGraphics
*graphics
= NULL
;
1301 GpPoint
*ptf
= NULL
;
1302 HDC hdc
= GetDC( hwnd
);
1304 /* make a graphics object and pen object */
1305 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1307 status
= GdipCreateFromHDC(hdc
, &graphics
);
1309 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1311 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1313 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1315 /* make some arbitrary valid points*/
1316 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1324 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1325 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1326 expect(InvalidParameter
, status
);
1328 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1329 expect(InvalidParameter
, status
);
1331 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1332 expect(InvalidParameter
, status
);
1334 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1335 expect(InvalidParameter
, status
);
1337 /* successful case */
1338 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1343 GdipDeleteGraphics(graphics
);
1345 ReleaseDC(hwnd
, hdc
);
1348 static void test_GdipFillClosedCurve(void)
1351 GpGraphics
*graphics
= NULL
;
1352 GpSolidFill
*brush
= NULL
;
1353 HDC hdc
= GetDC( hwnd
);
1365 /* make a graphics object and brush object */
1366 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1368 status
= GdipCreateFromHDC(hdc
, &graphics
);
1370 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1372 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1374 /* InvalidParameter cases: null graphics, null brush, null points */
1375 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1376 expect(InvalidParameter
, status
);
1378 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1379 expect(InvalidParameter
, status
);
1381 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1382 expect(InvalidParameter
, status
);
1384 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1385 expect(InvalidParameter
, status
);
1387 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1388 expect(InvalidParameter
, status
);
1390 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1391 expect(InvalidParameter
, status
);
1393 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1394 expect(InvalidParameter
, status
);
1396 /* InvalidParameter cases: invalid count */
1397 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1398 expect(InvalidParameter
, status
);
1400 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1401 expect(InvalidParameter
, status
);
1403 /* Valid test cases */
1404 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1407 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1410 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1413 GdipDeleteGraphics(graphics
);
1414 GdipDeleteBrush((GpBrush
*)brush
);
1416 ReleaseDC(hwnd
, hdc
);
1419 static void test_GdipFillClosedCurveI(void)
1422 GpGraphics
*graphics
= NULL
;
1423 GpSolidFill
*brush
= NULL
;
1424 HDC hdc
= GetDC( hwnd
);
1436 /* make a graphics object and brush object */
1437 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1439 status
= GdipCreateFromHDC(hdc
, &graphics
);
1441 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1443 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1445 /* InvalidParameter cases: null graphics, null brush */
1446 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1447 when points == NULL, so don't test this condition */
1448 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1449 expect(InvalidParameter
, status
);
1451 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1452 expect(InvalidParameter
, status
);
1454 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1455 expect(InvalidParameter
, status
);
1457 /* InvalidParameter cases: invalid count */
1458 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1459 expect(InvalidParameter
, status
);
1461 /* OutOfMemory cases: large (unsigned) int */
1462 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1463 expect(OutOfMemory
, status
);
1465 /* Valid test cases */
1466 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1469 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1472 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1475 GdipDeleteGraphics(graphics
);
1476 GdipDeleteBrush((GpBrush
*)brush
);
1478 ReleaseDC(hwnd
, hdc
);
1481 static void test_Get_Release_DC(void)
1484 GpGraphics
*graphics
= NULL
;
1488 HDC hdc
= GetDC( hwnd
);
1491 CompositingQuality quality
;
1492 CompositingMode compmode
;
1493 InterpolationMode intmode
;
1497 PixelOffsetMode offsetmode
;
1498 SmoothingMode smoothmode
;
1499 TextRenderingHint texthint
;
1507 ARGB color
= 0x00000000;
1508 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1521 for(i
= 0; i
< 5;i
++){
1522 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1523 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1529 rect
[0].Height
= 70;
1533 rect
[1].Height
= 20;
1535 for(i
= 0; i
< 2;i
++){
1536 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1537 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1538 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1539 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1542 status
= GdipCreateMatrix(&m
);
1544 GdipCreateRegion(®ion
);
1545 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1546 GdipCreatePath(FillModeAlternate
, &path
);
1547 GdipCreateRegion(&clip
);
1549 status
= GdipCreateFromHDC(hdc
, &graphics
);
1551 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1552 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1555 /* NULL arguments */
1556 status
= GdipGetDC(NULL
, NULL
);
1557 expect(InvalidParameter
, status
);
1558 status
= GdipGetDC(graphics
, NULL
);
1559 expect(InvalidParameter
, status
);
1560 status
= GdipGetDC(NULL
, &retdc
);
1561 expect(InvalidParameter
, status
);
1563 status
= GdipReleaseDC(NULL
, NULL
);
1564 expect(InvalidParameter
, status
);
1565 status
= GdipReleaseDC(graphics
, NULL
);
1566 expect(InvalidParameter
, status
);
1567 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1568 expect(InvalidParameter
, status
);
1570 /* Release without Get */
1571 status
= GdipReleaseDC(graphics
, hdc
);
1572 expect(InvalidParameter
, status
);
1575 status
= GdipGetDC(graphics
, &retdc
);
1577 ok(retdc
== hdc
, "Invalid HDC returned\n");
1578 /* call it once more */
1579 status
= GdipGetDC(graphics
, &retdc
);
1580 expect(ObjectBusy
, status
);
1582 /* try all Graphics calls here */
1583 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1584 expect(ObjectBusy
, status
);
1585 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1586 expect(ObjectBusy
, status
);
1587 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1588 expect(ObjectBusy
, status
);
1589 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1590 expect(ObjectBusy
, status
);
1591 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1592 expect(ObjectBusy
, status
);
1593 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1594 expect(ObjectBusy
, status
);
1595 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1596 expect(ObjectBusy
, status
);
1597 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1598 expect(ObjectBusy
, status
);
1599 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1600 expect(ObjectBusy
, status
);
1601 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1602 expect(ObjectBusy
, status
);
1603 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1604 expect(ObjectBusy
, status
);
1605 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1606 expect(ObjectBusy
, status
);
1607 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1608 expect(ObjectBusy
, status
);
1609 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1610 expect(ObjectBusy
, status
);
1611 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1612 expect(ObjectBusy
, status
);
1613 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1614 expect(ObjectBusy
, status
);
1615 /* GdipDrawImage/GdipDrawImageI */
1616 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1617 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1618 /* GdipDrawImageRect/GdipDrawImageRectI */
1619 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1620 expect(ObjectBusy
, status
);
1621 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1622 expect(ObjectBusy
, status
);
1623 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1624 expect(ObjectBusy
, status
);
1625 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1626 expect(ObjectBusy
, status
);
1627 status
= GdipDrawPath(graphics
, pen
, path
);
1628 expect(ObjectBusy
, status
);
1629 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1630 expect(ObjectBusy
, status
);
1631 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1632 expect(ObjectBusy
, status
);
1633 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1634 expect(ObjectBusy
, status
);
1635 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1636 expect(ObjectBusy
, status
);
1637 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1638 expect(ObjectBusy
, status
);
1639 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1640 expect(ObjectBusy
, status
);
1641 /* GdipDrawString */
1642 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1643 expect(ObjectBusy
, status
);
1644 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1645 expect(ObjectBusy
, status
);
1646 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1647 expect(ObjectBusy
, status
);
1648 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1649 expect(ObjectBusy
, status
);
1650 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1651 expect(ObjectBusy
, status
);
1652 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1653 expect(ObjectBusy
, status
);
1654 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1655 expect(ObjectBusy
, status
);
1656 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1657 expect(ObjectBusy
, status
);
1658 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1659 expect(ObjectBusy
, status
);
1660 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1661 expect(ObjectBusy
, status
);
1662 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1663 expect(ObjectBusy
, status
);
1664 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1665 expect(ObjectBusy
, status
);
1666 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1667 expect(ObjectBusy
, status
);
1668 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1669 expect(ObjectBusy
, status
);
1670 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1671 expect(ObjectBusy
, status
);
1672 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1673 expect(ObjectBusy
, status
);
1674 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1675 expect(ObjectBusy
, status
);
1676 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1677 expect(ObjectBusy
, status
);
1678 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1679 expect(ObjectBusy
, status
);
1680 status
= GdipGetClipBounds(graphics
, rectf
);
1681 expect(ObjectBusy
, status
);
1682 status
= GdipGetClipBoundsI(graphics
, rect
);
1683 expect(ObjectBusy
, status
);
1684 status
= GdipGetCompositingMode(graphics
, &compmode
);
1685 expect(ObjectBusy
, status
);
1686 status
= GdipGetCompositingQuality(graphics
, &quality
);
1687 expect(ObjectBusy
, status
);
1688 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1689 expect(ObjectBusy
, status
);
1690 status
= GdipGetNearestColor(graphics
, &color
);
1691 expect(ObjectBusy
, status
);
1692 status
= GdipGetPageScale(graphics
, &r
);
1693 expect(ObjectBusy
, status
);
1694 status
= GdipGetPageUnit(graphics
, &unit
);
1695 expect(ObjectBusy
, status
);
1696 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1697 expect(ObjectBusy
, status
);
1698 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1699 expect(ObjectBusy
, status
);
1700 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1701 expect(ObjectBusy
, status
);
1702 status
= GdipGetWorldTransform(graphics
, m
);
1703 expect(ObjectBusy
, status
);
1704 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1705 expect(ObjectBusy
, status
);
1706 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1707 expect(ObjectBusy
, status
);
1708 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1709 expect(ObjectBusy
, status
);
1710 /* GdipMeasureCharacterRanges */
1711 /* GdipMeasureString */
1712 status
= GdipResetClip(graphics
);
1713 expect(ObjectBusy
, status
);
1714 status
= GdipResetWorldTransform(graphics
);
1715 expect(ObjectBusy
, status
);
1716 /* GdipRestoreGraphics */
1717 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1718 expect(ObjectBusy
, status
);
1719 /* GdipSaveGraphics */
1720 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1721 expect(ObjectBusy
, status
);
1722 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1723 expect(ObjectBusy
, status
);
1724 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1725 expect(ObjectBusy
, status
);
1726 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1727 expect(ObjectBusy
, status
);
1728 status
= GdipSetPageScale(graphics
, 1.0);
1729 expect(ObjectBusy
, status
);
1730 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1731 expect(ObjectBusy
, status
);
1732 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1733 expect(ObjectBusy
, status
);
1734 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1735 expect(ObjectBusy
, status
);
1736 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1737 expect(ObjectBusy
, status
);
1738 status
= GdipSetWorldTransform(graphics
, m
);
1739 expect(ObjectBusy
, status
);
1740 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1741 expect(ObjectBusy
, status
);
1742 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1743 expect(ObjectBusy
, status
);
1744 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1745 expect(ObjectBusy
, status
);
1746 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1747 expect(ObjectBusy
, status
);
1748 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1749 expect(ObjectBusy
, status
);
1750 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1751 expect(ObjectBusy
, status
);
1752 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1753 expect(ObjectBusy
, status
);
1754 status
= GdipTranslateClipI(graphics
, 0, 0);
1755 expect(ObjectBusy
, status
);
1756 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1757 expect(ObjectBusy
, status
);
1758 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1759 expect(ObjectBusy
, status
);
1760 status
= GdipGetDpiX(graphics
, &r
);
1761 expect(ObjectBusy
, status
);
1762 status
= GdipGetDpiY(graphics
, &r
);
1763 expect(ObjectBusy
, status
);
1764 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1765 expect(ObjectBusy
, status
);
1766 status
= GdipGetClip(graphics
, region
);
1767 expect(ObjectBusy
, status
);
1768 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1769 expect(ObjectBusy
, status
);
1771 /* try to delete before release */
1772 status
= GdipDeleteGraphics(graphics
);
1773 expect(ObjectBusy
, status
);
1775 status
= GdipReleaseDC(graphics
, retdc
);
1779 GdipDeleteGraphics(graphics
);
1781 GdipDeleteRegion(clip
);
1782 GdipDeletePath(path
);
1783 GdipDeleteBrush((GpBrush
*)brush
);
1784 GdipDeleteRegion(region
);
1785 GdipDeleteMatrix(m
);
1788 ReleaseDC(hwnd
, hdc
);
1791 static void test_transformpoints(void)
1794 GpGraphics
*graphics
= NULL
;
1795 HDC hdc
= GetDC( hwnd
);
1799 status
= GdipCreateFromHDC(hdc
, &graphics
);
1802 /* NULL arguments */
1803 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1804 expect(InvalidParameter
, status
);
1805 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1806 expect(InvalidParameter
, status
);
1807 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1808 expect(InvalidParameter
, status
);
1809 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1810 expect(InvalidParameter
, status
);
1816 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1818 expectf(1.0, ptf
[0].X
);
1819 expectf(0.0, ptf
[0].Y
);
1820 expectf(0.0, ptf
[1].X
);
1821 expectf(1.0, ptf
[1].Y
);
1823 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1825 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1827 status
= GdipSetPageScale(graphics
, 3.0);
1834 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1836 expectf(18.0, ptf
[0].X
);
1837 expectf(15.0, ptf
[0].Y
);
1838 expectf(15.0, ptf
[1].X
);
1839 expectf(18.0, ptf
[1].Y
);
1845 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1847 expectf(6.0, ptf
[0].X
);
1848 expectf(5.0, ptf
[0].Y
);
1849 expectf(5.0, ptf
[1].X
);
1850 expectf(6.0, ptf
[1].Y
);
1856 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1858 expectf(3.0, ptf
[0].X
);
1859 expectf(0.0, ptf
[0].Y
);
1860 expectf(0.0, ptf
[1].X
);
1861 expectf(3.0, ptf
[1].Y
);
1867 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1869 expectf(1.0, ptf
[0].X
);
1870 expectf(0.0, ptf
[0].Y
);
1871 expectf(0.0, ptf
[1].X
);
1872 expectf(1.0, ptf
[1].Y
);
1878 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1880 expectf(1.0, ptf
[0].X
);
1881 expectf(0.0, ptf
[0].Y
);
1882 expectf(0.0, ptf
[1].X
);
1883 expectf(1.0, ptf
[1].Y
);
1889 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1891 expectf(1.0, ptf
[0].X
);
1892 expectf(0.0, ptf
[0].Y
);
1893 expectf(0.0, ptf
[1].X
);
1894 expectf(1.0, ptf
[1].Y
);
1900 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1902 expect(18, pt
[0].X
);
1903 expect(15, pt
[0].Y
);
1904 expect(15, pt
[1].X
);
1905 expect(18, pt
[1].Y
);
1907 GdipDeleteGraphics(graphics
);
1908 ReleaseDC(hwnd
, hdc
);
1911 static void test_get_set_clip(void)
1914 GpGraphics
*graphics
= NULL
;
1915 HDC hdc
= GetDC( hwnd
);
1920 status
= GdipCreateFromHDC(hdc
, &graphics
);
1923 rect
.X
= rect
.Y
= 0.0;
1924 rect
.Height
= rect
.Width
= 100.0;
1926 status
= GdipCreateRegionRect(&rect
, &clip
);
1929 /* NULL arguments */
1930 status
= GdipGetClip(NULL
, NULL
);
1931 expect(InvalidParameter
, status
);
1932 status
= GdipGetClip(graphics
, NULL
);
1933 expect(InvalidParameter
, status
);
1934 status
= GdipGetClip(NULL
, clip
);
1935 expect(InvalidParameter
, status
);
1937 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1938 expect(InvalidParameter
, status
);
1939 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1940 expect(InvalidParameter
, status
);
1942 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1943 expect(InvalidParameter
, status
);
1944 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1945 expect(InvalidParameter
, status
);
1948 status
= GdipGetClip(graphics
, clip
);
1950 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1954 /* remains infinite after reset */
1956 status
= GdipResetClip(graphics
);
1958 status
= GdipGetClip(graphics
, clip
);
1960 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1964 /* set to empty and then reset to infinite */
1965 status
= GdipSetEmpty(clip
);
1967 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1970 status
= GdipGetClip(graphics
, clip
);
1973 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1976 status
= GdipResetClip(graphics
);
1978 status
= GdipGetClip(graphics
, clip
);
1981 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1985 GdipDeleteRegion(clip
);
1987 GdipDeleteGraphics(graphics
);
1988 ReleaseDC(hwnd
, hdc
);
1991 static void test_isempty(void)
1994 GpGraphics
*graphics
= NULL
;
1995 HDC hdc
= GetDC( hwnd
);
1999 status
= GdipCreateFromHDC(hdc
, &graphics
);
2002 status
= GdipCreateRegion(&clip
);
2006 status
= GdipIsClipEmpty(NULL
, NULL
);
2007 expect(InvalidParameter
, status
);
2008 status
= GdipIsClipEmpty(graphics
, NULL
);
2009 expect(InvalidParameter
, status
);
2010 status
= GdipIsClipEmpty(NULL
, &res
);
2011 expect(InvalidParameter
, status
);
2013 /* default is infinite */
2015 status
= GdipIsClipEmpty(graphics
, &res
);
2019 GdipDeleteRegion(clip
);
2021 GdipDeleteGraphics(graphics
);
2022 ReleaseDC(hwnd
, hdc
);
2025 static void test_clear(void)
2029 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2030 expect(InvalidParameter
, status
);
2033 static void test_textcontrast(void)
2036 HDC hdc
= GetDC( hwnd
);
2037 GpGraphics
*graphics
;
2040 status
= GdipGetTextContrast(NULL
, NULL
);
2041 expect(InvalidParameter
, status
);
2043 status
= GdipCreateFromHDC(hdc
, &graphics
);
2046 status
= GdipGetTextContrast(graphics
, NULL
);
2047 expect(InvalidParameter
, status
);
2048 status
= GdipGetTextContrast(graphics
, &contrast
);
2050 expect(4, contrast
);
2052 GdipDeleteGraphics(graphics
);
2053 ReleaseDC(hwnd
, hdc
);
2056 static void test_GdipDrawString(void)
2059 GpGraphics
*graphics
= NULL
;
2062 GpStringFormat
*format
;
2065 HDC hdc
= GetDC( hwnd
);
2066 static const WCHAR string
[] = {'T','e','s','t',0};
2067 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2070 memset(&logfont
,0,sizeof(logfont
));
2071 strcpy(logfont
.lfFaceName
,"Arial");
2072 logfont
.lfHeight
= 12;
2073 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2075 status
= GdipCreateFromHDC(hdc
, &graphics
);
2078 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2079 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2081 skip("Arial not installed.\n");
2086 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2089 status
= GdipCreateStringFormat(0,0,&format
);
2097 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2100 status
= GdipCreateMatrix(&matrix
);
2103 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2104 expect(InvalidParameter
, status
);
2106 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2107 expect(InvalidParameter
, status
);
2109 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2110 expect(InvalidParameter
, status
);
2112 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2113 expect(InvalidParameter
, status
);
2115 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2116 expect(InvalidParameter
, status
);
2118 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2121 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2124 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2127 GdipDeleteMatrix(matrix
);
2128 GdipDeleteGraphics(graphics
);
2129 GdipDeleteBrush(brush
);
2130 GdipDeleteFont(fnt
);
2131 GdipDeleteStringFormat(format
);
2133 ReleaseDC(hwnd
, hdc
);
2136 static void test_GdipGetVisibleClipBounds_screen(void)
2139 GpGraphics
*graphics
= NULL
;
2141 GpRectF rectf
, exp
, clipr
;
2144 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2146 status
= GdipCreateFromHDC(hdc
, &graphics
);
2148 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2150 /* no clipping rect */
2153 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2154 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2156 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2158 ok(rectf
.X
== exp
.X
&&
2160 rectf
.Width
== exp
.Width
&&
2161 rectf
.Height
== exp
.Height
,
2162 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2163 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2164 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2165 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2167 /* clipping rect entirely within window */
2168 exp
.X
= clipr
.X
= 10;
2169 exp
.Y
= clipr
.Y
= 12;
2170 exp
.Width
= clipr
.Width
= 14;
2171 exp
.Height
= clipr
.Height
= 16;
2173 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2176 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2178 ok(rectf
.X
== exp
.X
&&
2180 rectf
.Width
== exp
.Width
&&
2181 rectf
.Height
== exp
.Height
,
2182 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2183 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2184 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2185 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2187 /* clipping rect partially outside of screen */
2193 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2201 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2203 ok(rectf
.X
== exp
.X
&&
2205 rectf
.Width
== exp
.Width
&&
2206 rectf
.Height
== exp
.Height
,
2207 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2208 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2209 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2210 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2212 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2214 ok(recti
.X
== exp
.X
&&
2216 recti
.Width
== exp
.Width
&&
2217 recti
.Height
== exp
.Height
,
2218 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2219 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2220 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2221 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2223 GdipDeleteGraphics(graphics
);
2227 static void test_GdipGetVisibleClipBounds_window(void)
2230 GpGraphics
*graphics
= NULL
;
2231 GpRectF rectf
, window
, exp
, clipr
;
2237 /* get client area size */
2238 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2239 window
.X
= wnd_rect
.left
;
2240 window
.Y
= wnd_rect
.top
;
2241 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2242 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2244 hdc
= BeginPaint(hwnd
, &ps
);
2246 status
= GdipCreateFromHDC(hdc
, &graphics
);
2248 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2250 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2252 ok(rectf
.X
== window
.X
&&
2253 rectf
.Y
== window
.Y
&&
2254 rectf
.Width
== window
.Width
&&
2255 rectf
.Height
== window
.Height
,
2256 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2257 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2258 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2259 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2261 /* clipping rect entirely within window */
2262 exp
.X
= clipr
.X
= 20;
2263 exp
.Y
= clipr
.Y
= 8;
2264 exp
.Width
= clipr
.Width
= 30;
2265 exp
.Height
= clipr
.Height
= 20;
2267 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2270 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2272 ok(rectf
.X
== exp
.X
&&
2274 rectf
.Width
== exp
.Width
&&
2275 rectf
.Height
== exp
.Height
,
2276 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2277 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2278 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2279 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2281 /* clipping rect partially outside of window */
2282 clipr
.X
= window
.Width
- 10;
2283 clipr
.Y
= window
.Height
- 15;
2287 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2290 exp
.X
= window
.Width
- 10;
2291 exp
.Y
= window
.Height
- 15;
2295 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2297 ok(rectf
.X
== exp
.X
&&
2299 rectf
.Width
== exp
.Width
&&
2300 rectf
.Height
== exp
.Height
,
2301 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2302 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2303 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2304 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2306 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2308 ok(recti
.X
== exp
.X
&&
2310 recti
.Width
== exp
.Width
&&
2311 recti
.Height
== exp
.Height
,
2312 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2313 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2314 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2315 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2317 GdipDeleteGraphics(graphics
);
2318 EndPaint(hwnd
, &ps
);
2321 static void test_GdipGetVisibleClipBounds(void)
2323 GpGraphics
* graphics
= NULL
;
2326 HDC hdc
= GetDC( hwnd
);
2329 status
= GdipCreateFromHDC(hdc
, &graphics
);
2331 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2333 /* test null parameters */
2334 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2335 expect(InvalidParameter
, status
);
2337 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2338 expect(InvalidParameter
, status
);
2340 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2341 expect(InvalidParameter
, status
);
2343 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2344 expect(InvalidParameter
, status
);
2346 GdipDeleteGraphics(graphics
);
2347 ReleaseDC(hwnd
, hdc
);
2349 test_GdipGetVisibleClipBounds_screen();
2350 test_GdipGetVisibleClipBounds_window();
2353 static void test_fromMemoryBitmap(void)
2356 GpGraphics
*graphics
= NULL
;
2357 GpBitmap
*bitmap
= NULL
;
2358 BYTE bits
[48] = {0};
2362 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2365 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2368 status
= GdipGraphicsClear(graphics
, 0xff686868);
2371 GdipDeleteGraphics(graphics
);
2373 /* drawing writes to the memory provided */
2374 expect(0x68, bits
[10]);
2376 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2379 status
= GdipGetDC(graphics
, &hdc
);
2381 ok(hdc
!= NULL
, "got NULL hdc\n");
2383 color
= GetPixel(hdc
, 0, 0);
2384 /* The HDC is write-only, and native fills with a solid color to figure out
2385 * which pixels have changed. */
2386 todo_wine
expect(0x0c0b0d, color
);
2388 SetPixel(hdc
, 0, 0, 0x797979);
2389 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2391 status
= GdipReleaseDC(graphics
, hdc
);
2394 GdipDeleteGraphics(graphics
);
2396 expect(0x79, bits
[0]);
2397 todo_wine
expect(0x68, bits
[3]);
2399 GdipDisposeImage((GpImage
*)bitmap
);
2401 /* We get the same kind of write-only HDC for a "normal" bitmap */
2402 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2405 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2408 status
= GdipGetDC(graphics
, &hdc
);
2410 ok(hdc
!= NULL
, "got NULL hdc\n");
2412 color
= GetPixel(hdc
, 0, 0);
2413 todo_wine
expect(0x0c0b0d, color
);
2415 status
= GdipReleaseDC(graphics
, hdc
);
2418 GdipDeleteGraphics(graphics
);
2420 GdipDisposeImage((GpImage
*)bitmap
);
2423 static void test_GdipIsVisiblePoint(void)
2426 GpGraphics
*graphics
= NULL
;
2427 HDC hdc
= GetDC( hwnd
);
2431 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2433 status
= GdipCreateFromHDC(hdc
, &graphics
);
2435 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2437 /* null parameters */
2438 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2439 expect(InvalidParameter
, status
);
2441 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2442 expect(InvalidParameter
, status
);
2444 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2445 expect(InvalidParameter
, status
);
2447 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2448 expect(InvalidParameter
, status
);
2452 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2454 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2458 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2460 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2464 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2466 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2470 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2472 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2474 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2479 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2481 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2485 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2487 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2489 /* translate into the center of the rect */
2490 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2494 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2496 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2500 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2502 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2504 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2509 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2511 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2515 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2517 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2521 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2523 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2527 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2529 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2533 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2535 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2539 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2541 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2545 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2547 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2551 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2553 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2557 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2559 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2563 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2565 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2569 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2571 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2575 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2577 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2581 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2583 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2585 /* integer version */
2588 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2590 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2594 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2596 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2598 GdipDeleteGraphics(graphics
);
2599 ReleaseDC(hwnd
, hdc
);
2602 static void test_GdipIsVisibleRect(void)
2605 GpGraphics
*graphics
= NULL
;
2606 HDC hdc
= GetDC( hwnd
);
2607 REAL x
, y
, width
, height
;
2610 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2612 status
= GdipCreateFromHDC(hdc
, &graphics
);
2614 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2616 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2617 expect(InvalidParameter
, status
);
2619 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2620 expect(InvalidParameter
, status
);
2622 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2623 expect(InvalidParameter
, status
);
2625 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2626 expect(InvalidParameter
, status
);
2628 /* entirely within the visible region */
2631 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2633 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2635 /* partially outside */
2636 x
= -10; width
= 20;
2637 y
= -10; height
= 20;
2638 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2640 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2642 /* entirely outside */
2644 y
= -10; height
= 5;
2645 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2647 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2649 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2652 /* entirely within the visible region */
2654 y
= 22; height
= 10;
2655 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2657 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2659 /* partially outside */
2661 y
= 55; height
= 10;
2662 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2664 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2666 /* entirely outside */
2669 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2671 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2673 /* translate into center of clipping rect */
2674 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2678 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2680 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2684 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2686 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2688 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2690 /* corners entirely outside, but some intersections */
2693 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2695 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2699 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2701 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2705 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2707 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2711 y
= 20; height
= 40;
2712 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2714 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2718 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2720 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2723 y
= 20; height
= 40;
2724 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2726 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2729 y
= 60; height
= 10;
2730 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2732 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2734 /* rounding tests */
2735 x
= 0.4; width
= 10.4;
2736 y
= 20; height
= 40;
2737 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2739 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2742 y
= 0.4; height
= 20.4;
2743 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2745 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2747 /* integer version */
2750 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2752 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2755 y
= 22; height
= 10;
2756 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2758 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2760 GdipDeleteGraphics(graphics
);
2761 ReleaseDC(hwnd
, hdc
);
2764 static void test_GdipGetNearestColor(void)
2767 GpGraphics
*graphics
;
2769 ARGB color
= 0xdeadbeef;
2770 HDC hdc
= GetDC( hwnd
);
2772 /* create a graphics object */
2773 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2775 status
= GdipCreateFromHDC(hdc
, &graphics
);
2777 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2779 status
= GdipGetNearestColor(graphics
, NULL
);
2780 expect(InvalidParameter
, status
);
2782 status
= GdipGetNearestColor(NULL
, &color
);
2783 expect(InvalidParameter
, status
);
2784 GdipDeleteGraphics(graphics
);
2786 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2788 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2789 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2792 status
= GdipGetNearestColor(graphics
, &color
);
2794 expect(0xdeadbeef, color
);
2795 GdipDeleteGraphics(graphics
);
2797 GdipDisposeImage((GpImage
*)bitmap
);
2799 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2801 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2802 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2805 status
= GdipGetNearestColor(graphics
, &color
);
2807 expect(0xdeadbeef, color
);
2808 GdipDeleteGraphics(graphics
);
2810 GdipDisposeImage((GpImage
*)bitmap
);
2812 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2814 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2815 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2818 status
= GdipGetNearestColor(graphics
, &color
);
2820 expect(0xdeadbeef, color
);
2821 GdipDeleteGraphics(graphics
);
2823 GdipDisposeImage((GpImage
*)bitmap
);
2825 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2827 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2828 todo_wine
expect(OutOfMemory
, status
);
2830 GdipDeleteGraphics(graphics
);
2831 GdipDisposeImage((GpImage
*)bitmap
);
2833 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2835 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2837 status
= GdipGetNearestColor(graphics
, &color
);
2839 expect(0xdeadbeef, color
);
2840 GdipDeleteGraphics(graphics
);
2841 GdipDisposeImage((GpImage
*)bitmap
);
2843 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2845 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2847 status
= GdipGetNearestColor(graphics
, &color
);
2849 expect(0xdeadbeef, color
);
2850 GdipDeleteGraphics(graphics
);
2851 GdipDisposeImage((GpImage
*)bitmap
);
2853 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2855 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2857 status
= GdipGetNearestColor(graphics
, &color
);
2859 expect(0xdeadbeef, color
);
2860 GdipDeleteGraphics(graphics
);
2861 GdipDisposeImage((GpImage
*)bitmap
);
2863 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2867 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2869 status
= GdipGetNearestColor(graphics
, &color
);
2871 expect(0xdeadbeef, color
);
2872 GdipDeleteGraphics(graphics
);
2873 GdipDisposeImage((GpImage
*)bitmap
);
2876 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2880 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2882 status
= GdipGetNearestColor(graphics
, &color
);
2884 expect(0xdeadbeef, color
);
2885 GdipDeleteGraphics(graphics
);
2886 GdipDisposeImage((GpImage
*)bitmap
);
2889 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2893 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2895 status
= GdipGetNearestColor(graphics
, &color
);
2897 expect(0xdeadbeef, color
);
2898 GdipDeleteGraphics(graphics
);
2899 GdipDisposeImage((GpImage
*)bitmap
);
2902 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2904 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2906 status
= GdipGetNearestColor(graphics
, &color
);
2908 todo_wine
expect(0xffa8bce8, color
);
2909 GdipDeleteGraphics(graphics
);
2910 GdipDisposeImage((GpImage
*)bitmap
);
2912 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2914 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2916 status
= GdipGetNearestColor(graphics
, &color
);
2919 ok(color
== 0xffa8b8e8 ||
2920 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2921 "Expected ffa8b8e8, got %.8x\n", color
);
2922 GdipDeleteGraphics(graphics
);
2923 GdipDisposeImage((GpImage
*)bitmap
);
2925 ReleaseDC(hwnd
, hdc
);
2928 static void test_string_functions(void)
2931 GpGraphics
*graphics
;
2932 GpFontFamily
*family
;
2934 RectF rc
, char_bounds
, bounds
;
2936 ARGB color
= 0xff000000;
2937 HDC hdc
= GetDC( hwnd
);
2938 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2939 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2940 const WCHAR teststring2
[] = {'j',0};
2941 REAL char_width
, char_height
;
2942 INT codepointsfitted
, linesfilled
;
2943 GpStringFormat
*format
;
2944 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2945 GpRegion
*regions
[4];
2946 BOOL region_isempty
[4];
2948 PointF positions
[8];
2951 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2952 status
= GdipCreateFromHDC(hdc
, &graphics
);
2954 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2956 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2959 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2962 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2965 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2973 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2974 expect(InvalidParameter
, status
);
2976 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2977 expect(InvalidParameter
, status
);
2979 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2980 expect(InvalidParameter
, status
);
2982 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2983 expect(InvalidParameter
, status
);
2985 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2986 expect(InvalidParameter
, status
);
2988 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
2991 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2992 expect(InvalidParameter
, status
);
2994 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2995 expect(InvalidParameter
, status
);
2997 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2998 expect(InvalidParameter
, status
);
3000 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3001 expect(InvalidParameter
, status
);
3003 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3004 expect(InvalidParameter
, status
);
3006 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3009 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3012 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3014 expectf(0.0, char_bounds
.X
);
3015 expectf(0.0, char_bounds
.Y
);
3016 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3017 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3018 expect(1, codepointsfitted
);
3019 expect(1, linesfilled
);
3021 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3023 expectf(0.0, bounds
.X
);
3024 expectf(0.0, bounds
.Y
);
3025 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3026 expectf(char_bounds
.Height
, bounds
.Height
);
3027 expect(2, codepointsfitted
);
3028 expect(1, linesfilled
);
3029 char_width
= bounds
.Width
- char_bounds
.Width
;
3031 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3033 expectf(0.0, bounds
.X
);
3034 expectf(0.0, bounds
.Y
);
3035 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3036 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3037 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3038 expect(6, codepointsfitted
);
3039 expect(2, linesfilled
);
3040 char_height
= bounds
.Height
- char_bounds
.Height
;
3042 /* Measure the first line. */
3043 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3045 expectf(0.0, bounds
.X
);
3046 expectf(0.0, bounds
.Y
);
3047 expect(4, codepointsfitted
);
3048 expect(1, linesfilled
);
3050 /* Give just enough space to fit the first line. */
3051 rc
.Width
= bounds
.Width
;
3052 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3054 expectf(0.0, bounds
.X
);
3055 expectf(0.0, bounds
.Y
);
3056 todo_wine
expect(5, codepointsfitted
);
3057 todo_wine
expect(1, linesfilled
);
3059 /* Cut off everything after the first space. */
3060 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3062 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3064 expectf(0.0, bounds
.X
);
3065 expectf(0.0, bounds
.Y
);
3066 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3067 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3068 expect(6, codepointsfitted
);
3069 expect(3, linesfilled
);
3071 /* Cut off everything including the first space. */
3072 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3074 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3076 expectf(0.0, bounds
.X
);
3077 expectf(0.0, bounds
.Y
);
3078 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3079 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3080 expect(6, codepointsfitted
);
3081 expect(3, linesfilled
);
3083 /* Cut off everything after the first character. */
3084 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3086 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3088 expectf(0.0, bounds
.X
);
3089 expectf(0.0, bounds
.Y
);
3090 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3091 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3092 expect(6, codepointsfitted
);
3093 todo_wine
expect(4, linesfilled
);
3095 for (i
= 0; i
< 4; i
++)
3096 regions
[i
] = (GpRegion
*)0xdeadbeef;
3098 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3101 for (i
= 0; i
< 4; i
++)
3102 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3104 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3107 for (i
= 0; i
< 4; i
++)
3108 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3110 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3113 set_rect_empty(&rc
);
3117 status
= GdipCreateRegion(®ions
[i
]);
3119 status
= GdipSetEmpty(regions
[i
]);
3123 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3124 expect(InvalidParameter
, status
);
3126 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3127 expect(InvalidParameter
, status
);
3129 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3130 expect(InvalidParameter
, status
);
3132 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3133 expect(InvalidParameter
, status
);
3137 /* Crashes on Windows XP */
3138 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3139 expect(InvalidParameter
, status
);
3142 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3143 expect(InvalidParameter
, status
);
3145 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3146 expect(InvalidParameter
, status
);
3148 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3151 for (i
= 0; i
< 4; i
++)
3153 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3157 ok(region_isempty
[0], "region should be empty\n");
3158 ok(region_isempty
[1], "region should be empty\n");
3159 ok(region_isempty
[2], "region should be empty\n");
3160 ok(region_isempty
[3], "region should be empty\n");
3165 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3170 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3174 ok(!region_isempty
[0], "region shouldn't be empty\n");
3175 ok(!region_isempty
[1], "region shouldn't be empty\n");
3176 ok(!region_isempty
[2], "region shouldn't be empty\n");
3177 ok(region_isempty
[3], "region should be empty\n");
3179 /* Cut off everything after the first space, and the second line. */
3180 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3181 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3183 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3188 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3192 ok(!region_isempty
[0], "region shouldn't be empty\n");
3193 ok(!region_isempty
[1], "region shouldn't be empty\n");
3194 ok(region_isempty
[2], "region should be empty\n");
3195 ok(region_isempty
[3], "region should be empty\n");
3198 GdipDeleteRegion(regions
[i
]);
3200 status
= GdipCreateMatrix(&identity
);
3207 memset(positions
, 0, sizeof(positions
));
3208 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3209 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3211 expect(InvalidParameter
, status
);
3213 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3214 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3216 expect(InvalidParameter
, status
);
3218 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3219 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3221 expect(InvalidParameter
, status
);
3223 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3224 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3226 expect(InvalidParameter
, status
);
3228 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3229 0x100, identity
, &rc
);
3232 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3233 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3237 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3238 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3240 expect(InvalidParameter
, status
);
3246 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3247 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3252 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3253 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3254 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3256 char_width
= rc
.Width
;
3257 char_height
= rc
.Height
;
3263 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3264 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3269 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3270 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3271 expectf(char_height
, rc
.Height
);
3277 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3278 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3283 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3284 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3285 expectf(rc
.Height
, char_height
);
3287 GdipDeleteMatrix(identity
);
3288 GdipDeleteStringFormat(format
);
3289 GdipDeleteBrush(brush
);
3290 GdipDeleteFont(font
);
3291 GdipDeleteFontFamily(family
);
3292 GdipDeleteGraphics(graphics
);
3294 ReleaseDC(hwnd
, hdc
);
3297 static void test_get_set_interpolation(void)
3299 GpGraphics
*graphics
;
3300 HDC hdc
= GetDC( hwnd
);
3302 InterpolationMode mode
;
3304 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3305 status
= GdipCreateFromHDC(hdc
, &graphics
);
3307 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3309 status
= GdipGetInterpolationMode(NULL
, &mode
);
3310 expect(InvalidParameter
, status
);
3314 /* Crashes on Windows XP */
3315 status
= GdipGetInterpolationMode(graphics
, NULL
);
3316 expect(InvalidParameter
, status
);
3319 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3320 expect(InvalidParameter
, status
);
3323 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3324 expect(InvalidParameter
, status
);
3326 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3327 expect(InvalidParameter
, status
);
3329 status
= GdipGetInterpolationMode(graphics
, &mode
);
3331 expect(InterpolationModeBilinear
, mode
);
3333 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3336 status
= GdipGetInterpolationMode(graphics
, &mode
);
3338 expect(InterpolationModeNearestNeighbor
, mode
);
3340 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3343 status
= GdipGetInterpolationMode(graphics
, &mode
);
3345 expect(InterpolationModeBilinear
, mode
);
3347 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3350 status
= GdipGetInterpolationMode(graphics
, &mode
);
3352 expect(InterpolationModeBilinear
, mode
);
3354 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3357 status
= GdipGetInterpolationMode(graphics
, &mode
);
3359 expect(InterpolationModeHighQualityBicubic
, mode
);
3361 GdipDeleteGraphics(graphics
);
3363 ReleaseDC(hwnd
, hdc
);
3366 static void test_get_set_textrenderinghint(void)
3368 GpGraphics
*graphics
;
3369 HDC hdc
= GetDC( hwnd
);
3371 TextRenderingHint hint
;
3373 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3374 status
= GdipCreateFromHDC(hdc
, &graphics
);
3376 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3378 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3379 expect(InvalidParameter
, status
);
3381 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3382 expect(InvalidParameter
, status
);
3384 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3385 expect(InvalidParameter
, status
);
3388 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3389 expect(InvalidParameter
, status
);
3391 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3393 expect(TextRenderingHintSystemDefault
, hint
);
3395 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3398 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3400 expect(TextRenderingHintSystemDefault
, hint
);
3402 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3405 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3407 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3409 GdipDeleteGraphics(graphics
);
3411 ReleaseDC(hwnd
, hdc
);
3414 static void test_getdc_scaled(void)
3417 GpGraphics
*graphics
= NULL
;
3418 GpBitmap
*bitmap
= NULL
;
3420 HBRUSH hbrush
, holdbrush
;
3423 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3426 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3429 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3432 status
= GdipGetDC(graphics
, &hdc
);
3434 ok(hdc
!= NULL
, "got NULL hdc\n");
3436 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3438 holdbrush
= SelectObject(hdc
, hbrush
);
3440 Rectangle(hdc
, 2, 2, 6, 6);
3442 SelectObject(hdc
, holdbrush
);
3444 DeleteObject(hbrush
);
3446 status
= GdipReleaseDC(graphics
, hdc
);
3449 GdipDeleteGraphics(graphics
);
3451 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3453 expect(0xffff0000, color
);
3455 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3457 expect(0xff000000, color
);
3459 GdipDisposeImage((GpImage
*)bitmap
);
3462 static void test_GdipMeasureString(void)
3464 static const struct test_data
3466 REAL res_x
, res_y
, page_scale
;
3470 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3471 { 200.0, 200.0, 2.0, UnitPixel
},
3472 { 200.0, 200.0, 1.0, UnitDisplay
},
3473 { 200.0, 200.0, 2.0, UnitDisplay
},
3474 { 200.0, 200.0, 1.0, UnitInch
},
3475 { 200.0, 200.0, 2.0, UnitInch
},
3476 { 200.0, 600.0, 1.0, UnitPoint
},
3477 { 200.0, 600.0, 2.0, UnitPoint
},
3478 { 200.0, 600.0, 1.0, UnitDocument
},
3479 { 200.0, 600.0, 2.0, UnitDocument
},
3480 { 200.0, 600.0, 1.0, UnitMillimeter
},
3481 { 200.0, 600.0, 2.0, UnitMillimeter
},
3482 { 200.0, 600.0, 1.0, UnitDisplay
},
3483 { 200.0, 600.0, 2.0, UnitDisplay
},
3484 { 200.0, 600.0, 1.0, UnitPixel
},
3485 { 200.0, 600.0, 2.0, UnitPixel
},
3487 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3488 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3490 GpGraphics
*graphics
;
3491 GpFontFamily
*family
;
3493 GpStringFormat
*format
;
3495 REAL base_cx
= 0, base_cy
= 0, height
;
3500 GpUnit font_unit
, unit
;
3502 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3504 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3507 /* font size in pixels */
3508 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3510 status
= GdipGetFontSize(font
, &font_size
);
3512 expectf(100.0, font_size
);
3513 status
= GdipGetFontUnit(font
, &font_unit
);
3515 expect(UnitPixel
, font_unit
);
3517 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3521 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3523 lf
.lfHeight
= 0xdeadbeef;
3524 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3526 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3527 if (td
[i
].unit
!= UnitDisplay
)
3528 height
*= td
[i
].page_scale
;
3529 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3530 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3532 height
= font_size
+ 2.0 * font_size
/ 6.0;
3534 set_rect_empty(&rc
);
3535 set_rect_empty(&bounds
);
3536 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3541 base_cx
= bounds
.Width
;
3542 base_cy
= bounds
.Height
;
3545 expectf(0.0, bounds
.X
);
3546 expectf(0.0, bounds
.Y
);
3548 expectf_(height
, bounds
.Height
, height
/ 100.0);
3549 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3553 /* make sure it really fits */
3554 bounds
.Width
+= 1.0;
3555 bounds
.Height
+= 1.0;
3559 set_rect_empty(&bounds
);
3560 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3562 expectf(50.0, bounds
.X
);
3563 expectf(50.0, bounds
.Y
);
3565 expectf_(height
, bounds
.Height
, height
/ 100.0);
3566 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3570 status
= GdipDeleteGraphics(graphics
);
3573 status
= GdipDisposeImage(image
);
3577 GdipDeleteFont(font
);
3579 /* font size in logical units */
3580 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3581 for (unit
= 3; unit
<= 6; unit
++)
3583 /* create a font which final height is 100.0 pixels with 200 dpi device */
3584 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3585 height
= pixels_to_units(75.0, unit
, 200.0);
3586 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3588 status
= GdipGetFontSize(font
, &font_size
);
3590 expectf(height
, font_size
);
3591 status
= GdipGetFontUnit(font
, &font_unit
);
3593 expect(unit
, font_unit
);
3595 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3600 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3602 lf
.lfHeight
= 0xdeadbeef;
3603 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3605 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3606 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3608 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3609 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3610 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3611 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3613 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3614 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3616 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3617 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3618 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3619 if (td
[i
].unit
!= UnitDisplay
)
3620 height
/= td
[i
].page_scale
;
3621 /*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);*/
3623 set_rect_empty(&rc
);
3624 set_rect_empty(&bounds
);
3625 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3630 base_cx
= bounds
.Width
;
3631 base_cy
= bounds
.Height
;
3634 expectf(0.0, bounds
.X
);
3635 expectf(0.0, bounds
.Y
);
3637 expectf_(height
, bounds
.Height
, height
/ 85.0);
3638 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3642 /* make sure it really fits */
3643 bounds
.Width
+= 1.0;
3644 bounds
.Height
+= 1.0;
3648 set_rect_empty(&bounds
);
3649 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3651 expectf(50.0, bounds
.X
);
3652 expectf(50.0, bounds
.Y
);
3654 expectf_(height
, bounds
.Height
, height
/ 85.0);
3655 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3659 /* verify the result */
3660 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3661 if (td
[i
].unit
!= UnitDisplay
)
3662 height
*= td
[i
].page_scale
;
3663 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3664 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3666 expectf_(100.0, height
, 1.1);
3668 status
= GdipDeleteGraphics(graphics
);
3671 status
= GdipDisposeImage(image
);
3675 GdipDeleteFont(font
);
3678 GdipDeleteFontFamily(family
);
3679 GdipDeleteStringFormat(format
);
3682 static void test_transform(void)
3684 static const struct test_data
3686 REAL res_x
, res_y
, scale
;
3688 GpPointF in
[2], out
[2];
3691 { 96.0, 96.0, 1.0, UnitPixel
,
3692 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3693 { 96.0, 96.0, 1.0, UnitDisplay
,
3694 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3695 { 96.0, 96.0, 1.0, UnitInch
,
3696 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3697 { 123.0, 456.0, 1.0, UnitPoint
,
3698 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3699 { 123.0, 456.0, 1.0, UnitDocument
,
3700 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3701 { 123.0, 456.0, 2.0, UnitMillimeter
,
3702 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3703 { 196.0, 296.0, 1.0, UnitDisplay
,
3704 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3705 { 196.0, 296.0, 1.0, UnitPixel
,
3706 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3709 GpGraphics
*graphics
;
3714 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3716 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3717 ptf
[0].X
= td
[i
].in
[0].X
;
3718 ptf
[0].Y
= td
[i
].in
[0].Y
;
3719 ptf
[1].X
= td
[i
].in
[1].X
;
3720 ptf
[1].Y
= td
[i
].in
[1].Y
;
3721 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3723 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3724 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3725 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3726 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3727 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3729 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3730 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3731 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3732 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3733 status
= GdipDeleteGraphics(graphics
);
3735 status
= GdipDisposeImage(image
);
3740 /* Many people on the net ask why there is so much difference in rendered
3741 * text height between gdiplus and gdi32, this test suggests an answer to
3742 * that question. Important: this test assumes that font dpi == device dpi.
3744 static void test_font_height_scaling(void)
3746 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3747 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3749 GpStringFormat
*format
;
3750 CharacterRange range
= { 0, 7 };
3752 GpGraphics
*graphics
;
3753 GpFontFamily
*family
;
3757 REAL height
, dpi
, scale
;
3759 GpUnit gfx_unit
, font_unit
;
3761 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3763 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3765 status
= GdipCreateRegion(®ion
);
3768 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3771 hdc
= CreateCompatibleDC(0);
3772 status
= GdipCreateFromHDC(hdc
, &graphics
);
3774 status
= GdipGetDpiY(graphics
, &dpi
);
3777 /* First check if tested functionality works:
3778 * under XP if font and graphics units differ then GdipTransformPoints
3779 * followed by GdipSetPageUnit to change the graphics units breaks region
3780 * scaling in GdipMeasureCharacterRanges called later.
3782 status
= GdipSetPageUnit(graphics
, UnitDocument
);
3787 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3790 status
= GdipSetPageUnit(graphics
, UnitInch
);
3793 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
3796 set_rect_empty(&rect
);
3797 set_rect_empty(&bounds
);
3798 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3800 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
3802 set_rect_empty(&rect
);
3803 rect
.Width
= 32000.0;
3804 rect
.Height
= 32000.0;
3805 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3808 set_rect_empty(&rect
);
3809 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3811 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
3813 GdipDeleteFont(font
);
3815 scale
= rect
.Height
/ bounds
.Height
;
3816 if (fabs(scale
- 1.0) > 0.1)
3818 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
3822 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
3825 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3826 /* UnitPixel as a font base unit is not tested because it drastically
3827 differs in behaviour */
3828 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
3830 /* create a font for the final text height of 100 pixels */
3831 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3832 status
= GdipSetPageUnit(graphics
, font_unit
);
3836 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3839 /*trace("height %f units\n", height);*/
3840 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
3843 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3844 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
3846 static const WCHAR doubleW
[2] = { 'W','W' };
3847 RectF bounds_1
, bounds_2
;
3848 REAL margin
, margin_y
, font_height
;
3851 status
= GdipSetPageUnit(graphics
, gfx_unit
);
3854 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
3855 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
3857 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
3860 set_rect_empty(&rect
);
3861 set_rect_empty(&bounds
);
3862 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3864 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
3866 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
3869 ptf
.Y
= bounds
.Height
;
3870 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
3872 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3874 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3876 /* verify the result */
3877 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
3879 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3881 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3883 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
3884 set_rect_empty(&rect
);
3885 set_rect_empty(&bounds_1
);
3886 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
3888 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
3889 set_rect_empty(&rect
);
3890 set_rect_empty(&bounds_2
);
3891 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
3894 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
3895 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
3896 /*trace("margin %f\n", margin);*/
3897 ok(margin
> 0.0, "wrong margin %f\n", margin
);
3899 set_rect_empty(&rect
);
3900 rect
.Width
= 320000.0;
3901 rect
.Height
= 320000.0;
3902 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3904 set_rect_empty(&rect
);
3905 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3907 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
3908 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
3909 expectf(0.0, rect
.Y
);
3910 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
3911 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
3912 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
3913 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
3914 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
3915 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
3918 GdipDeleteFont(font
);
3922 status
= GdipDeleteGraphics(graphics
);
3926 GdipDeleteFontFamily(family
);
3927 GdipDeleteRegion(region
);
3928 GdipDeleteStringFormat(format
);
3931 static void test_measure_string(void)
3933 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3934 static const WCHAR string
[] = { 'A','0','1',0 };
3936 GpStringFormat
*format
;
3937 CharacterRange range
;
3939 GpGraphics
*graphics
;
3940 GpFontFamily
*family
;
3944 REAL width
, height
, width_1
, width_2
;
3945 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
3948 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3952 status
= GdipCreateRegion(®ion
);
3955 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3958 hdc
= CreateCompatibleDC(0);
3959 status
= GdipCreateFromHDC(hdc
, &graphics
);
3961 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
3964 margin_x
= 20.0 / 6.0;
3965 margin_y
= 20.0 / 8.0;
3967 set_rect_empty(&rect
);
3968 set_rect_empty(&bounds
);
3969 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3973 expectf(0.0, bounds
.X
);
3974 expectf(0.0, bounds
.Y
);
3975 width
= bounds
.Width
;
3976 height
= bounds
.Height
;
3978 set_rect_empty(&rect
);
3979 rect
.Height
= height
/ 2.0;
3980 set_rect_empty(&bounds
);
3981 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3985 expectf(0.0, bounds
.X
);
3986 expectf(0.0, bounds
.Y
);
3987 expectf(width
, bounds
.Width
);
3989 expectf(height
/ 2.0, bounds
.Height
);
3992 range
.Length
= lstrlenW(string
);
3993 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3998 rect
.Width
= 32000.0;
3999 rect
.Height
= 32000.0;
4000 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4002 set_rect_empty(&bounds
);
4003 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4005 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4006 expectf(5.0, bounds
.Y
);
4007 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4009 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4011 width_rgn
= bounds
.Width
;
4012 height_rgn
= bounds
.Height
;
4016 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4019 set_rect_empty(&rect
);
4020 rect
.Width
= 32000.0;
4021 rect
.Height
= 32000.0;
4022 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4024 set_rect_empty(&bounds
);
4025 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4027 expectf_(margin_x
, bounds
.X
, 1.0);
4028 expectf(0.0, bounds
.Y
);
4029 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4030 expectf(height_rgn
, bounds
.Height
);
4031 width_1
= bounds
.Width
;
4034 range
.Length
= lstrlenW(string
);
4035 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4042 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4044 set_rect_empty(&bounds
);
4045 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4047 expectf(0.0, bounds
.X
);
4048 expectf(0.0, bounds
.Y
);
4049 expectf(0.0, bounds
.Width
);
4050 expectf(0.0, bounds
.Height
);
4054 rect
.Width
= width_rgn
/ 2.0;
4055 rect
.Height
= 32000.0;
4056 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4058 set_rect_empty(&bounds
);
4059 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4061 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4062 expectf(5.0, bounds
.Y
);
4063 expectf_(width_1
, bounds
.Width
, 1.0);
4065 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4067 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4073 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4075 set_rect_empty(&bounds
);
4076 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4078 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4079 expectf(5.0, bounds
.Y
);
4080 expectf(width_rgn
, bounds
.Width
);
4081 expectf(height_rgn
, bounds
.Height
);
4085 rect
.Width
= width_rgn
/ 2.0;
4086 rect
.Height
= 32000.0;
4087 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4089 set_rect_empty(&bounds
);
4090 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4092 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4093 expectf(5.0, bounds
.Y
);
4094 expectf_(width_1
, bounds
.Width
, 1.0);
4095 expectf(height_rgn
, bounds
.Height
);
4097 set_rect_empty(&rect
);
4098 rect
.Height
= height
/ 2.0;
4099 set_rect_empty(&bounds
);
4100 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4104 expectf(0.0, bounds
.X
);
4105 expectf(0.0, bounds
.Y
);
4106 expectf_(width
, bounds
.Width
, 0.01);
4108 expectf(height
, bounds
.Height
);
4110 set_rect_empty(&rect
);
4111 set_rect_empty(&bounds
);
4112 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4116 expectf(0.0, bounds
.X
);
4117 expectf(0.0, bounds
.Y
);
4118 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4119 expectf(height
, bounds
.Height
);
4120 width_1
= bounds
.Width
;
4122 set_rect_empty(&rect
);
4123 set_rect_empty(&bounds
);
4124 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4128 expectf(0.0, bounds
.X
);
4129 expectf(0.0, bounds
.Y
);
4130 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4131 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4132 expectf(height
, bounds
.Height
);
4133 width_2
= bounds
.Width
;
4135 set_rect_empty(&rect
);
4136 rect
.Width
= width
/ 2.0;
4137 set_rect_empty(&bounds
);
4138 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4142 expectf(0.0, bounds
.X
);
4143 expectf(0.0, bounds
.Y
);
4144 expectf_(width_1
, bounds
.Width
, 0.01);
4145 expectf(height
, bounds
.Height
);
4147 set_rect_empty(&rect
);
4148 rect
.Height
= height
;
4149 rect
.Width
= width
- 0.05;
4150 set_rect_empty(&bounds
);
4151 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4155 expectf(0.0, bounds
.X
);
4156 expectf(0.0, bounds
.Y
);
4157 expectf_(width_2
, bounds
.Width
, 0.01);
4158 expectf(height
, bounds
.Height
);
4160 set_rect_empty(&rect
);
4161 rect
.Height
= height
;
4162 rect
.Width
= width_2
- 0.05;
4163 set_rect_empty(&bounds
);
4164 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4168 expectf(0.0, bounds
.X
);
4169 expectf(0.0, bounds
.Y
);
4170 expectf_(width_1
, bounds
.Width
, 0.01);
4171 expectf(height
, bounds
.Height
);
4173 /* Default (Near) alignment */
4176 rect
.Width
= width
* 2.0;
4177 rect
.Height
= height
* 2.0;
4178 set_rect_empty(&bounds
);
4179 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4183 expectf(5.0, bounds
.X
);
4184 expectf(5.0, bounds
.Y
);
4185 expectf_(width
, bounds
.Width
, 0.01);
4186 expectf(height
, bounds
.Height
);
4190 rect
.Width
= 32000.0;
4191 rect
.Height
= 32000.0;
4192 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4194 set_rect_empty(&bounds
);
4195 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4197 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4198 expectf(5.0, bounds
.Y
);
4199 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4201 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4203 width_rgn
= bounds
.Width
;
4204 height_rgn
= bounds
.Height
;
4206 /* Center alignment */
4207 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4208 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4212 rect
.Width
= width
* 2.0;
4213 rect
.Height
= height
* 2.0;
4214 set_rect_empty(&bounds
);
4215 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4220 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4222 expectf(5.0 + height
/2.0, bounds
.Y
);
4223 expectf_(width
, bounds
.Width
, 0.01);
4224 expectf(height
, bounds
.Height
);
4230 set_rect_empty(&bounds
);
4231 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4236 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4238 expectf(5.0 - height
/2.0, bounds
.Y
);
4239 expectf_(width
, bounds
.Width
, 0.01);
4240 expectf(height
, bounds
.Height
);
4244 rect
.Width
= width_rgn
* 2.0;
4245 rect
.Height
= height_rgn
* 2.0;
4246 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4248 set_rect_empty(&bounds
);
4249 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4252 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4254 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4255 expectf_(width_rgn
, bounds
.Width
, 1.0);
4256 expectf_(height_rgn
, bounds
.Height
, 1.0);
4262 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4264 set_rect_empty(&bounds
);
4265 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4268 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4270 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4271 expectf_(width_rgn
, bounds
.Width
, 1.0);
4272 expectf_(height_rgn
, bounds
.Height
, 1.0);
4275 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4276 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4280 rect
.Width
= width
* 2.0;
4281 rect
.Height
= height
* 2.0;
4282 set_rect_empty(&bounds
);
4283 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4288 expectf_(5.0 + width
, bounds
.X
, 0.01);
4290 expectf(5.0 + height
, bounds
.Y
);
4291 expectf_(width
, bounds
.Width
, 0.01);
4292 expectf(height
, bounds
.Height
);
4298 set_rect_empty(&bounds
);
4299 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4304 expectf_(5.0 - width
, bounds
.X
, 0.01);
4306 expectf(5.0 - height
, bounds
.Y
);
4307 expectf_(width
, bounds
.Width
, 0.01);
4308 expectf(height
, bounds
.Height
);
4312 rect
.Width
= width_rgn
* 2.0;
4313 rect
.Height
= height_rgn
* 2.0;
4314 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4316 set_rect_empty(&bounds
);
4317 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4320 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4322 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4323 expectf_(width_rgn
, bounds
.Width
, 1.0);
4324 expectf_(height_rgn
, bounds
.Height
, 1.0);
4330 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4332 set_rect_empty(&bounds
);
4333 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4336 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4338 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4339 expectf_(width_rgn
, bounds
.Width
, 1.0);
4340 expectf_(height_rgn
, bounds
.Height
, 1.0);
4342 status
= GdipDeleteFont(font
);
4345 status
= GdipDeleteGraphics(graphics
);
4349 GdipDeleteFontFamily(family
);
4350 GdipDeleteRegion(region
);
4351 GdipDeleteStringFormat(format
);
4354 static void test_measured_extra_space(void)
4356 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4357 static const WCHAR string
[2] = { 'W','W' };
4358 GpStringFormat
*format
;
4360 GpGraphics
*graphics
;
4361 GpFontFamily
*family
;
4364 GpUnit gfx_unit
, font_unit
;
4365 RectF bounds_1
, bounds_2
, rect
;
4366 REAL margin
, font_size
, dpi
;
4368 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4371 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4373 hdc
= CreateCompatibleDC(0);
4374 status
= GdipCreateFromHDC(hdc
, &graphics
);
4377 status
= GdipGetDpiX(graphics
, &dpi
);
4380 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4381 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4382 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4384 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4387 status
= GdipGetFontSize(font
, &font_size
);
4389 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4390 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4392 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4393 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4395 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4398 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4399 set_rect_empty(&rect
);
4400 set_rect_empty(&bounds_1
);
4401 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4403 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4404 set_rect_empty(&rect
);
4405 set_rect_empty(&bounds_2
);
4406 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4409 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4410 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4411 /*trace("margin %f pixels\n", margin);*/
4412 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4415 GdipDeleteFont(font
);
4418 GdipDeleteGraphics(graphics
);
4420 GdipDeleteFontFamily(family
);
4421 GdipDeleteStringFormat(format
);
4424 static void test_alpha_hdc(void)
4428 HBITMAP hbm
, old_hbm
;
4429 GpGraphics
*graphics
;
4434 hdc
= CreateCompatibleDC(0);
4435 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4436 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4437 bmi
.bmiHeader
.biHeight
= 5;
4438 bmi
.bmiHeader
.biWidth
= 5;
4439 bmi
.bmiHeader
.biBitCount
= 32;
4440 bmi
.bmiHeader
.biPlanes
= 1;
4441 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4442 bmi
.bmiHeader
.biClrUsed
= 0;
4444 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4445 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4447 old_hbm
= SelectObject(hdc
, hbm
);
4449 status
= GdipCreateFromHDC(hdc
, &graphics
);
4452 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4454 expectf(0.0, bounds
.X
);
4455 expectf(0.0, bounds
.Y
);
4456 expectf(5.0, bounds
.Width
);
4457 expectf(5.0, bounds
.Height
);
4459 bits
[0] = 0xdeadbeef;
4461 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4464 expect(0xffaaaaaa, bits
[0]);
4466 SelectObject(hdc
, old_hbm
);
4468 bits
[0] = 0xdeadbeef;
4470 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4473 todo_wine
expect(0xffbbbbbb, bits
[0]);
4475 GdipDeleteGraphics(graphics
);
4481 static void test_bitmapfromgraphics(void)
4484 GpGraphics
*graphics
= NULL
;
4485 HDC hdc
= GetDC( hwnd
);
4486 GpBitmap
*bitmap
= NULL
;
4488 REAL imageres
, graphicsres
;
4491 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4494 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4495 expect(InvalidParameter
, stat
);
4497 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4498 expect(InvalidParameter
, stat
);
4500 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4503 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4505 expect(PixelFormat32bppPARGB
, format
);
4507 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4510 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4512 expectf(graphicsres
, imageres
);
4514 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4517 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4519 expectf(graphicsres
, imageres
);
4521 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4525 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4529 GdipDeleteGraphics(graphics
);
4530 GdipDisposeImage((GpImage
*)bitmap
);
4533 static void test_clipping(void)
4537 GpGraphics
*graphics
;
4538 GpRegion
*region
, *region100x100
;
4547 hdc
= CreateCompatibleDC(0);
4548 status
= GdipCreateFromHDC(hdc
, &graphics
);
4551 status
= GdipGetPageUnit(graphics
, &unit
);
4553 expect(UnitDisplay
, unit
);
4555 status
= GdipCreateRegion(®ion
);
4557 status
= GdipSetEmpty(region
);
4560 status
= GdipCreateRegion(®ion100x100
);
4562 status
= GdipSetEmpty(region100x100
);
4565 rect
.X
= rect
.Y
= 100.0;
4566 rect
.Width
= rect
.Height
= 100.0;
4567 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4569 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4572 status
= GdipGetClipBounds(graphics
, &rect
);
4574 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4575 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4577 status
= GdipSetEmpty(region
);
4579 status
= GdipGetClip(graphics
, region
);
4581 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4583 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4584 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4590 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4592 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4593 "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
);
4595 status
= GdipCreateMatrix(&matrix
);
4597 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4599 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4601 status
= GdipSetWorldTransform(graphics
, matrix
);
4604 status
= GdipGetClipBounds(graphics
, &rect
);
4606 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4607 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4609 status
= GdipSetEmpty(region
);
4611 status
= GdipGetClip(graphics
, region
);
4613 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4615 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4616 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4618 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4620 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4621 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4623 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4625 ret
= GetRgnBox(hrgn
, &rc
);
4626 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4627 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4628 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4631 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4633 ret
= GetRgnBox(hrgn
, &rc
);
4634 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4635 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4636 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4643 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4645 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4646 "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
);
4648 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4650 ret
= GetRgnBox(hrgn
, &rc
);
4651 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4652 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4653 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4656 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4658 ret
= GetRgnBox(hrgn
, &rc
);
4659 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4660 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4661 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4668 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4670 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4671 "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
);
4673 status
= GdipSetPageScale(graphics
, 2.0);
4676 status
= GdipGetClipBounds(graphics
, &rect
);
4678 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4679 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4681 status
= GdipSetEmpty(region
);
4683 status
= GdipGetClip(graphics
, region
);
4685 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4687 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4688 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4690 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4692 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4693 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4695 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4697 ret
= GetRgnBox(hrgn
, &rc
);
4698 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4699 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4700 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4703 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4705 ret
= GetRgnBox(hrgn
, &rc
);
4706 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4707 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4708 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4715 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4717 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4718 "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
);
4720 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4722 ret
= GetRgnBox(hrgn
, &rc
);
4723 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4724 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4725 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4728 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4730 ret
= GetRgnBox(hrgn
, &rc
);
4731 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4732 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4733 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4740 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4742 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4743 "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
);
4745 GdipSetPageUnit(graphics
, UnitPoint
);
4748 status
= GdipGetClipBounds(graphics
, &rect
);
4750 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4751 /* rounding under Wine is slightly different */
4752 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4753 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4754 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4756 status
= GdipSetEmpty(region
);
4758 status
= GdipGetClip(graphics
, region
);
4760 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4762 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4763 /* rounding under Wine is slightly different */
4764 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4765 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4766 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4768 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4770 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4771 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4773 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4775 ret
= GetRgnBox(hrgn
, &rc
);
4776 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4777 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
4778 /* rounding under Wine is slightly different */
4779 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
4780 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
4781 "expected 14,5-33,14, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4784 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4786 ret
= GetRgnBox(hrgn
, &rc
);
4787 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4788 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
4789 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
4790 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4797 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4799 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
4800 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
4801 "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
);
4803 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4805 ret
= GetRgnBox(hrgn
, &rc
);
4806 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4807 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4808 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4811 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4813 ret
= GetRgnBox(hrgn
, &rc
);
4814 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4815 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
4816 /* rounding under Wine is slightly different */
4817 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
4818 "expected 560,1120-1094,2187, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4825 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4827 if (fabs(ptf
[0].X
- 100.0) < 0.001)
4829 expectf(100.0, ptf
[0].X
);
4830 expectf(100.0, ptf
[0].Y
);
4831 expectf(200.125, ptf
[1].X
);
4832 expectf(200.03125, ptf
[1].Y
);
4834 else /* before Win7 */
4836 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
4837 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
4838 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
4839 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
4842 status
= GdipTransformRegion(region100x100
, matrix
);
4845 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4847 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4848 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4850 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4852 ret
= GetRgnBox(hrgn
, &rc
);
4853 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4854 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4855 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4858 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4860 ret
= GetRgnBox(hrgn
, &rc
);
4861 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4862 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
4863 /* rounding under Wine is slightly different */
4864 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
4865 "expected 1147,4534-2214,8800, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4872 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4874 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
4876 expectf(210.0625, ptf
[0].X
);
4877 expectf(420.0625, ptf
[0].Y
);
4878 expectf(410.125, ptf
[1].X
);
4879 expectf(820.0, ptf
[1].Y
);
4881 else /* before Win7 */
4883 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
4884 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
4885 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
4886 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
4889 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
4891 status
= GdipSetWorldTransform(graphics
, matrix
);
4894 status
= GdipGetClipBounds(graphics
, &rect
);
4896 expectf_(20.612978, rect
.X
, 1.0);
4897 expectf_(-6.256012, rect
.Y
, 1.5);
4898 expectf_(25.612978, rect
.Width
, 1.0);
4899 expectf_(12.806489, rect
.Height
, 1.0);
4901 status
= GdipSetEmpty(region
);
4903 status
= GdipGetClip(graphics
, region
);
4905 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4907 /* rounding under Wine is slightly different */
4908 expectf_(20.612978, rect
.X
, 1.0);
4909 expectf_(-6.256012, rect
.Y
, 1.5);
4910 expectf_(25.612978, rect
.Width
, 1.0);
4911 expectf_(12.806489, rect
.Height
, 1.0);
4913 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4915 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4916 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4918 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4920 ret
= GetRgnBox(hrgn
, &rc
);
4921 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4922 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
4923 /* rounding under Wine is slightly different */
4924 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
4925 "expected (22,-6)-(46,7), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4928 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4930 ret
= GetRgnBox(hrgn
, &rc
);
4931 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4932 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4933 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4944 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4946 expectf(20.612978, ptf
[0].X
);
4947 expectf(-1.568512, ptf
[0].Y
);
4948 expectf(46.225956, ptf
[1].X
);
4949 expectf(1.862977, ptf
[1].Y
);
4950 expectf(36.850956, ptf
[2].X
);
4951 expectf(-6.256012, ptf
[2].Y
);
4952 expectf(29.987980, ptf
[3].X
);
4953 expectf(6.550478, ptf
[3].Y
);
4955 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4957 ret
= GetRgnBox(hrgn
, &rc
);
4958 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4959 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4960 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4963 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4965 ret
= GetRgnBox(hrgn
, &rc
);
4966 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4967 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
4968 /* rounding under Wine is slightly different */
4969 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
4970 "expected (-3406,4500)-(-350,8728), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4981 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4983 expectf(-136.190491, ptf
[0].X
);
4984 expectf(520.010742, ptf
[0].Y
);
4985 expectf(756.417175, ptf
[1].X
);
4986 expectf(720.031616, ptf
[1].Y
);
4987 expectf(360.042114, ptf
[2].X
);
4988 expectf(376.760742, ptf
[2].Y
);
4989 expectf(260.184570, ptf
[3].X
);
4990 expectf(863.281616, ptf
[3].Y
);
4992 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
4994 status
= GdipSetWorldTransform(graphics
, matrix
);
4997 status
= GdipGetClipBounds(graphics
, &rect
);
4999 expectf_(-28.100956, rect
.X
, 1.0);
5000 expectf_(7.806488, rect
.Y
, 1.5);
5001 expectf_(25.612978, rect
.Width
, 1.0);
5002 expectf_(12.806489, rect
.Height
, 1.0);
5004 status
= GdipSetEmpty(region
);
5006 status
= GdipGetClip(graphics
, region
);
5008 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5010 /* rounding under Wine is slightly different */
5011 expectf_(-28.100956, rect
.X
, 1.0);
5012 expectf_(7.806488, rect
.Y
, 1.5);
5013 expectf_(25.612978, rect
.Width
, 1.0);
5014 expectf_(12.806489, rect
.Height
, 1.0);
5016 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5018 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5019 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5021 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5023 ret
= GetRgnBox(hrgn
, &rc
);
5024 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5025 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5026 /* rounding under Wine is slightly different */
5027 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5028 "expected (-27,8)-(-2,21), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5031 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5033 ret
= GetRgnBox(hrgn
, &rc
);
5034 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5035 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5036 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5047 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5049 expectf(-11.862979, ptf
[0].X
);
5050 expectf(7.806488, ptf
[0].Y
);
5051 expectf(-18.725958, ptf
[1].X
);
5052 expectf(20.612976, ptf
[1].Y
);
5053 expectf(-2.487981, ptf
[2].X
);
5054 expectf(15.925477, ptf
[2].Y
);
5055 expectf(-28.100956, ptf
[3].X
);
5056 expectf(12.493987, ptf
[3].Y
);
5058 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5060 ret
= GetRgnBox(hrgn
, &rc
);
5061 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5062 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5063 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5066 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5068 ret
= GetRgnBox(hrgn
, &rc
);
5069 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5070 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5071 /* rounding under Wine is slightly different */
5072 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5073 "expected (4500,351)-(8728,3407), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5084 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5086 expectf(-1055.021484, ptf
[0].X
);
5087 expectf(-70.595329, ptf
[0].Y
);
5088 expectf(-1455.063232, ptf
[1].X
);
5089 expectf(375.708435, ptf
[1].Y
);
5090 expectf(-768.521484, ptf
[2].X
);
5091 expectf(177.520981, ptf
[2].Y
);
5092 expectf(-1741.563110, ptf
[3].X
);
5093 expectf(127.592125, ptf
[3].Y
);
5095 GdipDeleteMatrix(matrix
);
5096 GdipDeleteRegion(region
);
5097 GdipDeleteRegion(region100x100
);
5098 GdipDeleteGraphics(graphics
);
5102 static void test_clipping_2(void)
5107 GpGraphics
*graphics
;
5117 hdc
= CreateCompatibleDC(0);
5118 status
= GdipCreateFromHDC(hdc
, &graphics
);
5121 status
= GdipGetPageUnit(graphics
, &unit
);
5123 expect(UnitDisplay
, unit
);
5125 GdipSetPageUnit(graphics
, UnitInch
);
5127 status
= GdipCreateRegion(®ion
);
5129 status
= GdipSetEmpty(region
);
5131 rect
.X
= rect
.Y
= 100.0;
5132 rect
.Width
= rect
.Height
= 100.0;
5133 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5135 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5138 status
= GdipGetClip(graphics
, region
);
5140 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5142 ret
= GetRgnBox(hrgn
, &rc
);
5143 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5144 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5145 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5147 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5149 ret
= GetRgnBox(hrgn
, &rc
);
5150 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5151 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5152 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5159 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5161 expectf(100.0, ptf
[0].X
);
5162 expectf(100.0, ptf
[0].Y
);
5163 expectf(200.0, ptf
[1].X
);
5164 expectf(200.0, ptf
[1].X
);
5166 GdipSetPageUnit(graphics
, UnitPoint
);
5168 status
= GdipGetClip(graphics
, region
);
5170 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5172 ret
= GetRgnBox(hrgn
, &rc
);
5173 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5174 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5175 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5176 "expected 7200,7200-14400,14400, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5178 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5180 ret
= GetRgnBox(hrgn
, &rc
);
5181 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5182 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5183 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5184 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5191 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5193 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5194 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5195 "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
);
5196 else /* before Win7 */
5198 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5199 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5200 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5201 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5204 GdipDeleteRegion(region
);
5206 GdipSetPageUnit(graphics
, UnitPixel
);
5208 status
= GdipCreateRegion(®ion
);
5210 status
= GdipSetEmpty(region
);
5212 rect
.X
= rect
.Y
= 100.0;
5213 rect
.Width
= rect
.Height
= 100.0;
5214 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5216 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5219 status
= GdipGetClip(graphics
, region
);
5221 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5223 ret
= GetRgnBox(hrgn
, &rc
);
5224 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5225 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5226 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5227 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5229 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5231 ret
= GetRgnBox(hrgn
, &rc
);
5232 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5233 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5234 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5235 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5242 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5244 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5245 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5246 "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
);
5247 else /* before Win7 */
5249 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5250 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5251 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5252 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5255 GdipSetPageUnit(graphics
, UnitPoint
);
5257 status
= GdipGetClip(graphics
, region
);
5259 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5261 ret
= GetRgnBox(hrgn
, &rc
);
5262 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5263 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5264 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5265 "expected 75,75-150,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5267 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5269 ret
= GetRgnBox(hrgn
, &rc
);
5270 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5271 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5272 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5273 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5280 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5282 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5283 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5284 "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
);
5285 else /* before Win7 */
5287 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5288 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5289 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5290 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5293 status
= GdipCreateMatrix(&matrix
);
5295 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5297 status
= GdipSetWorldTransform(graphics
, matrix
);
5299 GdipDeleteMatrix(matrix
);
5301 status
= GdipGetClip(graphics
, region
);
5303 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5305 ret
= GetRgnBox(hrgn
, &rc
);
5306 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5307 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5308 "expected 65,65-140,140, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5310 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5312 ret
= GetRgnBox(hrgn
, &rc
);
5313 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5314 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5315 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5322 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5324 expectf(65.0, ptf
[0].X
);
5325 expectf(65.0, ptf
[0].Y
);
5326 expectf(140.0, ptf
[1].X
);
5327 expectf(140.0, ptf
[1].X
);
5329 status
= GdipCreateMatrix(&matrix
);
5331 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5333 status
= GdipSetWorldTransform(graphics
, matrix
);
5335 GdipDeleteMatrix(matrix
);
5337 status
= GdipGetClip(graphics
, region
);
5339 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5341 ret
= GetRgnBox(hrgn
, &rc
);
5342 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5343 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5344 "expected 300,150-600,300, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5346 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5348 ret
= GetRgnBox(hrgn
, &rc
);
5349 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5350 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5351 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5358 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5360 expectf(300.0, ptf
[0].X
);
5361 expectf(150.0, ptf
[0].Y
);
5362 expectf(600.0, ptf
[1].X
);
5363 expectf(300.0, ptf
[1].Y
);
5365 status
= GdipSetPageScale(graphics
, 2.0);
5368 status
= GdipGetClip(graphics
, region
);
5370 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5372 ret
= GetRgnBox(hrgn
, &rc
);
5373 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5374 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5375 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5376 "expected 150,75-300,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5378 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5380 ret
= GetRgnBox(hrgn
, &rc
);
5381 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5382 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5383 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5384 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5391 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5393 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5395 expectf(150.0, ptf
[0].X
);
5396 expectf(75.0, ptf
[0].Y
);
5397 expectf(300.0, ptf
[1].X
);
5398 expectf(150.0, ptf
[1].Y
);
5400 else /* before Win7 */
5402 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5403 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5404 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5405 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5408 status
= GdipCreateMatrix(&matrix
);
5410 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5412 status
= GdipSetWorldTransform(graphics
, matrix
);
5414 GdipDeleteMatrix(matrix
);
5416 status
= GdipGetClip(graphics
, region
);
5418 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5420 ret
= GetRgnBox(hrgn
, &rc
);
5421 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5422 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5423 /* rounding under Wine is slightly different */
5424 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5425 "expected 54,-26-107,27, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5427 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5429 ret
= GetRgnBox(hrgn
, &rc
);
5430 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5431 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5432 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5443 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5445 expectf(53.033016, ptf
[0].X
);
5446 expectf(0.0, ptf
[0].Y
);
5447 expectf(106.066032, ptf
[1].X
);
5448 expectf(0.0, ptf
[1].Y
);
5449 expectf(79.549522, ptf
[2].X
);
5450 expectf(-26.516510, ptf
[2].Y
);
5451 expectf(79.549522, ptf
[3].X
);
5452 expectf(26.516508, ptf
[3].Y
);
5454 status
= GdipCreateMatrix(&matrix
);
5456 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5458 status
= GdipSetWorldTransform(graphics
, matrix
);
5460 GdipDeleteMatrix(matrix
);
5462 status
= GdipGetClip(graphics
, region
);
5464 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5466 ret
= GetRgnBox(hrgn
, &rc
);
5467 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5468 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5469 /* rounding under Wine is slightly different */
5470 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5471 "expected -26,54-27,107, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5473 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5475 ret
= GetRgnBox(hrgn
, &rc
);
5476 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5477 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5478 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5489 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5491 expectf(0.0, ptf
[0].X
);
5492 expectf(53.033005, ptf
[0].Y
);
5493 expectf(0.0, ptf
[1].X
);
5494 expectf(106.066010, ptf
[1].Y
);
5495 expectf(26.516491, ptf
[2].X
);
5496 expectf(79.549507, ptf
[2].Y
);
5497 expectf(-26.516520, ptf
[3].X
);
5498 expectf(79.549500, ptf
[3].Y
);
5500 GdipDeleteRegion(region
);
5501 GdipDeleteGraphics(graphics
);
5506 static void test_GdipFillRectangles(void)
5509 GpGraphics
*graphics
= NULL
;
5510 GpBrush
*brush
= NULL
;
5511 HDC hdc
= GetDC( hwnd
);
5512 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5514 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5516 status
= GdipCreateFromHDC(hdc
, &graphics
);
5518 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5520 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5522 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5524 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5525 expect(InvalidParameter
, status
);
5527 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5528 expect(InvalidParameter
, status
);
5530 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5531 expect(InvalidParameter
, status
);
5533 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5534 expect(InvalidParameter
, status
);
5536 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5537 expect(InvalidParameter
, status
);
5539 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5542 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5545 GdipDeleteBrush(brush
);
5546 GdipDeleteGraphics(graphics
);
5548 ReleaseDC(hwnd
, hdc
);
5551 START_TEST(graphics
)
5553 struct GdiplusStartupInput gdiplusStartupInput
;
5554 ULONG_PTR gdiplusToken
;
5557 memset( &class, 0, sizeof(class) );
5558 class.lpszClassName
= "gdiplus_test";
5559 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5560 class.lpfnWndProc
= DefWindowProcA
;
5561 class.hInstance
= GetModuleHandleA(0);
5562 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5563 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5564 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
5565 RegisterClassA( &class );
5566 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5567 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
5568 ok(hwnd
!= NULL
, "Expected window to be created\n");
5570 gdiplusStartupInput
.GdiplusVersion
= 1;
5571 gdiplusStartupInput
.DebugEventCallback
= NULL
;
5572 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
5573 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
5575 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
5579 test_measured_extra_space();
5580 test_measure_string();
5581 test_font_height_scaling();
5583 test_GdipMeasureString();
5584 test_constructor_destructor();
5585 test_save_restore();
5586 test_GdipFillClosedCurve2();
5587 test_GdipFillClosedCurve2I();
5588 test_GdipDrawBezierI();
5590 test_GdipDrawArcI();
5591 test_GdipDrawCurve();
5592 test_GdipDrawCurveI();
5593 test_GdipDrawCurve2();
5594 test_GdipDrawCurve2I();
5595 test_GdipDrawCurve3();
5596 test_GdipDrawCurve3I();
5597 test_GdipDrawLineI();
5598 test_GdipDrawLinesI();
5599 test_GdipDrawImagePointsRect();
5600 test_GdipFillClosedCurve();
5601 test_GdipFillClosedCurveI();
5602 test_GdipDrawString();
5603 test_GdipGetNearestColor();
5604 test_GdipGetVisibleClipBounds();
5605 test_GdipIsVisiblePoint();
5606 test_GdipIsVisibleRect();
5607 test_Get_Release_DC();
5608 test_BeginContainer2();
5609 test_transformpoints();
5610 test_get_set_clip();
5613 test_textcontrast();
5614 test_fromMemoryBitmap();
5615 test_string_functions();
5616 test_get_set_interpolation();
5617 test_get_set_textrenderinghint();
5618 test_getdc_scaled();
5620 test_bitmapfromgraphics();
5621 test_GdipFillRectangles();
5623 GdiplusShutdown(gdiplusToken
);
5624 DestroyWindow( hwnd
);