2 * Unit test suite for graphics objects
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
29 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
30 #define expectf(expected, got) expectf_((expected), (got), 0.001)
32 static const REAL mm_per_inch
= 25.4;
33 static const REAL point_per_inch
= 72.0;
36 static void set_rect_empty(RectF
*rc
)
44 /* converts a given unit to its value in pixels */
45 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
53 return units
* dpi
/ point_per_inch
;
57 return units
* dpi
/ 300.0; /* Per MSDN */
59 return units
* dpi
/ mm_per_inch
;
61 ok(0, "Unsupported unit: %d\n", unit
);
66 /* converts value in pixels to a given unit */
67 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
75 return pixels
* point_per_inch
/ dpi
;
79 return pixels
* 300.0 / dpi
;
81 return pixels
* mm_per_inch
/ dpi
;
83 ok(0, "Unsupported unit: %d\n", unit
);
88 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
90 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
91 return pixels_to_units(pixels
, to
, dpi
);
94 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
102 GpGraphics
*graphics
= NULL
;
105 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
108 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
110 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
113 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
117 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
122 status
= GdipGetDpiX(graphics
, &res
);
125 status
= GdipGetDpiY(graphics
, &res
);
129 status
= GdipSetPageUnit(graphics
, unit
);
131 status
= GdipSetPageScale(graphics
, scale
);
137 static void test_constructor_destructor(void)
140 GpGraphics
*graphics
= NULL
;
141 HDC hdc
= GetDC( hwnd
);
143 stat
= GdipCreateFromHDC(NULL
, &graphics
);
144 expect(OutOfMemory
, stat
);
145 stat
= GdipDeleteGraphics(graphics
);
146 expect(InvalidParameter
, stat
);
148 stat
= GdipCreateFromHDC(hdc
, &graphics
);
150 stat
= GdipDeleteGraphics(graphics
);
153 stat
= GdipCreateFromHWND(NULL
, &graphics
);
155 stat
= GdipDeleteGraphics(graphics
);
158 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
160 stat
= GdipDeleteGraphics(graphics
);
163 stat
= GdipDeleteGraphics(NULL
);
164 expect(InvalidParameter
, stat
);
165 ReleaseDC(hwnd
, hdc
);
173 /* Linked list prepend function. */
174 static void log_state(GraphicsState data
, node
** log
)
176 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
178 new_entry
->data
= data
;
179 new_entry
->next
= *log
;
183 /* Checks if there are duplicates in the list, and frees it. */
184 static void check_no_duplicates(node
* log
)
196 while((temp
= temp
->next
)){
197 if(log
->data
== temp
->data
){
204 }while((log
= log
->next
));
209 HeapFree(GetProcessHeap(), 0, temp
);
217 static void test_save_restore(void)
220 GraphicsState state_a
, state_b
, state_c
;
221 InterpolationMode mode
;
222 GpGraphics
*graphics1
, *graphics2
;
223 node
* state_log
= NULL
;
224 HDC hdc
= GetDC( hwnd
);
225 state_a
= state_b
= state_c
= 0xdeadbeef;
227 /* Invalid saving. */
228 GdipCreateFromHDC(hdc
, &graphics1
);
229 stat
= GdipSaveGraphics(graphics1
, NULL
);
230 expect(InvalidParameter
, stat
);
231 stat
= GdipSaveGraphics(NULL
, &state_a
);
232 expect(InvalidParameter
, stat
);
233 GdipDeleteGraphics(graphics1
);
235 log_state(state_a
, &state_log
);
237 /* Basic save/restore. */
238 GdipCreateFromHDC(hdc
, &graphics1
);
239 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
240 stat
= GdipSaveGraphics(graphics1
, &state_a
);
242 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
243 stat
= GdipRestoreGraphics(graphics1
, state_a
);
245 GdipGetInterpolationMode(graphics1
, &mode
);
246 expect(InterpolationModeBilinear
, mode
);
247 GdipDeleteGraphics(graphics1
);
249 log_state(state_a
, &state_log
);
251 /* Restoring garbage doesn't affect saves. */
252 GdipCreateFromHDC(hdc
, &graphics1
);
253 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
254 GdipSaveGraphics(graphics1
, &state_a
);
255 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
256 GdipSaveGraphics(graphics1
, &state_b
);
257 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
258 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
260 GdipRestoreGraphics(graphics1
, state_b
);
261 GdipGetInterpolationMode(graphics1
, &mode
);
262 expect(InterpolationModeBicubic
, mode
);
263 GdipRestoreGraphics(graphics1
, state_a
);
264 GdipGetInterpolationMode(graphics1
, &mode
);
265 expect(InterpolationModeBilinear
, mode
);
266 GdipDeleteGraphics(graphics1
);
268 log_state(state_a
, &state_log
);
269 log_state(state_b
, &state_log
);
271 /* Restoring older state invalidates newer saves (but not older saves). */
272 GdipCreateFromHDC(hdc
, &graphics1
);
273 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
274 GdipSaveGraphics(graphics1
, &state_a
);
275 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
276 GdipSaveGraphics(graphics1
, &state_b
);
277 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
278 GdipSaveGraphics(graphics1
, &state_c
);
279 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
280 GdipRestoreGraphics(graphics1
, state_b
);
281 GdipGetInterpolationMode(graphics1
, &mode
);
282 expect(InterpolationModeBicubic
, mode
);
283 GdipRestoreGraphics(graphics1
, state_c
);
284 GdipGetInterpolationMode(graphics1
, &mode
);
285 expect(InterpolationModeBicubic
, mode
);
286 GdipRestoreGraphics(graphics1
, state_a
);
287 GdipGetInterpolationMode(graphics1
, &mode
);
288 expect(InterpolationModeBilinear
, mode
);
289 GdipDeleteGraphics(graphics1
);
291 log_state(state_a
, &state_log
);
292 log_state(state_b
, &state_log
);
293 log_state(state_c
, &state_log
);
295 /* Restoring older save from one graphics object does not invalidate
296 * newer save from other graphics object. */
297 GdipCreateFromHDC(hdc
, &graphics1
);
298 GdipCreateFromHDC(hdc
, &graphics2
);
299 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
300 GdipSaveGraphics(graphics1
, &state_a
);
301 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
302 GdipSaveGraphics(graphics2
, &state_b
);
303 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
304 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
305 GdipRestoreGraphics(graphics1
, state_a
);
306 GdipGetInterpolationMode(graphics1
, &mode
);
307 expect(InterpolationModeBilinear
, mode
);
308 GdipRestoreGraphics(graphics2
, state_b
);
309 GdipGetInterpolationMode(graphics2
, &mode
);
310 expect(InterpolationModeBicubic
, mode
);
311 GdipDeleteGraphics(graphics1
);
312 GdipDeleteGraphics(graphics2
);
314 /* You can't restore a state to a graphics object that didn't save it. */
315 GdipCreateFromHDC(hdc
, &graphics1
);
316 GdipCreateFromHDC(hdc
, &graphics2
);
317 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
318 GdipSaveGraphics(graphics1
, &state_a
);
319 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
320 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
321 GdipRestoreGraphics(graphics2
, state_a
);
322 GdipGetInterpolationMode(graphics2
, &mode
);
323 expect(InterpolationModeNearestNeighbor
, mode
);
324 GdipDeleteGraphics(graphics1
);
325 GdipDeleteGraphics(graphics2
);
327 log_state(state_a
, &state_log
);
329 /* A state created by SaveGraphics cannot be restored with EndContainer. */
330 GdipCreateFromHDC(hdc
, &graphics1
);
331 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
332 stat
= GdipSaveGraphics(graphics1
, &state_a
);
334 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
335 stat
= GdipEndContainer(graphics1
, state_a
);
337 GdipGetInterpolationMode(graphics1
, &mode
);
338 todo_wine
expect(InterpolationModeBicubic
, mode
);
339 stat
= GdipRestoreGraphics(graphics1
, state_a
);
341 GdipGetInterpolationMode(graphics1
, &mode
);
342 expect(InterpolationModeBilinear
, mode
);
343 GdipDeleteGraphics(graphics1
);
345 log_state(state_a
, &state_log
);
347 /* A state created by BeginContainer cannot be restored with RestoreGraphics. */
348 GdipCreateFromHDC(hdc
, &graphics1
);
349 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
350 stat
= GdipBeginContainer2(graphics1
, &state_a
);
352 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
353 stat
= GdipRestoreGraphics(graphics1
, state_a
);
355 GdipGetInterpolationMode(graphics1
, &mode
);
356 todo_wine
expect(InterpolationModeBicubic
, mode
);
357 stat
= GdipEndContainer(graphics1
, state_a
);
359 GdipGetInterpolationMode(graphics1
, &mode
);
360 expect(InterpolationModeBilinear
, mode
);
361 GdipDeleteGraphics(graphics1
);
363 log_state(state_a
, &state_log
);
365 /* BeginContainer and SaveGraphics use the same stack. */
366 GdipCreateFromHDC(hdc
, &graphics1
);
367 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
368 stat
= GdipBeginContainer2(graphics1
, &state_a
);
370 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
371 stat
= GdipSaveGraphics(graphics1
, &state_b
);
373 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
374 stat
= GdipEndContainer(graphics1
, state_a
);
376 GdipGetInterpolationMode(graphics1
, &mode
);
377 expect(InterpolationModeBilinear
, mode
);
378 stat
= GdipRestoreGraphics(graphics1
, state_b
);
380 GdipGetInterpolationMode(graphics1
, &mode
);
381 expect(InterpolationModeBilinear
, mode
);
382 GdipDeleteGraphics(graphics1
);
384 log_state(state_a
, &state_log
);
385 log_state(state_b
, &state_log
);
387 /* The same state value should never be returned twice. */
389 check_no_duplicates(state_log
);
391 ReleaseDC(hwnd
, hdc
);
394 static void test_GdipFillClosedCurve2(void)
397 GpGraphics
*graphics
= NULL
;
398 GpSolidFill
*brush
= NULL
;
399 HDC hdc
= GetDC( hwnd
);
411 /* make a graphics object and brush object */
412 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
414 status
= GdipCreateFromHDC(hdc
, &graphics
);
416 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
418 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
420 /* InvalidParameter cases: null graphics, null brush, null points */
421 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
422 expect(InvalidParameter
, status
);
424 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
425 expect(InvalidParameter
, status
);
427 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
428 expect(InvalidParameter
, status
);
430 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
431 expect(InvalidParameter
, status
);
433 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
434 expect(InvalidParameter
, status
);
436 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
437 expect(InvalidParameter
, status
);
439 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
440 expect(InvalidParameter
, status
);
442 /* InvalidParameter cases: invalid count */
443 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
444 expect(InvalidParameter
, status
);
446 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
447 expect(InvalidParameter
, status
);
449 /* Valid test cases */
450 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
453 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
456 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
459 GdipDeleteGraphics(graphics
);
460 GdipDeleteBrush((GpBrush
*)brush
);
462 ReleaseDC(hwnd
, hdc
);
465 static void test_GdipFillClosedCurve2I(void)
468 GpGraphics
*graphics
= NULL
;
469 GpSolidFill
*brush
= NULL
;
470 HDC hdc
= GetDC( hwnd
);
482 /* make a graphics object and brush object */
483 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
485 status
= GdipCreateFromHDC(hdc
, &graphics
);
487 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
489 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
491 /* InvalidParameter cases: null graphics, null brush */
492 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
493 when points == NULL, so don't test this condition */
494 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
495 expect(InvalidParameter
, status
);
497 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
498 expect(InvalidParameter
, status
);
500 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
501 expect(InvalidParameter
, status
);
503 /* InvalidParameter cases: invalid count */
504 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
505 expect(InvalidParameter
, status
);
507 /* OutOfMemory cases: large (unsigned) int */
508 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
509 expect(OutOfMemory
, status
);
511 /* Valid test cases */
512 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
515 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
518 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
521 GdipDeleteGraphics(graphics
);
522 GdipDeleteBrush((GpBrush
*)brush
);
524 ReleaseDC(hwnd
, hdc
);
527 static void test_GdipDrawArc(void)
530 GpGraphics
*graphics
= NULL
;
532 HDC hdc
= GetDC( hwnd
);
534 /* make a graphics object and pen object */
535 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
537 status
= GdipCreateFromHDC(hdc
, &graphics
);
539 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
541 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
543 ok(pen
!= NULL
, "Expected pen to be initialized\n");
545 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
546 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
547 expect(InvalidParameter
, status
);
549 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
550 expect(InvalidParameter
, status
);
552 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
553 expect(InvalidParameter
, status
);
555 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
556 expect(InvalidParameter
, status
);
558 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
559 expect(InvalidParameter
, status
);
561 /* successful case */
562 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
566 GdipDeleteGraphics(graphics
);
568 ReleaseDC(hwnd
, hdc
);
571 static void test_GdipDrawArcI(void)
574 GpGraphics
*graphics
= NULL
;
576 HDC hdc
= GetDC( hwnd
);
578 /* make a graphics object and pen object */
579 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
581 status
= GdipCreateFromHDC(hdc
, &graphics
);
583 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
585 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
587 ok(pen
!= NULL
, "Expected pen to be initialized\n");
589 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
590 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
591 expect(InvalidParameter
, status
);
593 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
594 expect(InvalidParameter
, status
);
596 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
597 expect(InvalidParameter
, status
);
599 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
600 expect(InvalidParameter
, status
);
602 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
603 expect(InvalidParameter
, status
);
605 /* successful case */
606 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
610 GdipDeleteGraphics(graphics
);
612 ReleaseDC(hwnd
, hdc
);
615 static void test_BeginContainer2(void)
619 REAL defClip
[] = {5, 10, 15, 20};
620 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
621 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
622 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
623 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
624 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
625 REAL scale
, defScale
= 17;
626 GpUnit unit
, defUnit
= UnitPixel
;
627 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
628 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
629 UINT contrast
, defContrast
= 5;
630 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
633 GpGraphics
*graphics
= NULL
;
634 HDC hdc
= GetDC( hwnd
);
636 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
638 status
= GdipCreateFromHDC(hdc
, &graphics
);
640 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
642 /* null graphics, null container */
643 status
= GdipBeginContainer2(NULL
, &cont1
);
644 expect(InvalidParameter
, status
);
646 status
= GdipBeginContainer2(graphics
, NULL
);
647 expect(InvalidParameter
, status
);
649 status
= GdipEndContainer(NULL
, cont1
);
650 expect(InvalidParameter
, status
);
652 /* test all quality-related values */
653 GdipSetCompositingMode(graphics
, defCompmode
);
654 GdipSetCompositingQuality(graphics
, defCompqual
);
655 GdipSetInterpolationMode(graphics
, defInterp
);
656 GdipSetPageScale(graphics
, defScale
);
657 GdipSetPageUnit(graphics
, defUnit
);
658 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
659 GdipSetSmoothingMode(graphics
, defSmoothmode
);
660 GdipSetTextContrast(graphics
, defContrast
);
661 GdipSetTextRenderingHint(graphics
, defTexthint
);
663 status
= GdipBeginContainer2(graphics
, &cont1
);
666 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
667 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
668 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
669 GdipSetPageScale(graphics
, 10);
670 GdipSetPageUnit(graphics
, UnitDocument
);
671 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
672 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
673 GdipSetTextContrast(graphics
, 7);
674 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
676 status
= GdipEndContainer(graphics
, cont1
);
679 GdipGetCompositingMode(graphics
, &compmode
);
680 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
682 GdipGetCompositingQuality(graphics
, &compqual
);
683 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
685 GdipGetInterpolationMode(graphics
, &interp
);
686 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
688 GdipGetPageScale(graphics
, &scale
);
689 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
691 GdipGetPageUnit(graphics
, &unit
);
692 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
694 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
695 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
697 GdipGetSmoothingMode(graphics
, &smoothmode
);
698 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
700 GdipGetTextContrast(graphics
, &contrast
);
701 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
703 GdipGetTextRenderingHint(graphics
, &texthint
);
704 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
706 /* test world transform */
707 status
= GdipBeginContainer2(graphics
, &cont1
);
710 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
711 defTrans
[4], defTrans
[5], &transform
);
713 GdipSetWorldTransform(graphics
, transform
);
714 GdipDeleteMatrix(transform
);
717 status
= GdipBeginContainer2(graphics
, &cont2
);
720 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
722 GdipSetWorldTransform(graphics
, transform
);
723 GdipDeleteMatrix(transform
);
726 status
= GdipEndContainer(graphics
, cont2
);
729 status
= GdipCreateMatrix(&transform
);
731 GdipGetWorldTransform(graphics
, transform
);
732 GdipGetMatrixElements(transform
, elems
);
733 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
734 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
735 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
736 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
737 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
738 fabs(defTrans
[5] - elems
[5]) < 0.0001,
739 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
740 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
741 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
742 GdipDeleteMatrix(transform
);
745 status
= GdipEndContainer(graphics
, cont1
);
749 status
= GdipBeginContainer2(graphics
, &cont1
);
752 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
754 status
= GdipBeginContainer2(graphics
, &cont2
);
757 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
759 status
= GdipEndContainer(graphics
, cont2
);
762 status
= GdipGetClipBounds(graphics
, &clip
);
765 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
766 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
767 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
768 fabs(defClip
[3] - clip
.Height
) < 0.0001,
769 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
770 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
771 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
773 status
= GdipEndContainer(graphics
, cont1
);
777 status
= GdipBeginContainer2(graphics
, &cont1
);
780 status
= GdipBeginContainer2(graphics
, &cont2
);
783 status
= GdipBeginContainer2(graphics
, &cont3
);
786 status
= GdipEndContainer(graphics
, cont3
);
789 status
= GdipBeginContainer2(graphics
, &cont4
);
792 status
= GdipEndContainer(graphics
, cont4
);
796 status
= GdipEndContainer(graphics
, cont1
);
799 /* end an already-ended container */
800 status
= GdipEndContainer(graphics
, cont1
);
803 GdipDeleteGraphics(graphics
);
804 ReleaseDC(hwnd
, hdc
);
807 static void test_GdipDrawBezierI(void)
810 GpGraphics
*graphics
= NULL
;
812 HDC hdc
= GetDC( hwnd
);
814 /* make a graphics object and pen object */
815 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
817 status
= GdipCreateFromHDC(hdc
, &graphics
);
819 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
821 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
823 ok(pen
!= NULL
, "Expected pen to be initialized\n");
825 /* InvalidParameter cases: null graphics, null pen */
826 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
827 expect(InvalidParameter
, status
);
829 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
830 expect(InvalidParameter
, status
);
832 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
833 expect(InvalidParameter
, status
);
835 /* successful case */
836 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
840 GdipDeleteGraphics(graphics
);
842 ReleaseDC(hwnd
, hdc
);
845 static void test_GdipDrawCurve3(void)
848 GpGraphics
*graphics
= NULL
;
850 HDC hdc
= GetDC( hwnd
);
862 /* make a graphics object and pen object */
863 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
865 status
= GdipCreateFromHDC(hdc
, &graphics
);
867 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
869 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
871 ok(pen
!= NULL
, "Expected pen to be initialized\n");
873 /* InvalidParameter cases: null graphics, null pen */
874 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
875 expect(InvalidParameter
, status
);
877 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
878 expect(InvalidParameter
, status
);
880 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
881 expect(InvalidParameter
, status
);
883 /* InvalidParameter cases: invalid count */
884 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
885 expect(InvalidParameter
, status
);
887 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
888 expect(InvalidParameter
, status
);
890 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
891 expect(InvalidParameter
, status
);
893 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
894 expect(InvalidParameter
, status
);
896 /* InvalidParameter cases: invalid number of segments */
897 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
898 expect(InvalidParameter
, status
);
900 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
901 expect(InvalidParameter
, status
);
903 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
904 expect(InvalidParameter
, status
);
906 /* Valid test cases */
907 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
910 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
913 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
916 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
920 GdipDeleteGraphics(graphics
);
922 ReleaseDC(hwnd
, hdc
);
925 static void test_GdipDrawCurve3I(void)
928 GpGraphics
*graphics
= NULL
;
930 HDC hdc
= GetDC( hwnd
);
942 /* make a graphics object and pen object */
943 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
945 status
= GdipCreateFromHDC(hdc
, &graphics
);
947 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
949 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
951 ok(pen
!= NULL
, "Expected pen to be initialized\n");
953 /* InvalidParameter cases: null graphics, null pen */
954 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
955 expect(InvalidParameter
, status
);
957 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
958 expect(InvalidParameter
, status
);
960 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
961 expect(InvalidParameter
, status
);
963 /* InvalidParameter cases: invalid count */
964 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
965 expect(OutOfMemory
, status
);
967 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
968 expect(InvalidParameter
, status
);
970 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
971 expect(InvalidParameter
, status
);
973 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
974 expect(InvalidParameter
, status
);
976 /* InvalidParameter cases: invalid number of segments */
977 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
978 expect(InvalidParameter
, status
);
980 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
981 expect(InvalidParameter
, status
);
983 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
984 expect(InvalidParameter
, status
);
986 /* Valid test cases */
987 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
990 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
993 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
996 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
1000 GdipDeleteGraphics(graphics
);
1002 ReleaseDC(hwnd
, hdc
);
1005 static void test_GdipDrawCurve2(void)
1008 GpGraphics
*graphics
= NULL
;
1010 HDC hdc
= GetDC( hwnd
);
1022 /* make a graphics object and pen object */
1023 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1025 status
= GdipCreateFromHDC(hdc
, &graphics
);
1027 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1029 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1031 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1033 /* InvalidParameter cases: null graphics, null pen */
1034 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
1035 expect(InvalidParameter
, status
);
1037 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
1038 expect(InvalidParameter
, status
);
1040 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
1041 expect(InvalidParameter
, status
);
1043 /* InvalidParameter cases: invalid count */
1044 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
1045 expect(InvalidParameter
, status
);
1047 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
1048 expect(InvalidParameter
, status
);
1050 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
1051 expect(InvalidParameter
, status
);
1053 /* Valid test cases */
1054 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1057 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1060 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1063 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1067 GdipDeleteGraphics(graphics
);
1069 ReleaseDC(hwnd
, hdc
);
1072 static void test_GdipDrawCurve2I(void)
1075 GpGraphics
*graphics
= NULL
;
1077 HDC hdc
= GetDC( hwnd
);
1089 /* make a graphics object and pen object */
1090 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1092 status
= GdipCreateFromHDC(hdc
, &graphics
);
1094 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1096 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1098 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1100 /* InvalidParameter cases: null graphics, null pen */
1101 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1102 expect(InvalidParameter
, status
);
1104 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1105 expect(InvalidParameter
, status
);
1107 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1108 expect(InvalidParameter
, status
);
1110 /* InvalidParameter cases: invalid count */
1111 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1112 expect(OutOfMemory
, status
);
1114 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1115 expect(InvalidParameter
, status
);
1117 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1118 expect(InvalidParameter
, status
);
1120 /* Valid test cases */
1121 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1124 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1127 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1130 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1134 GdipDeleteGraphics(graphics
);
1136 ReleaseDC(hwnd
, hdc
);
1139 static void test_GdipDrawCurve(void)
1142 GpGraphics
*graphics
= NULL
;
1144 HDC hdc
= GetDC( hwnd
);
1156 /* make a graphics object and pen object */
1157 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1159 status
= GdipCreateFromHDC(hdc
, &graphics
);
1161 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1163 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1165 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1167 /* InvalidParameter cases: null graphics, null pen */
1168 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1169 expect(InvalidParameter
, status
);
1171 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1172 expect(InvalidParameter
, status
);
1174 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1175 expect(InvalidParameter
, status
);
1177 /* InvalidParameter cases: invalid count */
1178 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1179 expect(InvalidParameter
, status
);
1181 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1182 expect(InvalidParameter
, status
);
1184 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1185 expect(InvalidParameter
, status
);
1187 /* Valid test cases */
1188 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1191 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1195 GdipDeleteGraphics(graphics
);
1197 ReleaseDC(hwnd
, hdc
);
1200 static void test_GdipDrawCurveI(void)
1203 GpGraphics
*graphics
= NULL
;
1205 HDC hdc
= GetDC( hwnd
);
1217 /* make a graphics object and pen object */
1218 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1220 status
= GdipCreateFromHDC(hdc
, &graphics
);
1222 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1224 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1226 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1228 /* InvalidParameter cases: null graphics, null pen */
1229 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1230 expect(InvalidParameter
, status
);
1232 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1233 expect(InvalidParameter
, status
);
1235 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1236 expect(InvalidParameter
, status
);
1238 /* InvalidParameter cases: invalid count */
1239 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1240 expect(OutOfMemory
, status
);
1242 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1243 expect(InvalidParameter
, status
);
1245 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1246 expect(InvalidParameter
, status
);
1248 /* Valid test cases */
1249 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1252 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1256 GdipDeleteGraphics(graphics
);
1258 ReleaseDC(hwnd
, hdc
);
1261 static void test_GdipDrawLineI(void)
1264 GpGraphics
*graphics
= NULL
;
1266 HDC hdc
= GetDC( hwnd
);
1268 /* make a graphics object and pen object */
1269 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1271 status
= GdipCreateFromHDC(hdc
, &graphics
);
1273 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1275 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1277 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1279 /* InvalidParameter cases: null graphics, null pen */
1280 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1281 expect(InvalidParameter
, status
);
1283 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1284 expect(InvalidParameter
, status
);
1286 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1287 expect(InvalidParameter
, status
);
1289 /* successful case */
1290 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1294 GdipDeleteGraphics(graphics
);
1296 ReleaseDC(hwnd
, hdc
);
1299 static void test_GdipDrawImagePointsRect(void)
1302 GpGraphics
*graphics
= NULL
;
1304 GpBitmap
*bm
= NULL
;
1305 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1307 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1308 HDC hdc
= GetDC( hwnd
);
1312 memset(rbmi
, 0, sizeof(rbmi
));
1313 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1314 bmi
->bmiHeader
.biWidth
= 10;
1315 bmi
->bmiHeader
.biHeight
= 10;
1316 bmi
->bmiHeader
.biPlanes
= 1;
1317 bmi
->bmiHeader
.biBitCount
= 32;
1318 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1319 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1321 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1322 status
= GdipCreateFromHDC(hdc
, &graphics
);
1332 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1333 expect(NotImplemented
, status
);
1334 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1335 expect(InvalidParameter
, status
);
1336 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1338 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1339 expect(InvalidParameter
, status
);
1340 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1341 expect(InvalidParameter
, status
);
1342 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1344 memset(ptf
, 0, sizeof(ptf
));
1345 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1348 GdipDisposeImage((GpImage
*)bm
);
1349 GdipDeleteGraphics(graphics
);
1350 ReleaseDC(hwnd
, hdc
);
1353 static void test_GdipDrawLinesI(void)
1356 GpGraphics
*graphics
= NULL
;
1358 GpPoint
*ptf
= NULL
;
1359 HDC hdc
= GetDC( hwnd
);
1361 /* make a graphics object and pen object */
1362 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1364 status
= GdipCreateFromHDC(hdc
, &graphics
);
1366 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1368 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1370 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1372 /* make some arbitrary valid points*/
1373 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1381 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1382 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1383 expect(InvalidParameter
, status
);
1385 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1386 expect(InvalidParameter
, status
);
1388 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1389 expect(InvalidParameter
, status
);
1391 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1392 expect(InvalidParameter
, status
);
1394 /* successful case */
1395 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1400 GdipDeleteGraphics(graphics
);
1402 ReleaseDC(hwnd
, hdc
);
1405 static void test_GdipFillClosedCurve(void)
1408 GpGraphics
*graphics
= NULL
;
1409 GpSolidFill
*brush
= NULL
;
1410 HDC hdc
= GetDC( hwnd
);
1422 /* make a graphics object and brush object */
1423 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1425 status
= GdipCreateFromHDC(hdc
, &graphics
);
1427 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1429 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1431 /* InvalidParameter cases: null graphics, null brush, null points */
1432 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1433 expect(InvalidParameter
, status
);
1435 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1436 expect(InvalidParameter
, status
);
1438 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1439 expect(InvalidParameter
, status
);
1441 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1442 expect(InvalidParameter
, status
);
1444 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1445 expect(InvalidParameter
, status
);
1447 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1448 expect(InvalidParameter
, status
);
1450 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1451 expect(InvalidParameter
, status
);
1453 /* InvalidParameter cases: invalid count */
1454 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1455 expect(InvalidParameter
, status
);
1457 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1458 expect(InvalidParameter
, status
);
1460 /* Valid test cases */
1461 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1464 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1467 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1470 GdipDeleteGraphics(graphics
);
1471 GdipDeleteBrush((GpBrush
*)brush
);
1473 ReleaseDC(hwnd
, hdc
);
1476 static void test_GdipFillClosedCurveI(void)
1479 GpGraphics
*graphics
= NULL
;
1480 GpSolidFill
*brush
= NULL
;
1481 HDC hdc
= GetDC( hwnd
);
1493 /* make a graphics object and brush object */
1494 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1496 status
= GdipCreateFromHDC(hdc
, &graphics
);
1498 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1500 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1502 /* InvalidParameter cases: null graphics, null brush */
1503 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1504 when points == NULL, so don't test this condition */
1505 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1506 expect(InvalidParameter
, status
);
1508 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1509 expect(InvalidParameter
, status
);
1511 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1512 expect(InvalidParameter
, status
);
1514 /* InvalidParameter cases: invalid count */
1515 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1516 expect(InvalidParameter
, status
);
1518 /* OutOfMemory cases: large (unsigned) int */
1519 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1520 expect(OutOfMemory
, status
);
1522 /* Valid test cases */
1523 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1526 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1529 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1532 GdipDeleteGraphics(graphics
);
1533 GdipDeleteBrush((GpBrush
*)brush
);
1535 ReleaseDC(hwnd
, hdc
);
1538 static void test_Get_Release_DC(void)
1541 GpGraphics
*graphics
= NULL
;
1545 HDC hdc
= GetDC( hwnd
);
1548 CompositingQuality quality
;
1549 CompositingMode compmode
;
1550 InterpolationMode intmode
;
1554 PixelOffsetMode offsetmode
;
1555 SmoothingMode smoothmode
;
1556 TextRenderingHint texthint
;
1564 ARGB color
= 0x00000000;
1565 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1578 for(i
= 0; i
< 5;i
++){
1579 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1580 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1586 rect
[0].Height
= 70;
1590 rect
[1].Height
= 20;
1592 for(i
= 0; i
< 2;i
++){
1593 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1594 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1595 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1596 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1599 status
= GdipCreateMatrix(&m
);
1601 GdipCreateRegion(®ion
);
1602 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1603 GdipCreatePath(FillModeAlternate
, &path
);
1604 GdipCreateRegion(&clip
);
1606 status
= GdipCreateFromHDC(hdc
, &graphics
);
1608 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1609 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1612 /* NULL arguments */
1613 status
= GdipGetDC(NULL
, NULL
);
1614 expect(InvalidParameter
, status
);
1615 status
= GdipGetDC(graphics
, NULL
);
1616 expect(InvalidParameter
, status
);
1617 status
= GdipGetDC(NULL
, &retdc
);
1618 expect(InvalidParameter
, status
);
1620 status
= GdipReleaseDC(NULL
, NULL
);
1621 expect(InvalidParameter
, status
);
1622 status
= GdipReleaseDC(graphics
, NULL
);
1623 expect(InvalidParameter
, status
);
1624 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1625 expect(InvalidParameter
, status
);
1627 /* Release without Get */
1628 status
= GdipReleaseDC(graphics
, hdc
);
1629 expect(InvalidParameter
, status
);
1632 status
= GdipGetDC(graphics
, &retdc
);
1634 ok(retdc
== hdc
, "Invalid HDC returned\n");
1635 /* call it once more */
1636 status
= GdipGetDC(graphics
, &retdc
);
1637 expect(ObjectBusy
, status
);
1639 /* try all Graphics calls here */
1640 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1641 expect(ObjectBusy
, status
);
1642 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1643 expect(ObjectBusy
, status
);
1644 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1645 expect(ObjectBusy
, status
);
1646 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1647 expect(ObjectBusy
, status
);
1648 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1649 expect(ObjectBusy
, status
);
1650 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1651 expect(ObjectBusy
, status
);
1652 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1653 expect(ObjectBusy
, status
);
1654 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1655 expect(ObjectBusy
, status
);
1656 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1657 expect(ObjectBusy
, status
);
1658 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1659 expect(ObjectBusy
, status
);
1660 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1661 expect(ObjectBusy
, status
);
1662 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1663 expect(ObjectBusy
, status
);
1664 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1665 expect(ObjectBusy
, status
);
1666 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1667 expect(ObjectBusy
, status
);
1668 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1669 expect(ObjectBusy
, status
);
1670 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1671 expect(ObjectBusy
, status
);
1672 /* GdipDrawImage/GdipDrawImageI */
1673 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1674 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1675 /* GdipDrawImageRect/GdipDrawImageRectI */
1676 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1677 expect(ObjectBusy
, status
);
1678 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1679 expect(ObjectBusy
, status
);
1680 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1681 expect(ObjectBusy
, status
);
1682 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1683 expect(ObjectBusy
, status
);
1684 status
= GdipDrawPath(graphics
, pen
, path
);
1685 expect(ObjectBusy
, status
);
1686 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1687 expect(ObjectBusy
, status
);
1688 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1689 expect(ObjectBusy
, status
);
1690 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1691 expect(ObjectBusy
, status
);
1692 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1693 expect(ObjectBusy
, status
);
1694 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1695 expect(ObjectBusy
, status
);
1696 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1697 expect(ObjectBusy
, status
);
1698 /* GdipDrawString */
1699 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1700 expect(ObjectBusy
, status
);
1701 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1702 expect(ObjectBusy
, status
);
1703 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1704 expect(ObjectBusy
, status
);
1705 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1706 expect(ObjectBusy
, status
);
1707 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1708 expect(ObjectBusy
, status
);
1709 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1710 expect(ObjectBusy
, status
);
1711 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1712 expect(ObjectBusy
, status
);
1713 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1714 expect(ObjectBusy
, status
);
1715 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1716 expect(ObjectBusy
, status
);
1717 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1718 expect(ObjectBusy
, status
);
1719 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1720 expect(ObjectBusy
, status
);
1721 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1722 expect(ObjectBusy
, status
);
1723 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1724 expect(ObjectBusy
, status
);
1725 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1726 expect(ObjectBusy
, status
);
1727 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1728 expect(ObjectBusy
, status
);
1729 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1730 expect(ObjectBusy
, status
);
1731 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1732 expect(ObjectBusy
, status
);
1733 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1734 expect(ObjectBusy
, status
);
1735 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1736 expect(ObjectBusy
, status
);
1737 status
= GdipGetClipBounds(graphics
, rectf
);
1738 expect(ObjectBusy
, status
);
1739 status
= GdipGetClipBoundsI(graphics
, rect
);
1740 expect(ObjectBusy
, status
);
1741 status
= GdipGetCompositingMode(graphics
, &compmode
);
1742 expect(ObjectBusy
, status
);
1743 status
= GdipGetCompositingQuality(graphics
, &quality
);
1744 expect(ObjectBusy
, status
);
1745 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1746 expect(ObjectBusy
, status
);
1747 status
= GdipGetNearestColor(graphics
, &color
);
1748 expect(ObjectBusy
, status
);
1749 status
= GdipGetPageScale(graphics
, &r
);
1750 expect(ObjectBusy
, status
);
1751 status
= GdipGetPageUnit(graphics
, &unit
);
1752 expect(ObjectBusy
, status
);
1753 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1754 expect(ObjectBusy
, status
);
1755 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1756 expect(ObjectBusy
, status
);
1757 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1758 expect(ObjectBusy
, status
);
1759 status
= GdipGetWorldTransform(graphics
, m
);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1764 expect(ObjectBusy
, status
);
1765 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1766 expect(ObjectBusy
, status
);
1767 /* GdipMeasureCharacterRanges */
1768 /* GdipMeasureString */
1769 status
= GdipResetClip(graphics
);
1770 expect(ObjectBusy
, status
);
1771 status
= GdipResetWorldTransform(graphics
);
1772 expect(ObjectBusy
, status
);
1773 /* GdipRestoreGraphics */
1774 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1775 expect(ObjectBusy
, status
);
1776 /* GdipSaveGraphics */
1777 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1778 expect(ObjectBusy
, status
);
1779 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1780 expect(ObjectBusy
, status
);
1781 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1782 expect(ObjectBusy
, status
);
1783 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1784 expect(ObjectBusy
, status
);
1785 status
= GdipSetPageScale(graphics
, 1.0);
1786 expect(ObjectBusy
, status
);
1787 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1788 expect(ObjectBusy
, status
);
1789 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1790 expect(ObjectBusy
, status
);
1791 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1792 expect(ObjectBusy
, status
);
1793 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1794 expect(ObjectBusy
, status
);
1795 status
= GdipSetWorldTransform(graphics
, m
);
1796 expect(ObjectBusy
, status
);
1797 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1798 expect(ObjectBusy
, status
);
1799 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1800 expect(ObjectBusy
, status
);
1801 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1802 expect(ObjectBusy
, status
);
1803 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1804 expect(ObjectBusy
, status
);
1805 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1806 expect(ObjectBusy
, status
);
1807 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1808 expect(ObjectBusy
, status
);
1809 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1810 expect(ObjectBusy
, status
);
1811 status
= GdipTranslateClipI(graphics
, 0, 0);
1812 expect(ObjectBusy
, status
);
1813 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1814 expect(ObjectBusy
, status
);
1815 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1816 expect(ObjectBusy
, status
);
1817 status
= GdipGetDpiX(graphics
, &r
);
1818 expect(ObjectBusy
, status
);
1819 status
= GdipGetDpiY(graphics
, &r
);
1820 expect(ObjectBusy
, status
);
1821 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1822 expect(ObjectBusy
, status
);
1823 status
= GdipGetClip(graphics
, region
);
1824 expect(ObjectBusy
, status
);
1825 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1826 expect(ObjectBusy
, status
);
1828 /* try to delete before release */
1829 status
= GdipDeleteGraphics(graphics
);
1830 expect(ObjectBusy
, status
);
1832 status
= GdipReleaseDC(graphics
, retdc
);
1836 GdipDeleteGraphics(graphics
);
1838 GdipDeleteRegion(clip
);
1839 GdipDeletePath(path
);
1840 GdipDeleteBrush((GpBrush
*)brush
);
1841 GdipDeleteRegion(region
);
1842 GdipDeleteMatrix(m
);
1845 ReleaseDC(hwnd
, hdc
);
1848 static void test_transformpoints(void)
1851 GpGraphics
*graphics
= NULL
;
1852 HDC hdc
= GetDC( hwnd
);
1856 status
= GdipCreateFromHDC(hdc
, &graphics
);
1859 /* NULL arguments */
1860 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1861 expect(InvalidParameter
, status
);
1862 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1863 expect(InvalidParameter
, status
);
1864 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1865 expect(InvalidParameter
, status
);
1866 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1867 expect(InvalidParameter
, status
);
1873 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1875 expectf(1.0, ptf
[0].X
);
1876 expectf(0.0, ptf
[0].Y
);
1877 expectf(0.0, ptf
[1].X
);
1878 expectf(1.0, ptf
[1].Y
);
1880 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1882 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1884 status
= GdipSetPageScale(graphics
, 3.0);
1891 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1893 expectf(18.0, ptf
[0].X
);
1894 expectf(15.0, ptf
[0].Y
);
1895 expectf(15.0, ptf
[1].X
);
1896 expectf(18.0, ptf
[1].Y
);
1902 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1904 expectf(6.0, ptf
[0].X
);
1905 expectf(5.0, ptf
[0].Y
);
1906 expectf(5.0, ptf
[1].X
);
1907 expectf(6.0, ptf
[1].Y
);
1913 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1915 expectf(3.0, ptf
[0].X
);
1916 expectf(0.0, ptf
[0].Y
);
1917 expectf(0.0, ptf
[1].X
);
1918 expectf(3.0, ptf
[1].Y
);
1924 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1926 expectf(1.0, ptf
[0].X
);
1927 expectf(0.0, ptf
[0].Y
);
1928 expectf(0.0, ptf
[1].X
);
1929 expectf(1.0, ptf
[1].Y
);
1935 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1937 expectf(1.0, ptf
[0].X
);
1938 expectf(0.0, ptf
[0].Y
);
1939 expectf(0.0, ptf
[1].X
);
1940 expectf(1.0, ptf
[1].Y
);
1946 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1948 expectf(1.0, ptf
[0].X
);
1949 expectf(0.0, ptf
[0].Y
);
1950 expectf(0.0, ptf
[1].X
);
1951 expectf(1.0, ptf
[1].Y
);
1957 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1959 expect(18, pt
[0].X
);
1960 expect(15, pt
[0].Y
);
1961 expect(15, pt
[1].X
);
1962 expect(18, pt
[1].Y
);
1964 GdipDeleteGraphics(graphics
);
1965 ReleaseDC(hwnd
, hdc
);
1968 static void test_get_set_clip(void)
1971 GpGraphics
*graphics
= NULL
;
1972 HDC hdc
= GetDC( hwnd
);
1977 status
= GdipCreateFromHDC(hdc
, &graphics
);
1980 rect
.X
= rect
.Y
= 0.0;
1981 rect
.Height
= rect
.Width
= 100.0;
1983 status
= GdipCreateRegionRect(&rect
, &clip
);
1986 /* NULL arguments */
1987 status
= GdipGetClip(NULL
, NULL
);
1988 expect(InvalidParameter
, status
);
1989 status
= GdipGetClip(graphics
, NULL
);
1990 expect(InvalidParameter
, status
);
1991 status
= GdipGetClip(NULL
, clip
);
1992 expect(InvalidParameter
, status
);
1994 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1995 expect(InvalidParameter
, status
);
1996 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1997 expect(InvalidParameter
, status
);
1999 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
2000 expect(InvalidParameter
, status
);
2001 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
2002 expect(InvalidParameter
, status
);
2005 status
= GdipGetClip(graphics
, clip
);
2007 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2011 /* remains infinite after reset */
2013 status
= GdipResetClip(graphics
);
2015 status
= GdipGetClip(graphics
, clip
);
2017 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2021 /* set to empty and then reset to infinite */
2022 status
= GdipSetEmpty(clip
);
2024 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
2027 status
= GdipGetClip(graphics
, clip
);
2030 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
2033 status
= GdipResetClip(graphics
);
2035 status
= GdipGetClip(graphics
, clip
);
2038 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2042 GdipDeleteRegion(clip
);
2044 GdipDeleteGraphics(graphics
);
2045 ReleaseDC(hwnd
, hdc
);
2048 static void test_isempty(void)
2051 GpGraphics
*graphics
= NULL
;
2052 HDC hdc
= GetDC( hwnd
);
2056 status
= GdipCreateFromHDC(hdc
, &graphics
);
2059 status
= GdipCreateRegion(&clip
);
2063 status
= GdipIsClipEmpty(NULL
, NULL
);
2064 expect(InvalidParameter
, status
);
2065 status
= GdipIsClipEmpty(graphics
, NULL
);
2066 expect(InvalidParameter
, status
);
2067 status
= GdipIsClipEmpty(NULL
, &res
);
2068 expect(InvalidParameter
, status
);
2070 /* default is infinite */
2072 status
= GdipIsClipEmpty(graphics
, &res
);
2076 GdipDeleteRegion(clip
);
2078 GdipDeleteGraphics(graphics
);
2079 ReleaseDC(hwnd
, hdc
);
2082 static void test_clear(void)
2086 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2087 expect(InvalidParameter
, status
);
2090 static void test_textcontrast(void)
2093 HDC hdc
= GetDC( hwnd
);
2094 GpGraphics
*graphics
;
2097 status
= GdipGetTextContrast(NULL
, NULL
);
2098 expect(InvalidParameter
, status
);
2100 status
= GdipCreateFromHDC(hdc
, &graphics
);
2103 status
= GdipGetTextContrast(graphics
, NULL
);
2104 expect(InvalidParameter
, status
);
2105 status
= GdipGetTextContrast(graphics
, &contrast
);
2107 expect(4, contrast
);
2109 GdipDeleteGraphics(graphics
);
2110 ReleaseDC(hwnd
, hdc
);
2113 static void test_GdipDrawString(void)
2116 GpGraphics
*graphics
= NULL
;
2119 GpStringFormat
*format
;
2122 HDC hdc
= GetDC( hwnd
);
2123 static const WCHAR string
[] = {'T','e','s','t',0};
2124 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2127 memset(&logfont
,0,sizeof(logfont
));
2128 strcpy(logfont
.lfFaceName
,"Arial");
2129 logfont
.lfHeight
= 12;
2130 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2132 status
= GdipCreateFromHDC(hdc
, &graphics
);
2135 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2136 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2138 skip("Arial not installed.\n");
2143 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2146 status
= GdipCreateStringFormat(0,0,&format
);
2154 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2157 status
= GdipCreateMatrix(&matrix
);
2160 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2161 expect(InvalidParameter
, status
);
2163 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2164 expect(InvalidParameter
, status
);
2166 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2167 expect(InvalidParameter
, status
);
2169 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2170 expect(InvalidParameter
, status
);
2172 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2173 expect(InvalidParameter
, status
);
2175 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2178 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2181 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2184 GdipDeleteMatrix(matrix
);
2185 GdipDeleteGraphics(graphics
);
2186 GdipDeleteBrush(brush
);
2187 GdipDeleteFont(fnt
);
2188 GdipDeleteStringFormat(format
);
2190 ReleaseDC(hwnd
, hdc
);
2193 static void test_GdipGetVisibleClipBounds_screen(void)
2196 GpGraphics
*graphics
= NULL
;
2198 GpRectF rectf
, exp
, clipr
;
2201 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2203 status
= GdipCreateFromHDC(hdc
, &graphics
);
2205 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2207 /* no clipping rect */
2210 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2211 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2213 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2215 ok(rectf
.X
== exp
.X
&&
2217 rectf
.Width
== exp
.Width
&&
2218 rectf
.Height
== exp
.Height
,
2219 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2220 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2221 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2222 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2224 /* clipping rect entirely within window */
2225 exp
.X
= clipr
.X
= 10;
2226 exp
.Y
= clipr
.Y
= 12;
2227 exp
.Width
= clipr
.Width
= 14;
2228 exp
.Height
= clipr
.Height
= 16;
2230 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2233 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2235 ok(rectf
.X
== exp
.X
&&
2237 rectf
.Width
== exp
.Width
&&
2238 rectf
.Height
== exp
.Height
,
2239 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2240 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2241 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2242 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2244 /* clipping rect partially outside of screen */
2250 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2258 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2260 ok(rectf
.X
== exp
.X
&&
2262 rectf
.Width
== exp
.Width
&&
2263 rectf
.Height
== exp
.Height
,
2264 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2265 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2266 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2267 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2269 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2271 ok(recti
.X
== exp
.X
&&
2273 recti
.Width
== exp
.Width
&&
2274 recti
.Height
== exp
.Height
,
2275 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2276 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2277 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2278 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2280 GdipDeleteGraphics(graphics
);
2284 static void test_GdipGetVisibleClipBounds_window(void)
2287 GpGraphics
*graphics
= NULL
;
2288 GpRectF rectf
, window
, exp
, clipr
;
2294 /* get client area size */
2295 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2296 window
.X
= wnd_rect
.left
;
2297 window
.Y
= wnd_rect
.top
;
2298 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2299 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2301 hdc
= BeginPaint(hwnd
, &ps
);
2303 status
= GdipCreateFromHDC(hdc
, &graphics
);
2305 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2307 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2309 ok(rectf
.X
== window
.X
&&
2310 rectf
.Y
== window
.Y
&&
2311 rectf
.Width
== window
.Width
&&
2312 rectf
.Height
== window
.Height
,
2313 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2314 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2315 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2316 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2318 /* clipping rect entirely within window */
2319 exp
.X
= clipr
.X
= 20;
2320 exp
.Y
= clipr
.Y
= 8;
2321 exp
.Width
= clipr
.Width
= 30;
2322 exp
.Height
= clipr
.Height
= 20;
2324 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2327 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2329 ok(rectf
.X
== exp
.X
&&
2331 rectf
.Width
== exp
.Width
&&
2332 rectf
.Height
== exp
.Height
,
2333 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2334 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2335 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2336 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2338 /* clipping rect partially outside of window */
2339 clipr
.X
= window
.Width
- 10;
2340 clipr
.Y
= window
.Height
- 15;
2344 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2347 exp
.X
= window
.Width
- 10;
2348 exp
.Y
= window
.Height
- 15;
2352 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2354 ok(rectf
.X
== exp
.X
&&
2356 rectf
.Width
== exp
.Width
&&
2357 rectf
.Height
== exp
.Height
,
2358 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2359 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2360 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2361 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2363 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2365 ok(recti
.X
== exp
.X
&&
2367 recti
.Width
== exp
.Width
&&
2368 recti
.Height
== exp
.Height
,
2369 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2370 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2371 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2372 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2374 /* window bounds with transform applied */
2375 status
= GdipResetClip(graphics
);
2378 status
= GdipScaleWorldTransform(graphics
, 0.5, 0.5, MatrixOrderPrepend
);
2381 exp
.X
= window
.X
* 2.0;
2382 exp
.Y
= window
.Y
* 2.0;
2383 exp
.Width
= window
.Width
* 2.0;
2384 exp
.Height
= window
.Height
* 2.0;
2386 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2388 ok(rectf
.X
== exp
.X
&&
2390 rectf
.Width
== exp
.Width
&&
2391 rectf
.Height
== exp
.Height
,
2392 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2393 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2394 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2395 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2397 GdipDeleteGraphics(graphics
);
2398 EndPaint(hwnd
, &ps
);
2401 static void test_GdipGetVisibleClipBounds(void)
2403 GpGraphics
* graphics
= NULL
;
2406 HDC hdc
= GetDC( hwnd
);
2409 status
= GdipCreateFromHDC(hdc
, &graphics
);
2411 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2413 /* test null parameters */
2414 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2415 expect(InvalidParameter
, status
);
2417 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2418 expect(InvalidParameter
, status
);
2420 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2421 expect(InvalidParameter
, status
);
2423 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2424 expect(InvalidParameter
, status
);
2426 GdipDeleteGraphics(graphics
);
2427 ReleaseDC(hwnd
, hdc
);
2429 test_GdipGetVisibleClipBounds_screen();
2430 test_GdipGetVisibleClipBounds_window();
2433 static void test_fromMemoryBitmap(void)
2436 GpGraphics
*graphics
= NULL
;
2437 GpBitmap
*bitmap
= NULL
;
2438 BYTE bits
[48] = {0};
2442 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2445 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2448 status
= GdipGraphicsClear(graphics
, 0xff686868);
2451 GdipDeleteGraphics(graphics
);
2453 /* drawing writes to the memory provided */
2454 expect(0x68, bits
[10]);
2456 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2459 status
= GdipGetDC(graphics
, &hdc
);
2461 ok(hdc
!= NULL
, "got NULL hdc\n");
2463 color
= GetPixel(hdc
, 0, 0);
2464 /* The HDC is write-only, and native fills with a solid color to figure out
2465 * which pixels have changed. */
2466 todo_wine
expect(0x0c0b0d, color
);
2468 SetPixel(hdc
, 0, 0, 0x797979);
2469 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2471 status
= GdipReleaseDC(graphics
, hdc
);
2474 GdipDeleteGraphics(graphics
);
2476 expect(0x79, bits
[0]);
2477 todo_wine
expect(0x68, bits
[3]);
2479 GdipDisposeImage((GpImage
*)bitmap
);
2481 /* We get the same kind of write-only HDC for a "normal" bitmap */
2482 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2485 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2488 status
= GdipGetDC(graphics
, &hdc
);
2490 ok(hdc
!= NULL
, "got NULL hdc\n");
2492 color
= GetPixel(hdc
, 0, 0);
2493 todo_wine
expect(0x0c0b0d, color
);
2495 status
= GdipReleaseDC(graphics
, hdc
);
2498 GdipDeleteGraphics(graphics
);
2500 GdipDisposeImage((GpImage
*)bitmap
);
2502 /* If we don't draw to the HDC, the bits are never accessed */
2503 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2506 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2509 status
= GdipGetDC(graphics
, &hdc
);
2511 ok(hdc
!= NULL
, "got NULL hdc\n");
2513 color
= GetPixel(hdc
, 0, 0);
2514 todo_wine
expect(0x0c0b0d, color
);
2516 status
= GdipReleaseDC(graphics
, hdc
);
2519 GdipDeleteGraphics(graphics
);
2521 GdipDisposeImage((GpImage
*)bitmap
);
2524 static void test_GdipIsVisiblePoint(void)
2527 GpGraphics
*graphics
= NULL
;
2528 HDC hdc
= GetDC( hwnd
);
2532 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2534 status
= GdipCreateFromHDC(hdc
, &graphics
);
2536 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2538 /* null parameters */
2539 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2540 expect(InvalidParameter
, status
);
2542 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2543 expect(InvalidParameter
, status
);
2545 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2546 expect(InvalidParameter
, status
);
2548 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2549 expect(InvalidParameter
, status
);
2553 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2555 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2559 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2561 ok(val
== FALSE
, "Expected (%.2f, %.2f) not 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
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2575 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2580 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2582 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2586 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2588 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2590 /* translate into the center of the rect */
2591 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2595 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2597 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2601 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2603 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2605 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2610 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2612 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
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
== TRUE
, "After clipping, expected (%.2f, %.2f) 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
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2646 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2648 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) 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
== FALSE
, "After clipping, expected (%.2f, %.2f) not 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
);
2686 /* integer version */
2689 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2691 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2695 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2697 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2699 GdipDeleteGraphics(graphics
);
2700 ReleaseDC(hwnd
, hdc
);
2703 static void test_GdipIsVisibleRect(void)
2706 GpGraphics
*graphics
= NULL
;
2707 HDC hdc
= GetDC( hwnd
);
2708 REAL x
, y
, width
, height
;
2711 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2713 status
= GdipCreateFromHDC(hdc
, &graphics
);
2715 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2717 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2718 expect(InvalidParameter
, status
);
2720 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2721 expect(InvalidParameter
, status
);
2723 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2724 expect(InvalidParameter
, status
);
2726 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2727 expect(InvalidParameter
, status
);
2729 /* entirely within the visible region */
2732 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2734 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2736 /* partially outside */
2737 x
= -10; width
= 20;
2738 y
= -10; height
= 20;
2739 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2741 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2743 /* entirely outside */
2745 y
= -10; height
= 5;
2746 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2748 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2750 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2753 /* entirely within the visible region */
2755 y
= 22; height
= 10;
2756 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2758 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2760 /* partially outside */
2762 y
= 55; height
= 10;
2763 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2765 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2767 /* entirely outside */
2770 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2772 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2774 /* translate into center of clipping rect */
2775 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2779 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2781 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2785 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2787 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2789 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2791 /* corners entirely outside, but some intersections */
2794 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2796 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
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 y
= 20; height
= 40;
2813 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2815 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
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
);
2824 y
= 20; height
= 40;
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
= 60; height
= 10;
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
);
2835 /* rounding tests */
2836 x
= 0.4; width
= 10.4;
2837 y
= 20; height
= 40;
2838 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2840 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2843 y
= 0.4; height
= 20.4;
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
);
2848 /* integer version */
2851 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2853 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2856 y
= 22; height
= 10;
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
);
2861 GdipDeleteGraphics(graphics
);
2862 ReleaseDC(hwnd
, hdc
);
2865 static void test_GdipGetNearestColor(void)
2868 GpGraphics
*graphics
;
2870 ARGB color
= 0xdeadbeef;
2871 HDC hdc
= GetDC( hwnd
);
2873 /* create a graphics object */
2874 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2876 status
= GdipCreateFromHDC(hdc
, &graphics
);
2878 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2880 status
= GdipGetNearestColor(graphics
, NULL
);
2881 expect(InvalidParameter
, status
);
2883 status
= GdipGetNearestColor(NULL
, &color
);
2884 expect(InvalidParameter
, status
);
2885 GdipDeleteGraphics(graphics
);
2887 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2889 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2890 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2893 status
= GdipGetNearestColor(graphics
, &color
);
2895 expect(0xdeadbeef, color
);
2896 GdipDeleteGraphics(graphics
);
2898 GdipDisposeImage((GpImage
*)bitmap
);
2900 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2902 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2903 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2906 status
= GdipGetNearestColor(graphics
, &color
);
2908 expect(0xdeadbeef, color
);
2909 GdipDeleteGraphics(graphics
);
2911 GdipDisposeImage((GpImage
*)bitmap
);
2913 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2915 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2916 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2919 status
= GdipGetNearestColor(graphics
, &color
);
2921 expect(0xdeadbeef, color
);
2922 GdipDeleteGraphics(graphics
);
2924 GdipDisposeImage((GpImage
*)bitmap
);
2926 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2928 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2929 todo_wine
expect(OutOfMemory
, status
);
2931 GdipDeleteGraphics(graphics
);
2932 GdipDisposeImage((GpImage
*)bitmap
);
2934 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2936 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2938 status
= GdipGetNearestColor(graphics
, &color
);
2940 expect(0xdeadbeef, color
);
2941 GdipDeleteGraphics(graphics
);
2942 GdipDisposeImage((GpImage
*)bitmap
);
2944 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2946 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2948 status
= GdipGetNearestColor(graphics
, &color
);
2950 expect(0xdeadbeef, color
);
2951 GdipDeleteGraphics(graphics
);
2952 GdipDisposeImage((GpImage
*)bitmap
);
2954 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2956 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2958 status
= GdipGetNearestColor(graphics
, &color
);
2960 expect(0xdeadbeef, color
);
2961 GdipDeleteGraphics(graphics
);
2962 GdipDisposeImage((GpImage
*)bitmap
);
2964 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2968 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2970 status
= GdipGetNearestColor(graphics
, &color
);
2972 expect(0xdeadbeef, color
);
2973 GdipDeleteGraphics(graphics
);
2974 GdipDisposeImage((GpImage
*)bitmap
);
2977 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2981 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2983 status
= GdipGetNearestColor(graphics
, &color
);
2985 expect(0xdeadbeef, color
);
2986 GdipDeleteGraphics(graphics
);
2987 GdipDisposeImage((GpImage
*)bitmap
);
2990 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2994 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2996 status
= GdipGetNearestColor(graphics
, &color
);
2998 expect(0xdeadbeef, color
);
2999 GdipDeleteGraphics(graphics
);
3000 GdipDisposeImage((GpImage
*)bitmap
);
3003 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
3005 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3007 status
= GdipGetNearestColor(graphics
, &color
);
3009 todo_wine
expect(0xffa8bce8, color
);
3010 GdipDeleteGraphics(graphics
);
3011 GdipDisposeImage((GpImage
*)bitmap
);
3013 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
3015 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3017 status
= GdipGetNearestColor(graphics
, &color
);
3020 ok(color
== 0xffa8b8e8 ||
3021 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
3022 "Expected ffa8b8e8, got %.8x\n", color
);
3023 GdipDeleteGraphics(graphics
);
3024 GdipDisposeImage((GpImage
*)bitmap
);
3026 ReleaseDC(hwnd
, hdc
);
3029 static void test_string_functions(void)
3032 GpGraphics
*graphics
;
3033 GpFontFamily
*family
;
3035 RectF rc
, char_bounds
, bounds
;
3037 ARGB color
= 0xff000000;
3038 HDC hdc
= GetDC( hwnd
);
3039 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
3040 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
3041 const WCHAR teststring2
[] = {'j',0};
3042 REAL char_width
, char_height
;
3043 INT codepointsfitted
, linesfilled
;
3044 GpStringFormat
*format
;
3045 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
3046 GpRegion
*regions
[4];
3047 BOOL region_isempty
[4];
3049 PointF positions
[8];
3052 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3053 status
= GdipCreateFromHDC(hdc
, &graphics
);
3055 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3057 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
3060 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
3063 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
3066 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3074 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
3075 expect(InvalidParameter
, status
);
3077 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
3078 expect(InvalidParameter
, status
);
3080 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3081 expect(InvalidParameter
, status
);
3083 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3084 expect(InvalidParameter
, status
);
3086 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3087 expect(InvalidParameter
, status
);
3089 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3092 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3093 expect(InvalidParameter
, status
);
3095 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3096 expect(InvalidParameter
, status
);
3098 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3099 expect(InvalidParameter
, status
);
3101 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3102 expect(InvalidParameter
, status
);
3104 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3105 expect(InvalidParameter
, status
);
3107 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3110 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3113 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3115 expectf(0.0, char_bounds
.X
);
3116 expectf(0.0, char_bounds
.Y
);
3117 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3118 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3119 expect(1, codepointsfitted
);
3120 expect(1, linesfilled
);
3122 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3124 expectf(0.0, bounds
.X
);
3125 expectf(0.0, bounds
.Y
);
3126 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3127 expectf(char_bounds
.Height
, bounds
.Height
);
3128 expect(2, codepointsfitted
);
3129 expect(1, linesfilled
);
3130 char_width
= bounds
.Width
- char_bounds
.Width
;
3132 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3134 expectf(0.0, bounds
.X
);
3135 expectf(0.0, bounds
.Y
);
3136 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3137 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3138 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3139 expect(6, codepointsfitted
);
3140 expect(2, linesfilled
);
3141 char_height
= bounds
.Height
- char_bounds
.Height
;
3143 /* Measure the first line. */
3144 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3146 expectf(0.0, bounds
.X
);
3147 expectf(0.0, bounds
.Y
);
3148 expect(4, codepointsfitted
);
3149 expect(1, linesfilled
);
3151 /* Give just enough space to fit the first line. */
3152 rc
.Width
= bounds
.Width
;
3153 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3155 expectf(0.0, bounds
.X
);
3156 expectf(0.0, bounds
.Y
);
3157 todo_wine
expect(5, codepointsfitted
);
3158 todo_wine
expect(1, linesfilled
);
3160 /* Cut off everything after the first space. */
3161 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3163 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3165 expectf(0.0, bounds
.X
);
3166 expectf(0.0, bounds
.Y
);
3167 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3168 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3169 expect(6, codepointsfitted
);
3170 expect(3, linesfilled
);
3172 /* Cut off everything including the first space. */
3173 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3175 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3177 expectf(0.0, bounds
.X
);
3178 expectf(0.0, bounds
.Y
);
3179 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3180 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3181 expect(6, codepointsfitted
);
3182 expect(3, linesfilled
);
3184 /* Cut off everything after the first character. */
3185 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3187 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3189 expectf(0.0, bounds
.X
);
3190 expectf(0.0, bounds
.Y
);
3191 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3192 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3193 expect(6, codepointsfitted
);
3194 todo_wine
expect(4, linesfilled
);
3196 for (i
= 0; i
< 4; i
++)
3197 regions
[i
] = (GpRegion
*)0xdeadbeef;
3199 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3202 for (i
= 0; i
< 4; i
++)
3203 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3205 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3208 for (i
= 0; i
< 4; i
++)
3209 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3211 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3214 set_rect_empty(&rc
);
3218 status
= GdipCreateRegion(®ions
[i
]);
3220 status
= GdipSetEmpty(regions
[i
]);
3224 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3225 expect(InvalidParameter
, status
);
3227 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3228 expect(InvalidParameter
, status
);
3230 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3231 expect(InvalidParameter
, status
);
3233 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3234 expect(InvalidParameter
, status
);
3238 /* Crashes on Windows XP */
3239 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3240 expect(InvalidParameter
, status
);
3243 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3244 expect(InvalidParameter
, status
);
3246 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3247 expect(InvalidParameter
, status
);
3249 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3252 for (i
= 0; i
< 4; i
++)
3254 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3258 ok(region_isempty
[0], "region should be empty\n");
3259 ok(region_isempty
[1], "region should be empty\n");
3260 ok(region_isempty
[2], "region should be empty\n");
3261 ok(region_isempty
[3], "region should be empty\n");
3266 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3271 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3275 ok(!region_isempty
[0], "region shouldn't be empty\n");
3276 ok(!region_isempty
[1], "region shouldn't be empty\n");
3277 ok(!region_isempty
[2], "region shouldn't be empty\n");
3278 ok(region_isempty
[3], "region should be empty\n");
3280 /* Cut off everything after the first space, and the second line. */
3281 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3282 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3284 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3289 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3293 ok(!region_isempty
[0], "region shouldn't be empty\n");
3294 ok(!region_isempty
[1], "region shouldn't be empty\n");
3295 ok(region_isempty
[2], "region should be empty\n");
3296 ok(region_isempty
[3], "region should be empty\n");
3299 GdipDeleteRegion(regions
[i
]);
3301 status
= GdipCreateMatrix(&identity
);
3308 memset(positions
, 0, sizeof(positions
));
3309 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3310 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3312 expect(InvalidParameter
, status
);
3314 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3315 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3317 expect(InvalidParameter
, status
);
3319 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3320 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3322 expect(InvalidParameter
, status
);
3324 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3325 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3327 expect(InvalidParameter
, status
);
3329 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3330 0x100, identity
, &rc
);
3333 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3334 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3338 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3339 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3341 expect(InvalidParameter
, status
);
3347 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3348 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3353 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3354 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3355 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3357 char_width
= rc
.Width
;
3358 char_height
= rc
.Height
;
3364 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3365 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3370 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3371 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3372 expectf(char_height
, rc
.Height
);
3378 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3379 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3384 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3385 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3386 expectf(rc
.Height
, char_height
);
3388 GdipDeleteMatrix(identity
);
3389 GdipDeleteStringFormat(format
);
3390 GdipDeleteBrush(brush
);
3391 GdipDeleteFont(font
);
3392 GdipDeleteFontFamily(family
);
3393 GdipDeleteGraphics(graphics
);
3395 ReleaseDC(hwnd
, hdc
);
3398 static void test_get_set_interpolation(void)
3400 GpGraphics
*graphics
;
3401 HDC hdc
= GetDC( hwnd
);
3403 InterpolationMode mode
;
3405 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3406 status
= GdipCreateFromHDC(hdc
, &graphics
);
3408 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3410 status
= GdipGetInterpolationMode(NULL
, &mode
);
3411 expect(InvalidParameter
, status
);
3415 /* Crashes on Windows XP */
3416 status
= GdipGetInterpolationMode(graphics
, NULL
);
3417 expect(InvalidParameter
, status
);
3420 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3421 expect(InvalidParameter
, status
);
3424 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3425 expect(InvalidParameter
, status
);
3427 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3428 expect(InvalidParameter
, status
);
3430 status
= GdipGetInterpolationMode(graphics
, &mode
);
3432 expect(InterpolationModeBilinear
, mode
);
3434 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3437 status
= GdipGetInterpolationMode(graphics
, &mode
);
3439 expect(InterpolationModeNearestNeighbor
, mode
);
3441 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3444 status
= GdipGetInterpolationMode(graphics
, &mode
);
3446 expect(InterpolationModeBilinear
, mode
);
3448 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3451 status
= GdipGetInterpolationMode(graphics
, &mode
);
3453 expect(InterpolationModeBilinear
, mode
);
3455 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3458 status
= GdipGetInterpolationMode(graphics
, &mode
);
3460 expect(InterpolationModeHighQualityBicubic
, mode
);
3462 GdipDeleteGraphics(graphics
);
3464 ReleaseDC(hwnd
, hdc
);
3467 static void test_get_set_textrenderinghint(void)
3469 GpGraphics
*graphics
;
3470 HDC hdc
= GetDC( hwnd
);
3472 TextRenderingHint hint
;
3474 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3475 status
= GdipCreateFromHDC(hdc
, &graphics
);
3477 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3479 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3480 expect(InvalidParameter
, status
);
3482 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3483 expect(InvalidParameter
, status
);
3485 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3486 expect(InvalidParameter
, status
);
3489 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3490 expect(InvalidParameter
, status
);
3492 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3494 expect(TextRenderingHintSystemDefault
, hint
);
3496 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3499 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3501 expect(TextRenderingHintSystemDefault
, hint
);
3503 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3506 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3508 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3510 GdipDeleteGraphics(graphics
);
3512 ReleaseDC(hwnd
, hdc
);
3515 static void test_getdc_scaled(void)
3518 GpGraphics
*graphics
= NULL
;
3519 GpBitmap
*bitmap
= NULL
;
3521 HBRUSH hbrush
, holdbrush
;
3524 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3527 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3530 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3533 status
= GdipGetDC(graphics
, &hdc
);
3535 ok(hdc
!= NULL
, "got NULL hdc\n");
3537 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3539 holdbrush
= SelectObject(hdc
, hbrush
);
3541 Rectangle(hdc
, 2, 2, 6, 6);
3543 SelectObject(hdc
, holdbrush
);
3545 DeleteObject(hbrush
);
3547 status
= GdipReleaseDC(graphics
, hdc
);
3550 GdipDeleteGraphics(graphics
);
3552 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3554 expect(0xffff0000, color
);
3556 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3558 expect(0xff000000, color
);
3560 GdipDisposeImage((GpImage
*)bitmap
);
3563 static void test_GdipMeasureString(void)
3565 static const struct test_data
3567 REAL res_x
, res_y
, page_scale
;
3571 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3572 { 200.0, 200.0, 2.0, UnitPixel
},
3573 { 200.0, 200.0, 1.0, UnitDisplay
},
3574 { 200.0, 200.0, 2.0, UnitDisplay
},
3575 { 200.0, 200.0, 1.0, UnitInch
},
3576 { 200.0, 200.0, 2.0, UnitInch
},
3577 { 200.0, 600.0, 1.0, UnitPoint
},
3578 { 200.0, 600.0, 2.0, UnitPoint
},
3579 { 200.0, 600.0, 1.0, UnitDocument
},
3580 { 200.0, 600.0, 2.0, UnitDocument
},
3581 { 200.0, 600.0, 1.0, UnitMillimeter
},
3582 { 200.0, 600.0, 2.0, UnitMillimeter
},
3583 { 200.0, 600.0, 1.0, UnitDisplay
},
3584 { 200.0, 600.0, 2.0, UnitDisplay
},
3585 { 200.0, 600.0, 1.0, UnitPixel
},
3586 { 200.0, 600.0, 2.0, UnitPixel
},
3588 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3589 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3591 GpGraphics
*graphics
;
3592 GpFontFamily
*family
;
3594 GpStringFormat
*format
;
3596 REAL base_cx
= 0, base_cy
= 0, height
;
3601 GpUnit font_unit
, unit
;
3603 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3605 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3608 /* font size in pixels */
3609 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3611 status
= GdipGetFontSize(font
, &font_size
);
3613 expectf(100.0, font_size
);
3614 status
= GdipGetFontUnit(font
, &font_unit
);
3616 expect(UnitPixel
, font_unit
);
3618 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3622 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3624 lf
.lfHeight
= 0xdeadbeef;
3625 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3627 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3628 if (td
[i
].unit
!= UnitDisplay
)
3629 height
*= td
[i
].page_scale
;
3630 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3631 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3633 height
= font_size
+ 2.0 * font_size
/ 6.0;
3635 set_rect_empty(&rc
);
3636 set_rect_empty(&bounds
);
3637 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3642 base_cx
= bounds
.Width
;
3643 base_cy
= bounds
.Height
;
3646 expectf(0.0, bounds
.X
);
3647 expectf(0.0, bounds
.Y
);
3649 expectf_(height
, bounds
.Height
, height
/ 100.0);
3650 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3654 /* make sure it really fits */
3655 bounds
.Width
+= 1.0;
3656 bounds
.Height
+= 1.0;
3660 set_rect_empty(&bounds
);
3661 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3663 expectf(50.0, bounds
.X
);
3664 expectf(50.0, bounds
.Y
);
3666 expectf_(height
, bounds
.Height
, height
/ 100.0);
3667 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3671 status
= GdipDeleteGraphics(graphics
);
3674 status
= GdipDisposeImage(image
);
3678 GdipDeleteFont(font
);
3680 /* font size in logical units */
3681 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3682 for (unit
= 3; unit
<= 6; unit
++)
3684 /* create a font which final height is 100.0 pixels with 200 dpi device */
3685 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3686 height
= pixels_to_units(75.0, unit
, 200.0);
3687 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3689 status
= GdipGetFontSize(font
, &font_size
);
3691 expectf(height
, font_size
);
3692 status
= GdipGetFontUnit(font
, &font_unit
);
3694 expect(unit
, font_unit
);
3696 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3701 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3703 lf
.lfHeight
= 0xdeadbeef;
3704 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3706 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3707 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3709 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3710 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3711 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3712 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3714 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3715 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3717 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3718 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3719 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3720 if (td
[i
].unit
!= UnitDisplay
)
3721 height
/= td
[i
].page_scale
;
3722 /*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);*/
3724 set_rect_empty(&rc
);
3725 set_rect_empty(&bounds
);
3726 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3731 base_cx
= bounds
.Width
;
3732 base_cy
= bounds
.Height
;
3735 expectf(0.0, bounds
.X
);
3736 expectf(0.0, bounds
.Y
);
3738 expectf_(height
, bounds
.Height
, height
/ 85.0);
3739 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3743 /* make sure it really fits */
3744 bounds
.Width
+= 1.0;
3745 bounds
.Height
+= 1.0;
3749 set_rect_empty(&bounds
);
3750 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3752 expectf(50.0, bounds
.X
);
3753 expectf(50.0, bounds
.Y
);
3755 expectf_(height
, bounds
.Height
, height
/ 85.0);
3756 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3760 /* verify the result */
3761 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3762 if (td
[i
].unit
!= UnitDisplay
)
3763 height
*= td
[i
].page_scale
;
3764 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3765 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3767 expectf_(100.0, height
, 1.1);
3769 status
= GdipDeleteGraphics(graphics
);
3772 status
= GdipDisposeImage(image
);
3776 GdipDeleteFont(font
);
3779 /* Font with units = UnitWorld */
3780 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3782 GpPointF pt
= {0.0, 100.0};
3784 REAL expected_width
, expected_height
;
3786 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3788 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3791 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3794 status
= GdipGetFontUnit(font
, &font_unit
);
3796 expect(UnitWorld
, font_unit
);
3798 lf
.lfHeight
= 0xdeadbeef;
3799 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3801 ok(lf
.lfHeight
== -100, "%u: expected -100, got %d\n", i
, lf
.lfHeight
);
3803 set_rect_empty(&rc
);
3804 set_rect_empty(&bounds
);
3805 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3810 base_cx
= bounds
.Width
;
3811 base_cy
= bounds
.Height
;
3817 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3820 /* height is constant in device space, width is proportional to height in world space */
3821 expected_width
= base_cx
* pt
.Y
;
3822 expected_height
= base_cy
* pt
.Y
;
3824 todo_wine_if(td
[i
].unit
!= UnitDisplay
&& td
[i
].unit
!= UnitPixel
)
3825 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3826 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3828 GdipDeleteGraphics(graphics
);
3829 GdipDisposeImage(image
);
3830 GdipDeleteFont(font
);
3833 GdipDeleteFontFamily(family
);
3834 GdipDeleteStringFormat(format
);
3837 static void test_transform(void)
3839 static const struct test_data
3841 REAL res_x
, res_y
, scale
;
3843 GpPointF in
[2], out
[2];
3846 { 96.0, 96.0, 1.0, UnitPixel
,
3847 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3848 { 96.0, 96.0, 1.0, UnitDisplay
,
3849 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3850 { 96.0, 96.0, 1.0, UnitInch
,
3851 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3852 { 123.0, 456.0, 1.0, UnitPoint
,
3853 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3854 { 123.0, 456.0, 1.0, UnitDocument
,
3855 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3856 { 123.0, 456.0, 2.0, UnitMillimeter
,
3857 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3858 { 196.0, 296.0, 1.0, UnitDisplay
,
3859 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3860 { 196.0, 296.0, 1.0, UnitPixel
,
3861 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3864 GpGraphics
*graphics
;
3869 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3871 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3872 ptf
[0].X
= td
[i
].in
[0].X
;
3873 ptf
[0].Y
= td
[i
].in
[0].Y
;
3874 ptf
[1].X
= td
[i
].in
[1].X
;
3875 ptf
[1].Y
= td
[i
].in
[1].Y
;
3876 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3878 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3879 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3880 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3881 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3882 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3884 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3885 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3886 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3887 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3888 status
= GdipDeleteGraphics(graphics
);
3890 status
= GdipDisposeImage(image
);
3895 static void test_pen_thickness(void)
3897 static const struct test_data
3899 REAL res_x
, res_y
, scale
;
3900 GpUnit pen_unit
, page_unit
;
3905 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1 },
3906 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2 },
3907 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1 },
3908 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1 },
3909 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6 },
3910 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20 },
3914 GpGraphics
*graphics
;
3925 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3927 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
3930 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
3933 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
3936 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
3939 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
3942 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
3945 corner
.X
= corner
.Y
= 100.0;
3946 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
3949 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
3952 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
3955 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
3961 for (j
=0; j
<100; j
++)
3963 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3970 for (j
=99; j
>=0; j
--)
3972 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3981 ok(size
== td
[i
].cx
, "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
3986 for (j
=0; j
<100; j
++)
3988 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
3995 for (j
=99; j
>=0; j
--)
3997 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4006 ok(size
== td
[i
].cy
, "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
4008 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4012 GdipDeleteGraphics(graphics
);
4013 GdipDisposeImage(u
.image
);
4017 /* Many people on the net ask why there is so much difference in rendered
4018 * text height between gdiplus and gdi32, this test suggests an answer to
4019 * that question. Important: this test assumes that font dpi == device dpi.
4021 static void test_font_height_scaling(void)
4023 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4024 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
4026 GpStringFormat
*format
;
4027 CharacterRange range
= { 0, 7 };
4029 GpGraphics
*graphics
;
4030 GpFontFamily
*family
;
4034 REAL height
, dpi
, scale
;
4036 GpUnit gfx_unit
, font_unit
;
4038 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4040 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4042 status
= GdipCreateRegion(®ion
);
4045 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4048 hdc
= CreateCompatibleDC(0);
4049 status
= GdipCreateFromHDC(hdc
, &graphics
);
4052 status
= GdipGetDpiY(graphics
, &dpi
);
4055 /* First check if tested functionality works:
4056 * under XP if font and graphics units differ then GdipTransformPoints
4057 * followed by GdipSetPageUnit to change the graphics units breaks region
4058 * scaling in GdipMeasureCharacterRanges called later.
4060 status
= GdipSetPageUnit(graphics
, UnitDocument
);
4065 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4068 status
= GdipSetPageUnit(graphics
, UnitInch
);
4071 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
4074 set_rect_empty(&rect
);
4075 set_rect_empty(&bounds
);
4076 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4078 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4080 set_rect_empty(&rect
);
4081 rect
.Width
= 32000.0;
4082 rect
.Height
= 32000.0;
4083 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4086 set_rect_empty(&rect
);
4087 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4089 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4091 GdipDeleteFont(font
);
4093 scale
= rect
.Height
/ bounds
.Height
;
4094 if (fabs(scale
- 1.0) > 0.1)
4096 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4100 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4103 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4104 /* UnitPixel as a font base unit is not tested because it drastically
4105 differs in behaviour */
4106 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4108 /* create a font for the final text height of 100 pixels */
4109 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4110 status
= GdipSetPageUnit(graphics
, font_unit
);
4114 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4117 /*trace("height %f units\n", height);*/
4118 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4121 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4122 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4124 static const WCHAR doubleW
[2] = { 'W','W' };
4125 RectF bounds_1
, bounds_2
;
4126 REAL margin
, margin_y
, font_height
;
4129 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4132 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4133 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4135 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4138 set_rect_empty(&rect
);
4139 set_rect_empty(&bounds
);
4140 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4142 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4144 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4147 ptf
.Y
= bounds
.Height
;
4148 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4150 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4152 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4154 /* verify the result */
4155 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4157 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4159 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4161 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4162 set_rect_empty(&rect
);
4163 set_rect_empty(&bounds_1
);
4164 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4166 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4167 set_rect_empty(&rect
);
4168 set_rect_empty(&bounds_2
);
4169 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4172 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4173 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4174 /*trace("margin %f\n", margin);*/
4175 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4177 set_rect_empty(&rect
);
4178 rect
.Width
= 320000.0;
4179 rect
.Height
= 320000.0;
4180 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4182 set_rect_empty(&rect
);
4183 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4185 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4186 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4187 expectf(0.0, rect
.Y
);
4188 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4189 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4190 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4191 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4192 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4193 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4196 GdipDeleteFont(font
);
4200 status
= GdipDeleteGraphics(graphics
);
4204 GdipDeleteFontFamily(family
);
4205 GdipDeleteRegion(region
);
4206 GdipDeleteStringFormat(format
);
4209 static void test_measure_string(void)
4211 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4212 static const WCHAR string
[] = { 'A','0','1',0 };
4214 GpStringFormat
*format
;
4215 CharacterRange range
;
4217 GpGraphics
*graphics
;
4218 GpFontFamily
*family
;
4222 REAL width
, height
, width_1
, width_2
;
4223 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4226 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4230 status
= GdipCreateRegion(®ion
);
4233 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4236 hdc
= CreateCompatibleDC(0);
4237 status
= GdipCreateFromHDC(hdc
, &graphics
);
4239 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4242 margin_x
= 20.0 / 6.0;
4243 margin_y
= 20.0 / 8.0;
4245 set_rect_empty(&rect
);
4246 set_rect_empty(&bounds
);
4247 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4251 expectf(0.0, bounds
.X
);
4252 expectf(0.0, bounds
.Y
);
4253 width
= bounds
.Width
;
4254 height
= bounds
.Height
;
4256 set_rect_empty(&rect
);
4257 rect
.Height
= height
/ 2.0;
4258 set_rect_empty(&bounds
);
4259 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4263 expectf(0.0, bounds
.X
);
4264 expectf(0.0, bounds
.Y
);
4265 expectf(width
, bounds
.Width
);
4267 expectf(height
/ 2.0, bounds
.Height
);
4270 range
.Length
= lstrlenW(string
);
4271 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4276 rect
.Width
= 32000.0;
4277 rect
.Height
= 32000.0;
4278 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4280 set_rect_empty(&bounds
);
4281 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4283 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4284 expectf(5.0, bounds
.Y
);
4285 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4287 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4289 width_rgn
= bounds
.Width
;
4290 height_rgn
= bounds
.Height
;
4294 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4297 set_rect_empty(&rect
);
4298 rect
.Width
= 32000.0;
4299 rect
.Height
= 32000.0;
4300 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4302 set_rect_empty(&bounds
);
4303 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4305 expectf_(margin_x
, bounds
.X
, 1.0);
4306 expectf(0.0, bounds
.Y
);
4307 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4308 expectf(height_rgn
, bounds
.Height
);
4309 width_1
= bounds
.Width
;
4312 range
.Length
= lstrlenW(string
);
4313 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4320 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4322 set_rect_empty(&bounds
);
4323 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4325 expectf(0.0, bounds
.X
);
4326 expectf(0.0, bounds
.Y
);
4327 expectf(0.0, bounds
.Width
);
4328 expectf(0.0, bounds
.Height
);
4332 rect
.Width
= width_rgn
/ 2.0;
4333 rect
.Height
= 32000.0;
4334 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4336 set_rect_empty(&bounds
);
4337 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4339 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4340 expectf(5.0, bounds
.Y
);
4341 expectf_(width_1
, bounds
.Width
, 1.0);
4343 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4345 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4351 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4353 set_rect_empty(&bounds
);
4354 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4356 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4357 expectf(5.0, bounds
.Y
);
4358 expectf(width_rgn
, bounds
.Width
);
4359 expectf(height_rgn
, bounds
.Height
);
4363 rect
.Width
= width_rgn
/ 2.0;
4364 rect
.Height
= 32000.0;
4365 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4367 set_rect_empty(&bounds
);
4368 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4370 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4371 expectf(5.0, bounds
.Y
);
4372 expectf_(width_1
, bounds
.Width
, 1.0);
4373 expectf(height_rgn
, bounds
.Height
);
4375 set_rect_empty(&rect
);
4376 rect
.Height
= height
/ 2.0;
4377 set_rect_empty(&bounds
);
4378 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4382 expectf(0.0, bounds
.X
);
4383 expectf(0.0, bounds
.Y
);
4384 expectf_(width
, bounds
.Width
, 0.01);
4386 expectf(height
, bounds
.Height
);
4388 set_rect_empty(&rect
);
4389 set_rect_empty(&bounds
);
4390 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4394 expectf(0.0, bounds
.X
);
4395 expectf(0.0, bounds
.Y
);
4396 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4397 expectf(height
, bounds
.Height
);
4398 width_1
= bounds
.Width
;
4400 set_rect_empty(&rect
);
4401 set_rect_empty(&bounds
);
4402 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4406 expectf(0.0, bounds
.X
);
4407 expectf(0.0, bounds
.Y
);
4408 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4409 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4410 expectf(height
, bounds
.Height
);
4411 width_2
= bounds
.Width
;
4413 set_rect_empty(&rect
);
4414 rect
.Width
= width
/ 2.0;
4415 set_rect_empty(&bounds
);
4416 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4420 expectf(0.0, bounds
.X
);
4421 expectf(0.0, bounds
.Y
);
4422 expectf_(width_1
, bounds
.Width
, 0.01);
4423 expectf(height
, bounds
.Height
);
4425 set_rect_empty(&rect
);
4426 rect
.Height
= height
;
4427 rect
.Width
= width
- 0.05;
4428 set_rect_empty(&bounds
);
4429 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4433 expectf(0.0, bounds
.X
);
4434 expectf(0.0, bounds
.Y
);
4435 expectf_(width_2
, bounds
.Width
, 0.01);
4436 expectf(height
, bounds
.Height
);
4438 set_rect_empty(&rect
);
4439 rect
.Height
= height
;
4440 rect
.Width
= width_2
- 0.05;
4441 set_rect_empty(&bounds
);
4442 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4446 expectf(0.0, bounds
.X
);
4447 expectf(0.0, bounds
.Y
);
4448 expectf_(width_1
, bounds
.Width
, 0.01);
4449 expectf(height
, bounds
.Height
);
4451 /* Default (Near) alignment */
4454 rect
.Width
= width
* 2.0;
4455 rect
.Height
= height
* 2.0;
4456 set_rect_empty(&bounds
);
4457 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4461 expectf(5.0, bounds
.X
);
4462 expectf(5.0, bounds
.Y
);
4463 expectf_(width
, bounds
.Width
, 0.01);
4464 expectf(height
, bounds
.Height
);
4468 rect
.Width
= 32000.0;
4469 rect
.Height
= 32000.0;
4470 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4472 set_rect_empty(&bounds
);
4473 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4475 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4476 expectf(5.0, bounds
.Y
);
4477 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4479 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4481 width_rgn
= bounds
.Width
;
4482 height_rgn
= bounds
.Height
;
4484 /* Center alignment */
4485 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4486 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4490 rect
.Width
= width
* 2.0;
4491 rect
.Height
= height
* 2.0;
4492 set_rect_empty(&bounds
);
4493 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4498 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4500 expectf(5.0 + height
/2.0, bounds
.Y
);
4501 expectf_(width
, bounds
.Width
, 0.01);
4502 expectf(height
, bounds
.Height
);
4508 set_rect_empty(&bounds
);
4509 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4514 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4516 expectf(5.0 - height
/2.0, bounds
.Y
);
4517 expectf_(width
, bounds
.Width
, 0.01);
4518 expectf(height
, bounds
.Height
);
4522 rect
.Width
= width_rgn
* 2.0;
4523 rect
.Height
= height_rgn
* 2.0;
4524 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4526 set_rect_empty(&bounds
);
4527 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4530 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4532 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4533 expectf_(width_rgn
, bounds
.Width
, 1.0);
4534 expectf_(height_rgn
, bounds
.Height
, 1.0);
4540 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4542 set_rect_empty(&bounds
);
4543 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4546 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4548 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4549 expectf_(width_rgn
, bounds
.Width
, 1.0);
4550 expectf_(height_rgn
, bounds
.Height
, 1.0);
4553 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4554 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4558 rect
.Width
= width
* 2.0;
4559 rect
.Height
= height
* 2.0;
4560 set_rect_empty(&bounds
);
4561 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4566 expectf_(5.0 + width
, bounds
.X
, 0.01);
4568 expectf(5.0 + height
, bounds
.Y
);
4569 expectf_(width
, bounds
.Width
, 0.01);
4570 expectf(height
, bounds
.Height
);
4576 set_rect_empty(&bounds
);
4577 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4582 expectf_(5.0 - width
, bounds
.X
, 0.01);
4584 expectf(5.0 - height
, bounds
.Y
);
4585 expectf_(width
, bounds
.Width
, 0.01);
4586 expectf(height
, bounds
.Height
);
4590 rect
.Width
= width_rgn
* 2.0;
4591 rect
.Height
= height_rgn
* 2.0;
4592 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4594 set_rect_empty(&bounds
);
4595 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4598 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4600 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4601 expectf_(width_rgn
, bounds
.Width
, 1.0);
4602 expectf_(height_rgn
, bounds
.Height
, 1.0);
4608 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4610 set_rect_empty(&bounds
);
4611 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4614 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4616 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4617 expectf_(width_rgn
, bounds
.Width
, 1.0);
4618 expectf_(height_rgn
, bounds
.Height
, 1.0);
4620 status
= GdipDeleteFont(font
);
4623 status
= GdipDeleteGraphics(graphics
);
4627 GdipDeleteFontFamily(family
);
4628 GdipDeleteRegion(region
);
4629 GdipDeleteStringFormat(format
);
4632 static void test_measured_extra_space(void)
4634 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4635 static const WCHAR string
[2] = { 'W','W' };
4636 GpStringFormat
*format
;
4638 GpGraphics
*graphics
;
4639 GpFontFamily
*family
;
4642 GpUnit gfx_unit
, font_unit
;
4643 RectF bounds_1
, bounds_2
, rect
;
4644 REAL margin
, font_size
, dpi
;
4646 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4649 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4651 hdc
= CreateCompatibleDC(0);
4652 status
= GdipCreateFromHDC(hdc
, &graphics
);
4655 status
= GdipGetDpiX(graphics
, &dpi
);
4658 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4659 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4660 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4662 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4665 status
= GdipGetFontSize(font
, &font_size
);
4667 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4668 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4670 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4671 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4673 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4676 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4677 set_rect_empty(&rect
);
4678 set_rect_empty(&bounds_1
);
4679 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4681 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4682 set_rect_empty(&rect
);
4683 set_rect_empty(&bounds_2
);
4684 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4687 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4688 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4689 /*trace("margin %f pixels\n", margin);*/
4690 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4693 GdipDeleteFont(font
);
4696 GdipDeleteGraphics(graphics
);
4698 GdipDeleteFontFamily(family
);
4699 GdipDeleteStringFormat(format
);
4702 static void test_alpha_hdc(void)
4706 HBITMAP hbm
, old_hbm
;
4707 GpGraphics
*graphics
;
4713 hdc
= CreateCompatibleDC(0);
4714 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4715 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4716 bmi
.bmiHeader
.biHeight
= 5;
4717 bmi
.bmiHeader
.biWidth
= 5;
4718 bmi
.bmiHeader
.biBitCount
= 32;
4719 bmi
.bmiHeader
.biPlanes
= 1;
4720 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4721 bmi
.bmiHeader
.biClrUsed
= 0;
4723 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4724 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4726 old_hbm
= SelectObject(hdc
, hbm
);
4728 status
= GdipCreateFromHDC(hdc
, &graphics
);
4731 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4733 expectf(0.0, bounds
.X
);
4734 expectf(0.0, bounds
.Y
);
4735 expectf(5.0, bounds
.Width
);
4736 expectf(5.0, bounds
.Height
);
4738 bits
[0] = 0xdeadbeef;
4740 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4743 expect(0xffaaaaaa, bits
[0]);
4745 bits
[0] = 0xdeadbeef;
4747 status
= GdipGetDC(graphics
, &gp_hdc
);
4750 colorref
= GetPixel(gp_hdc
, 0, 4);
4751 expect(0xefbead, colorref
);
4753 SetPixel(gp_hdc
, 0, 4, 0xffffff);
4755 expect(0xffffff, bits
[0]);
4757 status
= GdipReleaseDC(graphics
, gp_hdc
);
4760 SelectObject(hdc
, old_hbm
);
4762 bits
[0] = 0xdeadbeef;
4764 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4767 todo_wine
expect(0xffbbbbbb, bits
[0]);
4769 GdipDeleteGraphics(graphics
);
4775 static void test_bitmapfromgraphics(void)
4778 GpGraphics
*graphics
= NULL
;
4779 HDC hdc
= GetDC( hwnd
);
4780 GpBitmap
*bitmap
= NULL
;
4782 REAL imageres
, graphicsres
;
4785 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4788 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4789 expect(InvalidParameter
, stat
);
4791 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4792 expect(InvalidParameter
, stat
);
4794 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4797 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4799 expect(PixelFormat32bppPARGB
, format
);
4801 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4804 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4806 expectf(graphicsres
, imageres
);
4808 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4811 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4813 expectf(graphicsres
, imageres
);
4815 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4819 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4823 GdipDeleteGraphics(graphics
);
4824 GdipDisposeImage((GpImage
*)bitmap
);
4827 static void test_clipping(void)
4831 GpGraphics
*graphics
;
4832 GpRegion
*region
, *region100x100
;
4841 hdc
= CreateCompatibleDC(0);
4842 status
= GdipCreateFromHDC(hdc
, &graphics
);
4845 status
= GdipGetPageUnit(graphics
, &unit
);
4847 expect(UnitDisplay
, unit
);
4849 status
= GdipCreateRegion(®ion
);
4851 status
= GdipSetEmpty(region
);
4854 status
= GdipCreateRegion(®ion100x100
);
4856 status
= GdipSetEmpty(region100x100
);
4859 rect
.X
= rect
.Y
= 100.0;
4860 rect
.Width
= rect
.Height
= 100.0;
4861 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4863 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4866 status
= GdipGetClipBounds(graphics
, &rect
);
4868 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4869 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4871 status
= GdipSetEmpty(region
);
4873 status
= GdipGetClip(graphics
, region
);
4875 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4877 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4878 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4884 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4886 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4887 "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
);
4889 status
= GdipCreateMatrix(&matrix
);
4891 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4893 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4895 status
= GdipSetWorldTransform(graphics
, matrix
);
4898 status
= GdipGetClipBounds(graphics
, &rect
);
4900 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4901 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4903 status
= GdipSetEmpty(region
);
4905 status
= GdipGetClip(graphics
, region
);
4907 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4909 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4910 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4912 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4914 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4915 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4917 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4919 ret
= GetRgnBox(hrgn
, &rc
);
4920 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4921 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4922 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
4925 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4927 ret
= GetRgnBox(hrgn
, &rc
);
4928 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4929 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4930 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
4937 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4939 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4940 "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
);
4942 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4944 ret
= GetRgnBox(hrgn
, &rc
);
4945 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4946 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4947 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
4950 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4952 ret
= GetRgnBox(hrgn
, &rc
);
4953 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4954 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4955 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
4962 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4964 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4965 "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
);
4967 status
= GdipSetPageScale(graphics
, 2.0);
4970 status
= GdipGetClipBounds(graphics
, &rect
);
4972 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4973 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4975 status
= GdipSetEmpty(region
);
4977 status
= GdipGetClip(graphics
, region
);
4979 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4981 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4982 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4984 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4986 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4987 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4989 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4991 ret
= GetRgnBox(hrgn
, &rc
);
4992 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4993 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4994 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
4997 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4999 ret
= GetRgnBox(hrgn
, &rc
);
5000 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5001 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5002 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5009 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5011 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5012 "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
);
5014 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5016 ret
= GetRgnBox(hrgn
, &rc
);
5017 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5018 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5019 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5022 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5024 ret
= GetRgnBox(hrgn
, &rc
);
5025 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5026 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5027 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5034 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5036 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5037 "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
);
5039 GdipSetPageUnit(graphics
, UnitPoint
);
5042 status
= GdipGetClipBounds(graphics
, &rect
);
5044 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5045 /* rounding under Wine is slightly different */
5046 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5047 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5048 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5050 status
= GdipSetEmpty(region
);
5052 status
= GdipGetClip(graphics
, region
);
5054 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5056 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5057 /* rounding under Wine is slightly different */
5058 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5059 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5060 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5062 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5064 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5065 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5067 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5069 ret
= GetRgnBox(hrgn
, &rc
);
5070 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5071 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
5072 /* rounding under Wine is slightly different */
5073 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
5074 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
5075 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc
));
5078 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5080 ret
= GetRgnBox(hrgn
, &rc
);
5081 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5082 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5083 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5084 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5091 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5093 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5094 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5095 "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
);
5097 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5099 ret
= GetRgnBox(hrgn
, &rc
);
5100 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5101 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5102 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5105 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5107 ret
= GetRgnBox(hrgn
, &rc
);
5108 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5109 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5110 /* rounding under Wine is slightly different */
5111 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5112 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc
));
5119 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5121 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5123 expectf(100.0, ptf
[0].X
);
5124 expectf(100.0, ptf
[0].Y
);
5125 expectf(200.125, ptf
[1].X
);
5126 expectf(200.03125, ptf
[1].Y
);
5128 else /* before Win7 */
5130 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5131 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5132 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5133 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5136 status
= GdipTransformRegion(region100x100
, matrix
);
5139 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5141 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5142 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5144 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5146 ret
= GetRgnBox(hrgn
, &rc
);
5147 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5148 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5149 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5152 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5154 ret
= GetRgnBox(hrgn
, &rc
);
5155 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5156 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5157 /* rounding under Wine is slightly different */
5158 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5159 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc
));
5166 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5168 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5170 expectf(210.0625, ptf
[0].X
);
5171 expectf(420.0625, ptf
[0].Y
);
5172 expectf(410.125, ptf
[1].X
);
5173 expectf(820.0, ptf
[1].Y
);
5175 else /* before Win7 */
5177 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5178 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5179 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5180 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5183 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5185 status
= GdipSetWorldTransform(graphics
, matrix
);
5188 status
= GdipGetClipBounds(graphics
, &rect
);
5190 expectf_(20.612978, rect
.X
, 1.0);
5191 expectf_(-6.256012, rect
.Y
, 1.5);
5192 expectf_(25.612978, rect
.Width
, 1.0);
5193 expectf_(12.806489, rect
.Height
, 1.0);
5195 status
= GdipSetEmpty(region
);
5197 status
= GdipGetClip(graphics
, region
);
5199 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5201 /* rounding under Wine is slightly different */
5202 expectf_(20.612978, rect
.X
, 1.0);
5203 expectf_(-6.256012, rect
.Y
, 1.5);
5204 expectf_(25.612978, rect
.Width
, 1.0);
5205 expectf_(12.806489, rect
.Height
, 1.0);
5207 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5209 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5210 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5212 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5214 ret
= GetRgnBox(hrgn
, &rc
);
5215 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5216 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5217 /* rounding under Wine is slightly different */
5218 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5219 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc
));
5222 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5224 ret
= GetRgnBox(hrgn
, &rc
);
5225 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5226 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5227 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5238 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5240 expectf(20.612978, ptf
[0].X
);
5241 expectf(-1.568512, ptf
[0].Y
);
5242 expectf(46.225956, ptf
[1].X
);
5243 expectf(1.862977, ptf
[1].Y
);
5244 expectf(36.850956, ptf
[2].X
);
5245 expectf(-6.256012, ptf
[2].Y
);
5246 expectf(29.987980, ptf
[3].X
);
5247 expectf(6.550478, ptf
[3].Y
);
5249 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5251 ret
= GetRgnBox(hrgn
, &rc
);
5252 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5253 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5254 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5257 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5259 ret
= GetRgnBox(hrgn
, &rc
);
5260 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5261 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5262 /* rounding under Wine is slightly different */
5263 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5264 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc
));
5275 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5277 expectf(-136.190491, ptf
[0].X
);
5278 expectf(520.010742, ptf
[0].Y
);
5279 expectf(756.417175, ptf
[1].X
);
5280 expectf(720.031616, ptf
[1].Y
);
5281 expectf(360.042114, ptf
[2].X
);
5282 expectf(376.760742, ptf
[2].Y
);
5283 expectf(260.184570, ptf
[3].X
);
5284 expectf(863.281616, ptf
[3].Y
);
5286 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5288 status
= GdipSetWorldTransform(graphics
, matrix
);
5291 status
= GdipGetClipBounds(graphics
, &rect
);
5293 expectf_(-28.100956, rect
.X
, 1.0);
5294 expectf_(7.806488, rect
.Y
, 1.5);
5295 expectf_(25.612978, rect
.Width
, 1.0);
5296 expectf_(12.806489, rect
.Height
, 1.0);
5298 status
= GdipSetEmpty(region
);
5300 status
= GdipGetClip(graphics
, region
);
5302 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5304 /* rounding under Wine is slightly different */
5305 expectf_(-28.100956, rect
.X
, 1.0);
5306 expectf_(7.806488, rect
.Y
, 1.5);
5307 expectf_(25.612978, rect
.Width
, 1.0);
5308 expectf_(12.806489, rect
.Height
, 1.0);
5310 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5312 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5313 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5315 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5317 ret
= GetRgnBox(hrgn
, &rc
);
5318 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5319 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5320 /* rounding under Wine is slightly different */
5321 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5322 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc
));
5325 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5327 ret
= GetRgnBox(hrgn
, &rc
);
5328 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5329 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5330 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5341 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5343 expectf(-11.862979, ptf
[0].X
);
5344 expectf(7.806488, ptf
[0].Y
);
5345 expectf(-18.725958, ptf
[1].X
);
5346 expectf(20.612976, ptf
[1].Y
);
5347 expectf(-2.487981, ptf
[2].X
);
5348 expectf(15.925477, ptf
[2].Y
);
5349 expectf(-28.100956, ptf
[3].X
);
5350 expectf(12.493987, ptf
[3].Y
);
5352 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5354 ret
= GetRgnBox(hrgn
, &rc
);
5355 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5356 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5357 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5360 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5362 ret
= GetRgnBox(hrgn
, &rc
);
5363 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5364 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5365 /* rounding under Wine is slightly different */
5366 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5367 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc
));
5378 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5380 expectf(-1055.021484, ptf
[0].X
);
5381 expectf(-70.595329, ptf
[0].Y
);
5382 expectf(-1455.063232, ptf
[1].X
);
5383 expectf(375.708435, ptf
[1].Y
);
5384 expectf(-768.521484, ptf
[2].X
);
5385 expectf(177.520981, ptf
[2].Y
);
5386 expectf(-1741.563110, ptf
[3].X
);
5387 expectf(127.592125, ptf
[3].Y
);
5389 GdipDeleteMatrix(matrix
);
5390 GdipDeleteRegion(region
);
5391 GdipDeleteRegion(region100x100
);
5392 GdipDeleteGraphics(graphics
);
5396 static void test_clipping_2(void)
5401 GpGraphics
*graphics
;
5411 hdc
= CreateCompatibleDC(0);
5412 status
= GdipCreateFromHDC(hdc
, &graphics
);
5415 status
= GdipGetPageUnit(graphics
, &unit
);
5417 expect(UnitDisplay
, unit
);
5419 GdipSetPageUnit(graphics
, UnitInch
);
5421 status
= GdipCreateRegion(®ion
);
5423 status
= GdipSetEmpty(region
);
5425 rect
.X
= rect
.Y
= 100.0;
5426 rect
.Width
= rect
.Height
= 100.0;
5427 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5429 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5432 status
= GdipGetClip(graphics
, region
);
5434 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5436 ret
= GetRgnBox(hrgn
, &rc
);
5437 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5438 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5439 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5441 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5443 ret
= GetRgnBox(hrgn
, &rc
);
5444 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5445 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5446 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5453 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5455 expectf(100.0, ptf
[0].X
);
5456 expectf(100.0, ptf
[0].Y
);
5457 expectf(200.0, ptf
[1].X
);
5458 expectf(200.0, ptf
[1].X
);
5460 GdipSetPageUnit(graphics
, UnitPoint
);
5462 status
= GdipGetClip(graphics
, region
);
5464 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5466 ret
= GetRgnBox(hrgn
, &rc
);
5467 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5468 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5469 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5470 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc
));
5472 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5474 ret
= GetRgnBox(hrgn
, &rc
);
5475 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5476 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5477 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5478 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5485 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5487 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5488 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5489 "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
);
5490 else /* before Win7 */
5492 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5493 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5494 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5495 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5498 GdipDeleteRegion(region
);
5500 GdipSetPageUnit(graphics
, UnitPixel
);
5502 status
= GdipCreateRegion(®ion
);
5504 status
= GdipSetEmpty(region
);
5506 rect
.X
= rect
.Y
= 100.0;
5507 rect
.Width
= rect
.Height
= 100.0;
5508 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5510 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5513 status
= GdipGetClip(graphics
, region
);
5515 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5517 ret
= GetRgnBox(hrgn
, &rc
);
5518 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5519 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5520 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5521 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5523 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5525 ret
= GetRgnBox(hrgn
, &rc
);
5526 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5527 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5528 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5529 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5536 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5538 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5539 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5540 "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
);
5541 else /* before Win7 */
5543 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5544 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5545 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5546 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5549 GdipSetPageUnit(graphics
, UnitPoint
);
5551 status
= GdipGetClip(graphics
, region
);
5553 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5555 ret
= GetRgnBox(hrgn
, &rc
);
5556 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5557 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5558 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5559 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc
));
5561 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5563 ret
= GetRgnBox(hrgn
, &rc
);
5564 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5565 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5566 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5567 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5574 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5576 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5577 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5578 "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
);
5579 else /* before Win7 */
5581 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5582 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5583 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5584 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5587 status
= GdipCreateMatrix(&matrix
);
5589 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5591 status
= GdipSetWorldTransform(graphics
, matrix
);
5593 GdipDeleteMatrix(matrix
);
5595 status
= GdipGetClip(graphics
, region
);
5597 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5599 ret
= GetRgnBox(hrgn
, &rc
);
5600 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5601 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5602 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc
));
5604 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5606 ret
= GetRgnBox(hrgn
, &rc
);
5607 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5608 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5609 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5616 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5618 expectf(65.0, ptf
[0].X
);
5619 expectf(65.0, ptf
[0].Y
);
5620 expectf(140.0, ptf
[1].X
);
5621 expectf(140.0, ptf
[1].X
);
5623 status
= GdipCreateMatrix(&matrix
);
5625 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5627 status
= GdipSetWorldTransform(graphics
, matrix
);
5629 GdipDeleteMatrix(matrix
);
5631 status
= GdipGetClip(graphics
, region
);
5633 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5635 ret
= GetRgnBox(hrgn
, &rc
);
5636 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5637 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5638 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc
));
5640 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5642 ret
= GetRgnBox(hrgn
, &rc
);
5643 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5644 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5645 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5652 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5654 expectf(300.0, ptf
[0].X
);
5655 expectf(150.0, ptf
[0].Y
);
5656 expectf(600.0, ptf
[1].X
);
5657 expectf(300.0, ptf
[1].Y
);
5659 status
= GdipSetPageScale(graphics
, 2.0);
5662 status
= GdipGetClip(graphics
, region
);
5664 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5666 ret
= GetRgnBox(hrgn
, &rc
);
5667 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5668 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5669 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5670 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc
));
5672 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5674 ret
= GetRgnBox(hrgn
, &rc
);
5675 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5676 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5677 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5678 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5685 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5687 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5689 expectf(150.0, ptf
[0].X
);
5690 expectf(75.0, ptf
[0].Y
);
5691 expectf(300.0, ptf
[1].X
);
5692 expectf(150.0, ptf
[1].Y
);
5694 else /* before Win7 */
5696 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5697 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5698 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5699 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5702 status
= GdipCreateMatrix(&matrix
);
5704 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5706 status
= GdipSetWorldTransform(graphics
, matrix
);
5708 GdipDeleteMatrix(matrix
);
5710 status
= GdipGetClip(graphics
, region
);
5712 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5714 ret
= GetRgnBox(hrgn
, &rc
);
5715 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5716 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5717 /* rounding under Wine is slightly different */
5718 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5719 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc
));
5721 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5723 ret
= GetRgnBox(hrgn
, &rc
);
5724 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5725 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5726 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5737 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5739 expectf(53.033016, ptf
[0].X
);
5740 expectf(0.0, ptf
[0].Y
);
5741 expectf(106.066032, ptf
[1].X
);
5742 expectf(0.0, ptf
[1].Y
);
5743 expectf(79.549522, ptf
[2].X
);
5744 expectf(-26.516510, ptf
[2].Y
);
5745 expectf(79.549522, ptf
[3].X
);
5746 expectf(26.516508, ptf
[3].Y
);
5748 status
= GdipCreateMatrix(&matrix
);
5750 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5752 status
= GdipSetWorldTransform(graphics
, matrix
);
5754 GdipDeleteMatrix(matrix
);
5756 status
= GdipGetClip(graphics
, region
);
5758 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5760 ret
= GetRgnBox(hrgn
, &rc
);
5761 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5762 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5763 /* rounding under Wine is slightly different */
5764 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5765 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc
));
5767 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5769 ret
= GetRgnBox(hrgn
, &rc
);
5770 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5771 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5772 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5783 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5785 expectf(0.0, ptf
[0].X
);
5786 expectf(53.033005, ptf
[0].Y
);
5787 expectf(0.0, ptf
[1].X
);
5788 expectf(106.066010, ptf
[1].Y
);
5789 expectf(26.516491, ptf
[2].X
);
5790 expectf(79.549507, ptf
[2].Y
);
5791 expectf(-26.516520, ptf
[3].X
);
5792 expectf(79.549500, ptf
[3].Y
);
5794 GdipDeleteRegion(region
);
5795 GdipDeleteGraphics(graphics
);
5800 static void test_GdipFillRectangles(void)
5803 GpGraphics
*graphics
= NULL
;
5804 GpBrush
*brush
= NULL
;
5805 HDC hdc
= GetDC( hwnd
);
5806 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5808 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5810 status
= GdipCreateFromHDC(hdc
, &graphics
);
5812 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5814 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5816 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5818 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5819 expect(InvalidParameter
, status
);
5821 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5822 expect(InvalidParameter
, status
);
5824 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5825 expect(InvalidParameter
, status
);
5827 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5828 expect(InvalidParameter
, status
);
5830 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5831 expect(InvalidParameter
, status
);
5833 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5836 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5839 GdipDeleteBrush(brush
);
5840 GdipDeleteGraphics(graphics
);
5842 ReleaseDC(hwnd
, hdc
);
5845 static void test_GdipGetVisibleClipBounds_memoryDC(void)
5854 GpGraphics
* graphics
= NULL
;
5858 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
5859 width
= rect
.right
- rect
.left
;
5860 height
= rect
.bottom
- rect
.top
;
5863 hdc
= CreateCompatibleDC ( dc
);
5864 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
5865 old
= SelectObject (hdc
, bmp
);
5867 /*change the window origin is the key test point*/
5868 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
5870 status
= GdipCreateFromHDC(hdc
, &graphics
);
5873 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5876 ok(boundRect
.X
==rect
.left
+10 &&
5877 boundRect
.Y
==rect
.top
+10 &&
5878 boundRect
.Width
==width
&&
5879 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
5881 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
5884 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5887 ok(boundRect
.X
==rect
.left
+10 &&
5888 boundRect
.Y
==rect
.top
+10 &&
5889 boundRect
.Width
==width
-10 &&
5890 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
5892 GdipDeleteGraphics(graphics
);
5894 SelectObject (hdc
, old
);
5897 ReleaseDC(hwnd
, dc
);
5900 START_TEST(graphics
)
5902 struct GdiplusStartupInput gdiplusStartupInput
;
5903 ULONG_PTR gdiplusToken
;
5906 memset( &class, 0, sizeof(class) );
5907 class.lpszClassName
= "gdiplus_test";
5908 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5909 class.lpfnWndProc
= DefWindowProcA
;
5910 class.hInstance
= GetModuleHandleA(0);
5911 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5912 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5913 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
5914 RegisterClassA( &class );
5915 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5916 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
5917 ok(hwnd
!= NULL
, "Expected window to be created\n");
5919 gdiplusStartupInput
.GdiplusVersion
= 1;
5920 gdiplusStartupInput
.DebugEventCallback
= NULL
;
5921 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
5922 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
5924 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
5928 test_measured_extra_space();
5929 test_measure_string();
5930 test_font_height_scaling();
5932 test_pen_thickness();
5933 test_GdipMeasureString();
5934 test_constructor_destructor();
5935 test_save_restore();
5936 test_GdipFillClosedCurve2();
5937 test_GdipFillClosedCurve2I();
5938 test_GdipDrawBezierI();
5940 test_GdipDrawArcI();
5941 test_GdipDrawCurve();
5942 test_GdipDrawCurveI();
5943 test_GdipDrawCurve2();
5944 test_GdipDrawCurve2I();
5945 test_GdipDrawCurve3();
5946 test_GdipDrawCurve3I();
5947 test_GdipDrawLineI();
5948 test_GdipDrawLinesI();
5949 test_GdipDrawImagePointsRect();
5950 test_GdipFillClosedCurve();
5951 test_GdipFillClosedCurveI();
5952 test_GdipDrawString();
5953 test_GdipGetNearestColor();
5954 test_GdipGetVisibleClipBounds();
5955 test_GdipIsVisiblePoint();
5956 test_GdipIsVisibleRect();
5957 test_Get_Release_DC();
5958 test_BeginContainer2();
5959 test_transformpoints();
5960 test_get_set_clip();
5963 test_textcontrast();
5964 test_fromMemoryBitmap();
5965 test_string_functions();
5966 test_get_set_interpolation();
5967 test_get_set_textrenderinghint();
5968 test_getdc_scaled();
5970 test_bitmapfromgraphics();
5971 test_GdipFillRectangles();
5972 test_GdipGetVisibleClipBounds_memoryDC();
5974 GdiplusShutdown(gdiplusToken
);
5975 DestroyWindow( hwnd
);