2 * Unit test suite for graphics objects
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WIN32_NO_STATUS
26 #define COM_NO_WINDOWS_H
28 //#include "windows.h"
29 #include <wine/test.h>
34 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
35 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
36 #define expectf(expected, got) expectf_((expected), (got), 0.001)
38 static const REAL mm_per_inch
= 25.4;
39 static const REAL point_per_inch
= 72.0;
42 static void set_rect_empty(RectF
*rc
)
50 /* converts a given unit to its value in pixels */
51 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
59 return units
* dpi
/ point_per_inch
;
63 return units
* dpi
/ 300.0; /* Per MSDN */
65 return units
* dpi
/ mm_per_inch
;
67 ok(0, "Unsupported unit: %d\n", unit
);
72 /* converts value in pixels to a given unit */
73 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
81 return pixels
* point_per_inch
/ dpi
;
85 return pixels
* 300.0 / dpi
;
87 return pixels
* mm_per_inch
/ dpi
;
89 ok(0, "Unsupported unit: %d\n", unit
);
94 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
96 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
97 return pixels_to_units(pixels
, to
, dpi
);
100 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
108 GpGraphics
*graphics
= NULL
;
111 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
114 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
116 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
119 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
123 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
128 status
= GdipGetDpiX(graphics
, &res
);
131 status
= GdipGetDpiY(graphics
, &res
);
135 status
= GdipSetPageUnit(graphics
, unit
);
137 status
= GdipSetPageScale(graphics
, scale
);
143 static void test_constructor_destructor(void)
146 GpGraphics
*graphics
= NULL
;
147 HDC hdc
= GetDC( hwnd
);
149 stat
= GdipCreateFromHDC(NULL
, &graphics
);
150 expect(OutOfMemory
, stat
);
151 stat
= GdipDeleteGraphics(graphics
);
152 expect(InvalidParameter
, stat
);
154 stat
= GdipCreateFromHDC(hdc
, &graphics
);
156 stat
= GdipDeleteGraphics(graphics
);
159 stat
= GdipCreateFromHWND(NULL
, &graphics
);
161 stat
= GdipDeleteGraphics(graphics
);
164 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
166 stat
= GdipDeleteGraphics(graphics
);
169 stat
= GdipDeleteGraphics(NULL
);
170 expect(InvalidParameter
, stat
);
171 ReleaseDC(hwnd
, hdc
);
179 /* Linked list prepend function. */
180 static void log_state(GraphicsState data
, node
** log
)
182 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
184 new_entry
->data
= data
;
185 new_entry
->next
= *log
;
189 /* Checks if there are duplicates in the list, and frees it. */
190 static void check_no_duplicates(node
* log
)
202 while((temp
= temp
->next
)){
203 if(log
->data
== temp
->data
){
210 }while((log
= log
->next
));
215 HeapFree(GetProcessHeap(), 0, temp
);
223 static void test_save_restore(void)
226 GraphicsState state_a
, state_b
, state_c
;
227 InterpolationMode mode
;
228 GpGraphics
*graphics1
, *graphics2
;
229 node
* state_log
= NULL
;
230 HDC hdc
= GetDC( hwnd
);
231 state_a
= state_b
= state_c
= 0xdeadbeef;
233 /* Invalid saving. */
234 GdipCreateFromHDC(hdc
, &graphics1
);
235 stat
= GdipSaveGraphics(graphics1
, NULL
);
236 expect(InvalidParameter
, stat
);
237 stat
= GdipSaveGraphics(NULL
, &state_a
);
238 expect(InvalidParameter
, stat
);
239 GdipDeleteGraphics(graphics1
);
241 log_state(state_a
, &state_log
);
243 /* Basic save/restore. */
244 GdipCreateFromHDC(hdc
, &graphics1
);
245 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
246 stat
= GdipSaveGraphics(graphics1
, &state_a
);
248 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
249 stat
= GdipRestoreGraphics(graphics1
, state_a
);
251 GdipGetInterpolationMode(graphics1
, &mode
);
252 expect(InterpolationModeBilinear
, mode
);
253 GdipDeleteGraphics(graphics1
);
255 log_state(state_a
, &state_log
);
257 /* Restoring garbage doesn't affect saves. */
258 GdipCreateFromHDC(hdc
, &graphics1
);
259 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
260 GdipSaveGraphics(graphics1
, &state_a
);
261 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
262 GdipSaveGraphics(graphics1
, &state_b
);
263 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
264 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
266 GdipRestoreGraphics(graphics1
, state_b
);
267 GdipGetInterpolationMode(graphics1
, &mode
);
268 expect(InterpolationModeBicubic
, mode
);
269 GdipRestoreGraphics(graphics1
, state_a
);
270 GdipGetInterpolationMode(graphics1
, &mode
);
271 expect(InterpolationModeBilinear
, mode
);
272 GdipDeleteGraphics(graphics1
);
274 log_state(state_a
, &state_log
);
275 log_state(state_b
, &state_log
);
277 /* Restoring older state invalidates newer saves (but not older saves). */
278 GdipCreateFromHDC(hdc
, &graphics1
);
279 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
280 GdipSaveGraphics(graphics1
, &state_a
);
281 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
282 GdipSaveGraphics(graphics1
, &state_b
);
283 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
284 GdipSaveGraphics(graphics1
, &state_c
);
285 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
286 GdipRestoreGraphics(graphics1
, state_b
);
287 GdipGetInterpolationMode(graphics1
, &mode
);
288 expect(InterpolationModeBicubic
, mode
);
289 GdipRestoreGraphics(graphics1
, state_c
);
290 GdipGetInterpolationMode(graphics1
, &mode
);
291 expect(InterpolationModeBicubic
, mode
);
292 GdipRestoreGraphics(graphics1
, state_a
);
293 GdipGetInterpolationMode(graphics1
, &mode
);
294 expect(InterpolationModeBilinear
, mode
);
295 GdipDeleteGraphics(graphics1
);
297 log_state(state_a
, &state_log
);
298 log_state(state_b
, &state_log
);
299 log_state(state_c
, &state_log
);
301 /* Restoring older save from one graphics object does not invalidate
302 * newer save from other graphics object. */
303 GdipCreateFromHDC(hdc
, &graphics1
);
304 GdipCreateFromHDC(hdc
, &graphics2
);
305 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
306 GdipSaveGraphics(graphics1
, &state_a
);
307 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
308 GdipSaveGraphics(graphics2
, &state_b
);
309 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
310 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
311 GdipRestoreGraphics(graphics1
, state_a
);
312 GdipGetInterpolationMode(graphics1
, &mode
);
313 expect(InterpolationModeBilinear
, mode
);
314 GdipRestoreGraphics(graphics2
, state_b
);
315 GdipGetInterpolationMode(graphics2
, &mode
);
316 expect(InterpolationModeBicubic
, mode
);
317 GdipDeleteGraphics(graphics1
);
318 GdipDeleteGraphics(graphics2
);
320 /* You can't restore a state to a graphics object that didn't save it. */
321 GdipCreateFromHDC(hdc
, &graphics1
);
322 GdipCreateFromHDC(hdc
, &graphics2
);
323 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
324 GdipSaveGraphics(graphics1
, &state_a
);
325 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
326 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
327 GdipRestoreGraphics(graphics2
, state_a
);
328 GdipGetInterpolationMode(graphics2
, &mode
);
329 expect(InterpolationModeNearestNeighbor
, mode
);
330 GdipDeleteGraphics(graphics1
);
331 GdipDeleteGraphics(graphics2
);
333 log_state(state_a
, &state_log
);
335 /* A state created by SaveGraphics cannot be restored with EndContainer. */
336 GdipCreateFromHDC(hdc
, &graphics1
);
337 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
338 stat
= GdipSaveGraphics(graphics1
, &state_a
);
340 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
341 stat
= GdipEndContainer(graphics1
, state_a
);
343 GdipGetInterpolationMode(graphics1
, &mode
);
344 expect(InterpolationModeBicubic
, mode
);
345 stat
= GdipRestoreGraphics(graphics1
, state_a
);
347 GdipGetInterpolationMode(graphics1
, &mode
);
348 expect(InterpolationModeBilinear
, mode
);
349 GdipDeleteGraphics(graphics1
);
351 log_state(state_a
, &state_log
);
353 /* A state created by BeginContainer cannot be restored with RestoreGraphics. */
354 GdipCreateFromHDC(hdc
, &graphics1
);
355 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
356 stat
= GdipBeginContainer2(graphics1
, &state_a
);
358 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
359 stat
= GdipRestoreGraphics(graphics1
, state_a
);
361 GdipGetInterpolationMode(graphics1
, &mode
);
362 expect(InterpolationModeBicubic
, mode
);
363 stat
= GdipEndContainer(graphics1
, state_a
);
365 GdipGetInterpolationMode(graphics1
, &mode
);
366 expect(InterpolationModeBilinear
, mode
);
367 GdipDeleteGraphics(graphics1
);
369 log_state(state_a
, &state_log
);
371 /* BeginContainer and SaveGraphics use the same stack. */
372 GdipCreateFromHDC(hdc
, &graphics1
);
373 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
374 stat
= GdipBeginContainer2(graphics1
, &state_a
);
376 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
377 stat
= GdipSaveGraphics(graphics1
, &state_b
);
379 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
380 stat
= GdipEndContainer(graphics1
, state_a
);
382 GdipGetInterpolationMode(graphics1
, &mode
);
383 expect(InterpolationModeBilinear
, mode
);
384 stat
= GdipRestoreGraphics(graphics1
, state_b
);
386 GdipGetInterpolationMode(graphics1
, &mode
);
387 expect(InterpolationModeBilinear
, mode
);
388 GdipDeleteGraphics(graphics1
);
390 log_state(state_a
, &state_log
);
391 log_state(state_b
, &state_log
);
393 /* The same state value should never be returned twice. */
395 check_no_duplicates(state_log
);
397 ReleaseDC(hwnd
, hdc
);
400 static void test_GdipFillClosedCurve2(void)
403 GpGraphics
*graphics
= NULL
;
404 GpSolidFill
*brush
= NULL
;
405 HDC hdc
= GetDC( hwnd
);
417 /* make a graphics object and brush object */
418 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
420 status
= GdipCreateFromHDC(hdc
, &graphics
);
422 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
424 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
426 /* InvalidParameter cases: null graphics, null brush, null points */
427 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
428 expect(InvalidParameter
, status
);
430 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
431 expect(InvalidParameter
, status
);
433 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
434 expect(InvalidParameter
, status
);
436 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
437 expect(InvalidParameter
, status
);
439 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
440 expect(InvalidParameter
, status
);
442 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
443 expect(InvalidParameter
, status
);
445 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
446 expect(InvalidParameter
, status
);
448 /* InvalidParameter cases: invalid count */
449 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
450 expect(InvalidParameter
, status
);
452 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
453 expect(InvalidParameter
, status
);
455 /* Valid test cases */
456 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
459 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
462 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
465 GdipDeleteGraphics(graphics
);
466 GdipDeleteBrush((GpBrush
*)brush
);
468 ReleaseDC(hwnd
, hdc
);
471 static void test_GdipFillClosedCurve2I(void)
474 GpGraphics
*graphics
= NULL
;
475 GpSolidFill
*brush
= NULL
;
476 HDC hdc
= GetDC( hwnd
);
488 /* make a graphics object and brush object */
489 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
491 status
= GdipCreateFromHDC(hdc
, &graphics
);
493 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
495 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
497 /* InvalidParameter cases: null graphics, null brush */
498 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
499 when points == NULL, so don't test this condition */
500 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
501 expect(InvalidParameter
, status
);
503 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
504 expect(InvalidParameter
, status
);
506 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
507 expect(InvalidParameter
, status
);
509 /* InvalidParameter cases: invalid count */
510 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
511 expect(InvalidParameter
, status
);
513 /* OutOfMemory cases: large (unsigned) int */
514 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
515 expect(OutOfMemory
, status
);
517 /* Valid test cases */
518 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
521 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
524 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
527 GdipDeleteGraphics(graphics
);
528 GdipDeleteBrush((GpBrush
*)brush
);
530 ReleaseDC(hwnd
, hdc
);
533 static void test_GdipDrawArc(void)
536 GpGraphics
*graphics
= NULL
;
538 HDC hdc
= GetDC( hwnd
);
540 /* make a graphics object and pen object */
541 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
543 status
= GdipCreateFromHDC(hdc
, &graphics
);
545 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
547 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
549 ok(pen
!= NULL
, "Expected pen to be initialized\n");
551 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
552 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
553 expect(InvalidParameter
, status
);
555 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
556 expect(InvalidParameter
, status
);
558 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
559 expect(InvalidParameter
, status
);
561 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
562 expect(InvalidParameter
, status
);
564 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
565 expect(InvalidParameter
, status
);
567 /* successful case */
568 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
572 GdipDeleteGraphics(graphics
);
574 ReleaseDC(hwnd
, hdc
);
577 static void test_GdipDrawArcI(void)
580 GpGraphics
*graphics
= NULL
;
582 HDC hdc
= GetDC( hwnd
);
584 /* make a graphics object and pen object */
585 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
587 status
= GdipCreateFromHDC(hdc
, &graphics
);
589 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
591 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
593 ok(pen
!= NULL
, "Expected pen to be initialized\n");
595 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
596 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
597 expect(InvalidParameter
, status
);
599 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
600 expect(InvalidParameter
, status
);
602 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
603 expect(InvalidParameter
, status
);
605 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
606 expect(InvalidParameter
, status
);
608 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
609 expect(InvalidParameter
, status
);
611 /* successful case */
612 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
616 GdipDeleteGraphics(graphics
);
618 ReleaseDC(hwnd
, hdc
);
621 static void test_BeginContainer2(void)
625 REAL defClip
[] = {5, 10, 15, 20};
626 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
627 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
628 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
629 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
630 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
631 REAL scale
, defScale
= 17;
632 GpUnit unit
, defUnit
= UnitPixel
;
633 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
634 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
635 UINT contrast
, defContrast
= 5;
636 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
639 GpGraphics
*graphics
= NULL
;
640 HDC hdc
= GetDC( hwnd
);
642 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
644 status
= GdipCreateFromHDC(hdc
, &graphics
);
646 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
648 /* null graphics, null container */
649 status
= GdipBeginContainer2(NULL
, &cont1
);
650 expect(InvalidParameter
, status
);
652 status
= GdipBeginContainer2(graphics
, NULL
);
653 expect(InvalidParameter
, status
);
655 status
= GdipEndContainer(NULL
, cont1
);
656 expect(InvalidParameter
, status
);
658 /* test all quality-related values */
659 GdipSetCompositingMode(graphics
, defCompmode
);
660 GdipSetCompositingQuality(graphics
, defCompqual
);
661 GdipSetInterpolationMode(graphics
, defInterp
);
662 GdipSetPageScale(graphics
, defScale
);
663 GdipSetPageUnit(graphics
, defUnit
);
664 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
665 GdipSetSmoothingMode(graphics
, defSmoothmode
);
666 GdipSetTextContrast(graphics
, defContrast
);
667 GdipSetTextRenderingHint(graphics
, defTexthint
);
669 status
= GdipBeginContainer2(graphics
, &cont1
);
672 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
673 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
674 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
675 GdipSetPageScale(graphics
, 10);
676 GdipSetPageUnit(graphics
, UnitDocument
);
677 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
678 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
679 GdipSetTextContrast(graphics
, 7);
680 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
682 status
= GdipEndContainer(graphics
, cont1
);
685 GdipGetCompositingMode(graphics
, &compmode
);
686 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
688 GdipGetCompositingQuality(graphics
, &compqual
);
689 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
691 GdipGetInterpolationMode(graphics
, &interp
);
692 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
694 GdipGetPageScale(graphics
, &scale
);
695 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
697 GdipGetPageUnit(graphics
, &unit
);
698 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
700 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
701 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
703 GdipGetSmoothingMode(graphics
, &smoothmode
);
704 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
706 GdipGetTextContrast(graphics
, &contrast
);
707 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
709 GdipGetTextRenderingHint(graphics
, &texthint
);
710 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
712 /* test world transform */
713 status
= GdipBeginContainer2(graphics
, &cont1
);
716 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
717 defTrans
[4], defTrans
[5], &transform
);
719 GdipSetWorldTransform(graphics
, transform
);
720 GdipDeleteMatrix(transform
);
723 status
= GdipBeginContainer2(graphics
, &cont2
);
726 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
728 GdipSetWorldTransform(graphics
, transform
);
729 GdipDeleteMatrix(transform
);
732 status
= GdipEndContainer(graphics
, cont2
);
735 status
= GdipCreateMatrix(&transform
);
737 GdipGetWorldTransform(graphics
, transform
);
738 GdipGetMatrixElements(transform
, elems
);
739 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
740 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
741 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
742 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
743 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
744 fabs(defTrans
[5] - elems
[5]) < 0.0001,
745 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
746 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
747 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
748 GdipDeleteMatrix(transform
);
751 status
= GdipEndContainer(graphics
, cont1
);
755 status
= GdipBeginContainer2(graphics
, &cont1
);
758 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
760 status
= GdipBeginContainer2(graphics
, &cont2
);
763 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
765 status
= GdipEndContainer(graphics
, cont2
);
768 status
= GdipGetClipBounds(graphics
, &clip
);
771 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
772 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
773 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
774 fabs(defClip
[3] - clip
.Height
) < 0.0001,
775 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
776 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
777 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
779 status
= GdipEndContainer(graphics
, cont1
);
783 status
= GdipBeginContainer2(graphics
, &cont1
);
786 status
= GdipBeginContainer2(graphics
, &cont2
);
789 status
= GdipBeginContainer2(graphics
, &cont3
);
792 status
= GdipEndContainer(graphics
, cont3
);
795 status
= GdipBeginContainer2(graphics
, &cont4
);
798 status
= GdipEndContainer(graphics
, cont4
);
802 status
= GdipEndContainer(graphics
, cont1
);
805 /* end an already-ended container */
806 status
= GdipEndContainer(graphics
, cont1
);
809 GdipDeleteGraphics(graphics
);
810 ReleaseDC(hwnd
, hdc
);
813 static void test_GdipDrawBezierI(void)
816 GpGraphics
*graphics
= NULL
;
818 HDC hdc
= GetDC( hwnd
);
820 /* make a graphics object and pen object */
821 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
823 status
= GdipCreateFromHDC(hdc
, &graphics
);
825 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
827 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
829 ok(pen
!= NULL
, "Expected pen to be initialized\n");
831 /* InvalidParameter cases: null graphics, null pen */
832 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
833 expect(InvalidParameter
, status
);
835 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
836 expect(InvalidParameter
, status
);
838 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
839 expect(InvalidParameter
, status
);
841 /* successful case */
842 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
846 GdipDeleteGraphics(graphics
);
848 ReleaseDC(hwnd
, hdc
);
851 static void test_GdipDrawCurve3(void)
854 GpGraphics
*graphics
= NULL
;
856 HDC hdc
= GetDC( hwnd
);
868 /* make a graphics object and pen object */
869 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
871 status
= GdipCreateFromHDC(hdc
, &graphics
);
873 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
875 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
877 ok(pen
!= NULL
, "Expected pen to be initialized\n");
879 /* InvalidParameter cases: null graphics, null pen */
880 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
881 expect(InvalidParameter
, status
);
883 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
884 expect(InvalidParameter
, status
);
886 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
887 expect(InvalidParameter
, status
);
889 /* InvalidParameter cases: invalid count */
890 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
891 expect(InvalidParameter
, status
);
893 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
894 expect(InvalidParameter
, status
);
896 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
897 expect(InvalidParameter
, status
);
899 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
900 expect(InvalidParameter
, status
);
902 /* InvalidParameter cases: invalid number of segments */
903 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
904 expect(InvalidParameter
, status
);
906 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
907 expect(InvalidParameter
, status
);
909 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
910 expect(InvalidParameter
, status
);
912 /* Valid test cases */
913 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
916 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
919 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
922 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
926 GdipDeleteGraphics(graphics
);
928 ReleaseDC(hwnd
, hdc
);
931 static void test_GdipDrawCurve3I(void)
934 GpGraphics
*graphics
= NULL
;
936 HDC hdc
= GetDC( hwnd
);
948 /* make a graphics object and pen object */
949 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
951 status
= GdipCreateFromHDC(hdc
, &graphics
);
953 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
955 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
957 ok(pen
!= NULL
, "Expected pen to be initialized\n");
959 /* InvalidParameter cases: null graphics, null pen */
960 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
961 expect(InvalidParameter
, status
);
963 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
964 expect(InvalidParameter
, status
);
966 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
967 expect(InvalidParameter
, status
);
969 /* InvalidParameter cases: invalid count */
970 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
971 expect(OutOfMemory
, status
);
973 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
974 expect(InvalidParameter
, status
);
976 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
977 expect(InvalidParameter
, status
);
979 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
980 expect(InvalidParameter
, status
);
982 /* InvalidParameter cases: invalid number of segments */
983 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
984 expect(InvalidParameter
, status
);
986 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
987 expect(InvalidParameter
, status
);
989 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
990 expect(InvalidParameter
, status
);
992 /* Valid test cases */
993 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
996 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
999 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
1002 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
1006 GdipDeleteGraphics(graphics
);
1008 ReleaseDC(hwnd
, hdc
);
1011 static void test_GdipDrawCurve2(void)
1014 GpGraphics
*graphics
= NULL
;
1016 HDC hdc
= GetDC( hwnd
);
1028 /* make a graphics object and pen object */
1029 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1031 status
= GdipCreateFromHDC(hdc
, &graphics
);
1033 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1035 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1037 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1039 /* InvalidParameter cases: null graphics, null pen */
1040 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
1041 expect(InvalidParameter
, status
);
1043 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
1044 expect(InvalidParameter
, status
);
1046 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
1047 expect(InvalidParameter
, status
);
1049 /* InvalidParameter cases: invalid count */
1050 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
1051 expect(InvalidParameter
, status
);
1053 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
1054 expect(InvalidParameter
, status
);
1056 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
1057 expect(InvalidParameter
, status
);
1059 /* Valid test cases */
1060 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1063 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1066 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1069 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1073 GdipDeleteGraphics(graphics
);
1075 ReleaseDC(hwnd
, hdc
);
1078 static void test_GdipDrawCurve2I(void)
1081 GpGraphics
*graphics
= NULL
;
1083 HDC hdc
= GetDC( hwnd
);
1095 /* make a graphics object and pen object */
1096 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1098 status
= GdipCreateFromHDC(hdc
, &graphics
);
1100 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1102 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1104 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1106 /* InvalidParameter cases: null graphics, null pen */
1107 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1108 expect(InvalidParameter
, status
);
1110 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1111 expect(InvalidParameter
, status
);
1113 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1114 expect(InvalidParameter
, status
);
1116 /* InvalidParameter cases: invalid count */
1117 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1118 expect(OutOfMemory
, status
);
1120 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1121 expect(InvalidParameter
, status
);
1123 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1124 expect(InvalidParameter
, status
);
1126 /* Valid test cases */
1127 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1130 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1133 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1136 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1140 GdipDeleteGraphics(graphics
);
1142 ReleaseDC(hwnd
, hdc
);
1145 static void test_GdipDrawCurve(void)
1148 GpGraphics
*graphics
= NULL
;
1150 HDC hdc
= GetDC( hwnd
);
1162 /* make a graphics object and pen object */
1163 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1165 status
= GdipCreateFromHDC(hdc
, &graphics
);
1167 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1169 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1171 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1173 /* InvalidParameter cases: null graphics, null pen */
1174 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1175 expect(InvalidParameter
, status
);
1177 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1178 expect(InvalidParameter
, status
);
1180 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1181 expect(InvalidParameter
, status
);
1183 /* InvalidParameter cases: invalid count */
1184 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1185 expect(InvalidParameter
, status
);
1187 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1188 expect(InvalidParameter
, status
);
1190 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1191 expect(InvalidParameter
, status
);
1193 /* Valid test cases */
1194 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1197 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1201 GdipDeleteGraphics(graphics
);
1203 ReleaseDC(hwnd
, hdc
);
1206 static void test_GdipDrawCurveI(void)
1209 GpGraphics
*graphics
= NULL
;
1211 HDC hdc
= GetDC( hwnd
);
1223 /* make a graphics object and pen object */
1224 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1226 status
= GdipCreateFromHDC(hdc
, &graphics
);
1228 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1230 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1232 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1234 /* InvalidParameter cases: null graphics, null pen */
1235 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1236 expect(InvalidParameter
, status
);
1238 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1239 expect(InvalidParameter
, status
);
1241 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1242 expect(InvalidParameter
, status
);
1244 /* InvalidParameter cases: invalid count */
1245 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1246 expect(OutOfMemory
, status
);
1248 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1249 expect(InvalidParameter
, status
);
1251 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1252 expect(InvalidParameter
, status
);
1254 /* Valid test cases */
1255 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1258 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1262 GdipDeleteGraphics(graphics
);
1264 ReleaseDC(hwnd
, hdc
);
1267 static void test_GdipDrawLineI(void)
1270 GpGraphics
*graphics
= NULL
;
1272 HDC hdc
= GetDC( hwnd
);
1274 /* make a graphics object and pen object */
1275 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1277 status
= GdipCreateFromHDC(hdc
, &graphics
);
1279 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1281 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1283 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1285 /* InvalidParameter cases: null graphics, null pen */
1286 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1287 expect(InvalidParameter
, status
);
1289 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1290 expect(InvalidParameter
, status
);
1292 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1293 expect(InvalidParameter
, status
);
1295 /* successful case */
1296 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1300 GdipDeleteGraphics(graphics
);
1302 ReleaseDC(hwnd
, hdc
);
1305 static void test_GdipDrawImagePointsRect(void)
1308 GpGraphics
*graphics
= NULL
;
1310 GpBitmap
*bm
= NULL
;
1311 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1313 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1314 HDC hdc
= GetDC( hwnd
);
1318 memset(rbmi
, 0, sizeof(rbmi
));
1319 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1320 bmi
->bmiHeader
.biWidth
= 10;
1321 bmi
->bmiHeader
.biHeight
= 10;
1322 bmi
->bmiHeader
.biPlanes
= 1;
1323 bmi
->bmiHeader
.biBitCount
= 32;
1324 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1325 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1327 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1328 status
= GdipCreateFromHDC(hdc
, &graphics
);
1338 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1339 expect(NotImplemented
, status
);
1340 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1341 expect(InvalidParameter
, status
);
1342 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1344 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1345 expect(InvalidParameter
, status
);
1346 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1347 expect(InvalidParameter
, status
);
1348 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1350 memset(ptf
, 0, sizeof(ptf
));
1351 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1354 GdipDisposeImage((GpImage
*)bm
);
1355 GdipDeleteGraphics(graphics
);
1356 ReleaseDC(hwnd
, hdc
);
1359 static void test_GdipDrawLinesI(void)
1362 GpGraphics
*graphics
= NULL
;
1364 GpPoint
*ptf
= NULL
;
1365 HDC hdc
= GetDC( hwnd
);
1367 /* make a graphics object and pen object */
1368 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1370 status
= GdipCreateFromHDC(hdc
, &graphics
);
1372 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1374 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1376 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1378 /* make some arbitrary valid points*/
1379 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1387 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1388 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1389 expect(InvalidParameter
, status
);
1391 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1392 expect(InvalidParameter
, status
);
1394 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1395 expect(InvalidParameter
, status
);
1397 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1398 expect(InvalidParameter
, status
);
1400 /* successful case */
1401 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1406 GdipDeleteGraphics(graphics
);
1408 ReleaseDC(hwnd
, hdc
);
1411 static void test_GdipFillClosedCurve(void)
1414 GpGraphics
*graphics
= NULL
;
1415 GpSolidFill
*brush
= NULL
;
1416 HDC hdc
= GetDC( hwnd
);
1428 /* make a graphics object and brush object */
1429 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1431 status
= GdipCreateFromHDC(hdc
, &graphics
);
1433 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1435 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1437 /* InvalidParameter cases: null graphics, null brush, null points */
1438 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1439 expect(InvalidParameter
, status
);
1441 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1442 expect(InvalidParameter
, status
);
1444 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1445 expect(InvalidParameter
, status
);
1447 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1448 expect(InvalidParameter
, status
);
1450 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1451 expect(InvalidParameter
, status
);
1453 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1454 expect(InvalidParameter
, status
);
1456 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1457 expect(InvalidParameter
, status
);
1459 /* InvalidParameter cases: invalid count */
1460 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1461 expect(InvalidParameter
, status
);
1463 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1464 expect(InvalidParameter
, status
);
1466 /* Valid test cases */
1467 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1470 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1473 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1476 GdipDeleteGraphics(graphics
);
1477 GdipDeleteBrush((GpBrush
*)brush
);
1479 ReleaseDC(hwnd
, hdc
);
1482 static void test_GdipFillClosedCurveI(void)
1485 GpGraphics
*graphics
= NULL
;
1486 GpSolidFill
*brush
= NULL
;
1487 HDC hdc
= GetDC( hwnd
);
1499 /* make a graphics object and brush object */
1500 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1502 status
= GdipCreateFromHDC(hdc
, &graphics
);
1504 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1506 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1508 /* InvalidParameter cases: null graphics, null brush */
1509 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1510 when points == NULL, so don't test this condition */
1511 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1512 expect(InvalidParameter
, status
);
1514 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1515 expect(InvalidParameter
, status
);
1517 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1518 expect(InvalidParameter
, status
);
1520 /* InvalidParameter cases: invalid count */
1521 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1522 expect(InvalidParameter
, status
);
1524 /* OutOfMemory cases: large (unsigned) int */
1525 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1526 expect(OutOfMemory
, status
);
1528 /* Valid test cases */
1529 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1532 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1535 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1538 GdipDeleteGraphics(graphics
);
1539 GdipDeleteBrush((GpBrush
*)brush
);
1541 ReleaseDC(hwnd
, hdc
);
1544 static void test_Get_Release_DC(void)
1547 GpGraphics
*graphics
= NULL
;
1551 HDC hdc
= GetDC( hwnd
);
1554 CompositingQuality quality
;
1555 CompositingMode compmode
;
1556 InterpolationMode intmode
;
1560 PixelOffsetMode offsetmode
;
1561 SmoothingMode smoothmode
;
1562 TextRenderingHint texthint
;
1570 ARGB color
= 0x00000000;
1571 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1584 for(i
= 0; i
< 5;i
++){
1585 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1586 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1592 rect
[0].Height
= 70;
1596 rect
[1].Height
= 20;
1598 for(i
= 0; i
< 2;i
++){
1599 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1600 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1601 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1602 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1605 status
= GdipCreateMatrix(&m
);
1607 GdipCreateRegion(®ion
);
1608 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1609 GdipCreatePath(FillModeAlternate
, &path
);
1610 GdipCreateRegion(&clip
);
1612 status
= GdipCreateFromHDC(hdc
, &graphics
);
1614 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1615 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1618 /* NULL arguments */
1619 status
= GdipGetDC(NULL
, NULL
);
1620 expect(InvalidParameter
, status
);
1621 status
= GdipGetDC(graphics
, NULL
);
1622 expect(InvalidParameter
, status
);
1623 status
= GdipGetDC(NULL
, &retdc
);
1624 expect(InvalidParameter
, status
);
1626 status
= GdipReleaseDC(NULL
, NULL
);
1627 expect(InvalidParameter
, status
);
1628 status
= GdipReleaseDC(graphics
, NULL
);
1629 expect(InvalidParameter
, status
);
1630 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1631 expect(InvalidParameter
, status
);
1633 /* Release without Get */
1634 status
= GdipReleaseDC(graphics
, hdc
);
1635 expect(InvalidParameter
, status
);
1638 status
= GdipGetDC(graphics
, &retdc
);
1640 ok(retdc
== hdc
, "Invalid HDC returned\n");
1641 /* call it once more */
1642 status
= GdipGetDC(graphics
, &retdc
);
1643 expect(ObjectBusy
, status
);
1645 /* try all Graphics calls here */
1646 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1647 expect(ObjectBusy
, status
);
1648 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1649 expect(ObjectBusy
, status
);
1650 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1651 expect(ObjectBusy
, status
);
1652 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1653 expect(ObjectBusy
, status
);
1654 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1655 expect(ObjectBusy
, status
);
1656 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1657 expect(ObjectBusy
, status
);
1658 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1659 expect(ObjectBusy
, status
);
1660 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1661 expect(ObjectBusy
, status
);
1662 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1663 expect(ObjectBusy
, status
);
1664 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1665 expect(ObjectBusy
, status
);
1666 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1667 expect(ObjectBusy
, status
);
1668 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1669 expect(ObjectBusy
, status
);
1670 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1671 expect(ObjectBusy
, status
);
1672 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1673 expect(ObjectBusy
, status
);
1674 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1675 expect(ObjectBusy
, status
);
1676 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1677 expect(ObjectBusy
, status
);
1678 /* GdipDrawImage/GdipDrawImageI */
1679 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1680 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1681 /* GdipDrawImageRect/GdipDrawImageRectI */
1682 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1683 expect(ObjectBusy
, status
);
1684 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1685 expect(ObjectBusy
, status
);
1686 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1687 expect(ObjectBusy
, status
);
1688 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1689 expect(ObjectBusy
, status
);
1690 status
= GdipDrawPath(graphics
, pen
, path
);
1691 expect(ObjectBusy
, status
);
1692 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1693 expect(ObjectBusy
, status
);
1694 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1695 expect(ObjectBusy
, status
);
1696 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1697 expect(ObjectBusy
, status
);
1698 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1699 expect(ObjectBusy
, status
);
1700 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1701 expect(ObjectBusy
, status
);
1702 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1703 expect(ObjectBusy
, status
);
1704 /* GdipDrawString */
1705 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1706 expect(ObjectBusy
, status
);
1707 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1708 expect(ObjectBusy
, status
);
1709 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1710 expect(ObjectBusy
, status
);
1711 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1712 expect(ObjectBusy
, status
);
1713 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1714 expect(ObjectBusy
, status
);
1715 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1716 expect(ObjectBusy
, status
);
1717 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1718 expect(ObjectBusy
, status
);
1719 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1720 expect(ObjectBusy
, status
);
1721 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1722 expect(ObjectBusy
, status
);
1723 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1724 expect(ObjectBusy
, status
);
1725 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1726 expect(ObjectBusy
, status
);
1727 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1728 expect(ObjectBusy
, status
);
1729 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1730 expect(ObjectBusy
, status
);
1731 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1732 expect(ObjectBusy
, status
);
1733 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1734 expect(ObjectBusy
, status
);
1735 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1736 expect(ObjectBusy
, status
);
1737 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1738 expect(ObjectBusy
, status
);
1739 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1740 expect(ObjectBusy
, status
);
1741 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1742 expect(ObjectBusy
, status
);
1743 status
= GdipGetClipBounds(graphics
, rectf
);
1744 expect(ObjectBusy
, status
);
1745 status
= GdipGetClipBoundsI(graphics
, rect
);
1746 expect(ObjectBusy
, status
);
1747 status
= GdipGetCompositingMode(graphics
, &compmode
);
1748 expect(ObjectBusy
, status
);
1749 status
= GdipGetCompositingQuality(graphics
, &quality
);
1750 expect(ObjectBusy
, status
);
1751 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1752 expect(ObjectBusy
, status
);
1753 status
= GdipGetNearestColor(graphics
, &color
);
1754 expect(ObjectBusy
, status
);
1755 status
= GdipGetPageScale(graphics
, &r
);
1756 expect(ObjectBusy
, status
);
1757 status
= GdipGetPageUnit(graphics
, &unit
);
1758 expect(ObjectBusy
, status
);
1759 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1764 expect(ObjectBusy
, status
);
1765 status
= GdipGetWorldTransform(graphics
, m
);
1766 expect(ObjectBusy
, status
);
1767 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1768 expect(ObjectBusy
, status
);
1769 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1770 expect(ObjectBusy
, status
);
1771 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1772 expect(ObjectBusy
, status
);
1773 /* GdipMeasureCharacterRanges */
1774 /* GdipMeasureString */
1775 status
= GdipResetClip(graphics
);
1776 expect(ObjectBusy
, status
);
1777 status
= GdipResetWorldTransform(graphics
);
1778 expect(ObjectBusy
, status
);
1779 /* GdipRestoreGraphics */
1780 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1781 expect(ObjectBusy
, status
);
1782 /* GdipSaveGraphics */
1783 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1784 expect(ObjectBusy
, status
);
1785 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1786 expect(ObjectBusy
, status
);
1787 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1788 expect(ObjectBusy
, status
);
1789 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1790 expect(ObjectBusy
, status
);
1791 status
= GdipSetPageScale(graphics
, 1.0);
1792 expect(ObjectBusy
, status
);
1793 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1794 expect(ObjectBusy
, status
);
1795 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1796 expect(ObjectBusy
, status
);
1797 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1798 expect(ObjectBusy
, status
);
1799 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1800 expect(ObjectBusy
, status
);
1801 status
= GdipSetWorldTransform(graphics
, m
);
1802 expect(ObjectBusy
, status
);
1803 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1804 expect(ObjectBusy
, status
);
1805 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1806 expect(ObjectBusy
, status
);
1807 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1808 expect(ObjectBusy
, status
);
1809 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1810 expect(ObjectBusy
, status
);
1811 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1812 expect(ObjectBusy
, status
);
1813 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1814 expect(ObjectBusy
, status
);
1815 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1816 expect(ObjectBusy
, status
);
1817 status
= GdipTranslateClipI(graphics
, 0, 0);
1818 expect(ObjectBusy
, status
);
1819 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1820 expect(ObjectBusy
, status
);
1821 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1822 expect(ObjectBusy
, status
);
1823 status
= GdipGetDpiX(graphics
, &r
);
1824 expect(ObjectBusy
, status
);
1825 status
= GdipGetDpiY(graphics
, &r
);
1826 expect(ObjectBusy
, status
);
1827 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1828 expect(ObjectBusy
, status
);
1829 status
= GdipGetClip(graphics
, region
);
1830 expect(ObjectBusy
, status
);
1831 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1832 expect(ObjectBusy
, status
);
1834 /* try to delete before release */
1835 status
= GdipDeleteGraphics(graphics
);
1836 expect(ObjectBusy
, status
);
1838 status
= GdipReleaseDC(graphics
, retdc
);
1842 GdipDeleteGraphics(graphics
);
1844 GdipDeleteRegion(clip
);
1845 GdipDeletePath(path
);
1846 GdipDeleteBrush((GpBrush
*)brush
);
1847 GdipDeleteRegion(region
);
1848 GdipDeleteMatrix(m
);
1851 ReleaseDC(hwnd
, hdc
);
1854 static void test_transformpoints(void)
1857 GpGraphics
*graphics
= NULL
;
1858 HDC hdc
= GetDC( hwnd
);
1862 status
= GdipCreateFromHDC(hdc
, &graphics
);
1865 /* NULL arguments */
1866 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1867 expect(InvalidParameter
, status
);
1868 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1869 expect(InvalidParameter
, status
);
1870 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1871 expect(InvalidParameter
, status
);
1872 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1873 expect(InvalidParameter
, status
);
1879 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1881 expectf(1.0, ptf
[0].X
);
1882 expectf(0.0, ptf
[0].Y
);
1883 expectf(0.0, ptf
[1].X
);
1884 expectf(1.0, ptf
[1].Y
);
1886 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1888 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1890 status
= GdipSetPageScale(graphics
, 3.0);
1897 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1899 expectf(18.0, ptf
[0].X
);
1900 expectf(15.0, ptf
[0].Y
);
1901 expectf(15.0, ptf
[1].X
);
1902 expectf(18.0, ptf
[1].Y
);
1908 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1910 expectf(6.0, ptf
[0].X
);
1911 expectf(5.0, ptf
[0].Y
);
1912 expectf(5.0, ptf
[1].X
);
1913 expectf(6.0, ptf
[1].Y
);
1919 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1921 expectf(3.0, ptf
[0].X
);
1922 expectf(0.0, ptf
[0].Y
);
1923 expectf(0.0, ptf
[1].X
);
1924 expectf(3.0, ptf
[1].Y
);
1930 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1932 expectf(1.0, ptf
[0].X
);
1933 expectf(0.0, ptf
[0].Y
);
1934 expectf(0.0, ptf
[1].X
);
1935 expectf(1.0, ptf
[1].Y
);
1941 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1943 expectf(1.0, ptf
[0].X
);
1944 expectf(0.0, ptf
[0].Y
);
1945 expectf(0.0, ptf
[1].X
);
1946 expectf(1.0, ptf
[1].Y
);
1952 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1954 expectf(1.0, ptf
[0].X
);
1955 expectf(0.0, ptf
[0].Y
);
1956 expectf(0.0, ptf
[1].X
);
1957 expectf(1.0, ptf
[1].Y
);
1963 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1965 expect(18, pt
[0].X
);
1966 expect(15, pt
[0].Y
);
1967 expect(15, pt
[1].X
);
1968 expect(18, pt
[1].Y
);
1970 GdipDeleteGraphics(graphics
);
1971 ReleaseDC(hwnd
, hdc
);
1974 static void test_get_set_clip(void)
1977 GpGraphics
*graphics
= NULL
;
1978 HDC hdc
= GetDC( hwnd
);
1983 status
= GdipCreateFromHDC(hdc
, &graphics
);
1986 rect
.X
= rect
.Y
= 0.0;
1987 rect
.Height
= rect
.Width
= 100.0;
1989 status
= GdipCreateRegionRect(&rect
, &clip
);
1992 /* NULL arguments */
1993 status
= GdipGetClip(NULL
, NULL
);
1994 expect(InvalidParameter
, status
);
1995 status
= GdipGetClip(graphics
, NULL
);
1996 expect(InvalidParameter
, status
);
1997 status
= GdipGetClip(NULL
, clip
);
1998 expect(InvalidParameter
, status
);
2000 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
2001 expect(InvalidParameter
, status
);
2002 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
2003 expect(InvalidParameter
, status
);
2005 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
2006 expect(InvalidParameter
, status
);
2007 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
2008 expect(InvalidParameter
, status
);
2011 status
= GdipGetClip(graphics
, clip
);
2013 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2017 /* remains infinite after reset */
2019 status
= GdipResetClip(graphics
);
2021 status
= GdipGetClip(graphics
, clip
);
2023 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2027 /* set to empty and then reset to infinite */
2028 status
= GdipSetEmpty(clip
);
2030 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
2033 status
= GdipGetClip(graphics
, clip
);
2036 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
2039 status
= GdipResetClip(graphics
);
2041 status
= GdipGetClip(graphics
, clip
);
2044 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2048 GdipDeleteRegion(clip
);
2050 GdipDeleteGraphics(graphics
);
2051 ReleaseDC(hwnd
, hdc
);
2054 static void test_isempty(void)
2057 GpGraphics
*graphics
= NULL
;
2058 HDC hdc
= GetDC( hwnd
);
2062 status
= GdipCreateFromHDC(hdc
, &graphics
);
2065 status
= GdipCreateRegion(&clip
);
2069 status
= GdipIsClipEmpty(NULL
, NULL
);
2070 expect(InvalidParameter
, status
);
2071 status
= GdipIsClipEmpty(graphics
, NULL
);
2072 expect(InvalidParameter
, status
);
2073 status
= GdipIsClipEmpty(NULL
, &res
);
2074 expect(InvalidParameter
, status
);
2076 /* default is infinite */
2078 status
= GdipIsClipEmpty(graphics
, &res
);
2082 GdipDeleteRegion(clip
);
2084 GdipDeleteGraphics(graphics
);
2085 ReleaseDC(hwnd
, hdc
);
2088 static void test_clear(void)
2092 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2093 expect(InvalidParameter
, status
);
2096 static void test_textcontrast(void)
2099 HDC hdc
= GetDC( hwnd
);
2100 GpGraphics
*graphics
;
2103 status
= GdipGetTextContrast(NULL
, NULL
);
2104 expect(InvalidParameter
, status
);
2106 status
= GdipCreateFromHDC(hdc
, &graphics
);
2109 status
= GdipGetTextContrast(graphics
, NULL
);
2110 expect(InvalidParameter
, status
);
2111 status
= GdipGetTextContrast(graphics
, &contrast
);
2113 expect(4, contrast
);
2115 GdipDeleteGraphics(graphics
);
2116 ReleaseDC(hwnd
, hdc
);
2119 static void test_GdipDrawString(void)
2122 GpGraphics
*graphics
= NULL
;
2125 GpStringFormat
*format
;
2128 HDC hdc
= GetDC( hwnd
);
2129 static const WCHAR string
[] = {'T','e','s','t',0};
2130 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2133 memset(&logfont
,0,sizeof(logfont
));
2134 strcpy(logfont
.lfFaceName
,"Arial");
2135 logfont
.lfHeight
= 12;
2136 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2138 status
= GdipCreateFromHDC(hdc
, &graphics
);
2141 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2142 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2144 skip("Arial not installed.\n");
2149 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2152 status
= GdipCreateStringFormat(0,0,&format
);
2160 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2163 status
= GdipCreateMatrix(&matrix
);
2166 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2167 expect(InvalidParameter
, status
);
2169 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2170 expect(InvalidParameter
, status
);
2172 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2173 expect(InvalidParameter
, status
);
2175 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2176 expect(InvalidParameter
, status
);
2178 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2179 expect(InvalidParameter
, status
);
2181 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2184 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2187 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2190 GdipDeleteMatrix(matrix
);
2191 GdipDeleteGraphics(graphics
);
2192 GdipDeleteBrush(brush
);
2193 GdipDeleteFont(fnt
);
2194 GdipDeleteStringFormat(format
);
2196 ReleaseDC(hwnd
, hdc
);
2199 static void test_GdipGetVisibleClipBounds_screen(void)
2202 GpGraphics
*graphics
= NULL
;
2204 GpRectF rectf
, exp
, clipr
;
2207 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2209 status
= GdipCreateFromHDC(hdc
, &graphics
);
2211 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2213 /* no clipping rect */
2216 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2217 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2219 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2221 ok(rectf
.X
== exp
.X
&&
2223 rectf
.Width
== exp
.Width
&&
2224 rectf
.Height
== exp
.Height
,
2225 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2226 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2227 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2228 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2230 /* clipping rect entirely within window */
2231 exp
.X
= clipr
.X
= 10;
2232 exp
.Y
= clipr
.Y
= 12;
2233 exp
.Width
= clipr
.Width
= 14;
2234 exp
.Height
= clipr
.Height
= 16;
2236 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2239 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2241 ok(rectf
.X
== exp
.X
&&
2243 rectf
.Width
== exp
.Width
&&
2244 rectf
.Height
== exp
.Height
,
2245 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2246 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2247 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2248 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2250 /* clipping rect partially outside of screen */
2256 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2264 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2266 ok(rectf
.X
== exp
.X
&&
2268 rectf
.Width
== exp
.Width
&&
2269 rectf
.Height
== exp
.Height
,
2270 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2271 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2272 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2273 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2275 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2277 ok(recti
.X
== exp
.X
&&
2279 recti
.Width
== exp
.Width
&&
2280 recti
.Height
== exp
.Height
,
2281 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2282 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2283 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2284 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2286 GdipDeleteGraphics(graphics
);
2290 static void test_GdipGetVisibleClipBounds_window(void)
2293 GpGraphics
*graphics
= NULL
;
2294 GpRectF rectf
, window
, exp
, clipr
;
2300 /* get client area size */
2301 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2302 window
.X
= wnd_rect
.left
;
2303 window
.Y
= wnd_rect
.top
;
2304 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2305 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2307 hdc
= BeginPaint(hwnd
, &ps
);
2309 status
= GdipCreateFromHDC(hdc
, &graphics
);
2311 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2313 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2315 ok(rectf
.X
== window
.X
&&
2316 rectf
.Y
== window
.Y
&&
2317 rectf
.Width
== window
.Width
&&
2318 rectf
.Height
== window
.Height
,
2319 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2320 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2321 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2322 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2324 /* clipping rect entirely within window */
2325 exp
.X
= clipr
.X
= 20;
2326 exp
.Y
= clipr
.Y
= 8;
2327 exp
.Width
= clipr
.Width
= 30;
2328 exp
.Height
= clipr
.Height
= 20;
2330 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2333 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2335 ok(rectf
.X
== exp
.X
&&
2337 rectf
.Width
== exp
.Width
&&
2338 rectf
.Height
== exp
.Height
,
2339 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2340 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2341 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2342 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2344 /* clipping rect partially outside of window */
2345 clipr
.X
= window
.Width
- 10;
2346 clipr
.Y
= window
.Height
- 15;
2350 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2353 exp
.X
= window
.Width
- 10;
2354 exp
.Y
= window
.Height
- 15;
2358 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2360 ok(rectf
.X
== exp
.X
&&
2362 rectf
.Width
== exp
.Width
&&
2363 rectf
.Height
== exp
.Height
,
2364 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2365 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2366 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2367 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2369 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2371 ok(recti
.X
== exp
.X
&&
2373 recti
.Width
== exp
.Width
&&
2374 recti
.Height
== exp
.Height
,
2375 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2376 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2377 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2378 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2380 /* window bounds with transform applied */
2381 status
= GdipResetClip(graphics
);
2384 status
= GdipScaleWorldTransform(graphics
, 0.5, 0.5, MatrixOrderPrepend
);
2387 exp
.X
= window
.X
* 2.0;
2388 exp
.Y
= window
.Y
* 2.0;
2389 exp
.Width
= window
.Width
* 2.0;
2390 exp
.Height
= window
.Height
* 2.0;
2392 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2394 ok(rectf
.X
== exp
.X
&&
2396 rectf
.Width
== exp
.Width
&&
2397 rectf
.Height
== exp
.Height
,
2398 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2399 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2400 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2401 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2403 GdipDeleteGraphics(graphics
);
2404 EndPaint(hwnd
, &ps
);
2407 static void test_GdipGetVisibleClipBounds(void)
2409 GpGraphics
* graphics
= NULL
;
2412 HDC hdc
= GetDC( hwnd
);
2415 status
= GdipCreateFromHDC(hdc
, &graphics
);
2417 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2419 /* test null parameters */
2420 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2421 expect(InvalidParameter
, status
);
2423 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2424 expect(InvalidParameter
, status
);
2426 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2427 expect(InvalidParameter
, status
);
2429 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2430 expect(InvalidParameter
, status
);
2432 GdipDeleteGraphics(graphics
);
2433 ReleaseDC(hwnd
, hdc
);
2435 test_GdipGetVisibleClipBounds_screen();
2436 test_GdipGetVisibleClipBounds_window();
2439 static void test_fromMemoryBitmap(void)
2442 GpGraphics
*graphics
= NULL
;
2443 GpBitmap
*bitmap
= NULL
;
2444 BYTE bits
[48] = {0};
2448 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2451 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2454 status
= GdipGraphicsClear(graphics
, 0xff686868);
2457 GdipDeleteGraphics(graphics
);
2459 /* drawing writes to the memory provided */
2460 expect(0x68, bits
[10]);
2462 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2465 status
= GdipGetDC(graphics
, &hdc
);
2467 ok(hdc
!= NULL
, "got NULL hdc\n");
2469 color
= GetPixel(hdc
, 0, 0);
2470 /* The HDC is write-only, and native fills with a solid color to figure out
2471 * which pixels have changed. */
2472 todo_wine
expect(0x0c0b0d, color
);
2474 SetPixel(hdc
, 0, 0, 0x797979);
2475 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2477 status
= GdipReleaseDC(graphics
, hdc
);
2480 GdipDeleteGraphics(graphics
);
2482 expect(0x79, bits
[0]);
2483 todo_wine
expect(0x68, bits
[3]);
2485 GdipDisposeImage((GpImage
*)bitmap
);
2487 /* We get the same kind of write-only HDC for a "normal" bitmap */
2488 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2491 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2494 status
= GdipGetDC(graphics
, &hdc
);
2496 ok(hdc
!= NULL
, "got NULL hdc\n");
2498 color
= GetPixel(hdc
, 0, 0);
2499 todo_wine
expect(0x0c0b0d, color
);
2501 status
= GdipReleaseDC(graphics
, hdc
);
2504 GdipDeleteGraphics(graphics
);
2506 GdipDisposeImage((GpImage
*)bitmap
);
2508 /* If we don't draw to the HDC, the bits are never accessed */
2509 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2512 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2515 status
= GdipGetDC(graphics
, &hdc
);
2517 ok(hdc
!= NULL
, "got NULL hdc\n");
2519 color
= GetPixel(hdc
, 0, 0);
2520 todo_wine
expect(0x0c0b0d, color
);
2522 status
= GdipReleaseDC(graphics
, hdc
);
2525 GdipDeleteGraphics(graphics
);
2527 GdipDisposeImage((GpImage
*)bitmap
);
2530 static void test_GdipIsVisiblePoint(void)
2533 GpGraphics
*graphics
= NULL
;
2534 HDC hdc
= GetDC( hwnd
);
2538 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2540 status
= GdipCreateFromHDC(hdc
, &graphics
);
2542 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2544 /* null parameters */
2545 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2546 expect(InvalidParameter
, status
);
2548 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2549 expect(InvalidParameter
, status
);
2551 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2552 expect(InvalidParameter
, status
);
2554 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2555 expect(InvalidParameter
, status
);
2559 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2561 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2565 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2567 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2571 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2573 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2577 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2579 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2581 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2586 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2588 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2592 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2594 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2596 /* translate into the center of the rect */
2597 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2601 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2603 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2607 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2609 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2611 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2616 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2618 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2622 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2624 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2628 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2630 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2634 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2636 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2640 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2642 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2646 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2648 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2652 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2654 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2658 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2660 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2664 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2666 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2670 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2672 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2676 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2678 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2682 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2684 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2688 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2690 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2692 /* integer version */
2695 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2697 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2701 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2703 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2705 GdipDeleteGraphics(graphics
);
2706 ReleaseDC(hwnd
, hdc
);
2709 static void test_GdipIsVisibleRect(void)
2712 GpGraphics
*graphics
= NULL
;
2713 HDC hdc
= GetDC( hwnd
);
2714 REAL x
, y
, width
, height
;
2717 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2719 status
= GdipCreateFromHDC(hdc
, &graphics
);
2721 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2723 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2724 expect(InvalidParameter
, status
);
2726 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2727 expect(InvalidParameter
, status
);
2729 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2730 expect(InvalidParameter
, status
);
2732 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2733 expect(InvalidParameter
, status
);
2735 /* entirely within the visible region */
2738 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2740 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2742 /* partially outside */
2743 x
= -10; width
= 20;
2744 y
= -10; height
= 20;
2745 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2747 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2749 /* entirely outside */
2751 y
= -10; height
= 5;
2752 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2754 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2756 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2759 /* entirely within the visible region */
2761 y
= 22; height
= 10;
2762 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2764 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2766 /* partially outside */
2768 y
= 55; height
= 10;
2769 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2771 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2773 /* entirely outside */
2776 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2778 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2780 /* translate into center of clipping rect */
2781 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2785 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2787 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2791 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2793 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2795 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2797 /* corners entirely outside, but some intersections */
2800 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2802 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2806 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2808 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2812 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2814 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2818 y
= 20; height
= 40;
2819 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2821 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2825 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2827 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2830 y
= 20; height
= 40;
2831 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2833 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2836 y
= 60; height
= 10;
2837 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2839 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2841 /* rounding tests */
2842 x
= 0.4; width
= 10.4;
2843 y
= 20; height
= 40;
2844 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2846 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2849 y
= 0.4; height
= 20.4;
2850 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2852 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2854 /* integer version */
2857 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2859 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2862 y
= 22; height
= 10;
2863 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2865 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2867 GdipDeleteGraphics(graphics
);
2868 ReleaseDC(hwnd
, hdc
);
2871 static void test_GdipGetNearestColor(void)
2874 GpGraphics
*graphics
;
2876 ARGB color
= 0xdeadbeef;
2877 HDC hdc
= GetDC( hwnd
);
2879 /* create a graphics object */
2880 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2882 status
= GdipCreateFromHDC(hdc
, &graphics
);
2884 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2886 status
= GdipGetNearestColor(graphics
, NULL
);
2887 expect(InvalidParameter
, status
);
2889 status
= GdipGetNearestColor(NULL
, &color
);
2890 expect(InvalidParameter
, status
);
2891 GdipDeleteGraphics(graphics
);
2893 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2895 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2896 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2899 status
= GdipGetNearestColor(graphics
, &color
);
2901 expect(0xdeadbeef, color
);
2902 GdipDeleteGraphics(graphics
);
2904 GdipDisposeImage((GpImage
*)bitmap
);
2906 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2908 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2909 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2912 status
= GdipGetNearestColor(graphics
, &color
);
2914 expect(0xdeadbeef, color
);
2915 GdipDeleteGraphics(graphics
);
2917 GdipDisposeImage((GpImage
*)bitmap
);
2919 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2921 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2922 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2925 status
= GdipGetNearestColor(graphics
, &color
);
2927 expect(0xdeadbeef, color
);
2928 GdipDeleteGraphics(graphics
);
2930 GdipDisposeImage((GpImage
*)bitmap
);
2932 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2934 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2935 todo_wine
expect(OutOfMemory
, status
);
2937 GdipDeleteGraphics(graphics
);
2938 GdipDisposeImage((GpImage
*)bitmap
);
2940 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2942 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2944 status
= GdipGetNearestColor(graphics
, &color
);
2946 expect(0xdeadbeef, color
);
2947 GdipDeleteGraphics(graphics
);
2948 GdipDisposeImage((GpImage
*)bitmap
);
2950 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2952 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2954 status
= GdipGetNearestColor(graphics
, &color
);
2956 expect(0xdeadbeef, color
);
2957 GdipDeleteGraphics(graphics
);
2958 GdipDisposeImage((GpImage
*)bitmap
);
2960 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2962 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2964 status
= GdipGetNearestColor(graphics
, &color
);
2966 expect(0xdeadbeef, color
);
2967 GdipDeleteGraphics(graphics
);
2968 GdipDisposeImage((GpImage
*)bitmap
);
2970 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2974 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2976 status
= GdipGetNearestColor(graphics
, &color
);
2978 expect(0xdeadbeef, color
);
2979 GdipDeleteGraphics(graphics
);
2980 GdipDisposeImage((GpImage
*)bitmap
);
2983 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2987 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2989 status
= GdipGetNearestColor(graphics
, &color
);
2991 expect(0xdeadbeef, color
);
2992 GdipDeleteGraphics(graphics
);
2993 GdipDisposeImage((GpImage
*)bitmap
);
2996 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
3000 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3002 status
= GdipGetNearestColor(graphics
, &color
);
3004 expect(0xdeadbeef, color
);
3005 GdipDeleteGraphics(graphics
);
3006 GdipDisposeImage((GpImage
*)bitmap
);
3009 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
3011 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3013 status
= GdipGetNearestColor(graphics
, &color
);
3015 todo_wine
expect(0xffa8bce8, color
);
3016 GdipDeleteGraphics(graphics
);
3017 GdipDisposeImage((GpImage
*)bitmap
);
3019 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
3021 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3023 status
= GdipGetNearestColor(graphics
, &color
);
3026 ok(color
== 0xffa8b8e8 ||
3027 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
3028 "Expected ffa8b8e8, got %.8x\n", color
);
3029 GdipDeleteGraphics(graphics
);
3030 GdipDisposeImage((GpImage
*)bitmap
);
3032 ReleaseDC(hwnd
, hdc
);
3035 static void test_string_functions(void)
3038 GpGraphics
*graphics
;
3039 GpFontFamily
*family
;
3041 RectF rc
, char_bounds
, bounds
;
3043 ARGB color
= 0xff000000;
3044 HDC hdc
= GetDC( hwnd
);
3045 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
3046 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
3047 const WCHAR teststring2
[] = {'j',0};
3048 REAL char_width
, char_height
;
3049 INT codepointsfitted
, linesfilled
;
3050 GpStringFormat
*format
;
3051 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
3052 GpRegion
*regions
[4];
3053 BOOL region_isempty
[4];
3055 PointF positions
[8];
3058 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3059 status
= GdipCreateFromHDC(hdc
, &graphics
);
3061 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3063 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
3066 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
3069 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
3072 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3080 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
3081 expect(InvalidParameter
, status
);
3083 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
3084 expect(InvalidParameter
, status
);
3086 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3087 expect(InvalidParameter
, status
);
3089 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3090 expect(InvalidParameter
, status
);
3092 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3093 expect(InvalidParameter
, status
);
3095 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3098 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3099 expect(InvalidParameter
, status
);
3101 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3102 expect(InvalidParameter
, status
);
3104 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3105 expect(InvalidParameter
, status
);
3107 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3108 expect(InvalidParameter
, status
);
3110 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3111 expect(InvalidParameter
, status
);
3113 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3116 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3119 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3121 expectf(0.0, char_bounds
.X
);
3122 expectf(0.0, char_bounds
.Y
);
3123 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3124 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3125 expect(1, codepointsfitted
);
3126 expect(1, linesfilled
);
3128 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3130 expectf(0.0, bounds
.X
);
3131 expectf(0.0, bounds
.Y
);
3132 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3133 expectf(char_bounds
.Height
, bounds
.Height
);
3134 expect(2, codepointsfitted
);
3135 expect(1, linesfilled
);
3136 char_width
= bounds
.Width
- char_bounds
.Width
;
3138 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3140 expectf(0.0, bounds
.X
);
3141 expectf(0.0, bounds
.Y
);
3142 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3143 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3144 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3145 expect(6, codepointsfitted
);
3146 expect(2, linesfilled
);
3147 char_height
= bounds
.Height
- char_bounds
.Height
;
3149 /* Measure the first line. */
3150 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3152 expectf(0.0, bounds
.X
);
3153 expectf(0.0, bounds
.Y
);
3154 expect(4, codepointsfitted
);
3155 expect(1, linesfilled
);
3157 /* Give just enough space to fit the first line. */
3158 rc
.Width
= bounds
.Width
;
3159 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3161 expectf(0.0, bounds
.X
);
3162 expectf(0.0, bounds
.Y
);
3163 todo_wine
expect(5, codepointsfitted
);
3164 todo_wine
expect(1, linesfilled
);
3166 /* Cut off everything after the first space. */
3167 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3169 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3171 expectf(0.0, bounds
.X
);
3172 expectf(0.0, bounds
.Y
);
3173 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3174 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3175 expect(6, codepointsfitted
);
3176 expect(3, linesfilled
);
3178 /* Cut off everything including the first space. */
3179 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3181 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3183 expectf(0.0, bounds
.X
);
3184 expectf(0.0, bounds
.Y
);
3185 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3186 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3187 expect(6, codepointsfitted
);
3188 expect(3, linesfilled
);
3190 /* Cut off everything after the first character. */
3191 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3193 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3195 expectf(0.0, bounds
.X
);
3196 expectf(0.0, bounds
.Y
);
3197 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3198 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3199 expect(6, codepointsfitted
);
3200 todo_wine
expect(4, linesfilled
);
3202 for (i
= 0; i
< 4; i
++)
3203 regions
[i
] = (GpRegion
*)0xdeadbeef;
3205 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3208 for (i
= 0; i
< 4; i
++)
3209 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3211 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3214 for (i
= 0; i
< 4; i
++)
3215 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3217 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3220 set_rect_empty(&rc
);
3224 status
= GdipCreateRegion(®ions
[i
]);
3226 status
= GdipSetEmpty(regions
[i
]);
3230 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3231 expect(InvalidParameter
, status
);
3233 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3234 expect(InvalidParameter
, status
);
3236 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3237 expect(InvalidParameter
, status
);
3239 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3240 expect(InvalidParameter
, status
);
3244 /* Crashes on Windows XP */
3245 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3246 expect(InvalidParameter
, status
);
3249 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3250 expect(InvalidParameter
, status
);
3252 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3253 expect(InvalidParameter
, status
);
3255 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3258 for (i
= 0; i
< 4; i
++)
3260 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3264 ok(region_isempty
[0], "region should be empty\n");
3265 ok(region_isempty
[1], "region should be empty\n");
3266 ok(region_isempty
[2], "region should be empty\n");
3267 ok(region_isempty
[3], "region should be empty\n");
3272 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3277 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3281 ok(!region_isempty
[0], "region shouldn't be empty\n");
3282 ok(!region_isempty
[1], "region shouldn't be empty\n");
3283 ok(!region_isempty
[2], "region shouldn't be empty\n");
3284 ok(region_isempty
[3], "region should be empty\n");
3286 /* Cut off everything after the first space, and the second line. */
3287 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3288 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3290 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3295 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3299 ok(!region_isempty
[0], "region shouldn't be empty\n");
3300 ok(!region_isempty
[1], "region shouldn't be empty\n");
3301 ok(region_isempty
[2], "region should be empty\n");
3302 ok(region_isempty
[3], "region should be empty\n");
3305 GdipDeleteRegion(regions
[i
]);
3307 status
= GdipCreateMatrix(&identity
);
3314 memset(positions
, 0, sizeof(positions
));
3315 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3316 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3318 expect(InvalidParameter
, status
);
3320 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3321 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3323 expect(InvalidParameter
, status
);
3325 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3326 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3328 expect(InvalidParameter
, status
);
3330 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3331 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3333 expect(InvalidParameter
, status
);
3335 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3336 0x100, identity
, &rc
);
3339 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3340 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3344 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3345 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3347 expect(InvalidParameter
, status
);
3353 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3354 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3359 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3360 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3361 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3363 char_width
= rc
.Width
;
3364 char_height
= rc
.Height
;
3370 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3371 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3376 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3377 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3378 expectf(char_height
, rc
.Height
);
3384 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3385 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3390 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3391 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3392 expectf(rc
.Height
, char_height
);
3394 GdipDeleteMatrix(identity
);
3395 GdipDeleteStringFormat(format
);
3396 GdipDeleteBrush(brush
);
3397 GdipDeleteFont(font
);
3398 GdipDeleteFontFamily(family
);
3399 GdipDeleteGraphics(graphics
);
3401 ReleaseDC(hwnd
, hdc
);
3404 static void test_get_set_interpolation(void)
3406 GpGraphics
*graphics
;
3407 HDC hdc
= GetDC( hwnd
);
3409 InterpolationMode mode
;
3411 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3412 status
= GdipCreateFromHDC(hdc
, &graphics
);
3414 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3416 status
= GdipGetInterpolationMode(NULL
, &mode
);
3417 expect(InvalidParameter
, status
);
3421 /* Crashes on Windows XP */
3422 status
= GdipGetInterpolationMode(graphics
, NULL
);
3423 expect(InvalidParameter
, status
);
3426 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3427 expect(InvalidParameter
, status
);
3430 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3431 expect(InvalidParameter
, status
);
3433 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3434 expect(InvalidParameter
, status
);
3436 status
= GdipGetInterpolationMode(graphics
, &mode
);
3438 expect(InterpolationModeBilinear
, mode
);
3440 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3443 status
= GdipGetInterpolationMode(graphics
, &mode
);
3445 expect(InterpolationModeNearestNeighbor
, mode
);
3447 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3450 status
= GdipGetInterpolationMode(graphics
, &mode
);
3452 expect(InterpolationModeBilinear
, mode
);
3454 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3457 status
= GdipGetInterpolationMode(graphics
, &mode
);
3459 expect(InterpolationModeBilinear
, mode
);
3461 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3464 status
= GdipGetInterpolationMode(graphics
, &mode
);
3466 expect(InterpolationModeHighQualityBicubic
, mode
);
3468 GdipDeleteGraphics(graphics
);
3470 ReleaseDC(hwnd
, hdc
);
3473 static void test_get_set_textrenderinghint(void)
3475 GpGraphics
*graphics
;
3476 HDC hdc
= GetDC( hwnd
);
3478 TextRenderingHint hint
;
3480 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3481 status
= GdipCreateFromHDC(hdc
, &graphics
);
3483 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3485 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3486 expect(InvalidParameter
, status
);
3488 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3489 expect(InvalidParameter
, status
);
3491 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3492 expect(InvalidParameter
, status
);
3495 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3496 expect(InvalidParameter
, status
);
3498 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3500 expect(TextRenderingHintSystemDefault
, hint
);
3502 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3505 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3507 expect(TextRenderingHintSystemDefault
, hint
);
3509 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3512 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3514 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3516 GdipDeleteGraphics(graphics
);
3518 ReleaseDC(hwnd
, hdc
);
3521 static void test_getdc_scaled(void)
3524 GpGraphics
*graphics
= NULL
;
3525 GpBitmap
*bitmap
= NULL
;
3527 HBRUSH hbrush
, holdbrush
;
3530 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3533 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3536 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3539 status
= GdipGetDC(graphics
, &hdc
);
3541 ok(hdc
!= NULL
, "got NULL hdc\n");
3543 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3545 holdbrush
= SelectObject(hdc
, hbrush
);
3547 Rectangle(hdc
, 2, 2, 6, 6);
3549 SelectObject(hdc
, holdbrush
);
3551 DeleteObject(hbrush
);
3553 status
= GdipReleaseDC(graphics
, hdc
);
3556 GdipDeleteGraphics(graphics
);
3558 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3560 expect(0xffff0000, color
);
3562 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3564 expect(0xff000000, color
);
3566 GdipDisposeImage((GpImage
*)bitmap
);
3569 static void test_GdipMeasureString(void)
3571 static const struct test_data
3573 REAL res_x
, res_y
, page_scale
;
3577 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3578 { 200.0, 200.0, 2.0, UnitPixel
},
3579 { 200.0, 200.0, 1.0, UnitDisplay
},
3580 { 200.0, 200.0, 2.0, UnitDisplay
},
3581 { 200.0, 200.0, 1.0, UnitInch
},
3582 { 200.0, 200.0, 2.0, UnitInch
},
3583 { 200.0, 600.0, 1.0, UnitPoint
},
3584 { 200.0, 600.0, 2.0, UnitPoint
},
3585 { 200.0, 600.0, 1.0, UnitDocument
},
3586 { 200.0, 600.0, 2.0, UnitDocument
},
3587 { 200.0, 600.0, 1.0, UnitMillimeter
},
3588 { 200.0, 600.0, 2.0, UnitMillimeter
},
3589 { 200.0, 600.0, 1.0, UnitDisplay
},
3590 { 200.0, 600.0, 2.0, UnitDisplay
},
3591 { 200.0, 600.0, 1.0, UnitPixel
},
3592 { 200.0, 600.0, 2.0, UnitPixel
},
3594 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3595 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3597 GpGraphics
*graphics
;
3598 GpFontFamily
*family
;
3600 GpStringFormat
*format
;
3602 REAL base_cx
= 0, base_cy
= 0, height
;
3607 GpUnit font_unit
, unit
;
3609 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3611 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3614 /* font size in pixels */
3615 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3617 status
= GdipGetFontSize(font
, &font_size
);
3619 expectf(100.0, font_size
);
3620 status
= GdipGetFontUnit(font
, &font_unit
);
3622 expect(UnitPixel
, font_unit
);
3624 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3628 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3630 lf
.lfHeight
= 0xdeadbeef;
3631 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3633 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3634 if (td
[i
].unit
!= UnitDisplay
)
3635 height
*= td
[i
].page_scale
;
3636 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3637 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3639 height
= font_size
+ 2.0 * font_size
/ 6.0;
3641 set_rect_empty(&rc
);
3642 set_rect_empty(&bounds
);
3643 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3648 base_cx
= bounds
.Width
;
3649 base_cy
= bounds
.Height
;
3652 expectf(0.0, bounds
.X
);
3653 expectf(0.0, bounds
.Y
);
3655 expectf_(height
, bounds
.Height
, height
/ 100.0);
3656 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3660 /* make sure it really fits */
3661 bounds
.Width
+= 1.0;
3662 bounds
.Height
+= 1.0;
3666 set_rect_empty(&bounds
);
3667 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3669 expectf(50.0, bounds
.X
);
3670 expectf(50.0, bounds
.Y
);
3672 expectf_(height
, bounds
.Height
, height
/ 100.0);
3673 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3677 status
= GdipDeleteGraphics(graphics
);
3680 status
= GdipDisposeImage(image
);
3684 GdipDeleteFont(font
);
3686 /* font size in logical units */
3687 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3688 for (unit
= 3; unit
<= 6; unit
++)
3690 /* create a font which final height is 100.0 pixels with 200 dpi device */
3691 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3692 height
= pixels_to_units(75.0, unit
, 200.0);
3693 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3695 status
= GdipGetFontSize(font
, &font_size
);
3697 expectf(height
, font_size
);
3698 status
= GdipGetFontUnit(font
, &font_unit
);
3700 expect(unit
, font_unit
);
3702 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3707 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3709 lf
.lfHeight
= 0xdeadbeef;
3710 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3712 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3713 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3715 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3716 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3717 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3718 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3720 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3721 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3723 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3724 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3725 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3726 if (td
[i
].unit
!= UnitDisplay
)
3727 height
/= td
[i
].page_scale
;
3728 /*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);*/
3730 set_rect_empty(&rc
);
3731 set_rect_empty(&bounds
);
3732 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3737 base_cx
= bounds
.Width
;
3738 base_cy
= bounds
.Height
;
3741 expectf(0.0, bounds
.X
);
3742 expectf(0.0, bounds
.Y
);
3744 expectf_(height
, bounds
.Height
, height
/ 85.0);
3745 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3749 /* make sure it really fits */
3750 bounds
.Width
+= 1.0;
3751 bounds
.Height
+= 1.0;
3755 set_rect_empty(&bounds
);
3756 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3758 expectf(50.0, bounds
.X
);
3759 expectf(50.0, bounds
.Y
);
3761 expectf_(height
, bounds
.Height
, height
/ 85.0);
3762 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3766 /* verify the result */
3767 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3768 if (td
[i
].unit
!= UnitDisplay
)
3769 height
*= td
[i
].page_scale
;
3770 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3771 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3773 expectf_(100.0, height
, 1.1);
3775 status
= GdipDeleteGraphics(graphics
);
3778 status
= GdipDisposeImage(image
);
3782 GdipDeleteFont(font
);
3785 /* Font with units = UnitWorld */
3786 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3788 GpPointF pt
= {0.0, 100.0};
3790 REAL expected_width
, expected_height
;
3792 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3794 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3797 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3800 status
= GdipGetFontUnit(font
, &font_unit
);
3802 expect(UnitWorld
, font_unit
);
3804 lf
.lfHeight
= 0xdeadbeef;
3805 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3807 ok(lf
.lfHeight
== -100, "%u: expected -100, got %d\n", i
, lf
.lfHeight
);
3809 set_rect_empty(&rc
);
3810 set_rect_empty(&bounds
);
3811 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3816 base_cx
= bounds
.Width
;
3817 base_cy
= bounds
.Height
;
3823 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3826 /* height is constant in device space, width is proportional to height in world space */
3827 expected_width
= base_cx
* pt
.Y
;
3828 expected_height
= base_cy
* pt
.Y
;
3830 todo_wine_if(td
[i
].unit
!= UnitDisplay
&& td
[i
].unit
!= UnitPixel
)
3831 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3832 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3834 GdipDeleteGraphics(graphics
);
3835 GdipDisposeImage(image
);
3836 GdipDeleteFont(font
);
3839 GdipDeleteFontFamily(family
);
3840 GdipDeleteStringFormat(format
);
3843 static void test_transform(void)
3845 static const struct test_data
3847 REAL res_x
, res_y
, scale
;
3849 GpPointF in
[2], out
[2];
3852 { 96.0, 96.0, 1.0, UnitPixel
,
3853 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3854 { 96.0, 96.0, 1.0, UnitDisplay
,
3855 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3856 { 96.0, 96.0, 1.0, UnitInch
,
3857 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3858 { 123.0, 456.0, 1.0, UnitPoint
,
3859 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3860 { 123.0, 456.0, 1.0, UnitDocument
,
3861 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3862 { 123.0, 456.0, 2.0, UnitMillimeter
,
3863 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3864 { 196.0, 296.0, 1.0, UnitDisplay
,
3865 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3866 { 196.0, 296.0, 1.0, UnitPixel
,
3867 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3870 GpGraphics
*graphics
;
3875 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3877 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3878 ptf
[0].X
= td
[i
].in
[0].X
;
3879 ptf
[0].Y
= td
[i
].in
[0].Y
;
3880 ptf
[1].X
= td
[i
].in
[1].X
;
3881 ptf
[1].Y
= td
[i
].in
[1].Y
;
3882 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3884 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3885 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3886 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3887 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3888 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3890 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3891 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3892 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3893 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3894 status
= GdipDeleteGraphics(graphics
);
3896 status
= GdipDisposeImage(image
);
3901 static void test_pen_thickness(void)
3903 static const struct test_data
3905 REAL res_x
, res_y
, scale
;
3906 GpUnit pen_unit
, page_unit
;
3908 INT cx
, cy
, path_cx
, path_cy
;
3911 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1, 1, 1 },
3912 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.0, 0, 0, 1, 1 },
3913 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.1, 1, 1, 1, 1 },
3914 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2, 2, 2 },
3915 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1, 1, 1 },
3916 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1, 1, 1 },
3917 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 0.0, 1, 1, 1, 1 },
3918 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6, 6, 6 },
3919 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20, 20, 20 },
3923 GpGraphics
*graphics
;
3935 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3937 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
3940 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
3943 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
3946 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
3949 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
3952 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
3955 corner
.X
= corner
.Y
= 100.0;
3956 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
3959 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
3962 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
3965 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
3971 for (j
=0; j
<100; j
++)
3973 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3980 for (j
=99; j
>=0; j
--)
3982 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3991 ok(size
== td
[i
].cx
, "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
3996 for (j
=0; j
<100; j
++)
3998 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4005 for (j
=99; j
>=0; j
--)
4007 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4016 ok(size
== td
[i
].cy
, "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
4018 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4021 status
= GdipGraphicsClear(graphics
, 0xff000000);
4024 status
= GdipCreatePath(FillModeAlternate
, &path
);
4027 status
= GdipAddPathLine(path
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4030 status
= GdipClosePathFigure(path
);
4033 status
= GdipAddPathLine(path
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4036 status
= GdipDrawPath(graphics
, pen
, path
);
4039 GdipDeletePath(path
);
4041 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4047 for (j
=0; j
<100; j
++)
4049 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4056 for (j
=99; j
>=0; j
--)
4058 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4067 ok(size
== td
[i
].path_cx
, "%u: expected %d, got %d\n", i
, td
[i
].path_cx
, size
);
4072 for (j
=0; j
<100; j
++)
4074 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4081 for (j
=99; j
>=0; j
--)
4083 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4092 ok(size
== td
[i
].path_cy
, "%u: expected %d, got %d\n", i
, td
[i
].path_cy
, size
);
4094 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4098 GdipDeleteGraphics(graphics
);
4099 GdipDisposeImage(u
.image
);
4103 /* Many people on the net ask why there is so much difference in rendered
4104 * text height between gdiplus and gdi32, this test suggests an answer to
4105 * that question. Important: this test assumes that font dpi == device dpi.
4107 static void test_font_height_scaling(void)
4109 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4110 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
4112 GpStringFormat
*format
;
4113 CharacterRange range
= { 0, 7 };
4115 GpGraphics
*graphics
;
4116 GpFontFamily
*family
;
4120 REAL height
, dpi
, scale
;
4122 GpUnit gfx_unit
, font_unit
;
4124 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4126 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4128 status
= GdipCreateRegion(®ion
);
4131 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4134 hdc
= CreateCompatibleDC(0);
4135 status
= GdipCreateFromHDC(hdc
, &graphics
);
4138 status
= GdipGetDpiY(graphics
, &dpi
);
4141 /* First check if tested functionality works:
4142 * under XP if font and graphics units differ then GdipTransformPoints
4143 * followed by GdipSetPageUnit to change the graphics units breaks region
4144 * scaling in GdipMeasureCharacterRanges called later.
4146 status
= GdipSetPageUnit(graphics
, UnitDocument
);
4151 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4154 status
= GdipSetPageUnit(graphics
, UnitInch
);
4157 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
4160 set_rect_empty(&rect
);
4161 set_rect_empty(&bounds
);
4162 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4164 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4166 set_rect_empty(&rect
);
4167 rect
.Width
= 32000.0;
4168 rect
.Height
= 32000.0;
4169 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4172 set_rect_empty(&rect
);
4173 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4175 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4177 GdipDeleteFont(font
);
4179 scale
= rect
.Height
/ bounds
.Height
;
4180 if (fabs(scale
- 1.0) > 0.1)
4182 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4186 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4189 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4190 /* UnitPixel as a font base unit is not tested because it drastically
4191 differs in behaviour */
4192 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4194 /* create a font for the final text height of 100 pixels */
4195 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4196 status
= GdipSetPageUnit(graphics
, font_unit
);
4200 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4203 /*trace("height %f units\n", height);*/
4204 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4207 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4208 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4210 static const WCHAR doubleW
[2] = { 'W','W' };
4211 RectF bounds_1
, bounds_2
;
4212 REAL margin
, margin_y
, font_height
;
4215 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4218 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4219 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4221 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4224 set_rect_empty(&rect
);
4225 set_rect_empty(&bounds
);
4226 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4228 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4230 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4233 ptf
.Y
= bounds
.Height
;
4234 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4236 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4238 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4240 /* verify the result */
4241 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4243 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4245 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4247 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4248 set_rect_empty(&rect
);
4249 set_rect_empty(&bounds_1
);
4250 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4252 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4253 set_rect_empty(&rect
);
4254 set_rect_empty(&bounds_2
);
4255 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4258 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4259 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4260 /*trace("margin %f\n", margin);*/
4261 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4263 set_rect_empty(&rect
);
4264 rect
.Width
= 320000.0;
4265 rect
.Height
= 320000.0;
4266 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4268 set_rect_empty(&rect
);
4269 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4271 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4272 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4273 expectf(0.0, rect
.Y
);
4274 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4275 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4276 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4277 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4278 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4279 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4282 GdipDeleteFont(font
);
4286 status
= GdipDeleteGraphics(graphics
);
4290 GdipDeleteFontFamily(family
);
4291 GdipDeleteRegion(region
);
4292 GdipDeleteStringFormat(format
);
4295 static void test_measure_string(void)
4297 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4298 static const WCHAR string
[] = { 'A','0','1',0 };
4300 GpStringFormat
*format
;
4301 CharacterRange range
;
4303 GpGraphics
*graphics
;
4304 GpFontFamily
*family
;
4308 REAL width
, height
, width_1
, width_2
;
4309 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4312 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4316 status
= GdipCreateRegion(®ion
);
4319 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4322 hdc
= CreateCompatibleDC(0);
4323 status
= GdipCreateFromHDC(hdc
, &graphics
);
4325 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4328 margin_x
= 20.0 / 6.0;
4329 margin_y
= 20.0 / 8.0;
4331 set_rect_empty(&rect
);
4332 set_rect_empty(&bounds
);
4333 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4337 expectf(0.0, bounds
.X
);
4338 expectf(0.0, bounds
.Y
);
4339 width
= bounds
.Width
;
4340 height
= bounds
.Height
;
4342 set_rect_empty(&rect
);
4343 rect
.Height
= height
/ 2.0;
4344 set_rect_empty(&bounds
);
4345 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4349 expectf(0.0, bounds
.X
);
4350 expectf(0.0, bounds
.Y
);
4351 expectf(width
, bounds
.Width
);
4353 expectf(height
/ 2.0, bounds
.Height
);
4356 range
.Length
= lstrlenW(string
);
4357 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4362 rect
.Width
= 32000.0;
4363 rect
.Height
= 32000.0;
4364 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4366 set_rect_empty(&bounds
);
4367 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4369 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4370 expectf(5.0, bounds
.Y
);
4371 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4373 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4375 width_rgn
= bounds
.Width
;
4376 height_rgn
= bounds
.Height
;
4380 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4383 set_rect_empty(&rect
);
4384 rect
.Width
= 32000.0;
4385 rect
.Height
= 32000.0;
4386 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4388 set_rect_empty(&bounds
);
4389 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4391 expectf_(margin_x
, bounds
.X
, 1.0);
4392 expectf(0.0, bounds
.Y
);
4393 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4394 expectf(height_rgn
, bounds
.Height
);
4395 width_1
= bounds
.Width
;
4398 range
.Length
= lstrlenW(string
);
4399 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4406 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4408 set_rect_empty(&bounds
);
4409 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4411 expectf(0.0, bounds
.X
);
4412 expectf(0.0, bounds
.Y
);
4413 expectf(0.0, bounds
.Width
);
4414 expectf(0.0, bounds
.Height
);
4418 rect
.Width
= width_rgn
/ 2.0;
4419 rect
.Height
= 32000.0;
4420 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4422 set_rect_empty(&bounds
);
4423 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4425 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4426 expectf(5.0, bounds
.Y
);
4427 expectf_(width_1
, bounds
.Width
, 1.0);
4429 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4431 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4437 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4439 set_rect_empty(&bounds
);
4440 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4442 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4443 expectf(5.0, bounds
.Y
);
4444 expectf(width_rgn
, bounds
.Width
);
4445 expectf(height_rgn
, bounds
.Height
);
4449 rect
.Width
= width_rgn
/ 2.0;
4450 rect
.Height
= 32000.0;
4451 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4453 set_rect_empty(&bounds
);
4454 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4456 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4457 expectf(5.0, bounds
.Y
);
4458 expectf_(width_1
, bounds
.Width
, 1.0);
4459 expectf(height_rgn
, bounds
.Height
);
4461 set_rect_empty(&rect
);
4462 rect
.Height
= height
/ 2.0;
4463 set_rect_empty(&bounds
);
4464 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4468 expectf(0.0, bounds
.X
);
4469 expectf(0.0, bounds
.Y
);
4470 expectf_(width
, bounds
.Width
, 0.01);
4472 expectf(height
, bounds
.Height
);
4474 set_rect_empty(&rect
);
4475 set_rect_empty(&bounds
);
4476 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4480 expectf(0.0, bounds
.X
);
4481 expectf(0.0, bounds
.Y
);
4482 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4483 expectf(height
, bounds
.Height
);
4484 width_1
= bounds
.Width
;
4486 set_rect_empty(&rect
);
4487 set_rect_empty(&bounds
);
4488 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4492 expectf(0.0, bounds
.X
);
4493 expectf(0.0, bounds
.Y
);
4494 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4495 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4496 expectf(height
, bounds
.Height
);
4497 width_2
= bounds
.Width
;
4499 set_rect_empty(&rect
);
4500 rect
.Width
= width
/ 2.0;
4501 set_rect_empty(&bounds
);
4502 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4506 expectf(0.0, bounds
.X
);
4507 expectf(0.0, bounds
.Y
);
4508 expectf_(width_1
, bounds
.Width
, 0.01);
4509 expectf(height
, bounds
.Height
);
4511 set_rect_empty(&rect
);
4512 rect
.Height
= height
;
4513 rect
.Width
= width
- 0.05;
4514 set_rect_empty(&bounds
);
4515 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4519 expectf(0.0, bounds
.X
);
4520 expectf(0.0, bounds
.Y
);
4521 expectf_(width_2
, bounds
.Width
, 0.01);
4522 expectf(height
, bounds
.Height
);
4524 set_rect_empty(&rect
);
4525 rect
.Height
= height
;
4526 rect
.Width
= width_2
- 0.05;
4527 set_rect_empty(&bounds
);
4528 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4532 expectf(0.0, bounds
.X
);
4533 expectf(0.0, bounds
.Y
);
4534 expectf_(width_1
, bounds
.Width
, 0.01);
4535 expectf(height
, bounds
.Height
);
4537 /* Default (Near) alignment */
4540 rect
.Width
= width
* 2.0;
4541 rect
.Height
= height
* 2.0;
4542 set_rect_empty(&bounds
);
4543 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4547 expectf(5.0, bounds
.X
);
4548 expectf(5.0, bounds
.Y
);
4549 expectf_(width
, bounds
.Width
, 0.01);
4550 expectf(height
, bounds
.Height
);
4554 rect
.Width
= 32000.0;
4555 rect
.Height
= 32000.0;
4556 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4558 set_rect_empty(&bounds
);
4559 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4561 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4562 expectf(5.0, bounds
.Y
);
4563 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4565 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4567 width_rgn
= bounds
.Width
;
4568 height_rgn
= bounds
.Height
;
4570 /* Center alignment */
4571 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4572 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4576 rect
.Width
= width
* 2.0;
4577 rect
.Height
= height
* 2.0;
4578 set_rect_empty(&bounds
);
4579 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4584 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4586 expectf(5.0 + height
/2.0, bounds
.Y
);
4587 expectf_(width
, bounds
.Width
, 0.01);
4588 expectf(height
, bounds
.Height
);
4594 set_rect_empty(&bounds
);
4595 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4600 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4602 expectf(5.0 - height
/2.0, bounds
.Y
);
4603 expectf_(width
, bounds
.Width
, 0.01);
4604 expectf(height
, bounds
.Height
);
4608 rect
.Width
= width_rgn
* 2.0;
4609 rect
.Height
= height_rgn
* 2.0;
4610 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4612 set_rect_empty(&bounds
);
4613 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4616 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4618 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4619 expectf_(width_rgn
, bounds
.Width
, 1.0);
4620 expectf_(height_rgn
, bounds
.Height
, 1.0);
4626 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4628 set_rect_empty(&bounds
);
4629 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4632 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4634 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4635 expectf_(width_rgn
, bounds
.Width
, 1.0);
4636 expectf_(height_rgn
, bounds
.Height
, 1.0);
4639 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4640 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4644 rect
.Width
= width
* 2.0;
4645 rect
.Height
= height
* 2.0;
4646 set_rect_empty(&bounds
);
4647 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4652 expectf_(5.0 + width
, bounds
.X
, 0.01);
4654 expectf(5.0 + height
, bounds
.Y
);
4655 expectf_(width
, bounds
.Width
, 0.01);
4656 expectf(height
, bounds
.Height
);
4662 set_rect_empty(&bounds
);
4663 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4668 expectf_(5.0 - width
, bounds
.X
, 0.01);
4670 expectf(5.0 - height
, bounds
.Y
);
4671 expectf_(width
, bounds
.Width
, 0.01);
4672 expectf(height
, bounds
.Height
);
4676 rect
.Width
= width_rgn
* 2.0;
4677 rect
.Height
= height_rgn
* 2.0;
4678 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4680 set_rect_empty(&bounds
);
4681 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4684 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4686 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4687 expectf_(width_rgn
, bounds
.Width
, 1.0);
4688 expectf_(height_rgn
, bounds
.Height
, 1.0);
4694 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4696 set_rect_empty(&bounds
);
4697 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4700 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4702 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4703 expectf_(width_rgn
, bounds
.Width
, 1.0);
4704 expectf_(height_rgn
, bounds
.Height
, 1.0);
4706 status
= GdipDeleteFont(font
);
4709 status
= GdipDeleteGraphics(graphics
);
4713 GdipDeleteFontFamily(family
);
4714 GdipDeleteRegion(region
);
4715 GdipDeleteStringFormat(format
);
4718 static void test_measured_extra_space(void)
4720 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4721 static const WCHAR string
[2] = { 'W','W' };
4722 GpStringFormat
*format
;
4724 GpGraphics
*graphics
;
4725 GpFontFamily
*family
;
4728 GpUnit gfx_unit
, font_unit
;
4729 RectF bounds_1
, bounds_2
, rect
;
4730 REAL margin
, font_size
, dpi
;
4732 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4735 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4737 hdc
= CreateCompatibleDC(0);
4738 status
= GdipCreateFromHDC(hdc
, &graphics
);
4741 status
= GdipGetDpiX(graphics
, &dpi
);
4744 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4745 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4746 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4748 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4751 status
= GdipGetFontSize(font
, &font_size
);
4753 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4754 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4756 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4757 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4759 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4762 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4763 set_rect_empty(&rect
);
4764 set_rect_empty(&bounds_1
);
4765 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4767 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4768 set_rect_empty(&rect
);
4769 set_rect_empty(&bounds_2
);
4770 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4773 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4774 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4775 /*trace("margin %f pixels\n", margin);*/
4776 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4779 GdipDeleteFont(font
);
4782 GdipDeleteGraphics(graphics
);
4784 GdipDeleteFontFamily(family
);
4785 GdipDeleteStringFormat(format
);
4788 static void test_alpha_hdc(void)
4792 HBITMAP hbm
, old_hbm
;
4793 GpGraphics
*graphics
;
4799 hdc
= CreateCompatibleDC(0);
4800 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4801 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4802 bmi
.bmiHeader
.biHeight
= 5;
4803 bmi
.bmiHeader
.biWidth
= 5;
4804 bmi
.bmiHeader
.biBitCount
= 32;
4805 bmi
.bmiHeader
.biPlanes
= 1;
4806 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4807 bmi
.bmiHeader
.biClrUsed
= 0;
4809 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4810 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4812 old_hbm
= SelectObject(hdc
, hbm
);
4814 status
= GdipCreateFromHDC(hdc
, &graphics
);
4817 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4819 expectf(0.0, bounds
.X
);
4820 expectf(0.0, bounds
.Y
);
4821 expectf(5.0, bounds
.Width
);
4822 expectf(5.0, bounds
.Height
);
4824 bits
[0] = 0xdeadbeef;
4826 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4829 expect(0xffaaaaaa, bits
[0]);
4831 bits
[0] = 0xdeadbeef;
4833 status
= GdipGetDC(graphics
, &gp_hdc
);
4836 colorref
= GetPixel(gp_hdc
, 0, 4);
4837 expect(0xefbead, colorref
);
4839 SetPixel(gp_hdc
, 0, 4, 0xffffff);
4841 expect(0xffffff, bits
[0]);
4843 status
= GdipReleaseDC(graphics
, gp_hdc
);
4846 SelectObject(hdc
, old_hbm
);
4848 bits
[0] = 0xdeadbeef;
4850 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4853 todo_wine
expect(0xffbbbbbb, bits
[0]);
4855 GdipDeleteGraphics(graphics
);
4861 static void test_bitmapfromgraphics(void)
4864 GpGraphics
*graphics
= NULL
;
4865 HDC hdc
= GetDC( hwnd
);
4866 GpBitmap
*bitmap
= NULL
;
4868 REAL imageres
, graphicsres
;
4871 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4874 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4875 expect(InvalidParameter
, stat
);
4877 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4878 expect(InvalidParameter
, stat
);
4880 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4883 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4885 expect(PixelFormat32bppPARGB
, format
);
4887 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4890 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4892 expectf(graphicsres
, imageres
);
4894 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4897 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4899 expectf(graphicsres
, imageres
);
4901 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4905 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4909 GdipDeleteGraphics(graphics
);
4910 GdipDisposeImage((GpImage
*)bitmap
);
4913 static void test_clipping(void)
4917 GpGraphics
*graphics
;
4918 GpRegion
*region
, *region100x100
;
4927 hdc
= CreateCompatibleDC(0);
4928 status
= GdipCreateFromHDC(hdc
, &graphics
);
4931 status
= GdipGetPageUnit(graphics
, &unit
);
4933 expect(UnitDisplay
, unit
);
4935 status
= GdipCreateRegion(®ion
);
4937 status
= GdipSetEmpty(region
);
4940 status
= GdipCreateRegion(®ion100x100
);
4942 status
= GdipSetEmpty(region100x100
);
4945 rect
.X
= rect
.Y
= 100.0;
4946 rect
.Width
= rect
.Height
= 100.0;
4947 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4949 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4952 status
= GdipGetClipBounds(graphics
, &rect
);
4954 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4955 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4957 status
= GdipSetEmpty(region
);
4959 status
= GdipGetClip(graphics
, region
);
4961 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4963 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4964 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4970 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4972 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4973 "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
);
4975 status
= GdipCreateMatrix(&matrix
);
4977 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4979 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4981 status
= GdipSetWorldTransform(graphics
, matrix
);
4984 status
= GdipGetClipBounds(graphics
, &rect
);
4986 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4987 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4989 status
= GdipSetEmpty(region
);
4991 status
= GdipGetClip(graphics
, region
);
4993 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4995 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4996 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4998 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5000 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5001 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5003 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5005 ret
= GetRgnBox(hrgn
, &rc
);
5006 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5007 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5008 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5011 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5013 ret
= GetRgnBox(hrgn
, &rc
);
5014 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5015 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5016 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5023 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5025 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5026 "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
);
5028 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5030 ret
= GetRgnBox(hrgn
, &rc
);
5031 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5032 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5033 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5036 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5038 ret
= GetRgnBox(hrgn
, &rc
);
5039 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5040 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5041 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5048 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5050 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5051 "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
);
5053 status
= GdipSetPageScale(graphics
, 2.0);
5056 status
= GdipGetClipBounds(graphics
, &rect
);
5058 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5059 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5061 status
= GdipSetEmpty(region
);
5063 status
= GdipGetClip(graphics
, region
);
5065 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5067 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5068 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5070 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5072 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5073 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5075 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5077 ret
= GetRgnBox(hrgn
, &rc
);
5078 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5079 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5080 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5083 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5085 ret
= GetRgnBox(hrgn
, &rc
);
5086 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5087 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5088 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5095 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5097 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5098 "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
);
5100 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5102 ret
= GetRgnBox(hrgn
, &rc
);
5103 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5104 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5105 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5108 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5110 ret
= GetRgnBox(hrgn
, &rc
);
5111 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5112 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5113 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5120 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5122 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5123 "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
);
5125 GdipSetPageUnit(graphics
, UnitPoint
);
5128 status
= GdipGetClipBounds(graphics
, &rect
);
5130 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5131 /* rounding under Wine is slightly different */
5132 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5133 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5134 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5136 status
= GdipSetEmpty(region
);
5138 status
= GdipGetClip(graphics
, region
);
5140 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5142 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5143 /* rounding under Wine is slightly different */
5144 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5145 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5146 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5148 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5150 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5151 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5153 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5155 ret
= GetRgnBox(hrgn
, &rc
);
5156 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5157 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
5158 /* rounding under Wine is slightly different */
5159 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
5160 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
5161 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc
));
5164 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5166 ret
= GetRgnBox(hrgn
, &rc
);
5167 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5168 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5169 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5170 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5177 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5179 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5180 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5181 "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
);
5183 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5185 ret
= GetRgnBox(hrgn
, &rc
);
5186 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5187 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5188 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5191 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5193 ret
= GetRgnBox(hrgn
, &rc
);
5194 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5195 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5196 /* rounding under Wine is slightly different */
5197 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5198 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc
));
5205 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5207 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5209 expectf(100.0, ptf
[0].X
);
5210 expectf(100.0, ptf
[0].Y
);
5211 expectf(200.125, ptf
[1].X
);
5212 expectf(200.03125, ptf
[1].Y
);
5214 else /* before Win7 */
5216 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5217 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5218 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5219 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5222 status
= GdipTransformRegion(region100x100
, matrix
);
5225 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5227 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5228 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5230 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5232 ret
= GetRgnBox(hrgn
, &rc
);
5233 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5234 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5235 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5238 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5240 ret
= GetRgnBox(hrgn
, &rc
);
5241 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5242 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5243 /* rounding under Wine is slightly different */
5244 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5245 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc
));
5252 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5254 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5256 expectf(210.0625, ptf
[0].X
);
5257 expectf(420.0625, ptf
[0].Y
);
5258 expectf(410.125, ptf
[1].X
);
5259 expectf(820.0, ptf
[1].Y
);
5261 else /* before Win7 */
5263 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5264 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5265 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5266 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5269 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5271 status
= GdipSetWorldTransform(graphics
, matrix
);
5274 status
= GdipGetClipBounds(graphics
, &rect
);
5276 expectf_(20.612978, rect
.X
, 1.0);
5277 expectf_(-6.256012, rect
.Y
, 1.5);
5278 expectf_(25.612978, rect
.Width
, 1.0);
5279 expectf_(12.806489, rect
.Height
, 1.0);
5281 status
= GdipSetEmpty(region
);
5283 status
= GdipGetClip(graphics
, region
);
5285 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5287 /* rounding under Wine is slightly different */
5288 expectf_(20.612978, rect
.X
, 1.0);
5289 expectf_(-6.256012, rect
.Y
, 1.5);
5290 expectf_(25.612978, rect
.Width
, 1.0);
5291 expectf_(12.806489, rect
.Height
, 1.0);
5293 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5295 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5296 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5298 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5300 ret
= GetRgnBox(hrgn
, &rc
);
5301 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5302 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5303 /* rounding under Wine is slightly different */
5304 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5305 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc
));
5308 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5310 ret
= GetRgnBox(hrgn
, &rc
);
5311 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5312 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5313 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5324 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5326 expectf(20.612978, ptf
[0].X
);
5327 expectf(-1.568512, ptf
[0].Y
);
5328 expectf(46.225956, ptf
[1].X
);
5329 expectf(1.862977, ptf
[1].Y
);
5330 expectf(36.850956, ptf
[2].X
);
5331 expectf(-6.256012, ptf
[2].Y
);
5332 expectf(29.987980, ptf
[3].X
);
5333 expectf(6.550478, ptf
[3].Y
);
5335 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5337 ret
= GetRgnBox(hrgn
, &rc
);
5338 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5339 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5340 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5343 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5345 ret
= GetRgnBox(hrgn
, &rc
);
5346 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5347 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5348 /* rounding under Wine is slightly different */
5349 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5350 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc
));
5361 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5363 expectf(-136.190491, ptf
[0].X
);
5364 expectf(520.010742, ptf
[0].Y
);
5365 expectf(756.417175, ptf
[1].X
);
5366 expectf(720.031616, ptf
[1].Y
);
5367 expectf(360.042114, ptf
[2].X
);
5368 expectf(376.760742, ptf
[2].Y
);
5369 expectf(260.184570, ptf
[3].X
);
5370 expectf(863.281616, ptf
[3].Y
);
5372 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5374 status
= GdipSetWorldTransform(graphics
, matrix
);
5377 status
= GdipGetClipBounds(graphics
, &rect
);
5379 expectf_(-28.100956, rect
.X
, 1.0);
5380 expectf_(7.806488, rect
.Y
, 1.5);
5381 expectf_(25.612978, rect
.Width
, 1.0);
5382 expectf_(12.806489, rect
.Height
, 1.0);
5384 status
= GdipSetEmpty(region
);
5386 status
= GdipGetClip(graphics
, region
);
5388 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5390 /* rounding under Wine is slightly different */
5391 expectf_(-28.100956, rect
.X
, 1.0);
5392 expectf_(7.806488, rect
.Y
, 1.5);
5393 expectf_(25.612978, rect
.Width
, 1.0);
5394 expectf_(12.806489, rect
.Height
, 1.0);
5396 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5398 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5399 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5401 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5403 ret
= GetRgnBox(hrgn
, &rc
);
5404 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5405 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5406 /* rounding under Wine is slightly different */
5407 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5408 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc
));
5411 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5413 ret
= GetRgnBox(hrgn
, &rc
);
5414 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5415 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5416 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5427 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5429 expectf(-11.862979, ptf
[0].X
);
5430 expectf(7.806488, ptf
[0].Y
);
5431 expectf(-18.725958, ptf
[1].X
);
5432 expectf(20.612976, ptf
[1].Y
);
5433 expectf(-2.487981, ptf
[2].X
);
5434 expectf(15.925477, ptf
[2].Y
);
5435 expectf(-28.100956, ptf
[3].X
);
5436 expectf(12.493987, ptf
[3].Y
);
5438 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5440 ret
= GetRgnBox(hrgn
, &rc
);
5441 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5442 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5443 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5446 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5448 ret
= GetRgnBox(hrgn
, &rc
);
5449 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5450 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5451 /* rounding under Wine is slightly different */
5452 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5453 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc
));
5464 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5466 expectf(-1055.021484, ptf
[0].X
);
5467 expectf(-70.595329, ptf
[0].Y
);
5468 expectf(-1455.063232, ptf
[1].X
);
5469 expectf(375.708435, ptf
[1].Y
);
5470 expectf(-768.521484, ptf
[2].X
);
5471 expectf(177.520981, ptf
[2].Y
);
5472 expectf(-1741.563110, ptf
[3].X
);
5473 expectf(127.592125, ptf
[3].Y
);
5475 GdipDeleteMatrix(matrix
);
5476 GdipDeleteRegion(region
);
5477 GdipDeleteRegion(region100x100
);
5478 GdipDeleteGraphics(graphics
);
5482 static void test_clipping_2(void)
5487 GpGraphics
*graphics
;
5497 hdc
= CreateCompatibleDC(0);
5498 status
= GdipCreateFromHDC(hdc
, &graphics
);
5501 status
= GdipGetPageUnit(graphics
, &unit
);
5503 expect(UnitDisplay
, unit
);
5505 GdipSetPageUnit(graphics
, UnitInch
);
5507 status
= GdipCreateRegion(®ion
);
5509 status
= GdipSetEmpty(region
);
5511 rect
.X
= rect
.Y
= 100.0;
5512 rect
.Width
= rect
.Height
= 100.0;
5513 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5515 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5518 status
= GdipGetClip(graphics
, region
);
5520 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5522 ret
= GetRgnBox(hrgn
, &rc
);
5523 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5524 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5525 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5527 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5529 ret
= GetRgnBox(hrgn
, &rc
);
5530 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5531 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5532 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5539 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5541 expectf(100.0, ptf
[0].X
);
5542 expectf(100.0, ptf
[0].Y
);
5543 expectf(200.0, ptf
[1].X
);
5544 expectf(200.0, ptf
[1].X
);
5546 GdipSetPageUnit(graphics
, UnitPoint
);
5548 status
= GdipGetClip(graphics
, region
);
5550 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5552 ret
= GetRgnBox(hrgn
, &rc
);
5553 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5554 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5555 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5556 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc
));
5558 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5560 ret
= GetRgnBox(hrgn
, &rc
);
5561 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5562 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5563 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5564 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5571 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5573 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5574 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5575 "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
);
5576 else /* before Win7 */
5578 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5579 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5580 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5581 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5584 GdipDeleteRegion(region
);
5586 GdipSetPageUnit(graphics
, UnitPixel
);
5588 status
= GdipCreateRegion(®ion
);
5590 status
= GdipSetEmpty(region
);
5592 rect
.X
= rect
.Y
= 100.0;
5593 rect
.Width
= rect
.Height
= 100.0;
5594 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5596 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5599 status
= GdipGetClip(graphics
, region
);
5601 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5603 ret
= GetRgnBox(hrgn
, &rc
);
5604 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5605 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5606 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5607 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5609 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5611 ret
= GetRgnBox(hrgn
, &rc
);
5612 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5613 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5614 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5615 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5622 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5624 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5625 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5626 "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
);
5627 else /* before Win7 */
5629 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5630 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5631 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5632 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5635 GdipSetPageUnit(graphics
, UnitPoint
);
5637 status
= GdipGetClip(graphics
, region
);
5639 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5641 ret
= GetRgnBox(hrgn
, &rc
);
5642 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5643 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5644 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5645 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc
));
5647 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5649 ret
= GetRgnBox(hrgn
, &rc
);
5650 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5651 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5652 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5653 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5660 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5662 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5663 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5664 "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
);
5665 else /* before Win7 */
5667 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5668 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5669 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5670 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5673 status
= GdipCreateMatrix(&matrix
);
5675 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5677 status
= GdipSetWorldTransform(graphics
, matrix
);
5679 GdipDeleteMatrix(matrix
);
5681 status
= GdipGetClip(graphics
, region
);
5683 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5685 ret
= GetRgnBox(hrgn
, &rc
);
5686 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5687 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5688 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc
));
5690 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5692 ret
= GetRgnBox(hrgn
, &rc
);
5693 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5694 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5695 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5702 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5704 expectf(65.0, ptf
[0].X
);
5705 expectf(65.0, ptf
[0].Y
);
5706 expectf(140.0, ptf
[1].X
);
5707 expectf(140.0, ptf
[1].X
);
5709 status
= GdipCreateMatrix(&matrix
);
5711 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5713 status
= GdipSetWorldTransform(graphics
, matrix
);
5715 GdipDeleteMatrix(matrix
);
5717 status
= GdipGetClip(graphics
, region
);
5719 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5721 ret
= GetRgnBox(hrgn
, &rc
);
5722 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5723 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5724 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc
));
5726 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5728 ret
= GetRgnBox(hrgn
, &rc
);
5729 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5730 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5731 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5738 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5740 expectf(300.0, ptf
[0].X
);
5741 expectf(150.0, ptf
[0].Y
);
5742 expectf(600.0, ptf
[1].X
);
5743 expectf(300.0, ptf
[1].Y
);
5745 status
= GdipSetPageScale(graphics
, 2.0);
5748 status
= GdipGetClip(graphics
, region
);
5750 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5752 ret
= GetRgnBox(hrgn
, &rc
);
5753 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5754 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5755 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5756 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc
));
5758 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5760 ret
= GetRgnBox(hrgn
, &rc
);
5761 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5762 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5763 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5764 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5771 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5773 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5775 expectf(150.0, ptf
[0].X
);
5776 expectf(75.0, ptf
[0].Y
);
5777 expectf(300.0, ptf
[1].X
);
5778 expectf(150.0, ptf
[1].Y
);
5780 else /* before Win7 */
5782 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5783 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5784 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5785 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5788 status
= GdipCreateMatrix(&matrix
);
5790 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5792 status
= GdipSetWorldTransform(graphics
, matrix
);
5794 GdipDeleteMatrix(matrix
);
5796 status
= GdipGetClip(graphics
, region
);
5798 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5800 ret
= GetRgnBox(hrgn
, &rc
);
5801 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5802 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5803 /* rounding under Wine is slightly different */
5804 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5805 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc
));
5807 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5809 ret
= GetRgnBox(hrgn
, &rc
);
5810 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5811 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5812 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5823 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5825 expectf(53.033016, ptf
[0].X
);
5826 expectf(0.0, ptf
[0].Y
);
5827 expectf(106.066032, ptf
[1].X
);
5828 expectf(0.0, ptf
[1].Y
);
5829 expectf(79.549522, ptf
[2].X
);
5830 expectf(-26.516510, ptf
[2].Y
);
5831 expectf(79.549522, ptf
[3].X
);
5832 expectf(26.516508, ptf
[3].Y
);
5834 status
= GdipCreateMatrix(&matrix
);
5836 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5838 status
= GdipSetWorldTransform(graphics
, matrix
);
5840 GdipDeleteMatrix(matrix
);
5842 status
= GdipGetClip(graphics
, region
);
5844 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5846 ret
= GetRgnBox(hrgn
, &rc
);
5847 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5848 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5849 /* rounding under Wine is slightly different */
5850 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5851 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc
));
5853 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5855 ret
= GetRgnBox(hrgn
, &rc
);
5856 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5857 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5858 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5869 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5871 expectf(0.0, ptf
[0].X
);
5872 expectf(53.033005, ptf
[0].Y
);
5873 expectf(0.0, ptf
[1].X
);
5874 expectf(106.066010, ptf
[1].Y
);
5875 expectf(26.516491, ptf
[2].X
);
5876 expectf(79.549507, ptf
[2].Y
);
5877 expectf(-26.516520, ptf
[3].X
);
5878 expectf(79.549500, ptf
[3].Y
);
5880 GdipDeleteRegion(region
);
5881 GdipDeleteGraphics(graphics
);
5886 static void test_GdipFillRectangles(void)
5889 GpGraphics
*graphics
= NULL
;
5890 GpBrush
*brush
= NULL
;
5891 HDC hdc
= GetDC( hwnd
);
5892 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5894 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5896 status
= GdipCreateFromHDC(hdc
, &graphics
);
5898 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5900 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5902 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5904 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5905 expect(InvalidParameter
, status
);
5907 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5908 expect(InvalidParameter
, status
);
5910 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5911 expect(InvalidParameter
, status
);
5913 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5914 expect(InvalidParameter
, status
);
5916 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5917 expect(InvalidParameter
, status
);
5919 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5922 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5925 GdipDeleteBrush(brush
);
5926 GdipDeleteGraphics(graphics
);
5928 ReleaseDC(hwnd
, hdc
);
5931 static void test_GdipGetVisibleClipBounds_memoryDC(void)
5940 GpGraphics
* graphics
= NULL
;
5944 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
5945 width
= rect
.right
- rect
.left
;
5946 height
= rect
.bottom
- rect
.top
;
5949 hdc
= CreateCompatibleDC ( dc
);
5950 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
5951 old
= SelectObject (hdc
, bmp
);
5953 /*change the window origin is the key test point*/
5954 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
5956 status
= GdipCreateFromHDC(hdc
, &graphics
);
5959 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5962 ok(boundRect
.X
==rect
.left
+10 &&
5963 boundRect
.Y
==rect
.top
+10 &&
5964 boundRect
.Width
==width
&&
5965 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
5967 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
5970 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5973 ok(boundRect
.X
==rect
.left
+10 &&
5974 boundRect
.Y
==rect
.top
+10 &&
5975 boundRect
.Width
==width
-10 &&
5976 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
5978 GdipDeleteGraphics(graphics
);
5980 SelectObject (hdc
, old
);
5983 ReleaseDC(hwnd
, dc
);
5986 static void test_container_rects(void)
5989 GpGraphics
*graphics
;
5990 HDC hdc
= GetDC( hwnd
);
5991 GpRectF dstrect
, srcrect
;
5992 GraphicsContainer state
;
5993 static const GpPointF test_points
[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
5997 status
= GdipCreateFromHDC(hdc
, &graphics
);
6002 dstrect
.Width
= 1.0;
6003 dstrect
.Height
= 1.0;
6006 status
= GdipGetDpiX(graphics
, &dpix
);
6009 status
= GdipGetDpiY(graphics
, &dpiy
);
6012 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitWorld
, &state
);
6013 expect(InvalidParameter
, status
);
6015 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitDisplay
, &state
);
6016 expect(InvalidParameter
, status
);
6018 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitMillimeter
+1, &state
);
6019 expect(InvalidParameter
, status
);
6021 status
= GdipBeginContainer(NULL
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6022 expect(InvalidParameter
, status
);
6024 status
= GdipBeginContainer(graphics
, NULL
, &srcrect
, UnitPixel
, &state
);
6025 expect(InvalidParameter
, status
);
6027 status
= GdipBeginContainer(graphics
, &dstrect
, NULL
, UnitPixel
, &state
);
6028 expect(InvalidParameter
, status
);
6030 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, -1, &state
);
6031 expect(InvalidParameter
, status
);
6033 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, NULL
);
6034 expect(InvalidParameter
, status
);
6036 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6039 memcpy(points
, test_points
, sizeof(points
));
6040 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6042 expectf(0.0, points
[0].X
);
6043 expectf(0.0, points
[0].Y
);
6044 expectf(1.0, points
[1].X
);
6045 expectf(0.0, points
[1].Y
);
6046 expectf(0.0, points
[2].X
);
6047 expectf(1.0, points
[2].Y
);
6049 status
= GdipEndContainer(graphics
, state
);
6052 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6055 memcpy(points
, test_points
, sizeof(points
));
6056 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6058 expectf(0.0, points
[0].X
);
6059 expectf(0.0, points
[0].Y
);
6060 expectf(1.0/dpix
, points
[1].X
);
6061 expectf(0.0, points
[1].Y
);
6062 expectf(0.0, points
[2].X
);
6063 expectf(1.0/dpiy
, points
[2].Y
);
6065 status
= GdipEndContainer(graphics
, state
);
6068 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
6072 dstrect
.Height
= 3.0;
6073 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6076 memcpy(points
, test_points
, sizeof(points
));
6077 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6079 expectf(2.0, points
[0].X
);
6080 expectf(0.0, points
[0].Y
);
6081 expectf(4.0, points
[1].X
);
6082 expectf(0.0, points
[1].Y
);
6083 expectf(2.0, points
[2].X
);
6084 expectf(6.0, points
[2].Y
);
6086 status
= GdipEndContainer(graphics
, state
);
6089 memcpy(points
, test_points
, sizeof(points
));
6090 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6092 expectf(0.0, points
[0].X
);
6093 expectf(0.0, points
[0].Y
);
6094 expectf(2.0, points
[1].X
);
6095 expectf(0.0, points
[1].Y
);
6096 expectf(0.0, points
[2].X
);
6097 expectf(2.0, points
[2].Y
);
6099 status
= GdipResetWorldTransform(graphics
);
6102 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6105 memcpy(points
, test_points
, sizeof(points
));
6106 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6108 expectf(1.0, points
[0].X
);
6109 expectf(0.0, points
[0].Y
);
6110 expectf((dpix
+1.0)/dpix
, points
[1].X
);
6111 expectf(0.0, points
[1].Y
);
6112 expectf(1.0, points
[2].X
);
6113 expectf(3.0/dpiy
, points
[2].Y
);
6115 status
= GdipEndContainer(graphics
, state
);
6118 status
= GdipSetPageUnit(graphics
, UnitInch
);
6121 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6124 memcpy(points
, test_points
, sizeof(points
));
6125 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6127 expectf(dpix
, points
[0].X
);
6128 expectf(0.0, points
[0].Y
);
6129 expectf(dpix
*2, points
[1].X
);
6130 expectf(0.0, points
[1].Y
);
6131 expectf(dpix
, points
[2].X
);
6132 expectf(dpiy
*3, points
[2].Y
);
6134 status
= GdipEndContainer(graphics
, state
);
6137 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6140 memcpy(points
, test_points
, sizeof(points
));
6141 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6143 expectf(dpix
, points
[0].X
);
6144 expectf(0.0, points
[0].Y
);
6145 expectf(dpix
+1.0, points
[1].X
);
6146 expectf(0.0, points
[1].Y
);
6147 expectf(dpix
, points
[2].X
);
6148 expectf(3.0, points
[2].Y
);
6150 status
= GdipEndContainer(graphics
, state
);
6153 GdipDeleteGraphics(graphics
);
6155 ReleaseDC(hwnd
, hdc
);
6158 START_TEST(graphics
)
6160 struct GdiplusStartupInput gdiplusStartupInput
;
6161 ULONG_PTR gdiplusToken
;
6164 memset( &class, 0, sizeof(class) );
6165 class.lpszClassName
= "gdiplus_test";
6166 class.style
= CS_HREDRAW
| CS_VREDRAW
;
6167 class.lpfnWndProc
= DefWindowProcA
;
6168 class.hInstance
= GetModuleHandleA(0);
6169 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
6170 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6171 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
6172 RegisterClassA( &class );
6173 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6174 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
6175 ok(hwnd
!= NULL
, "Expected window to be created\n");
6177 gdiplusStartupInput
.GdiplusVersion
= 1;
6178 gdiplusStartupInput
.DebugEventCallback
= NULL
;
6179 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
6180 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
6182 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
6186 test_measured_extra_space();
6187 test_measure_string();
6188 test_font_height_scaling();
6190 test_pen_thickness();
6191 test_GdipMeasureString();
6192 test_constructor_destructor();
6193 test_save_restore();
6194 test_GdipFillClosedCurve2();
6195 test_GdipFillClosedCurve2I();
6196 test_GdipDrawBezierI();
6198 test_GdipDrawArcI();
6199 test_GdipDrawCurve();
6200 test_GdipDrawCurveI();
6201 test_GdipDrawCurve2();
6202 test_GdipDrawCurve2I();
6203 test_GdipDrawCurve3();
6204 test_GdipDrawCurve3I();
6205 test_GdipDrawLineI();
6206 test_GdipDrawLinesI();
6207 test_GdipDrawImagePointsRect();
6208 test_GdipFillClosedCurve();
6209 test_GdipFillClosedCurveI();
6210 test_GdipDrawString();
6211 test_GdipGetNearestColor();
6212 test_GdipGetVisibleClipBounds();
6213 test_GdipIsVisiblePoint();
6214 test_GdipIsVisibleRect();
6215 test_Get_Release_DC();
6216 test_BeginContainer2();
6217 test_transformpoints();
6218 test_get_set_clip();
6221 test_textcontrast();
6222 test_fromMemoryBitmap();
6223 test_string_functions();
6224 test_get_set_interpolation();
6225 test_get_set_textrenderinghint();
6226 test_getdc_scaled();
6228 test_bitmapfromgraphics();
6229 test_GdipFillRectangles();
6230 test_GdipGetVisibleClipBounds_memoryDC();
6231 test_container_rects();
6233 GdiplusShutdown(gdiplusToken
);
6234 DestroyWindow( hwnd
);