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 /* The same state value should never be returned twice. */
331 check_no_duplicates(state_log
);
333 ReleaseDC(hwnd
, hdc
);
336 static void test_GdipFillClosedCurve2(void)
339 GpGraphics
*graphics
= NULL
;
340 GpSolidFill
*brush
= NULL
;
341 HDC hdc
= GetDC( hwnd
);
353 /* make a graphics object and brush object */
354 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
356 status
= GdipCreateFromHDC(hdc
, &graphics
);
358 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
360 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
362 /* InvalidParameter cases: null graphics, null brush, null points */
363 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
364 expect(InvalidParameter
, status
);
366 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
367 expect(InvalidParameter
, status
);
369 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
370 expect(InvalidParameter
, status
);
372 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
373 expect(InvalidParameter
, status
);
375 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
376 expect(InvalidParameter
, status
);
378 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
379 expect(InvalidParameter
, status
);
381 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
382 expect(InvalidParameter
, status
);
384 /* InvalidParameter cases: invalid count */
385 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
386 expect(InvalidParameter
, status
);
388 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
389 expect(InvalidParameter
, status
);
391 /* Valid test cases */
392 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
395 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
398 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
401 GdipDeleteGraphics(graphics
);
402 GdipDeleteBrush((GpBrush
*)brush
);
404 ReleaseDC(hwnd
, hdc
);
407 static void test_GdipFillClosedCurve2I(void)
410 GpGraphics
*graphics
= NULL
;
411 GpSolidFill
*brush
= NULL
;
412 HDC hdc
= GetDC( hwnd
);
424 /* make a graphics object and brush object */
425 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
427 status
= GdipCreateFromHDC(hdc
, &graphics
);
429 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
431 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
433 /* InvalidParameter cases: null graphics, null brush */
434 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
435 when points == NULL, so don't test this condition */
436 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
437 expect(InvalidParameter
, status
);
439 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
440 expect(InvalidParameter
, status
);
442 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
443 expect(InvalidParameter
, status
);
445 /* InvalidParameter cases: invalid count */
446 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
447 expect(InvalidParameter
, status
);
449 /* OutOfMemory cases: large (unsigned) int */
450 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
451 expect(OutOfMemory
, status
);
453 /* Valid test cases */
454 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
457 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
460 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
463 GdipDeleteGraphics(graphics
);
464 GdipDeleteBrush((GpBrush
*)brush
);
466 ReleaseDC(hwnd
, hdc
);
469 static void test_GdipDrawArc(void)
472 GpGraphics
*graphics
= NULL
;
474 HDC hdc
= GetDC( hwnd
);
476 /* make a graphics object and pen object */
477 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
479 status
= GdipCreateFromHDC(hdc
, &graphics
);
481 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
483 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
485 ok(pen
!= NULL
, "Expected pen to be initialized\n");
487 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
488 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
489 expect(InvalidParameter
, status
);
491 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
492 expect(InvalidParameter
, status
);
494 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
495 expect(InvalidParameter
, status
);
497 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
498 expect(InvalidParameter
, status
);
500 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
501 expect(InvalidParameter
, status
);
503 /* successful case */
504 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
508 GdipDeleteGraphics(graphics
);
510 ReleaseDC(hwnd
, hdc
);
513 static void test_GdipDrawArcI(void)
516 GpGraphics
*graphics
= NULL
;
518 HDC hdc
= GetDC( hwnd
);
520 /* make a graphics object and pen object */
521 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
523 status
= GdipCreateFromHDC(hdc
, &graphics
);
525 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
527 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
529 ok(pen
!= NULL
, "Expected pen to be initialized\n");
531 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
532 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
533 expect(InvalidParameter
, status
);
535 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
536 expect(InvalidParameter
, status
);
538 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
539 expect(InvalidParameter
, status
);
541 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
542 expect(InvalidParameter
, status
);
544 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
545 expect(InvalidParameter
, status
);
547 /* successful case */
548 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
552 GdipDeleteGraphics(graphics
);
554 ReleaseDC(hwnd
, hdc
);
557 static void test_BeginContainer2(void)
561 REAL defClip
[] = {5, 10, 15, 20};
562 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
563 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
564 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
565 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
566 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
567 REAL scale
, defScale
= 17;
568 GpUnit unit
, defUnit
= UnitPixel
;
569 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
570 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
571 UINT contrast
, defContrast
= 5;
572 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
575 GpGraphics
*graphics
= NULL
;
576 HDC hdc
= GetDC( hwnd
);
578 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
580 status
= GdipCreateFromHDC(hdc
, &graphics
);
582 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
584 /* null graphics, null container */
585 status
= GdipBeginContainer2(NULL
, &cont1
);
586 expect(InvalidParameter
, status
);
588 status
= GdipBeginContainer2(graphics
, NULL
);
589 expect(InvalidParameter
, status
);
591 status
= GdipEndContainer(NULL
, cont1
);
592 expect(InvalidParameter
, status
);
594 /* test all quality-related values */
595 GdipSetCompositingMode(graphics
, defCompmode
);
596 GdipSetCompositingQuality(graphics
, defCompqual
);
597 GdipSetInterpolationMode(graphics
, defInterp
);
598 GdipSetPageScale(graphics
, defScale
);
599 GdipSetPageUnit(graphics
, defUnit
);
600 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
601 GdipSetSmoothingMode(graphics
, defSmoothmode
);
602 GdipSetTextContrast(graphics
, defContrast
);
603 GdipSetTextRenderingHint(graphics
, defTexthint
);
605 status
= GdipBeginContainer2(graphics
, &cont1
);
608 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
609 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
610 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
611 GdipSetPageScale(graphics
, 10);
612 GdipSetPageUnit(graphics
, UnitDocument
);
613 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
614 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
615 GdipSetTextContrast(graphics
, 7);
616 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
618 status
= GdipEndContainer(graphics
, cont1
);
621 GdipGetCompositingMode(graphics
, &compmode
);
622 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
624 GdipGetCompositingQuality(graphics
, &compqual
);
625 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
627 GdipGetInterpolationMode(graphics
, &interp
);
628 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
630 GdipGetPageScale(graphics
, &scale
);
631 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
633 GdipGetPageUnit(graphics
, &unit
);
634 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
636 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
637 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
639 GdipGetSmoothingMode(graphics
, &smoothmode
);
640 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
642 GdipGetTextContrast(graphics
, &contrast
);
643 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
645 GdipGetTextRenderingHint(graphics
, &texthint
);
646 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
648 /* test world transform */
649 status
= GdipBeginContainer2(graphics
, &cont1
);
652 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
653 defTrans
[4], defTrans
[5], &transform
);
655 GdipSetWorldTransform(graphics
, transform
);
656 GdipDeleteMatrix(transform
);
659 status
= GdipBeginContainer2(graphics
, &cont2
);
662 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
664 GdipSetWorldTransform(graphics
, transform
);
665 GdipDeleteMatrix(transform
);
668 status
= GdipEndContainer(graphics
, cont2
);
671 status
= GdipCreateMatrix(&transform
);
673 GdipGetWorldTransform(graphics
, transform
);
674 GdipGetMatrixElements(transform
, elems
);
675 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
676 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
677 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
678 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
679 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
680 fabs(defTrans
[5] - elems
[5]) < 0.0001,
681 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
682 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
683 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
684 GdipDeleteMatrix(transform
);
687 status
= GdipEndContainer(graphics
, cont1
);
691 status
= GdipBeginContainer2(graphics
, &cont1
);
694 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
696 status
= GdipBeginContainer2(graphics
, &cont2
);
699 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
701 status
= GdipEndContainer(graphics
, cont2
);
704 status
= GdipGetClipBounds(graphics
, &clip
);
707 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
708 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
709 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
710 fabs(defClip
[3] - clip
.Height
) < 0.0001,
711 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
712 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
713 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
715 status
= GdipEndContainer(graphics
, cont1
);
719 status
= GdipBeginContainer2(graphics
, &cont1
);
722 status
= GdipBeginContainer2(graphics
, &cont2
);
725 status
= GdipBeginContainer2(graphics
, &cont3
);
728 status
= GdipEndContainer(graphics
, cont3
);
731 status
= GdipBeginContainer2(graphics
, &cont4
);
734 status
= GdipEndContainer(graphics
, cont4
);
738 status
= GdipEndContainer(graphics
, cont1
);
741 /* end an already-ended container */
742 status
= GdipEndContainer(graphics
, cont1
);
745 GdipDeleteGraphics(graphics
);
746 ReleaseDC(hwnd
, hdc
);
749 static void test_GdipDrawBezierI(void)
752 GpGraphics
*graphics
= NULL
;
754 HDC hdc
= GetDC( hwnd
);
756 /* make a graphics object and pen object */
757 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
759 status
= GdipCreateFromHDC(hdc
, &graphics
);
761 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
763 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
765 ok(pen
!= NULL
, "Expected pen to be initialized\n");
767 /* InvalidParameter cases: null graphics, null pen */
768 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
769 expect(InvalidParameter
, status
);
771 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
772 expect(InvalidParameter
, status
);
774 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
775 expect(InvalidParameter
, status
);
777 /* successful case */
778 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
782 GdipDeleteGraphics(graphics
);
784 ReleaseDC(hwnd
, hdc
);
787 static void test_GdipDrawCurve3(void)
790 GpGraphics
*graphics
= NULL
;
792 HDC hdc
= GetDC( hwnd
);
804 /* make a graphics object and pen object */
805 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
807 status
= GdipCreateFromHDC(hdc
, &graphics
);
809 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
811 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
813 ok(pen
!= NULL
, "Expected pen to be initialized\n");
815 /* InvalidParameter cases: null graphics, null pen */
816 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
817 expect(InvalidParameter
, status
);
819 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
820 expect(InvalidParameter
, status
);
822 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
823 expect(InvalidParameter
, status
);
825 /* InvalidParameter cases: invalid count */
826 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
827 expect(InvalidParameter
, status
);
829 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
830 expect(InvalidParameter
, status
);
832 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
833 expect(InvalidParameter
, status
);
835 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
836 expect(InvalidParameter
, status
);
838 /* InvalidParameter cases: invalid number of segments */
839 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
840 expect(InvalidParameter
, status
);
842 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
843 expect(InvalidParameter
, status
);
845 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
846 expect(InvalidParameter
, status
);
848 /* Valid test cases */
849 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
852 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
855 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
858 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
862 GdipDeleteGraphics(graphics
);
864 ReleaseDC(hwnd
, hdc
);
867 static void test_GdipDrawCurve3I(void)
870 GpGraphics
*graphics
= NULL
;
872 HDC hdc
= GetDC( hwnd
);
884 /* make a graphics object and pen object */
885 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
887 status
= GdipCreateFromHDC(hdc
, &graphics
);
889 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
891 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
893 ok(pen
!= NULL
, "Expected pen to be initialized\n");
895 /* InvalidParameter cases: null graphics, null pen */
896 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
897 expect(InvalidParameter
, status
);
899 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
900 expect(InvalidParameter
, status
);
902 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
903 expect(InvalidParameter
, status
);
905 /* InvalidParameter cases: invalid count */
906 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
907 expect(OutOfMemory
, status
);
909 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
910 expect(InvalidParameter
, status
);
912 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
913 expect(InvalidParameter
, status
);
915 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
916 expect(InvalidParameter
, status
);
918 /* InvalidParameter cases: invalid number of segments */
919 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
920 expect(InvalidParameter
, status
);
922 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
923 expect(InvalidParameter
, status
);
925 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
926 expect(InvalidParameter
, status
);
928 /* Valid test cases */
929 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
932 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
935 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
938 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
942 GdipDeleteGraphics(graphics
);
944 ReleaseDC(hwnd
, hdc
);
947 static void test_GdipDrawCurve2(void)
950 GpGraphics
*graphics
= NULL
;
952 HDC hdc
= GetDC( hwnd
);
964 /* make a graphics object and pen object */
965 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
967 status
= GdipCreateFromHDC(hdc
, &graphics
);
969 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
971 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
973 ok(pen
!= NULL
, "Expected pen to be initialized\n");
975 /* InvalidParameter cases: null graphics, null pen */
976 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
977 expect(InvalidParameter
, status
);
979 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
980 expect(InvalidParameter
, status
);
982 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
983 expect(InvalidParameter
, status
);
985 /* InvalidParameter cases: invalid count */
986 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
987 expect(InvalidParameter
, status
);
989 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
990 expect(InvalidParameter
, status
);
992 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
993 expect(InvalidParameter
, status
);
995 /* Valid test cases */
996 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
999 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1002 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1005 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1009 GdipDeleteGraphics(graphics
);
1011 ReleaseDC(hwnd
, hdc
);
1014 static void test_GdipDrawCurve2I(void)
1017 GpGraphics
*graphics
= NULL
;
1019 HDC hdc
= GetDC( hwnd
);
1031 /* make a graphics object and pen object */
1032 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1034 status
= GdipCreateFromHDC(hdc
, &graphics
);
1036 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1038 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1040 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1042 /* InvalidParameter cases: null graphics, null pen */
1043 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1044 expect(InvalidParameter
, status
);
1046 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1047 expect(InvalidParameter
, status
);
1049 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1050 expect(InvalidParameter
, status
);
1052 /* InvalidParameter cases: invalid count */
1053 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1054 expect(OutOfMemory
, status
);
1056 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1057 expect(InvalidParameter
, status
);
1059 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1060 expect(InvalidParameter
, status
);
1062 /* Valid test cases */
1063 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1066 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1069 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1072 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1076 GdipDeleteGraphics(graphics
);
1078 ReleaseDC(hwnd
, hdc
);
1081 static void test_GdipDrawCurve(void)
1084 GpGraphics
*graphics
= NULL
;
1086 HDC hdc
= GetDC( hwnd
);
1098 /* make a graphics object and pen object */
1099 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1101 status
= GdipCreateFromHDC(hdc
, &graphics
);
1103 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1105 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1107 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1109 /* InvalidParameter cases: null graphics, null pen */
1110 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1111 expect(InvalidParameter
, status
);
1113 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1114 expect(InvalidParameter
, status
);
1116 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1117 expect(InvalidParameter
, status
);
1119 /* InvalidParameter cases: invalid count */
1120 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1121 expect(InvalidParameter
, status
);
1123 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1124 expect(InvalidParameter
, status
);
1126 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1127 expect(InvalidParameter
, status
);
1129 /* Valid test cases */
1130 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1133 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1137 GdipDeleteGraphics(graphics
);
1139 ReleaseDC(hwnd
, hdc
);
1142 static void test_GdipDrawCurveI(void)
1145 GpGraphics
*graphics
= NULL
;
1147 HDC hdc
= GetDC( hwnd
);
1159 /* make a graphics object and pen object */
1160 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1162 status
= GdipCreateFromHDC(hdc
, &graphics
);
1164 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1166 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1168 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1170 /* InvalidParameter cases: null graphics, null pen */
1171 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1172 expect(InvalidParameter
, status
);
1174 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1175 expect(InvalidParameter
, status
);
1177 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1178 expect(InvalidParameter
, status
);
1180 /* InvalidParameter cases: invalid count */
1181 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1182 expect(OutOfMemory
, status
);
1184 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1185 expect(InvalidParameter
, status
);
1187 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1188 expect(InvalidParameter
, status
);
1190 /* Valid test cases */
1191 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1194 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1198 GdipDeleteGraphics(graphics
);
1200 ReleaseDC(hwnd
, hdc
);
1203 static void test_GdipDrawLineI(void)
1206 GpGraphics
*graphics
= NULL
;
1208 HDC hdc
= GetDC( hwnd
);
1210 /* make a graphics object and pen object */
1211 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1213 status
= GdipCreateFromHDC(hdc
, &graphics
);
1215 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1217 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1219 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1221 /* InvalidParameter cases: null graphics, null pen */
1222 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1223 expect(InvalidParameter
, status
);
1225 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1226 expect(InvalidParameter
, status
);
1228 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1229 expect(InvalidParameter
, status
);
1231 /* successful case */
1232 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1236 GdipDeleteGraphics(graphics
);
1238 ReleaseDC(hwnd
, hdc
);
1241 static void test_GdipDrawImagePointsRect(void)
1244 GpGraphics
*graphics
= NULL
;
1246 GpBitmap
*bm
= NULL
;
1247 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1249 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1250 HDC hdc
= GetDC( hwnd
);
1254 memset(rbmi
, 0, sizeof(rbmi
));
1255 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1256 bmi
->bmiHeader
.biWidth
= 10;
1257 bmi
->bmiHeader
.biHeight
= 10;
1258 bmi
->bmiHeader
.biPlanes
= 1;
1259 bmi
->bmiHeader
.biBitCount
= 32;
1260 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1261 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1263 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1264 status
= GdipCreateFromHDC(hdc
, &graphics
);
1274 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1275 expect(NotImplemented
, status
);
1276 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1277 expect(InvalidParameter
, status
);
1278 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1280 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1281 expect(InvalidParameter
, status
);
1282 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1283 expect(InvalidParameter
, status
);
1284 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1286 memset(ptf
, 0, sizeof(ptf
));
1287 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1290 GdipDisposeImage((GpImage
*)bm
);
1291 GdipDeleteGraphics(graphics
);
1292 ReleaseDC(hwnd
, hdc
);
1295 static void test_GdipDrawLinesI(void)
1298 GpGraphics
*graphics
= NULL
;
1300 GpPoint
*ptf
= NULL
;
1301 HDC hdc
= GetDC( hwnd
);
1303 /* make a graphics object and pen object */
1304 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1306 status
= GdipCreateFromHDC(hdc
, &graphics
);
1308 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1310 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1312 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1314 /* make some arbitrary valid points*/
1315 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1323 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1324 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1325 expect(InvalidParameter
, status
);
1327 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1328 expect(InvalidParameter
, status
);
1330 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1331 expect(InvalidParameter
, status
);
1333 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1334 expect(InvalidParameter
, status
);
1336 /* successful case */
1337 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1342 GdipDeleteGraphics(graphics
);
1344 ReleaseDC(hwnd
, hdc
);
1347 static void test_GdipFillClosedCurve(void)
1350 GpGraphics
*graphics
= NULL
;
1351 GpSolidFill
*brush
= NULL
;
1352 HDC hdc
= GetDC( hwnd
);
1364 /* make a graphics object and brush object */
1365 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1367 status
= GdipCreateFromHDC(hdc
, &graphics
);
1369 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1371 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1373 /* InvalidParameter cases: null graphics, null brush, null points */
1374 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1375 expect(InvalidParameter
, status
);
1377 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1378 expect(InvalidParameter
, status
);
1380 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1381 expect(InvalidParameter
, status
);
1383 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1384 expect(InvalidParameter
, status
);
1386 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1387 expect(InvalidParameter
, status
);
1389 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1390 expect(InvalidParameter
, status
);
1392 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1393 expect(InvalidParameter
, status
);
1395 /* InvalidParameter cases: invalid count */
1396 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1397 expect(InvalidParameter
, status
);
1399 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1400 expect(InvalidParameter
, status
);
1402 /* Valid test cases */
1403 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1406 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1409 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1412 GdipDeleteGraphics(graphics
);
1413 GdipDeleteBrush((GpBrush
*)brush
);
1415 ReleaseDC(hwnd
, hdc
);
1418 static void test_GdipFillClosedCurveI(void)
1421 GpGraphics
*graphics
= NULL
;
1422 GpSolidFill
*brush
= NULL
;
1423 HDC hdc
= GetDC( hwnd
);
1435 /* make a graphics object and brush object */
1436 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1438 status
= GdipCreateFromHDC(hdc
, &graphics
);
1440 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1442 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1444 /* InvalidParameter cases: null graphics, null brush */
1445 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1446 when points == NULL, so don't test this condition */
1447 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1448 expect(InvalidParameter
, status
);
1450 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1451 expect(InvalidParameter
, status
);
1453 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1454 expect(InvalidParameter
, status
);
1456 /* InvalidParameter cases: invalid count */
1457 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1458 expect(InvalidParameter
, status
);
1460 /* OutOfMemory cases: large (unsigned) int */
1461 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1462 expect(OutOfMemory
, status
);
1464 /* Valid test cases */
1465 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1468 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1471 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1474 GdipDeleteGraphics(graphics
);
1475 GdipDeleteBrush((GpBrush
*)brush
);
1477 ReleaseDC(hwnd
, hdc
);
1480 static void test_Get_Release_DC(void)
1483 GpGraphics
*graphics
= NULL
;
1487 HDC hdc
= GetDC( hwnd
);
1490 CompositingQuality quality
;
1491 CompositingMode compmode
;
1492 InterpolationMode intmode
;
1496 PixelOffsetMode offsetmode
;
1497 SmoothingMode smoothmode
;
1498 TextRenderingHint texthint
;
1506 ARGB color
= 0x00000000;
1507 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1520 for(i
= 0; i
< 5;i
++){
1521 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1522 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1528 rect
[0].Height
= 70;
1532 rect
[1].Height
= 20;
1534 for(i
= 0; i
< 2;i
++){
1535 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1536 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1537 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1538 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1541 status
= GdipCreateMatrix(&m
);
1543 GdipCreateRegion(®ion
);
1544 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1545 GdipCreatePath(FillModeAlternate
, &path
);
1546 GdipCreateRegion(&clip
);
1548 status
= GdipCreateFromHDC(hdc
, &graphics
);
1550 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1551 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1554 /* NULL arguments */
1555 status
= GdipGetDC(NULL
, NULL
);
1556 expect(InvalidParameter
, status
);
1557 status
= GdipGetDC(graphics
, NULL
);
1558 expect(InvalidParameter
, status
);
1559 status
= GdipGetDC(NULL
, &retdc
);
1560 expect(InvalidParameter
, status
);
1562 status
= GdipReleaseDC(NULL
, NULL
);
1563 expect(InvalidParameter
, status
);
1564 status
= GdipReleaseDC(graphics
, NULL
);
1565 expect(InvalidParameter
, status
);
1566 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1567 expect(InvalidParameter
, status
);
1569 /* Release without Get */
1570 status
= GdipReleaseDC(graphics
, hdc
);
1571 expect(InvalidParameter
, status
);
1574 status
= GdipGetDC(graphics
, &retdc
);
1576 ok(retdc
== hdc
, "Invalid HDC returned\n");
1577 /* call it once more */
1578 status
= GdipGetDC(graphics
, &retdc
);
1579 expect(ObjectBusy
, status
);
1581 /* try all Graphics calls here */
1582 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1583 expect(ObjectBusy
, status
);
1584 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1585 expect(ObjectBusy
, status
);
1586 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1587 expect(ObjectBusy
, status
);
1588 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1589 expect(ObjectBusy
, status
);
1590 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1591 expect(ObjectBusy
, status
);
1592 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1593 expect(ObjectBusy
, status
);
1594 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1595 expect(ObjectBusy
, status
);
1596 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1597 expect(ObjectBusy
, status
);
1598 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1599 expect(ObjectBusy
, status
);
1600 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1601 expect(ObjectBusy
, status
);
1602 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1603 expect(ObjectBusy
, status
);
1604 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1605 expect(ObjectBusy
, status
);
1606 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1607 expect(ObjectBusy
, status
);
1608 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1609 expect(ObjectBusy
, status
);
1610 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1611 expect(ObjectBusy
, status
);
1612 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1613 expect(ObjectBusy
, status
);
1614 /* GdipDrawImage/GdipDrawImageI */
1615 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1616 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1617 /* GdipDrawImageRect/GdipDrawImageRectI */
1618 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1619 expect(ObjectBusy
, status
);
1620 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1621 expect(ObjectBusy
, status
);
1622 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1623 expect(ObjectBusy
, status
);
1624 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1625 expect(ObjectBusy
, status
);
1626 status
= GdipDrawPath(graphics
, pen
, path
);
1627 expect(ObjectBusy
, status
);
1628 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1629 expect(ObjectBusy
, status
);
1630 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1631 expect(ObjectBusy
, status
);
1632 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1633 expect(ObjectBusy
, status
);
1634 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1635 expect(ObjectBusy
, status
);
1636 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1637 expect(ObjectBusy
, status
);
1638 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1639 expect(ObjectBusy
, status
);
1640 /* GdipDrawString */
1641 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1642 expect(ObjectBusy
, status
);
1643 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1644 expect(ObjectBusy
, status
);
1645 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1646 expect(ObjectBusy
, status
);
1647 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1648 expect(ObjectBusy
, status
);
1649 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1650 expect(ObjectBusy
, status
);
1651 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1652 expect(ObjectBusy
, status
);
1653 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1654 expect(ObjectBusy
, status
);
1655 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1656 expect(ObjectBusy
, status
);
1657 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1658 expect(ObjectBusy
, status
);
1659 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1660 expect(ObjectBusy
, status
);
1661 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1662 expect(ObjectBusy
, status
);
1663 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1664 expect(ObjectBusy
, status
);
1665 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1666 expect(ObjectBusy
, status
);
1667 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1668 expect(ObjectBusy
, status
);
1669 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1670 expect(ObjectBusy
, status
);
1671 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1672 expect(ObjectBusy
, status
);
1673 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1674 expect(ObjectBusy
, status
);
1675 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1676 expect(ObjectBusy
, status
);
1677 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1678 expect(ObjectBusy
, status
);
1679 status
= GdipGetClipBounds(graphics
, rectf
);
1680 expect(ObjectBusy
, status
);
1681 status
= GdipGetClipBoundsI(graphics
, rect
);
1682 expect(ObjectBusy
, status
);
1683 status
= GdipGetCompositingMode(graphics
, &compmode
);
1684 expect(ObjectBusy
, status
);
1685 status
= GdipGetCompositingQuality(graphics
, &quality
);
1686 expect(ObjectBusy
, status
);
1687 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1688 expect(ObjectBusy
, status
);
1689 status
= GdipGetNearestColor(graphics
, &color
);
1690 expect(ObjectBusy
, status
);
1691 status
= GdipGetPageScale(graphics
, &r
);
1692 expect(ObjectBusy
, status
);
1693 status
= GdipGetPageUnit(graphics
, &unit
);
1694 expect(ObjectBusy
, status
);
1695 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1696 expect(ObjectBusy
, status
);
1697 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1698 expect(ObjectBusy
, status
);
1699 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1700 expect(ObjectBusy
, status
);
1701 status
= GdipGetWorldTransform(graphics
, m
);
1702 expect(ObjectBusy
, status
);
1703 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1704 expect(ObjectBusy
, status
);
1705 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1706 expect(ObjectBusy
, status
);
1707 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1708 expect(ObjectBusy
, status
);
1709 /* GdipMeasureCharacterRanges */
1710 /* GdipMeasureString */
1711 status
= GdipResetClip(graphics
);
1712 expect(ObjectBusy
, status
);
1713 status
= GdipResetWorldTransform(graphics
);
1714 expect(ObjectBusy
, status
);
1715 /* GdipRestoreGraphics */
1716 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1717 expect(ObjectBusy
, status
);
1718 /* GdipSaveGraphics */
1719 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1720 expect(ObjectBusy
, status
);
1721 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1722 expect(ObjectBusy
, status
);
1723 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1724 expect(ObjectBusy
, status
);
1725 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1726 expect(ObjectBusy
, status
);
1727 status
= GdipSetPageScale(graphics
, 1.0);
1728 expect(ObjectBusy
, status
);
1729 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1730 expect(ObjectBusy
, status
);
1731 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1732 expect(ObjectBusy
, status
);
1733 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1734 expect(ObjectBusy
, status
);
1735 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1736 expect(ObjectBusy
, status
);
1737 status
= GdipSetWorldTransform(graphics
, m
);
1738 expect(ObjectBusy
, status
);
1739 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1740 expect(ObjectBusy
, status
);
1741 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1742 expect(ObjectBusy
, status
);
1743 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1744 expect(ObjectBusy
, status
);
1745 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1746 expect(ObjectBusy
, status
);
1747 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1748 expect(ObjectBusy
, status
);
1749 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1750 expect(ObjectBusy
, status
);
1751 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1752 expect(ObjectBusy
, status
);
1753 status
= GdipTranslateClipI(graphics
, 0, 0);
1754 expect(ObjectBusy
, status
);
1755 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1756 expect(ObjectBusy
, status
);
1757 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1758 expect(ObjectBusy
, status
);
1759 status
= GdipGetDpiX(graphics
, &r
);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipGetDpiY(graphics
, &r
);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1764 expect(ObjectBusy
, status
);
1765 status
= GdipGetClip(graphics
, region
);
1766 expect(ObjectBusy
, status
);
1767 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1768 expect(ObjectBusy
, status
);
1770 /* try to delete before release */
1771 status
= GdipDeleteGraphics(graphics
);
1772 expect(ObjectBusy
, status
);
1774 status
= GdipReleaseDC(graphics
, retdc
);
1778 GdipDeleteGraphics(graphics
);
1780 GdipDeleteRegion(clip
);
1781 GdipDeletePath(path
);
1782 GdipDeleteBrush((GpBrush
*)brush
);
1783 GdipDeleteRegion(region
);
1784 GdipDeleteMatrix(m
);
1787 ReleaseDC(hwnd
, hdc
);
1790 static void test_transformpoints(void)
1793 GpGraphics
*graphics
= NULL
;
1794 HDC hdc
= GetDC( hwnd
);
1798 status
= GdipCreateFromHDC(hdc
, &graphics
);
1801 /* NULL arguments */
1802 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1803 expect(InvalidParameter
, status
);
1804 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1805 expect(InvalidParameter
, status
);
1806 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1807 expect(InvalidParameter
, status
);
1808 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1809 expect(InvalidParameter
, status
);
1815 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1817 expectf(1.0, ptf
[0].X
);
1818 expectf(0.0, ptf
[0].Y
);
1819 expectf(0.0, ptf
[1].X
);
1820 expectf(1.0, ptf
[1].Y
);
1822 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1824 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1826 status
= GdipSetPageScale(graphics
, 3.0);
1833 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1835 expectf(18.0, ptf
[0].X
);
1836 expectf(15.0, ptf
[0].Y
);
1837 expectf(15.0, ptf
[1].X
);
1838 expectf(18.0, ptf
[1].Y
);
1844 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1846 expectf(6.0, ptf
[0].X
);
1847 expectf(5.0, ptf
[0].Y
);
1848 expectf(5.0, ptf
[1].X
);
1849 expectf(6.0, ptf
[1].Y
);
1855 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1857 expectf(3.0, ptf
[0].X
);
1858 expectf(0.0, ptf
[0].Y
);
1859 expectf(0.0, ptf
[1].X
);
1860 expectf(3.0, ptf
[1].Y
);
1866 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1868 expectf(1.0, ptf
[0].X
);
1869 expectf(0.0, ptf
[0].Y
);
1870 expectf(0.0, ptf
[1].X
);
1871 expectf(1.0, ptf
[1].Y
);
1877 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1879 expectf(1.0, ptf
[0].X
);
1880 expectf(0.0, ptf
[0].Y
);
1881 expectf(0.0, ptf
[1].X
);
1882 expectf(1.0, ptf
[1].Y
);
1888 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1890 expectf(1.0, ptf
[0].X
);
1891 expectf(0.0, ptf
[0].Y
);
1892 expectf(0.0, ptf
[1].X
);
1893 expectf(1.0, ptf
[1].Y
);
1899 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1901 expect(18, pt
[0].X
);
1902 expect(15, pt
[0].Y
);
1903 expect(15, pt
[1].X
);
1904 expect(18, pt
[1].Y
);
1906 GdipDeleteGraphics(graphics
);
1907 ReleaseDC(hwnd
, hdc
);
1910 static void test_get_set_clip(void)
1913 GpGraphics
*graphics
= NULL
;
1914 HDC hdc
= GetDC( hwnd
);
1919 status
= GdipCreateFromHDC(hdc
, &graphics
);
1922 rect
.X
= rect
.Y
= 0.0;
1923 rect
.Height
= rect
.Width
= 100.0;
1925 status
= GdipCreateRegionRect(&rect
, &clip
);
1928 /* NULL arguments */
1929 status
= GdipGetClip(NULL
, NULL
);
1930 expect(InvalidParameter
, status
);
1931 status
= GdipGetClip(graphics
, NULL
);
1932 expect(InvalidParameter
, status
);
1933 status
= GdipGetClip(NULL
, clip
);
1934 expect(InvalidParameter
, status
);
1936 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1937 expect(InvalidParameter
, status
);
1938 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1939 expect(InvalidParameter
, status
);
1941 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1942 expect(InvalidParameter
, status
);
1943 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1944 expect(InvalidParameter
, status
);
1947 status
= GdipGetClip(graphics
, clip
);
1949 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1953 /* remains infinite after reset */
1955 status
= GdipResetClip(graphics
);
1957 status
= GdipGetClip(graphics
, clip
);
1959 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1963 /* set to empty and then reset to infinite */
1964 status
= GdipSetEmpty(clip
);
1966 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1969 status
= GdipGetClip(graphics
, clip
);
1972 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1975 status
= GdipResetClip(graphics
);
1977 status
= GdipGetClip(graphics
, clip
);
1980 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1984 GdipDeleteRegion(clip
);
1986 GdipDeleteGraphics(graphics
);
1987 ReleaseDC(hwnd
, hdc
);
1990 static void test_isempty(void)
1993 GpGraphics
*graphics
= NULL
;
1994 HDC hdc
= GetDC( hwnd
);
1998 status
= GdipCreateFromHDC(hdc
, &graphics
);
2001 status
= GdipCreateRegion(&clip
);
2005 status
= GdipIsClipEmpty(NULL
, NULL
);
2006 expect(InvalidParameter
, status
);
2007 status
= GdipIsClipEmpty(graphics
, NULL
);
2008 expect(InvalidParameter
, status
);
2009 status
= GdipIsClipEmpty(NULL
, &res
);
2010 expect(InvalidParameter
, status
);
2012 /* default is infinite */
2014 status
= GdipIsClipEmpty(graphics
, &res
);
2018 GdipDeleteRegion(clip
);
2020 GdipDeleteGraphics(graphics
);
2021 ReleaseDC(hwnd
, hdc
);
2024 static void test_clear(void)
2028 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2029 expect(InvalidParameter
, status
);
2032 static void test_textcontrast(void)
2035 HDC hdc
= GetDC( hwnd
);
2036 GpGraphics
*graphics
;
2039 status
= GdipGetTextContrast(NULL
, NULL
);
2040 expect(InvalidParameter
, status
);
2042 status
= GdipCreateFromHDC(hdc
, &graphics
);
2045 status
= GdipGetTextContrast(graphics
, NULL
);
2046 expect(InvalidParameter
, status
);
2047 status
= GdipGetTextContrast(graphics
, &contrast
);
2049 expect(4, contrast
);
2051 GdipDeleteGraphics(graphics
);
2052 ReleaseDC(hwnd
, hdc
);
2055 static void test_GdipDrawString(void)
2058 GpGraphics
*graphics
= NULL
;
2061 GpStringFormat
*format
;
2064 HDC hdc
= GetDC( hwnd
);
2065 static const WCHAR string
[] = {'T','e','s','t',0};
2066 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2069 memset(&logfont
,0,sizeof(logfont
));
2070 strcpy(logfont
.lfFaceName
,"Arial");
2071 logfont
.lfHeight
= 12;
2072 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2074 status
= GdipCreateFromHDC(hdc
, &graphics
);
2077 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2078 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2080 skip("Arial not installed.\n");
2085 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2088 status
= GdipCreateStringFormat(0,0,&format
);
2096 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2099 status
= GdipCreateMatrix(&matrix
);
2102 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2103 expect(InvalidParameter
, status
);
2105 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2106 expect(InvalidParameter
, status
);
2108 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2109 expect(InvalidParameter
, status
);
2111 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2112 expect(InvalidParameter
, status
);
2114 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2115 expect(InvalidParameter
, status
);
2117 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2120 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2123 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2126 GdipDeleteMatrix(matrix
);
2127 GdipDeleteGraphics(graphics
);
2128 GdipDeleteBrush(brush
);
2129 GdipDeleteFont(fnt
);
2130 GdipDeleteStringFormat(format
);
2132 ReleaseDC(hwnd
, hdc
);
2135 static void test_GdipGetVisibleClipBounds_screen(void)
2138 GpGraphics
*graphics
= NULL
;
2140 GpRectF rectf
, exp
, clipr
;
2143 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2145 status
= GdipCreateFromHDC(hdc
, &graphics
);
2147 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2149 /* no clipping rect */
2152 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2153 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2155 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2157 ok(rectf
.X
== exp
.X
&&
2159 rectf
.Width
== exp
.Width
&&
2160 rectf
.Height
== exp
.Height
,
2161 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2162 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2163 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2164 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2166 /* clipping rect entirely within window */
2167 exp
.X
= clipr
.X
= 10;
2168 exp
.Y
= clipr
.Y
= 12;
2169 exp
.Width
= clipr
.Width
= 14;
2170 exp
.Height
= clipr
.Height
= 16;
2172 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2175 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2177 ok(rectf
.X
== exp
.X
&&
2179 rectf
.Width
== exp
.Width
&&
2180 rectf
.Height
== exp
.Height
,
2181 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2182 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2183 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2184 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2186 /* clipping rect partially outside of screen */
2192 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2200 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2202 ok(rectf
.X
== exp
.X
&&
2204 rectf
.Width
== exp
.Width
&&
2205 rectf
.Height
== exp
.Height
,
2206 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2207 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2208 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2209 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2211 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2213 ok(recti
.X
== exp
.X
&&
2215 recti
.Width
== exp
.Width
&&
2216 recti
.Height
== exp
.Height
,
2217 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2218 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2219 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2220 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2222 GdipDeleteGraphics(graphics
);
2226 static void test_GdipGetVisibleClipBounds_window(void)
2229 GpGraphics
*graphics
= NULL
;
2230 GpRectF rectf
, window
, exp
, clipr
;
2236 /* get client area size */
2237 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2238 window
.X
= wnd_rect
.left
;
2239 window
.Y
= wnd_rect
.top
;
2240 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2241 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2243 hdc
= BeginPaint(hwnd
, &ps
);
2245 status
= GdipCreateFromHDC(hdc
, &graphics
);
2247 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2249 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2251 ok(rectf
.X
== window
.X
&&
2252 rectf
.Y
== window
.Y
&&
2253 rectf
.Width
== window
.Width
&&
2254 rectf
.Height
== window
.Height
,
2255 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2256 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2257 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2258 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2260 /* clipping rect entirely within window */
2261 exp
.X
= clipr
.X
= 20;
2262 exp
.Y
= clipr
.Y
= 8;
2263 exp
.Width
= clipr
.Width
= 30;
2264 exp
.Height
= clipr
.Height
= 20;
2266 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2269 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2271 ok(rectf
.X
== exp
.X
&&
2273 rectf
.Width
== exp
.Width
&&
2274 rectf
.Height
== exp
.Height
,
2275 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2276 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2277 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2278 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2280 /* clipping rect partially outside of window */
2281 clipr
.X
= window
.Width
- 10;
2282 clipr
.Y
= window
.Height
- 15;
2286 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2289 exp
.X
= window
.Width
- 10;
2290 exp
.Y
= window
.Height
- 15;
2294 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2296 ok(rectf
.X
== exp
.X
&&
2298 rectf
.Width
== exp
.Width
&&
2299 rectf
.Height
== exp
.Height
,
2300 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2301 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2302 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2303 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2305 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2307 ok(recti
.X
== exp
.X
&&
2309 recti
.Width
== exp
.Width
&&
2310 recti
.Height
== exp
.Height
,
2311 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2312 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2313 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2314 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2316 GdipDeleteGraphics(graphics
);
2317 EndPaint(hwnd
, &ps
);
2320 static void test_GdipGetVisibleClipBounds(void)
2322 GpGraphics
* graphics
= NULL
;
2325 HDC hdc
= GetDC( hwnd
);
2328 status
= GdipCreateFromHDC(hdc
, &graphics
);
2330 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2332 /* test null parameters */
2333 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2334 expect(InvalidParameter
, status
);
2336 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2337 expect(InvalidParameter
, status
);
2339 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2340 expect(InvalidParameter
, status
);
2342 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2343 expect(InvalidParameter
, status
);
2345 GdipDeleteGraphics(graphics
);
2346 ReleaseDC(hwnd
, hdc
);
2348 test_GdipGetVisibleClipBounds_screen();
2349 test_GdipGetVisibleClipBounds_window();
2352 static void test_fromMemoryBitmap(void)
2355 GpGraphics
*graphics
= NULL
;
2356 GpBitmap
*bitmap
= NULL
;
2357 BYTE bits
[48] = {0};
2361 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2364 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2367 status
= GdipGraphicsClear(graphics
, 0xff686868);
2370 GdipDeleteGraphics(graphics
);
2372 /* drawing writes to the memory provided */
2373 expect(0x68, bits
[10]);
2375 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2378 status
= GdipGetDC(graphics
, &hdc
);
2380 ok(hdc
!= NULL
, "got NULL hdc\n");
2382 color
= GetPixel(hdc
, 0, 0);
2383 /* The HDC is write-only, and native fills with a solid color to figure out
2384 * which pixels have changed. */
2385 todo_wine
expect(0x0c0b0d, color
);
2387 SetPixel(hdc
, 0, 0, 0x797979);
2388 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2390 status
= GdipReleaseDC(graphics
, hdc
);
2393 GdipDeleteGraphics(graphics
);
2395 expect(0x79, bits
[0]);
2396 todo_wine
expect(0x68, bits
[3]);
2398 GdipDisposeImage((GpImage
*)bitmap
);
2400 /* We get the same kind of write-only HDC for a "normal" bitmap */
2401 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2404 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2407 status
= GdipGetDC(graphics
, &hdc
);
2409 ok(hdc
!= NULL
, "got NULL hdc\n");
2411 color
= GetPixel(hdc
, 0, 0);
2412 todo_wine
expect(0x0c0b0d, color
);
2414 status
= GdipReleaseDC(graphics
, hdc
);
2417 GdipDeleteGraphics(graphics
);
2419 GdipDisposeImage((GpImage
*)bitmap
);
2422 static void test_GdipIsVisiblePoint(void)
2425 GpGraphics
*graphics
= NULL
;
2426 HDC hdc
= GetDC( hwnd
);
2430 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2432 status
= GdipCreateFromHDC(hdc
, &graphics
);
2434 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2436 /* null parameters */
2437 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2438 expect(InvalidParameter
, status
);
2440 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2441 expect(InvalidParameter
, status
);
2443 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2444 expect(InvalidParameter
, status
);
2446 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2447 expect(InvalidParameter
, status
);
2451 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2453 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2457 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2459 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2463 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2465 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2469 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2471 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2473 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2478 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2480 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2484 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2486 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2488 /* translate into the center of the rect */
2489 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2493 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2495 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2499 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2501 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2503 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2508 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2510 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2514 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2516 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2520 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2522 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2526 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2528 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2532 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2534 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2538 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2540 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2544 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2546 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2550 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2552 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2556 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2558 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2562 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2564 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2568 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2570 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2574 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2576 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2580 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2582 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2584 /* integer version */
2587 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2589 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2593 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2595 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2597 GdipDeleteGraphics(graphics
);
2598 ReleaseDC(hwnd
, hdc
);
2601 static void test_GdipIsVisibleRect(void)
2604 GpGraphics
*graphics
= NULL
;
2605 HDC hdc
= GetDC( hwnd
);
2606 REAL x
, y
, width
, height
;
2609 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2611 status
= GdipCreateFromHDC(hdc
, &graphics
);
2613 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2615 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2616 expect(InvalidParameter
, status
);
2618 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2619 expect(InvalidParameter
, status
);
2621 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2622 expect(InvalidParameter
, status
);
2624 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2625 expect(InvalidParameter
, status
);
2627 /* entirely within the visible region */
2630 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2632 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2634 /* partially outside */
2635 x
= -10; width
= 20;
2636 y
= -10; height
= 20;
2637 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2639 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2641 /* entirely outside */
2643 y
= -10; height
= 5;
2644 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2646 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2648 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2651 /* entirely within the visible region */
2653 y
= 22; height
= 10;
2654 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2656 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2658 /* partially outside */
2660 y
= 55; height
= 10;
2661 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2663 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2665 /* entirely outside */
2668 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2670 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2672 /* translate into center of clipping rect */
2673 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2677 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2679 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2683 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2685 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2687 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2689 /* corners entirely outside, but some intersections */
2692 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2694 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2698 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2700 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2704 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2706 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2710 y
= 20; height
= 40;
2711 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2713 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2717 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2719 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2722 y
= 20; height
= 40;
2723 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2725 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2728 y
= 60; height
= 10;
2729 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2731 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2733 /* rounding tests */
2734 x
= 0.4; width
= 10.4;
2735 y
= 20; height
= 40;
2736 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2738 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2741 y
= 0.4; height
= 20.4;
2742 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2744 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2746 /* integer version */
2749 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2751 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2754 y
= 22; height
= 10;
2755 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2757 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2759 GdipDeleteGraphics(graphics
);
2760 ReleaseDC(hwnd
, hdc
);
2763 static void test_GdipGetNearestColor(void)
2766 GpGraphics
*graphics
;
2768 ARGB color
= 0xdeadbeef;
2769 HDC hdc
= GetDC( hwnd
);
2771 /* create a graphics object */
2772 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2774 status
= GdipCreateFromHDC(hdc
, &graphics
);
2776 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2778 status
= GdipGetNearestColor(graphics
, NULL
);
2779 expect(InvalidParameter
, status
);
2781 status
= GdipGetNearestColor(NULL
, &color
);
2782 expect(InvalidParameter
, status
);
2783 GdipDeleteGraphics(graphics
);
2785 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2787 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2788 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2791 status
= GdipGetNearestColor(graphics
, &color
);
2793 expect(0xdeadbeef, color
);
2794 GdipDeleteGraphics(graphics
);
2796 GdipDisposeImage((GpImage
*)bitmap
);
2798 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2800 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2801 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2804 status
= GdipGetNearestColor(graphics
, &color
);
2806 expect(0xdeadbeef, color
);
2807 GdipDeleteGraphics(graphics
);
2809 GdipDisposeImage((GpImage
*)bitmap
);
2811 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2813 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2814 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2817 status
= GdipGetNearestColor(graphics
, &color
);
2819 expect(0xdeadbeef, color
);
2820 GdipDeleteGraphics(graphics
);
2822 GdipDisposeImage((GpImage
*)bitmap
);
2824 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2826 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2827 todo_wine
expect(OutOfMemory
, status
);
2829 GdipDeleteGraphics(graphics
);
2830 GdipDisposeImage((GpImage
*)bitmap
);
2832 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2834 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2836 status
= GdipGetNearestColor(graphics
, &color
);
2838 expect(0xdeadbeef, color
);
2839 GdipDeleteGraphics(graphics
);
2840 GdipDisposeImage((GpImage
*)bitmap
);
2842 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2844 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2846 status
= GdipGetNearestColor(graphics
, &color
);
2848 expect(0xdeadbeef, color
);
2849 GdipDeleteGraphics(graphics
);
2850 GdipDisposeImage((GpImage
*)bitmap
);
2852 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2854 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2856 status
= GdipGetNearestColor(graphics
, &color
);
2858 expect(0xdeadbeef, color
);
2859 GdipDeleteGraphics(graphics
);
2860 GdipDisposeImage((GpImage
*)bitmap
);
2862 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2866 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2868 status
= GdipGetNearestColor(graphics
, &color
);
2870 expect(0xdeadbeef, color
);
2871 GdipDeleteGraphics(graphics
);
2872 GdipDisposeImage((GpImage
*)bitmap
);
2875 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2879 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2881 status
= GdipGetNearestColor(graphics
, &color
);
2883 expect(0xdeadbeef, color
);
2884 GdipDeleteGraphics(graphics
);
2885 GdipDisposeImage((GpImage
*)bitmap
);
2888 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2892 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2894 status
= GdipGetNearestColor(graphics
, &color
);
2896 expect(0xdeadbeef, color
);
2897 GdipDeleteGraphics(graphics
);
2898 GdipDisposeImage((GpImage
*)bitmap
);
2901 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2903 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2905 status
= GdipGetNearestColor(graphics
, &color
);
2907 todo_wine
expect(0xffa8bce8, color
);
2908 GdipDeleteGraphics(graphics
);
2909 GdipDisposeImage((GpImage
*)bitmap
);
2911 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2913 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2915 status
= GdipGetNearestColor(graphics
, &color
);
2918 ok(color
== 0xffa8b8e8 ||
2919 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2920 "Expected ffa8b8e8, got %.8x\n", color
);
2921 GdipDeleteGraphics(graphics
);
2922 GdipDisposeImage((GpImage
*)bitmap
);
2924 ReleaseDC(hwnd
, hdc
);
2927 static void test_string_functions(void)
2930 GpGraphics
*graphics
;
2931 GpFontFamily
*family
;
2933 RectF rc
, char_bounds
, bounds
;
2935 ARGB color
= 0xff000000;
2936 HDC hdc
= GetDC( hwnd
);
2937 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2938 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2939 const WCHAR teststring2
[] = {'j',0};
2940 REAL char_width
, char_height
;
2941 INT codepointsfitted
, linesfilled
;
2942 GpStringFormat
*format
;
2943 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2944 GpRegion
*regions
[4];
2945 BOOL region_isempty
[4];
2947 PointF positions
[8];
2950 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2951 status
= GdipCreateFromHDC(hdc
, &graphics
);
2953 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2955 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2958 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2961 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2964 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2972 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2973 expect(InvalidParameter
, status
);
2975 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2976 expect(InvalidParameter
, status
);
2978 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2979 expect(InvalidParameter
, status
);
2981 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2982 expect(InvalidParameter
, status
);
2984 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2985 expect(InvalidParameter
, status
);
2987 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
2990 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2991 expect(InvalidParameter
, status
);
2993 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2994 expect(InvalidParameter
, status
);
2996 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
2997 expect(InvalidParameter
, status
);
2999 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3000 expect(InvalidParameter
, status
);
3002 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3003 expect(InvalidParameter
, status
);
3005 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3008 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3011 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3013 expectf(0.0, char_bounds
.X
);
3014 expectf(0.0, char_bounds
.Y
);
3015 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3016 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3017 expect(1, codepointsfitted
);
3018 expect(1, linesfilled
);
3020 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3022 expectf(0.0, bounds
.X
);
3023 expectf(0.0, bounds
.Y
);
3024 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3025 expectf(char_bounds
.Height
, bounds
.Height
);
3026 expect(2, codepointsfitted
);
3027 expect(1, linesfilled
);
3028 char_width
= bounds
.Width
- char_bounds
.Width
;
3030 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3032 expectf(0.0, bounds
.X
);
3033 expectf(0.0, bounds
.Y
);
3034 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3035 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3036 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3037 expect(6, codepointsfitted
);
3038 expect(2, linesfilled
);
3039 char_height
= bounds
.Height
- char_bounds
.Height
;
3041 /* Measure the first line. */
3042 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3044 expectf(0.0, bounds
.X
);
3045 expectf(0.0, bounds
.Y
);
3046 expect(4, codepointsfitted
);
3047 expect(1, linesfilled
);
3049 /* Give just enough space to fit the first line. */
3050 rc
.Width
= bounds
.Width
;
3051 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3053 expectf(0.0, bounds
.X
);
3054 expectf(0.0, bounds
.Y
);
3055 todo_wine
expect(5, codepointsfitted
);
3056 todo_wine
expect(1, linesfilled
);
3058 /* Cut off everything after the first space. */
3059 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3061 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3063 expectf(0.0, bounds
.X
);
3064 expectf(0.0, bounds
.Y
);
3065 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3066 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3067 expect(6, codepointsfitted
);
3068 expect(3, linesfilled
);
3070 /* Cut off everything including the first space. */
3071 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3073 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3075 expectf(0.0, bounds
.X
);
3076 expectf(0.0, bounds
.Y
);
3077 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3078 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3079 expect(6, codepointsfitted
);
3080 expect(3, linesfilled
);
3082 /* Cut off everything after the first character. */
3083 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3085 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3087 expectf(0.0, bounds
.X
);
3088 expectf(0.0, bounds
.Y
);
3089 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3090 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3091 expect(6, codepointsfitted
);
3092 todo_wine
expect(4, linesfilled
);
3094 for (i
= 0; i
< 4; i
++)
3095 regions
[i
] = (GpRegion
*)0xdeadbeef;
3097 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3100 for (i
= 0; i
< 4; i
++)
3101 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3103 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3106 for (i
= 0; i
< 4; i
++)
3107 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3109 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3112 set_rect_empty(&rc
);
3116 status
= GdipCreateRegion(®ions
[i
]);
3118 status
= GdipSetEmpty(regions
[i
]);
3122 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3123 expect(InvalidParameter
, status
);
3125 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3126 expect(InvalidParameter
, status
);
3128 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3129 expect(InvalidParameter
, status
);
3131 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3132 expect(InvalidParameter
, status
);
3136 /* Crashes on Windows XP */
3137 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3138 expect(InvalidParameter
, status
);
3141 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3142 expect(InvalidParameter
, status
);
3144 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3145 expect(InvalidParameter
, status
);
3147 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3150 for (i
= 0; i
< 4; i
++)
3152 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3156 ok(region_isempty
[0], "region should be empty\n");
3157 ok(region_isempty
[1], "region should be empty\n");
3158 ok(region_isempty
[2], "region should be empty\n");
3159 ok(region_isempty
[3], "region should be empty\n");
3164 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3169 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3173 ok(!region_isempty
[0], "region shouldn't be empty\n");
3174 ok(!region_isempty
[1], "region shouldn't be empty\n");
3175 ok(!region_isempty
[2], "region shouldn't be empty\n");
3176 ok(region_isempty
[3], "region should be empty\n");
3178 /* Cut off everything after the first space, and the second line. */
3179 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3180 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3182 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3187 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3191 ok(!region_isempty
[0], "region shouldn't be empty\n");
3192 ok(!region_isempty
[1], "region shouldn't be empty\n");
3193 ok(region_isempty
[2], "region should be empty\n");
3194 ok(region_isempty
[3], "region should be empty\n");
3197 GdipDeleteRegion(regions
[i
]);
3199 status
= GdipCreateMatrix(&identity
);
3206 memset(positions
, 0, sizeof(positions
));
3207 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3208 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3210 expect(InvalidParameter
, status
);
3212 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3213 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3215 expect(InvalidParameter
, status
);
3217 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3218 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3220 expect(InvalidParameter
, status
);
3222 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3223 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3225 expect(InvalidParameter
, status
);
3227 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3228 0x100, identity
, &rc
);
3231 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3232 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3236 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3237 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3239 expect(InvalidParameter
, status
);
3245 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3246 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3251 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3252 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3253 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3255 char_width
= rc
.Width
;
3256 char_height
= rc
.Height
;
3262 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3263 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3268 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3269 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3270 expectf(char_height
, rc
.Height
);
3276 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3277 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3282 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3283 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3284 expectf(rc
.Height
, char_height
);
3286 GdipDeleteMatrix(identity
);
3287 GdipDeleteStringFormat(format
);
3288 GdipDeleteBrush(brush
);
3289 GdipDeleteFont(font
);
3290 GdipDeleteFontFamily(family
);
3291 GdipDeleteGraphics(graphics
);
3293 ReleaseDC(hwnd
, hdc
);
3296 static void test_get_set_interpolation(void)
3298 GpGraphics
*graphics
;
3299 HDC hdc
= GetDC( hwnd
);
3301 InterpolationMode mode
;
3303 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3304 status
= GdipCreateFromHDC(hdc
, &graphics
);
3306 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3308 status
= GdipGetInterpolationMode(NULL
, &mode
);
3309 expect(InvalidParameter
, status
);
3313 /* Crashes on Windows XP */
3314 status
= GdipGetInterpolationMode(graphics
, NULL
);
3315 expect(InvalidParameter
, status
);
3318 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3319 expect(InvalidParameter
, status
);
3322 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3323 expect(InvalidParameter
, status
);
3325 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3326 expect(InvalidParameter
, status
);
3328 status
= GdipGetInterpolationMode(graphics
, &mode
);
3330 expect(InterpolationModeBilinear
, mode
);
3332 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3335 status
= GdipGetInterpolationMode(graphics
, &mode
);
3337 expect(InterpolationModeNearestNeighbor
, mode
);
3339 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3342 status
= GdipGetInterpolationMode(graphics
, &mode
);
3344 expect(InterpolationModeBilinear
, mode
);
3346 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3349 status
= GdipGetInterpolationMode(graphics
, &mode
);
3351 expect(InterpolationModeBilinear
, mode
);
3353 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3356 status
= GdipGetInterpolationMode(graphics
, &mode
);
3358 expect(InterpolationModeHighQualityBicubic
, mode
);
3360 GdipDeleteGraphics(graphics
);
3362 ReleaseDC(hwnd
, hdc
);
3365 static void test_get_set_textrenderinghint(void)
3367 GpGraphics
*graphics
;
3368 HDC hdc
= GetDC( hwnd
);
3370 TextRenderingHint hint
;
3372 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3373 status
= GdipCreateFromHDC(hdc
, &graphics
);
3375 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3377 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3378 expect(InvalidParameter
, status
);
3380 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3381 expect(InvalidParameter
, status
);
3383 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3384 expect(InvalidParameter
, status
);
3387 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3388 expect(InvalidParameter
, status
);
3390 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3392 expect(TextRenderingHintSystemDefault
, hint
);
3394 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3397 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3399 expect(TextRenderingHintSystemDefault
, hint
);
3401 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3404 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3406 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3408 GdipDeleteGraphics(graphics
);
3410 ReleaseDC(hwnd
, hdc
);
3413 static void test_getdc_scaled(void)
3416 GpGraphics
*graphics
= NULL
;
3417 GpBitmap
*bitmap
= NULL
;
3419 HBRUSH hbrush
, holdbrush
;
3422 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3425 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3428 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3431 status
= GdipGetDC(graphics
, &hdc
);
3433 ok(hdc
!= NULL
, "got NULL hdc\n");
3435 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3437 holdbrush
= SelectObject(hdc
, hbrush
);
3439 Rectangle(hdc
, 2, 2, 6, 6);
3441 SelectObject(hdc
, holdbrush
);
3443 DeleteObject(hbrush
);
3445 status
= GdipReleaseDC(graphics
, hdc
);
3448 GdipDeleteGraphics(graphics
);
3450 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3452 expect(0xffff0000, color
);
3454 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3456 expect(0xff000000, color
);
3458 GdipDisposeImage((GpImage
*)bitmap
);
3461 static void test_GdipMeasureString(void)
3463 static const struct test_data
3465 REAL res_x
, res_y
, page_scale
;
3469 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3470 { 200.0, 200.0, 2.0, UnitPixel
},
3471 { 200.0, 200.0, 1.0, UnitDisplay
},
3472 { 200.0, 200.0, 2.0, UnitDisplay
},
3473 { 200.0, 200.0, 1.0, UnitInch
},
3474 { 200.0, 200.0, 2.0, UnitInch
},
3475 { 200.0, 600.0, 1.0, UnitPoint
},
3476 { 200.0, 600.0, 2.0, UnitPoint
},
3477 { 200.0, 600.0, 1.0, UnitDocument
},
3478 { 200.0, 600.0, 2.0, UnitDocument
},
3479 { 200.0, 600.0, 1.0, UnitMillimeter
},
3480 { 200.0, 600.0, 2.0, UnitMillimeter
},
3481 { 200.0, 600.0, 1.0, UnitDisplay
},
3482 { 200.0, 600.0, 2.0, UnitDisplay
},
3483 { 200.0, 600.0, 1.0, UnitPixel
},
3484 { 200.0, 600.0, 2.0, UnitPixel
},
3486 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3487 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3489 GpGraphics
*graphics
;
3490 GpFontFamily
*family
;
3492 GpStringFormat
*format
;
3494 REAL base_cx
= 0, base_cy
= 0, height
;
3499 GpUnit font_unit
, unit
;
3501 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3503 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3506 /* font size in pixels */
3507 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3509 status
= GdipGetFontSize(font
, &font_size
);
3511 expectf(100.0, font_size
);
3512 status
= GdipGetFontUnit(font
, &font_unit
);
3514 expect(UnitPixel
, font_unit
);
3516 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3520 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3522 lf
.lfHeight
= 0xdeadbeef;
3523 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3525 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3526 if (td
[i
].unit
!= UnitDisplay
)
3527 height
*= td
[i
].page_scale
;
3528 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3529 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3531 height
= font_size
+ 2.0 * font_size
/ 6.0;
3533 set_rect_empty(&rc
);
3534 set_rect_empty(&bounds
);
3535 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3540 base_cx
= bounds
.Width
;
3541 base_cy
= bounds
.Height
;
3544 expectf(0.0, bounds
.X
);
3545 expectf(0.0, bounds
.Y
);
3547 expectf_(height
, bounds
.Height
, height
/ 100.0);
3548 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3552 /* make sure it really fits */
3553 bounds
.Width
+= 1.0;
3554 bounds
.Height
+= 1.0;
3558 set_rect_empty(&bounds
);
3559 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3561 expectf(50.0, bounds
.X
);
3562 expectf(50.0, bounds
.Y
);
3564 expectf_(height
, bounds
.Height
, height
/ 100.0);
3565 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3569 status
= GdipDeleteGraphics(graphics
);
3572 status
= GdipDisposeImage(image
);
3576 GdipDeleteFont(font
);
3578 /* font size in logical units */
3579 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3580 for (unit
= 3; unit
<= 6; unit
++)
3582 /* create a font which final height is 100.0 pixels with 200 dpi device */
3583 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3584 height
= pixels_to_units(75.0, unit
, 200.0);
3585 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3587 status
= GdipGetFontSize(font
, &font_size
);
3589 expectf(height
, font_size
);
3590 status
= GdipGetFontUnit(font
, &font_unit
);
3592 expect(unit
, font_unit
);
3594 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3599 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3601 lf
.lfHeight
= 0xdeadbeef;
3602 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3604 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3605 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3607 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3608 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3609 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3610 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3612 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3613 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3615 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3616 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3617 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3618 if (td
[i
].unit
!= UnitDisplay
)
3619 height
/= td
[i
].page_scale
;
3620 /*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);*/
3622 set_rect_empty(&rc
);
3623 set_rect_empty(&bounds
);
3624 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3629 base_cx
= bounds
.Width
;
3630 base_cy
= bounds
.Height
;
3633 expectf(0.0, bounds
.X
);
3634 expectf(0.0, bounds
.Y
);
3636 expectf_(height
, bounds
.Height
, height
/ 85.0);
3637 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3641 /* make sure it really fits */
3642 bounds
.Width
+= 1.0;
3643 bounds
.Height
+= 1.0;
3647 set_rect_empty(&bounds
);
3648 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3650 expectf(50.0, bounds
.X
);
3651 expectf(50.0, bounds
.Y
);
3653 expectf_(height
, bounds
.Height
, height
/ 85.0);
3654 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3658 /* verify the result */
3659 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3660 if (td
[i
].unit
!= UnitDisplay
)
3661 height
*= td
[i
].page_scale
;
3662 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3663 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3665 expectf_(100.0, height
, 1.1);
3667 status
= GdipDeleteGraphics(graphics
);
3670 status
= GdipDisposeImage(image
);
3674 GdipDeleteFont(font
);
3677 GdipDeleteFontFamily(family
);
3678 GdipDeleteStringFormat(format
);
3681 static void test_transform(void)
3683 static const struct test_data
3685 REAL res_x
, res_y
, scale
;
3687 GpPointF in
[2], out
[2];
3690 { 96.0, 96.0, 1.0, UnitPixel
,
3691 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3692 { 96.0, 96.0, 1.0, UnitDisplay
,
3693 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3694 { 96.0, 96.0, 1.0, UnitInch
,
3695 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3696 { 123.0, 456.0, 1.0, UnitPoint
,
3697 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3698 { 123.0, 456.0, 1.0, UnitDocument
,
3699 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3700 { 123.0, 456.0, 2.0, UnitMillimeter
,
3701 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3702 { 196.0, 296.0, 1.0, UnitDisplay
,
3703 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3704 { 196.0, 296.0, 1.0, UnitPixel
,
3705 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3708 GpGraphics
*graphics
;
3713 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3715 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3716 ptf
[0].X
= td
[i
].in
[0].X
;
3717 ptf
[0].Y
= td
[i
].in
[0].Y
;
3718 ptf
[1].X
= td
[i
].in
[1].X
;
3719 ptf
[1].Y
= td
[i
].in
[1].Y
;
3720 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3722 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3723 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3724 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3725 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3726 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3728 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3729 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3730 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3731 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3732 status
= GdipDeleteGraphics(graphics
);
3734 status
= GdipDisposeImage(image
);
3739 /* Many people on the net ask why there is so much difference in rendered
3740 * text height between gdiplus and gdi32, this test suggests an answer to
3741 * that question. Important: this test assumes that font dpi == device dpi.
3743 static void test_font_height_scaling(void)
3745 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3746 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3748 GpStringFormat
*format
;
3749 CharacterRange range
= { 0, 7 };
3751 GpGraphics
*graphics
;
3752 GpFontFamily
*family
;
3756 REAL height
, dpi
, scale
;
3758 GpUnit gfx_unit
, font_unit
;
3760 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3762 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3764 status
= GdipCreateRegion(®ion
);
3767 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3770 hdc
= CreateCompatibleDC(0);
3771 status
= GdipCreateFromHDC(hdc
, &graphics
);
3773 status
= GdipGetDpiY(graphics
, &dpi
);
3776 /* First check if tested functionality works:
3777 * under XP if font and graphics units differ then GdipTransformPoints
3778 * followed by GdipSetPageUnit to change the graphics units breaks region
3779 * scaling in GdipMeasureCharacterRanges called later.
3781 status
= GdipSetPageUnit(graphics
, UnitDocument
);
3786 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3789 status
= GdipSetPageUnit(graphics
, UnitInch
);
3792 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
3795 set_rect_empty(&rect
);
3796 set_rect_empty(&bounds
);
3797 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3799 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
3801 set_rect_empty(&rect
);
3802 rect
.Width
= 32000.0;
3803 rect
.Height
= 32000.0;
3804 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3807 set_rect_empty(&rect
);
3808 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3810 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
3812 GdipDeleteFont(font
);
3814 scale
= rect
.Height
/ bounds
.Height
;
3815 if (fabs(scale
- 1.0) > 0.1)
3817 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
3821 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
3824 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3825 /* UnitPixel as a font base unit is not tested because it drastically
3826 differs in behaviour */
3827 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
3829 /* create a font for the final text height of 100 pixels */
3830 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3831 status
= GdipSetPageUnit(graphics
, font_unit
);
3835 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3838 /*trace("height %f units\n", height);*/
3839 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
3842 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3843 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
3845 static const WCHAR doubleW
[2] = { 'W','W' };
3846 RectF bounds_1
, bounds_2
;
3847 REAL margin
, margin_y
, font_height
;
3850 status
= GdipSetPageUnit(graphics
, gfx_unit
);
3853 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
3854 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
3856 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
3859 set_rect_empty(&rect
);
3860 set_rect_empty(&bounds
);
3861 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3863 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
3865 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
3868 ptf
.Y
= bounds
.Height
;
3869 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
3871 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3873 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3875 /* verify the result */
3876 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
3878 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3880 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3882 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
3883 set_rect_empty(&rect
);
3884 set_rect_empty(&bounds_1
);
3885 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
3887 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
3888 set_rect_empty(&rect
);
3889 set_rect_empty(&bounds_2
);
3890 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
3893 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
3894 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
3895 /*trace("margin %f\n", margin);*/
3896 ok(margin
> 0.0, "wrong margin %f\n", margin
);
3898 set_rect_empty(&rect
);
3899 rect
.Width
= 320000.0;
3900 rect
.Height
= 320000.0;
3901 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3903 set_rect_empty(&rect
);
3904 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3906 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
3907 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
3908 expectf(0.0, rect
.Y
);
3909 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
3910 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
3911 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
3912 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
3913 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
3914 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
3917 GdipDeleteFont(font
);
3921 status
= GdipDeleteGraphics(graphics
);
3925 GdipDeleteFontFamily(family
);
3926 GdipDeleteRegion(region
);
3927 GdipDeleteStringFormat(format
);
3930 static void test_measure_string(void)
3932 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3933 static const WCHAR string
[] = { 'A','0','1',0 };
3935 GpStringFormat
*format
;
3936 CharacterRange range
;
3938 GpGraphics
*graphics
;
3939 GpFontFamily
*family
;
3943 REAL width
, height
, width_1
, width_2
;
3944 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
3947 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3951 status
= GdipCreateRegion(®ion
);
3954 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3957 hdc
= CreateCompatibleDC(0);
3958 status
= GdipCreateFromHDC(hdc
, &graphics
);
3960 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
3963 margin_x
= 20.0 / 6.0;
3964 margin_y
= 20.0 / 8.0;
3966 set_rect_empty(&rect
);
3967 set_rect_empty(&bounds
);
3968 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3972 expectf(0.0, bounds
.X
);
3973 expectf(0.0, bounds
.Y
);
3974 width
= bounds
.Width
;
3975 height
= bounds
.Height
;
3977 set_rect_empty(&rect
);
3978 rect
.Height
= height
/ 2.0;
3979 set_rect_empty(&bounds
);
3980 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3984 expectf(0.0, bounds
.X
);
3985 expectf(0.0, bounds
.Y
);
3986 expectf(width
, bounds
.Width
);
3988 expectf(height
/ 2.0, bounds
.Height
);
3991 range
.Length
= lstrlenW(string
);
3992 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3997 rect
.Width
= 32000.0;
3998 rect
.Height
= 32000.0;
3999 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4001 set_rect_empty(&bounds
);
4002 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4004 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4005 expectf(5.0, bounds
.Y
);
4006 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4008 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4010 width_rgn
= bounds
.Width
;
4011 height_rgn
= bounds
.Height
;
4015 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4018 set_rect_empty(&rect
);
4019 rect
.Width
= 32000.0;
4020 rect
.Height
= 32000.0;
4021 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4023 set_rect_empty(&bounds
);
4024 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4026 expectf_(margin_x
, bounds
.X
, 1.0);
4027 expectf(0.0, bounds
.Y
);
4028 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4029 expectf(height_rgn
, bounds
.Height
);
4030 width_1
= bounds
.Width
;
4033 range
.Length
= lstrlenW(string
);
4034 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4041 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4043 set_rect_empty(&bounds
);
4044 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4046 expectf(0.0, bounds
.X
);
4047 expectf(0.0, bounds
.Y
);
4048 expectf(0.0, bounds
.Width
);
4049 expectf(0.0, bounds
.Height
);
4053 rect
.Width
= width_rgn
/ 2.0;
4054 rect
.Height
= 32000.0;
4055 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4057 set_rect_empty(&bounds
);
4058 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4060 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4061 expectf(5.0, bounds
.Y
);
4062 expectf_(width_1
, bounds
.Width
, 1.0);
4064 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4066 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4072 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4074 set_rect_empty(&bounds
);
4075 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4077 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4078 expectf(5.0, bounds
.Y
);
4079 expectf(width_rgn
, bounds
.Width
);
4080 expectf(height_rgn
, bounds
.Height
);
4084 rect
.Width
= width_rgn
/ 2.0;
4085 rect
.Height
= 32000.0;
4086 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4088 set_rect_empty(&bounds
);
4089 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4091 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4092 expectf(5.0, bounds
.Y
);
4093 expectf_(width_1
, bounds
.Width
, 1.0);
4094 expectf(height_rgn
, bounds
.Height
);
4096 set_rect_empty(&rect
);
4097 rect
.Height
= height
/ 2.0;
4098 set_rect_empty(&bounds
);
4099 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4103 expectf(0.0, bounds
.X
);
4104 expectf(0.0, bounds
.Y
);
4105 expectf_(width
, bounds
.Width
, 0.01);
4107 expectf(height
, bounds
.Height
);
4109 set_rect_empty(&rect
);
4110 set_rect_empty(&bounds
);
4111 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4115 expectf(0.0, bounds
.X
);
4116 expectf(0.0, bounds
.Y
);
4117 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4118 expectf(height
, bounds
.Height
);
4119 width_1
= bounds
.Width
;
4121 set_rect_empty(&rect
);
4122 set_rect_empty(&bounds
);
4123 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4127 expectf(0.0, bounds
.X
);
4128 expectf(0.0, bounds
.Y
);
4129 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4130 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4131 expectf(height
, bounds
.Height
);
4132 width_2
= bounds
.Width
;
4134 set_rect_empty(&rect
);
4135 rect
.Width
= width
/ 2.0;
4136 set_rect_empty(&bounds
);
4137 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4141 expectf(0.0, bounds
.X
);
4142 expectf(0.0, bounds
.Y
);
4143 expectf_(width_1
, bounds
.Width
, 0.01);
4144 expectf(height
, bounds
.Height
);
4146 set_rect_empty(&rect
);
4147 rect
.Height
= height
;
4148 rect
.Width
= width
- 0.05;
4149 set_rect_empty(&bounds
);
4150 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4154 expectf(0.0, bounds
.X
);
4155 expectf(0.0, bounds
.Y
);
4156 expectf_(width_2
, bounds
.Width
, 0.01);
4157 expectf(height
, bounds
.Height
);
4159 set_rect_empty(&rect
);
4160 rect
.Height
= height
;
4161 rect
.Width
= width_2
- 0.05;
4162 set_rect_empty(&bounds
);
4163 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4167 expectf(0.0, bounds
.X
);
4168 expectf(0.0, bounds
.Y
);
4169 expectf_(width_1
, bounds
.Width
, 0.01);
4170 expectf(height
, bounds
.Height
);
4172 /* Default (Near) alignment */
4175 rect
.Width
= width
* 2.0;
4176 rect
.Height
= height
* 2.0;
4177 set_rect_empty(&bounds
);
4178 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4182 expectf(5.0, bounds
.X
);
4183 expectf(5.0, bounds
.Y
);
4184 expectf_(width
, bounds
.Width
, 0.01);
4185 expectf(height
, bounds
.Height
);
4189 rect
.Width
= 32000.0;
4190 rect
.Height
= 32000.0;
4191 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4193 set_rect_empty(&bounds
);
4194 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4196 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4197 expectf(5.0, bounds
.Y
);
4198 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4200 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4202 width_rgn
= bounds
.Width
;
4203 height_rgn
= bounds
.Height
;
4205 /* Center alignment */
4206 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4207 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4211 rect
.Width
= width
* 2.0;
4212 rect
.Height
= height
* 2.0;
4213 set_rect_empty(&bounds
);
4214 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4219 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4221 expectf(5.0 + height
/2.0, bounds
.Y
);
4222 expectf_(width
, bounds
.Width
, 0.01);
4223 expectf(height
, bounds
.Height
);
4229 set_rect_empty(&bounds
);
4230 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4235 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4237 expectf(5.0 - height
/2.0, bounds
.Y
);
4238 expectf_(width
, bounds
.Width
, 0.01);
4239 expectf(height
, bounds
.Height
);
4243 rect
.Width
= width_rgn
* 2.0;
4244 rect
.Height
= height_rgn
* 2.0;
4245 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4247 set_rect_empty(&bounds
);
4248 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4251 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4253 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4254 expectf_(width_rgn
, bounds
.Width
, 1.0);
4255 expectf_(height_rgn
, bounds
.Height
, 1.0);
4261 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4263 set_rect_empty(&bounds
);
4264 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4267 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4269 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4270 expectf_(width_rgn
, bounds
.Width
, 1.0);
4271 expectf_(height_rgn
, bounds
.Height
, 1.0);
4274 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4275 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4279 rect
.Width
= width
* 2.0;
4280 rect
.Height
= height
* 2.0;
4281 set_rect_empty(&bounds
);
4282 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4287 expectf_(5.0 + width
, bounds
.X
, 0.01);
4289 expectf(5.0 + height
, bounds
.Y
);
4290 expectf_(width
, bounds
.Width
, 0.01);
4291 expectf(height
, bounds
.Height
);
4297 set_rect_empty(&bounds
);
4298 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4303 expectf_(5.0 - width
, bounds
.X
, 0.01);
4305 expectf(5.0 - height
, bounds
.Y
);
4306 expectf_(width
, bounds
.Width
, 0.01);
4307 expectf(height
, bounds
.Height
);
4311 rect
.Width
= width_rgn
* 2.0;
4312 rect
.Height
= height_rgn
* 2.0;
4313 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4315 set_rect_empty(&bounds
);
4316 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4319 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4321 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4322 expectf_(width_rgn
, bounds
.Width
, 1.0);
4323 expectf_(height_rgn
, bounds
.Height
, 1.0);
4329 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4331 set_rect_empty(&bounds
);
4332 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4335 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4337 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4338 expectf_(width_rgn
, bounds
.Width
, 1.0);
4339 expectf_(height_rgn
, bounds
.Height
, 1.0);
4341 status
= GdipDeleteFont(font
);
4344 status
= GdipDeleteGraphics(graphics
);
4348 GdipDeleteFontFamily(family
);
4349 GdipDeleteRegion(region
);
4350 GdipDeleteStringFormat(format
);
4353 static void test_measured_extra_space(void)
4355 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4356 static const WCHAR string
[2] = { 'W','W' };
4357 GpStringFormat
*format
;
4359 GpGraphics
*graphics
;
4360 GpFontFamily
*family
;
4363 GpUnit gfx_unit
, font_unit
;
4364 RectF bounds_1
, bounds_2
, rect
;
4365 REAL margin
, font_size
, dpi
;
4367 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4370 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4372 hdc
= CreateCompatibleDC(0);
4373 status
= GdipCreateFromHDC(hdc
, &graphics
);
4376 status
= GdipGetDpiX(graphics
, &dpi
);
4379 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4380 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4381 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4383 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4386 status
= GdipGetFontSize(font
, &font_size
);
4388 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4389 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4391 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4392 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4394 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4397 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4398 set_rect_empty(&rect
);
4399 set_rect_empty(&bounds_1
);
4400 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4402 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4403 set_rect_empty(&rect
);
4404 set_rect_empty(&bounds_2
);
4405 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4408 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4409 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4410 /*trace("margin %f pixels\n", margin);*/
4411 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4414 GdipDeleteFont(font
);
4417 GdipDeleteGraphics(graphics
);
4419 GdipDeleteFontFamily(family
);
4420 GdipDeleteStringFormat(format
);
4423 static void test_alpha_hdc(void)
4427 HBITMAP hbm
, old_hbm
;
4428 GpGraphics
*graphics
;
4433 hdc
= CreateCompatibleDC(0);
4434 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4435 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4436 bmi
.bmiHeader
.biHeight
= 5;
4437 bmi
.bmiHeader
.biWidth
= 5;
4438 bmi
.bmiHeader
.biBitCount
= 32;
4439 bmi
.bmiHeader
.biPlanes
= 1;
4440 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4441 bmi
.bmiHeader
.biClrUsed
= 0;
4443 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4444 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4446 old_hbm
= SelectObject(hdc
, hbm
);
4448 status
= GdipCreateFromHDC(hdc
, &graphics
);
4451 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4453 expectf(0.0, bounds
.X
);
4454 expectf(0.0, bounds
.Y
);
4455 expectf(5.0, bounds
.Width
);
4456 expectf(5.0, bounds
.Height
);
4458 bits
[0] = 0xdeadbeef;
4460 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4463 expect(0xffaaaaaa, bits
[0]);
4465 SelectObject(hdc
, old_hbm
);
4467 bits
[0] = 0xdeadbeef;
4469 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4472 todo_wine
expect(0xffbbbbbb, bits
[0]);
4474 GdipDeleteGraphics(graphics
);
4480 static void test_bitmapfromgraphics(void)
4483 GpGraphics
*graphics
= NULL
;
4484 HDC hdc
= GetDC( hwnd
);
4485 GpBitmap
*bitmap
= NULL
;
4487 REAL imageres
, graphicsres
;
4490 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4493 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4494 expect(InvalidParameter
, stat
);
4496 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4497 expect(InvalidParameter
, stat
);
4499 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4502 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4504 expect(PixelFormat32bppPARGB
, format
);
4506 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4509 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4511 expectf(graphicsres
, imageres
);
4513 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4516 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4518 expectf(graphicsres
, imageres
);
4520 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4524 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4528 GdipDeleteGraphics(graphics
);
4529 GdipDisposeImage((GpImage
*)bitmap
);
4532 static void test_clipping(void)
4536 GpGraphics
*graphics
;
4537 GpRegion
*region
, *region100x100
;
4546 hdc
= CreateCompatibleDC(0);
4547 status
= GdipCreateFromHDC(hdc
, &graphics
);
4550 status
= GdipGetPageUnit(graphics
, &unit
);
4552 expect(UnitDisplay
, unit
);
4554 status
= GdipCreateRegion(®ion
);
4556 status
= GdipSetEmpty(region
);
4559 status
= GdipCreateRegion(®ion100x100
);
4561 status
= GdipSetEmpty(region100x100
);
4564 rect
.X
= rect
.Y
= 100.0;
4565 rect
.Width
= rect
.Height
= 100.0;
4566 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4568 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4571 status
= GdipGetClipBounds(graphics
, &rect
);
4573 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4574 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4576 status
= GdipSetEmpty(region
);
4578 status
= GdipGetClip(graphics
, region
);
4580 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4582 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4583 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4589 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4591 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4592 "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
);
4594 status
= GdipCreateMatrix(&matrix
);
4596 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4598 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4600 status
= GdipSetWorldTransform(graphics
, matrix
);
4603 status
= GdipGetClipBounds(graphics
, &rect
);
4605 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4606 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4608 status
= GdipSetEmpty(region
);
4610 status
= GdipGetClip(graphics
, region
);
4612 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4614 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4615 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4617 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4619 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4620 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4622 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4624 ret
= GetRgnBox(hrgn
, &rc
);
4625 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4626 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4627 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4630 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4632 ret
= GetRgnBox(hrgn
, &rc
);
4633 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4634 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4635 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4642 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4644 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4645 "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
);
4647 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4649 ret
= GetRgnBox(hrgn
, &rc
);
4650 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4651 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4652 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4655 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4657 ret
= GetRgnBox(hrgn
, &rc
);
4658 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4659 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4660 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4667 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4669 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4670 "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
);
4672 status
= GdipSetPageScale(graphics
, 2.0);
4675 status
= GdipGetClipBounds(graphics
, &rect
);
4677 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4678 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4680 status
= GdipSetEmpty(region
);
4682 status
= GdipGetClip(graphics
, region
);
4684 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4686 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4687 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4689 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4691 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4692 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4694 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4696 ret
= GetRgnBox(hrgn
, &rc
);
4697 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4698 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4699 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4702 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4704 ret
= GetRgnBox(hrgn
, &rc
);
4705 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4706 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4707 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4714 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4716 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4717 "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
);
4719 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4721 ret
= GetRgnBox(hrgn
, &rc
);
4722 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4723 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4724 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4727 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4729 ret
= GetRgnBox(hrgn
, &rc
);
4730 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4731 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4732 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4739 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4741 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4742 "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
);
4744 GdipSetPageUnit(graphics
, UnitPoint
);
4747 status
= GdipGetClipBounds(graphics
, &rect
);
4749 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4750 /* rounding under Wine is slightly different */
4751 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4752 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4753 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4755 status
= GdipSetEmpty(region
);
4757 status
= GdipGetClip(graphics
, region
);
4759 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4761 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4762 /* rounding under Wine is slightly different */
4763 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4764 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4765 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4767 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4769 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4770 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4772 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4774 ret
= GetRgnBox(hrgn
, &rc
);
4775 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4776 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
4777 /* rounding under Wine is slightly different */
4778 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
4779 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
4780 "expected 14,5-33,14, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4783 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4785 ret
= GetRgnBox(hrgn
, &rc
);
4786 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4787 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
4788 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
4789 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4796 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4798 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
4799 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
4800 "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
);
4802 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4804 ret
= GetRgnBox(hrgn
, &rc
);
4805 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4806 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4807 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4810 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4812 ret
= GetRgnBox(hrgn
, &rc
);
4813 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4814 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
4815 /* rounding under Wine is slightly different */
4816 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
4817 "expected 560,1120-1094,2187, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4824 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4826 if (fabs(ptf
[0].X
- 100.0) < 0.001)
4828 expectf(100.0, ptf
[0].X
);
4829 expectf(100.0, ptf
[0].Y
);
4830 expectf(200.125, ptf
[1].X
);
4831 expectf(200.03125, ptf
[1].Y
);
4833 else /* before Win7 */
4835 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
4836 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
4837 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
4838 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
4841 status
= GdipTransformRegion(region100x100
, matrix
);
4844 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4846 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4847 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4849 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4851 ret
= GetRgnBox(hrgn
, &rc
);
4852 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4853 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4854 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4857 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4859 ret
= GetRgnBox(hrgn
, &rc
);
4860 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4861 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
4862 /* rounding under Wine is slightly different */
4863 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
4864 "expected 1147,4534-2214,8800, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4871 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4873 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
4875 expectf(210.0625, ptf
[0].X
);
4876 expectf(420.0625, ptf
[0].Y
);
4877 expectf(410.125, ptf
[1].X
);
4878 expectf(820.0, ptf
[1].Y
);
4880 else /* before Win7 */
4882 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
4883 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
4884 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
4885 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
4888 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
4890 status
= GdipSetWorldTransform(graphics
, matrix
);
4893 status
= GdipGetClipBounds(graphics
, &rect
);
4895 expectf_(20.612978, rect
.X
, 1.0);
4896 expectf_(-6.256012, rect
.Y
, 1.5);
4897 expectf_(25.612978, rect
.Width
, 1.0);
4898 expectf_(12.806489, rect
.Height
, 1.0);
4900 status
= GdipSetEmpty(region
);
4902 status
= GdipGetClip(graphics
, region
);
4904 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4906 /* rounding under Wine is slightly different */
4907 expectf_(20.612978, rect
.X
, 1.0);
4908 expectf_(-6.256012, rect
.Y
, 1.5);
4909 expectf_(25.612978, rect
.Width
, 1.0);
4910 expectf_(12.806489, rect
.Height
, 1.0);
4912 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4914 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4915 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4917 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4919 ret
= GetRgnBox(hrgn
, &rc
);
4920 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4921 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
4922 /* rounding under Wine is slightly different */
4923 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
4924 "expected (22,-6)-(46,7), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4927 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4929 ret
= GetRgnBox(hrgn
, &rc
);
4930 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4931 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4932 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4943 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4945 expectf(20.612978, ptf
[0].X
);
4946 expectf(-1.568512, ptf
[0].Y
);
4947 expectf(46.225956, ptf
[1].X
);
4948 expectf(1.862977, ptf
[1].Y
);
4949 expectf(36.850956, ptf
[2].X
);
4950 expectf(-6.256012, ptf
[2].Y
);
4951 expectf(29.987980, ptf
[3].X
);
4952 expectf(6.550478, ptf
[3].Y
);
4954 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4956 ret
= GetRgnBox(hrgn
, &rc
);
4957 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4958 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4959 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4962 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4964 ret
= GetRgnBox(hrgn
, &rc
);
4965 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4966 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
4967 /* rounding under Wine is slightly different */
4968 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
4969 "expected (-3406,4500)-(-350,8728), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4980 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4982 expectf(-136.190491, ptf
[0].X
);
4983 expectf(520.010742, ptf
[0].Y
);
4984 expectf(756.417175, ptf
[1].X
);
4985 expectf(720.031616, ptf
[1].Y
);
4986 expectf(360.042114, ptf
[2].X
);
4987 expectf(376.760742, ptf
[2].Y
);
4988 expectf(260.184570, ptf
[3].X
);
4989 expectf(863.281616, ptf
[3].Y
);
4991 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
4993 status
= GdipSetWorldTransform(graphics
, matrix
);
4996 status
= GdipGetClipBounds(graphics
, &rect
);
4998 expectf_(-28.100956, rect
.X
, 1.0);
4999 expectf_(7.806488, rect
.Y
, 1.5);
5000 expectf_(25.612978, rect
.Width
, 1.0);
5001 expectf_(12.806489, rect
.Height
, 1.0);
5003 status
= GdipSetEmpty(region
);
5005 status
= GdipGetClip(graphics
, region
);
5007 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5009 /* rounding under Wine is slightly different */
5010 expectf_(-28.100956, rect
.X
, 1.0);
5011 expectf_(7.806488, rect
.Y
, 1.5);
5012 expectf_(25.612978, rect
.Width
, 1.0);
5013 expectf_(12.806489, rect
.Height
, 1.0);
5015 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5017 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5018 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5020 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5022 ret
= GetRgnBox(hrgn
, &rc
);
5023 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5024 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5025 /* rounding under Wine is slightly different */
5026 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5027 "expected (-27,8)-(-2,21), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5030 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5032 ret
= GetRgnBox(hrgn
, &rc
);
5033 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5034 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5035 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5046 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5048 expectf(-11.862979, ptf
[0].X
);
5049 expectf(7.806488, ptf
[0].Y
);
5050 expectf(-18.725958, ptf
[1].X
);
5051 expectf(20.612976, ptf
[1].Y
);
5052 expectf(-2.487981, ptf
[2].X
);
5053 expectf(15.925477, ptf
[2].Y
);
5054 expectf(-28.100956, ptf
[3].X
);
5055 expectf(12.493987, ptf
[3].Y
);
5057 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5059 ret
= GetRgnBox(hrgn
, &rc
);
5060 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5061 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5062 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5065 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5067 ret
= GetRgnBox(hrgn
, &rc
);
5068 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5069 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5070 /* rounding under Wine is slightly different */
5071 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5072 "expected (4500,351)-(8728,3407), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5083 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5085 expectf(-1055.021484, ptf
[0].X
);
5086 expectf(-70.595329, ptf
[0].Y
);
5087 expectf(-1455.063232, ptf
[1].X
);
5088 expectf(375.708435, ptf
[1].Y
);
5089 expectf(-768.521484, ptf
[2].X
);
5090 expectf(177.520981, ptf
[2].Y
);
5091 expectf(-1741.563110, ptf
[3].X
);
5092 expectf(127.592125, ptf
[3].Y
);
5094 GdipDeleteMatrix(matrix
);
5095 GdipDeleteRegion(region
);
5096 GdipDeleteRegion(region100x100
);
5097 GdipDeleteGraphics(graphics
);
5101 static void test_clipping_2(void)
5106 GpGraphics
*graphics
;
5116 hdc
= CreateCompatibleDC(0);
5117 status
= GdipCreateFromHDC(hdc
, &graphics
);
5120 status
= GdipGetPageUnit(graphics
, &unit
);
5122 expect(UnitDisplay
, unit
);
5124 GdipSetPageUnit(graphics
, UnitInch
);
5126 status
= GdipCreateRegion(®ion
);
5128 status
= GdipSetEmpty(region
);
5130 rect
.X
= rect
.Y
= 100.0;
5131 rect
.Width
= rect
.Height
= 100.0;
5132 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5134 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5137 status
= GdipGetClip(graphics
, region
);
5139 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5141 ret
= GetRgnBox(hrgn
, &rc
);
5142 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5143 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5144 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5146 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5148 ret
= GetRgnBox(hrgn
, &rc
);
5149 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5150 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5151 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5158 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5160 expectf(100.0, ptf
[0].X
);
5161 expectf(100.0, ptf
[0].Y
);
5162 expectf(200.0, ptf
[1].X
);
5163 expectf(200.0, ptf
[1].X
);
5165 GdipSetPageUnit(graphics
, UnitPoint
);
5167 status
= GdipGetClip(graphics
, region
);
5169 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5171 ret
= GetRgnBox(hrgn
, &rc
);
5172 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5173 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5174 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5175 "expected 7200,7200-14400,14400, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5177 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5179 ret
= GetRgnBox(hrgn
, &rc
);
5180 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5181 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5182 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5183 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5190 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5192 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5193 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5194 "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
);
5195 else /* before Win7 */
5197 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5198 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5199 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5200 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5203 GdipDeleteRegion(region
);
5205 GdipSetPageUnit(graphics
, UnitPixel
);
5207 status
= GdipCreateRegion(®ion
);
5209 status
= GdipSetEmpty(region
);
5211 rect
.X
= rect
.Y
= 100.0;
5212 rect
.Width
= rect
.Height
= 100.0;
5213 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5215 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5218 status
= GdipGetClip(graphics
, region
);
5220 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5222 ret
= GetRgnBox(hrgn
, &rc
);
5223 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5224 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5225 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5226 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5228 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5230 ret
= GetRgnBox(hrgn
, &rc
);
5231 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5232 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5233 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5234 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5241 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5243 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5244 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5245 "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
);
5246 else /* before Win7 */
5248 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5249 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5250 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5251 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5254 GdipSetPageUnit(graphics
, UnitPoint
);
5256 status
= GdipGetClip(graphics
, region
);
5258 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5260 ret
= GetRgnBox(hrgn
, &rc
);
5261 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5262 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5263 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5264 "expected 75,75-150,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5266 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5268 ret
= GetRgnBox(hrgn
, &rc
);
5269 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5270 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5271 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5272 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5279 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5281 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5282 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5283 "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
);
5284 else /* before Win7 */
5286 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5287 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5288 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5289 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5292 status
= GdipCreateMatrix(&matrix
);
5294 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5296 status
= GdipSetWorldTransform(graphics
, matrix
);
5298 GdipDeleteMatrix(matrix
);
5300 status
= GdipGetClip(graphics
, region
);
5302 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5304 ret
= GetRgnBox(hrgn
, &rc
);
5305 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5306 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5307 "expected 65,65-140,140, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5309 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5311 ret
= GetRgnBox(hrgn
, &rc
);
5312 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5313 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5314 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5321 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5323 expectf(65.0, ptf
[0].X
);
5324 expectf(65.0, ptf
[0].Y
);
5325 expectf(140.0, ptf
[1].X
);
5326 expectf(140.0, ptf
[1].X
);
5328 status
= GdipCreateMatrix(&matrix
);
5330 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5332 status
= GdipSetWorldTransform(graphics
, matrix
);
5334 GdipDeleteMatrix(matrix
);
5336 status
= GdipGetClip(graphics
, region
);
5338 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5340 ret
= GetRgnBox(hrgn
, &rc
);
5341 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5342 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5343 "expected 300,150-600,300, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5345 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5347 ret
= GetRgnBox(hrgn
, &rc
);
5348 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5349 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5350 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5357 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5359 expectf(300.0, ptf
[0].X
);
5360 expectf(150.0, ptf
[0].Y
);
5361 expectf(600.0, ptf
[1].X
);
5362 expectf(300.0, ptf
[1].Y
);
5364 status
= GdipSetPageScale(graphics
, 2.0);
5367 status
= GdipGetClip(graphics
, region
);
5369 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5371 ret
= GetRgnBox(hrgn
, &rc
);
5372 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5373 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5374 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5375 "expected 150,75-300,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5377 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5379 ret
= GetRgnBox(hrgn
, &rc
);
5380 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5381 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5382 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5383 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5390 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5392 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5394 expectf(150.0, ptf
[0].X
);
5395 expectf(75.0, ptf
[0].Y
);
5396 expectf(300.0, ptf
[1].X
);
5397 expectf(150.0, ptf
[1].Y
);
5399 else /* before Win7 */
5401 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5402 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5403 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5404 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5407 status
= GdipCreateMatrix(&matrix
);
5409 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5411 status
= GdipSetWorldTransform(graphics
, matrix
);
5413 GdipDeleteMatrix(matrix
);
5415 status
= GdipGetClip(graphics
, region
);
5417 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5419 ret
= GetRgnBox(hrgn
, &rc
);
5420 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5421 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5422 /* rounding under Wine is slightly different */
5423 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5424 "expected 54,-26-107,27, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5426 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5428 ret
= GetRgnBox(hrgn
, &rc
);
5429 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5430 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5431 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5442 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5444 expectf(53.033016, ptf
[0].X
);
5445 expectf(0.0, ptf
[0].Y
);
5446 expectf(106.066032, ptf
[1].X
);
5447 expectf(0.0, ptf
[1].Y
);
5448 expectf(79.549522, ptf
[2].X
);
5449 expectf(-26.516510, ptf
[2].Y
);
5450 expectf(79.549522, ptf
[3].X
);
5451 expectf(26.516508, ptf
[3].Y
);
5453 status
= GdipCreateMatrix(&matrix
);
5455 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5457 status
= GdipSetWorldTransform(graphics
, matrix
);
5459 GdipDeleteMatrix(matrix
);
5461 status
= GdipGetClip(graphics
, region
);
5463 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5465 ret
= GetRgnBox(hrgn
, &rc
);
5466 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5467 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5468 /* rounding under Wine is slightly different */
5469 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5470 "expected -26,54-27,107, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
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
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5477 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5488 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5490 expectf(0.0, ptf
[0].X
);
5491 expectf(53.033005, ptf
[0].Y
);
5492 expectf(0.0, ptf
[1].X
);
5493 expectf(106.066010, ptf
[1].Y
);
5494 expectf(26.516491, ptf
[2].X
);
5495 expectf(79.549507, ptf
[2].Y
);
5496 expectf(-26.516520, ptf
[3].X
);
5497 expectf(79.549500, ptf
[3].Y
);
5499 GdipDeleteRegion(region
);
5500 GdipDeleteGraphics(graphics
);
5505 static void test_GdipFillRectangles(void)
5508 GpGraphics
*graphics
= NULL
;
5509 GpBrush
*brush
= NULL
;
5510 HDC hdc
= GetDC( hwnd
);
5511 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5513 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5515 status
= GdipCreateFromHDC(hdc
, &graphics
);
5517 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5519 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5521 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5523 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5524 expect(InvalidParameter
, status
);
5526 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5527 expect(InvalidParameter
, status
);
5529 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5530 expect(InvalidParameter
, status
);
5532 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5533 expect(InvalidParameter
, status
);
5535 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5536 expect(InvalidParameter
, status
);
5538 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5541 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5544 GdipDeleteBrush(brush
);
5545 GdipDeleteGraphics(graphics
);
5547 ReleaseDC(hwnd
, hdc
);
5550 START_TEST(graphics
)
5552 struct GdiplusStartupInput gdiplusStartupInput
;
5553 ULONG_PTR gdiplusToken
;
5556 memset( &class, 0, sizeof(class) );
5557 class.lpszClassName
= "gdiplus_test";
5558 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5559 class.lpfnWndProc
= DefWindowProcA
;
5560 class.hInstance
= GetModuleHandleA(0);
5561 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5562 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5563 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
5564 RegisterClassA( &class );
5565 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5566 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
5567 ok(hwnd
!= NULL
, "Expected window to be created\n");
5569 gdiplusStartupInput
.GdiplusVersion
= 1;
5570 gdiplusStartupInput
.DebugEventCallback
= NULL
;
5571 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
5572 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
5574 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
5578 test_measured_extra_space();
5579 test_measure_string();
5580 test_font_height_scaling();
5582 test_GdipMeasureString();
5583 test_constructor_destructor();
5584 test_save_restore();
5585 test_GdipFillClosedCurve2();
5586 test_GdipFillClosedCurve2I();
5587 test_GdipDrawBezierI();
5589 test_GdipDrawArcI();
5590 test_GdipDrawCurve();
5591 test_GdipDrawCurveI();
5592 test_GdipDrawCurve2();
5593 test_GdipDrawCurve2I();
5594 test_GdipDrawCurve3();
5595 test_GdipDrawCurve3I();
5596 test_GdipDrawLineI();
5597 test_GdipDrawLinesI();
5598 test_GdipDrawImagePointsRect();
5599 test_GdipFillClosedCurve();
5600 test_GdipFillClosedCurveI();
5601 test_GdipDrawString();
5602 test_GdipGetNearestColor();
5603 test_GdipGetVisibleClipBounds();
5604 test_GdipIsVisiblePoint();
5605 test_GdipIsVisibleRect();
5606 test_Get_Release_DC();
5607 test_BeginContainer2();
5608 test_transformpoints();
5609 test_get_set_clip();
5612 test_textcontrast();
5613 test_fromMemoryBitmap();
5614 test_string_functions();
5615 test_get_set_interpolation();
5616 test_get_set_textrenderinghint();
5617 test_getdc_scaled();
5619 test_bitmapfromgraphics();
5620 test_GdipFillRectangles();
5622 GdiplusShutdown(gdiplusToken
);
5623 DestroyWindow( hwnd
);