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
);
2421 /* If we don't draw to the HDC, the bits are never accessed */
2422 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2425 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2428 status
= GdipGetDC(graphics
, &hdc
);
2430 ok(hdc
!= NULL
, "got NULL hdc\n");
2432 color
= GetPixel(hdc
, 0, 0);
2433 todo_wine
expect(0x0c0b0d, color
);
2435 status
= GdipReleaseDC(graphics
, hdc
);
2438 GdipDeleteGraphics(graphics
);
2440 GdipDisposeImage((GpImage
*)bitmap
);
2443 static void test_GdipIsVisiblePoint(void)
2446 GpGraphics
*graphics
= NULL
;
2447 HDC hdc
= GetDC( hwnd
);
2451 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2453 status
= GdipCreateFromHDC(hdc
, &graphics
);
2455 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2457 /* null parameters */
2458 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2459 expect(InvalidParameter
, status
);
2461 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2462 expect(InvalidParameter
, status
);
2464 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2465 expect(InvalidParameter
, status
);
2467 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2468 expect(InvalidParameter
, status
);
2472 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2474 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2478 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2480 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2484 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2486 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2490 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2492 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2494 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2499 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2501 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2505 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2507 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2509 /* translate into the center of the rect */
2510 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2514 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2516 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2520 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2522 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2524 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2529 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2531 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2535 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2537 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2541 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2543 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2547 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2549 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2553 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2555 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2559 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2561 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2565 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2567 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2571 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2573 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2577 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2579 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2583 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2585 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2589 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2591 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2595 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2597 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2601 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2603 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2605 /* integer version */
2608 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2610 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2614 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2616 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2618 GdipDeleteGraphics(graphics
);
2619 ReleaseDC(hwnd
, hdc
);
2622 static void test_GdipIsVisibleRect(void)
2625 GpGraphics
*graphics
= NULL
;
2626 HDC hdc
= GetDC( hwnd
);
2627 REAL x
, y
, width
, height
;
2630 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2632 status
= GdipCreateFromHDC(hdc
, &graphics
);
2634 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2636 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2637 expect(InvalidParameter
, status
);
2639 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2640 expect(InvalidParameter
, status
);
2642 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2643 expect(InvalidParameter
, status
);
2645 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2646 expect(InvalidParameter
, status
);
2648 /* entirely within the visible region */
2651 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2653 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2655 /* partially outside */
2656 x
= -10; width
= 20;
2657 y
= -10; height
= 20;
2658 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2660 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2662 /* entirely outside */
2664 y
= -10; height
= 5;
2665 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2667 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2669 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2672 /* entirely within the visible region */
2674 y
= 22; height
= 10;
2675 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2677 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2679 /* partially outside */
2681 y
= 55; height
= 10;
2682 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2684 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2686 /* entirely outside */
2689 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2691 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2693 /* translate into center of clipping rect */
2694 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
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
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2708 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2710 /* corners entirely outside, but some intersections */
2713 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2715 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2719 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2721 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2725 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2727 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2731 y
= 20; height
= 40;
2732 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2734 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2738 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2740 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2743 y
= 20; height
= 40;
2744 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2746 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2749 y
= 60; height
= 10;
2750 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2752 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2754 /* rounding tests */
2755 x
= 0.4; width
= 10.4;
2756 y
= 20; height
= 40;
2757 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2759 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2762 y
= 0.4; height
= 20.4;
2763 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2765 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2767 /* integer version */
2770 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2772 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2775 y
= 22; height
= 10;
2776 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2778 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2780 GdipDeleteGraphics(graphics
);
2781 ReleaseDC(hwnd
, hdc
);
2784 static void test_GdipGetNearestColor(void)
2787 GpGraphics
*graphics
;
2789 ARGB color
= 0xdeadbeef;
2790 HDC hdc
= GetDC( hwnd
);
2792 /* create a graphics object */
2793 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2795 status
= GdipCreateFromHDC(hdc
, &graphics
);
2797 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2799 status
= GdipGetNearestColor(graphics
, NULL
);
2800 expect(InvalidParameter
, status
);
2802 status
= GdipGetNearestColor(NULL
, &color
);
2803 expect(InvalidParameter
, status
);
2804 GdipDeleteGraphics(graphics
);
2806 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2808 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2809 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2812 status
= GdipGetNearestColor(graphics
, &color
);
2814 expect(0xdeadbeef, color
);
2815 GdipDeleteGraphics(graphics
);
2817 GdipDisposeImage((GpImage
*)bitmap
);
2819 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2821 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2822 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2825 status
= GdipGetNearestColor(graphics
, &color
);
2827 expect(0xdeadbeef, color
);
2828 GdipDeleteGraphics(graphics
);
2830 GdipDisposeImage((GpImage
*)bitmap
);
2832 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2834 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2835 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2838 status
= GdipGetNearestColor(graphics
, &color
);
2840 expect(0xdeadbeef, color
);
2841 GdipDeleteGraphics(graphics
);
2843 GdipDisposeImage((GpImage
*)bitmap
);
2845 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2847 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2848 todo_wine
expect(OutOfMemory
, status
);
2850 GdipDeleteGraphics(graphics
);
2851 GdipDisposeImage((GpImage
*)bitmap
);
2853 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2855 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2857 status
= GdipGetNearestColor(graphics
, &color
);
2859 expect(0xdeadbeef, color
);
2860 GdipDeleteGraphics(graphics
);
2861 GdipDisposeImage((GpImage
*)bitmap
);
2863 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2865 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2867 status
= GdipGetNearestColor(graphics
, &color
);
2869 expect(0xdeadbeef, color
);
2870 GdipDeleteGraphics(graphics
);
2871 GdipDisposeImage((GpImage
*)bitmap
);
2873 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2875 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2877 status
= GdipGetNearestColor(graphics
, &color
);
2879 expect(0xdeadbeef, color
);
2880 GdipDeleteGraphics(graphics
);
2881 GdipDisposeImage((GpImage
*)bitmap
);
2883 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2887 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2889 status
= GdipGetNearestColor(graphics
, &color
);
2891 expect(0xdeadbeef, color
);
2892 GdipDeleteGraphics(graphics
);
2893 GdipDisposeImage((GpImage
*)bitmap
);
2896 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2900 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2902 status
= GdipGetNearestColor(graphics
, &color
);
2904 expect(0xdeadbeef, color
);
2905 GdipDeleteGraphics(graphics
);
2906 GdipDisposeImage((GpImage
*)bitmap
);
2909 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2913 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2915 status
= GdipGetNearestColor(graphics
, &color
);
2917 expect(0xdeadbeef, color
);
2918 GdipDeleteGraphics(graphics
);
2919 GdipDisposeImage((GpImage
*)bitmap
);
2922 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2924 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2926 status
= GdipGetNearestColor(graphics
, &color
);
2928 todo_wine
expect(0xffa8bce8, color
);
2929 GdipDeleteGraphics(graphics
);
2930 GdipDisposeImage((GpImage
*)bitmap
);
2932 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2934 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2936 status
= GdipGetNearestColor(graphics
, &color
);
2939 ok(color
== 0xffa8b8e8 ||
2940 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2941 "Expected ffa8b8e8, got %.8x\n", color
);
2942 GdipDeleteGraphics(graphics
);
2943 GdipDisposeImage((GpImage
*)bitmap
);
2945 ReleaseDC(hwnd
, hdc
);
2948 static void test_string_functions(void)
2951 GpGraphics
*graphics
;
2952 GpFontFamily
*family
;
2954 RectF rc
, char_bounds
, bounds
;
2956 ARGB color
= 0xff000000;
2957 HDC hdc
= GetDC( hwnd
);
2958 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2959 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2960 const WCHAR teststring2
[] = {'j',0};
2961 REAL char_width
, char_height
;
2962 INT codepointsfitted
, linesfilled
;
2963 GpStringFormat
*format
;
2964 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2965 GpRegion
*regions
[4];
2966 BOOL region_isempty
[4];
2968 PointF positions
[8];
2971 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2972 status
= GdipCreateFromHDC(hdc
, &graphics
);
2974 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2976 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2979 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2982 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2985 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2993 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2994 expect(InvalidParameter
, status
);
2996 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2997 expect(InvalidParameter
, status
);
2999 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3000 expect(InvalidParameter
, status
);
3002 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3003 expect(InvalidParameter
, status
);
3005 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3006 expect(InvalidParameter
, status
);
3008 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3011 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3012 expect(InvalidParameter
, status
);
3014 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3015 expect(InvalidParameter
, status
);
3017 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3018 expect(InvalidParameter
, status
);
3020 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3021 expect(InvalidParameter
, status
);
3023 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3024 expect(InvalidParameter
, status
);
3026 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3029 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3032 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3034 expectf(0.0, char_bounds
.X
);
3035 expectf(0.0, char_bounds
.Y
);
3036 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3037 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3038 expect(1, codepointsfitted
);
3039 expect(1, linesfilled
);
3041 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3043 expectf(0.0, bounds
.X
);
3044 expectf(0.0, bounds
.Y
);
3045 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3046 expectf(char_bounds
.Height
, bounds
.Height
);
3047 expect(2, codepointsfitted
);
3048 expect(1, linesfilled
);
3049 char_width
= bounds
.Width
- char_bounds
.Width
;
3051 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3053 expectf(0.0, bounds
.X
);
3054 expectf(0.0, bounds
.Y
);
3055 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3056 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3057 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3058 expect(6, codepointsfitted
);
3059 expect(2, linesfilled
);
3060 char_height
= bounds
.Height
- char_bounds
.Height
;
3062 /* Measure the first line. */
3063 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3065 expectf(0.0, bounds
.X
);
3066 expectf(0.0, bounds
.Y
);
3067 expect(4, codepointsfitted
);
3068 expect(1, linesfilled
);
3070 /* Give just enough space to fit the first line. */
3071 rc
.Width
= bounds
.Width
;
3072 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3074 expectf(0.0, bounds
.X
);
3075 expectf(0.0, bounds
.Y
);
3076 todo_wine
expect(5, codepointsfitted
);
3077 todo_wine
expect(1, linesfilled
);
3079 /* Cut off everything after the first space. */
3080 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3082 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3084 expectf(0.0, bounds
.X
);
3085 expectf(0.0, bounds
.Y
);
3086 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3087 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3088 expect(6, codepointsfitted
);
3089 expect(3, linesfilled
);
3091 /* Cut off everything including the first space. */
3092 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3094 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3096 expectf(0.0, bounds
.X
);
3097 expectf(0.0, bounds
.Y
);
3098 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3099 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3100 expect(6, codepointsfitted
);
3101 expect(3, linesfilled
);
3103 /* Cut off everything after the first character. */
3104 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3106 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3108 expectf(0.0, bounds
.X
);
3109 expectf(0.0, bounds
.Y
);
3110 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3111 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3112 expect(6, codepointsfitted
);
3113 todo_wine
expect(4, linesfilled
);
3115 for (i
= 0; i
< 4; i
++)
3116 regions
[i
] = (GpRegion
*)0xdeadbeef;
3118 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3121 for (i
= 0; i
< 4; i
++)
3122 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3124 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3127 for (i
= 0; i
< 4; i
++)
3128 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3130 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3133 set_rect_empty(&rc
);
3137 status
= GdipCreateRegion(®ions
[i
]);
3139 status
= GdipSetEmpty(regions
[i
]);
3143 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3144 expect(InvalidParameter
, status
);
3146 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3147 expect(InvalidParameter
, status
);
3149 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3150 expect(InvalidParameter
, status
);
3152 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3153 expect(InvalidParameter
, status
);
3157 /* Crashes on Windows XP */
3158 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3159 expect(InvalidParameter
, status
);
3162 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3163 expect(InvalidParameter
, status
);
3165 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3166 expect(InvalidParameter
, status
);
3168 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3171 for (i
= 0; i
< 4; i
++)
3173 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3177 ok(region_isempty
[0], "region should be empty\n");
3178 ok(region_isempty
[1], "region should be empty\n");
3179 ok(region_isempty
[2], "region should be empty\n");
3180 ok(region_isempty
[3], "region should be empty\n");
3185 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3190 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3194 ok(!region_isempty
[0], "region shouldn't be empty\n");
3195 ok(!region_isempty
[1], "region shouldn't be empty\n");
3196 ok(!region_isempty
[2], "region shouldn't be empty\n");
3197 ok(region_isempty
[3], "region should be empty\n");
3199 /* Cut off everything after the first space, and the second line. */
3200 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3201 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3203 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3208 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3212 ok(!region_isempty
[0], "region shouldn't be empty\n");
3213 ok(!region_isempty
[1], "region shouldn't be empty\n");
3214 ok(region_isempty
[2], "region should be empty\n");
3215 ok(region_isempty
[3], "region should be empty\n");
3218 GdipDeleteRegion(regions
[i
]);
3220 status
= GdipCreateMatrix(&identity
);
3227 memset(positions
, 0, sizeof(positions
));
3228 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3229 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3231 expect(InvalidParameter
, status
);
3233 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3234 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3236 expect(InvalidParameter
, status
);
3238 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3239 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3241 expect(InvalidParameter
, status
);
3243 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3244 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3246 expect(InvalidParameter
, status
);
3248 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3249 0x100, identity
, &rc
);
3252 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3253 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3257 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3258 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3260 expect(InvalidParameter
, status
);
3266 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3267 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3272 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3273 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3274 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3276 char_width
= rc
.Width
;
3277 char_height
= rc
.Height
;
3283 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3284 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3289 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3290 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3291 expectf(char_height
, rc
.Height
);
3297 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3298 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3303 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3304 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3305 expectf(rc
.Height
, char_height
);
3307 GdipDeleteMatrix(identity
);
3308 GdipDeleteStringFormat(format
);
3309 GdipDeleteBrush(brush
);
3310 GdipDeleteFont(font
);
3311 GdipDeleteFontFamily(family
);
3312 GdipDeleteGraphics(graphics
);
3314 ReleaseDC(hwnd
, hdc
);
3317 static void test_get_set_interpolation(void)
3319 GpGraphics
*graphics
;
3320 HDC hdc
= GetDC( hwnd
);
3322 InterpolationMode mode
;
3324 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3325 status
= GdipCreateFromHDC(hdc
, &graphics
);
3327 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3329 status
= GdipGetInterpolationMode(NULL
, &mode
);
3330 expect(InvalidParameter
, status
);
3334 /* Crashes on Windows XP */
3335 status
= GdipGetInterpolationMode(graphics
, NULL
);
3336 expect(InvalidParameter
, status
);
3339 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3340 expect(InvalidParameter
, status
);
3343 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3344 expect(InvalidParameter
, status
);
3346 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3347 expect(InvalidParameter
, status
);
3349 status
= GdipGetInterpolationMode(graphics
, &mode
);
3351 expect(InterpolationModeBilinear
, mode
);
3353 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3356 status
= GdipGetInterpolationMode(graphics
, &mode
);
3358 expect(InterpolationModeNearestNeighbor
, mode
);
3360 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3363 status
= GdipGetInterpolationMode(graphics
, &mode
);
3365 expect(InterpolationModeBilinear
, mode
);
3367 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3370 status
= GdipGetInterpolationMode(graphics
, &mode
);
3372 expect(InterpolationModeBilinear
, mode
);
3374 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3377 status
= GdipGetInterpolationMode(graphics
, &mode
);
3379 expect(InterpolationModeHighQualityBicubic
, mode
);
3381 GdipDeleteGraphics(graphics
);
3383 ReleaseDC(hwnd
, hdc
);
3386 static void test_get_set_textrenderinghint(void)
3388 GpGraphics
*graphics
;
3389 HDC hdc
= GetDC( hwnd
);
3391 TextRenderingHint hint
;
3393 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3394 status
= GdipCreateFromHDC(hdc
, &graphics
);
3396 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3398 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3399 expect(InvalidParameter
, status
);
3401 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3402 expect(InvalidParameter
, status
);
3404 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3405 expect(InvalidParameter
, status
);
3408 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3409 expect(InvalidParameter
, status
);
3411 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3413 expect(TextRenderingHintSystemDefault
, hint
);
3415 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3418 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3420 expect(TextRenderingHintSystemDefault
, hint
);
3422 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3425 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3427 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3429 GdipDeleteGraphics(graphics
);
3431 ReleaseDC(hwnd
, hdc
);
3434 static void test_getdc_scaled(void)
3437 GpGraphics
*graphics
= NULL
;
3438 GpBitmap
*bitmap
= NULL
;
3440 HBRUSH hbrush
, holdbrush
;
3443 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3446 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3449 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3452 status
= GdipGetDC(graphics
, &hdc
);
3454 ok(hdc
!= NULL
, "got NULL hdc\n");
3456 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3458 holdbrush
= SelectObject(hdc
, hbrush
);
3460 Rectangle(hdc
, 2, 2, 6, 6);
3462 SelectObject(hdc
, holdbrush
);
3464 DeleteObject(hbrush
);
3466 status
= GdipReleaseDC(graphics
, hdc
);
3469 GdipDeleteGraphics(graphics
);
3471 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3473 expect(0xffff0000, color
);
3475 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3477 expect(0xff000000, color
);
3479 GdipDisposeImage((GpImage
*)bitmap
);
3482 static void test_GdipMeasureString(void)
3484 static const struct test_data
3486 REAL res_x
, res_y
, page_scale
;
3490 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3491 { 200.0, 200.0, 2.0, UnitPixel
},
3492 { 200.0, 200.0, 1.0, UnitDisplay
},
3493 { 200.0, 200.0, 2.0, UnitDisplay
},
3494 { 200.0, 200.0, 1.0, UnitInch
},
3495 { 200.0, 200.0, 2.0, UnitInch
},
3496 { 200.0, 600.0, 1.0, UnitPoint
},
3497 { 200.0, 600.0, 2.0, UnitPoint
},
3498 { 200.0, 600.0, 1.0, UnitDocument
},
3499 { 200.0, 600.0, 2.0, UnitDocument
},
3500 { 200.0, 600.0, 1.0, UnitMillimeter
},
3501 { 200.0, 600.0, 2.0, UnitMillimeter
},
3502 { 200.0, 600.0, 1.0, UnitDisplay
},
3503 { 200.0, 600.0, 2.0, UnitDisplay
},
3504 { 200.0, 600.0, 1.0, UnitPixel
},
3505 { 200.0, 600.0, 2.0, UnitPixel
},
3507 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3508 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3510 GpGraphics
*graphics
;
3511 GpFontFamily
*family
;
3513 GpStringFormat
*format
;
3515 REAL base_cx
= 0, base_cy
= 0, height
;
3520 GpUnit font_unit
, unit
;
3522 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3524 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3527 /* font size in pixels */
3528 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3530 status
= GdipGetFontSize(font
, &font_size
);
3532 expectf(100.0, font_size
);
3533 status
= GdipGetFontUnit(font
, &font_unit
);
3535 expect(UnitPixel
, font_unit
);
3537 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3541 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3543 lf
.lfHeight
= 0xdeadbeef;
3544 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3546 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3547 if (td
[i
].unit
!= UnitDisplay
)
3548 height
*= td
[i
].page_scale
;
3549 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3550 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3552 height
= font_size
+ 2.0 * font_size
/ 6.0;
3554 set_rect_empty(&rc
);
3555 set_rect_empty(&bounds
);
3556 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3561 base_cx
= bounds
.Width
;
3562 base_cy
= bounds
.Height
;
3565 expectf(0.0, bounds
.X
);
3566 expectf(0.0, bounds
.Y
);
3568 expectf_(height
, bounds
.Height
, height
/ 100.0);
3569 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3573 /* make sure it really fits */
3574 bounds
.Width
+= 1.0;
3575 bounds
.Height
+= 1.0;
3579 set_rect_empty(&bounds
);
3580 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3582 expectf(50.0, bounds
.X
);
3583 expectf(50.0, bounds
.Y
);
3585 expectf_(height
, bounds
.Height
, height
/ 100.0);
3586 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3590 status
= GdipDeleteGraphics(graphics
);
3593 status
= GdipDisposeImage(image
);
3597 GdipDeleteFont(font
);
3599 /* font size in logical units */
3600 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3601 for (unit
= 3; unit
<= 6; unit
++)
3603 /* create a font which final height is 100.0 pixels with 200 dpi device */
3604 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3605 height
= pixels_to_units(75.0, unit
, 200.0);
3606 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3608 status
= GdipGetFontSize(font
, &font_size
);
3610 expectf(height
, font_size
);
3611 status
= GdipGetFontUnit(font
, &font_unit
);
3613 expect(unit
, font_unit
);
3615 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3620 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3622 lf
.lfHeight
= 0xdeadbeef;
3623 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3625 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3626 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3628 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3629 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3630 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3631 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3633 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3634 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3636 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3637 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3638 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3639 if (td
[i
].unit
!= UnitDisplay
)
3640 height
/= td
[i
].page_scale
;
3641 /*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);*/
3643 set_rect_empty(&rc
);
3644 set_rect_empty(&bounds
);
3645 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3650 base_cx
= bounds
.Width
;
3651 base_cy
= bounds
.Height
;
3654 expectf(0.0, bounds
.X
);
3655 expectf(0.0, bounds
.Y
);
3657 expectf_(height
, bounds
.Height
, height
/ 85.0);
3658 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3662 /* make sure it really fits */
3663 bounds
.Width
+= 1.0;
3664 bounds
.Height
+= 1.0;
3668 set_rect_empty(&bounds
);
3669 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3671 expectf(50.0, bounds
.X
);
3672 expectf(50.0, bounds
.Y
);
3674 expectf_(height
, bounds
.Height
, height
/ 85.0);
3675 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3679 /* verify the result */
3680 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3681 if (td
[i
].unit
!= UnitDisplay
)
3682 height
*= td
[i
].page_scale
;
3683 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3684 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3686 expectf_(100.0, height
, 1.1);
3688 status
= GdipDeleteGraphics(graphics
);
3691 status
= GdipDisposeImage(image
);
3695 GdipDeleteFont(font
);
3698 /* Font with units = UnitWorld */
3699 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3701 GpPointF pt
= {0.0, 100.0};
3703 REAL expected_width
, expected_height
;
3705 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3707 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3710 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3713 status
= GdipGetFontUnit(font
, &font_unit
);
3715 expect(UnitWorld
, font_unit
);
3717 lf
.lfHeight
= 0xdeadbeef;
3718 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3720 ok(lf
.lfHeight
== -100, "%u: expected -100, got %d\n", i
, lf
.lfHeight
);
3722 set_rect_empty(&rc
);
3723 set_rect_empty(&bounds
);
3724 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3729 base_cx
= bounds
.Width
;
3730 base_cy
= bounds
.Height
;
3736 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3739 /* height is constant in device space, width is proportional to height in world space */
3740 expected_width
= base_cx
* pt
.Y
;
3741 expected_height
= base_cy
* pt
.Y
;
3743 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3744 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3746 todo_wine
ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3747 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3749 GdipDeleteGraphics(graphics
);
3750 GdipDisposeImage(image
);
3751 GdipDeleteFont(font
);
3754 GdipDeleteFontFamily(family
);
3755 GdipDeleteStringFormat(format
);
3758 static void test_transform(void)
3760 static const struct test_data
3762 REAL res_x
, res_y
, scale
;
3764 GpPointF in
[2], out
[2];
3767 { 96.0, 96.0, 1.0, UnitPixel
,
3768 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3769 { 96.0, 96.0, 1.0, UnitDisplay
,
3770 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3771 { 96.0, 96.0, 1.0, UnitInch
,
3772 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3773 { 123.0, 456.0, 1.0, UnitPoint
,
3774 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3775 { 123.0, 456.0, 1.0, UnitDocument
,
3776 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3777 { 123.0, 456.0, 2.0, UnitMillimeter
,
3778 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3779 { 196.0, 296.0, 1.0, UnitDisplay
,
3780 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3781 { 196.0, 296.0, 1.0, UnitPixel
,
3782 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3785 GpGraphics
*graphics
;
3790 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3792 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3793 ptf
[0].X
= td
[i
].in
[0].X
;
3794 ptf
[0].Y
= td
[i
].in
[0].Y
;
3795 ptf
[1].X
= td
[i
].in
[1].X
;
3796 ptf
[1].Y
= td
[i
].in
[1].Y
;
3797 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3799 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3800 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3801 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3802 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3803 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3805 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3806 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3807 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3808 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3809 status
= GdipDeleteGraphics(graphics
);
3811 status
= GdipDisposeImage(image
);
3816 static void test_pen_thickness(void)
3818 static const struct test_data
3820 REAL res_x
, res_y
, scale
;
3821 GpUnit pen_unit
, page_unit
;
3826 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1 },
3827 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2 },
3828 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1 },
3829 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1 },
3830 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6 },
3831 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20 },
3835 GpGraphics
*graphics
;
3846 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3848 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
3851 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
3854 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
3857 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
3860 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
3863 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
3866 corner
.X
= corner
.Y
= 100.0;
3867 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
3870 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
3873 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
3876 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
3882 for (j
=0; j
<100; j
++)
3884 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3891 for (j
=99; j
>=0; j
--)
3893 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3902 ok(size
== td
[i
].cx
, "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
3907 for (j
=0; j
<100; j
++)
3909 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
3916 for (j
=99; j
>=0; j
--)
3918 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
3927 ok(size
== td
[i
].cy
, "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
3929 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
3933 GdipDeleteGraphics(graphics
);
3934 GdipDisposeImage(u
.image
);
3938 /* Many people on the net ask why there is so much difference in rendered
3939 * text height between gdiplus and gdi32, this test suggests an answer to
3940 * that question. Important: this test assumes that font dpi == device dpi.
3942 static void test_font_height_scaling(void)
3944 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3945 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3947 GpStringFormat
*format
;
3948 CharacterRange range
= { 0, 7 };
3950 GpGraphics
*graphics
;
3951 GpFontFamily
*family
;
3955 REAL height
, dpi
, scale
;
3957 GpUnit gfx_unit
, font_unit
;
3959 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3961 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3963 status
= GdipCreateRegion(®ion
);
3966 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3969 hdc
= CreateCompatibleDC(0);
3970 status
= GdipCreateFromHDC(hdc
, &graphics
);
3973 status
= GdipGetDpiY(graphics
, &dpi
);
3976 /* First check if tested functionality works:
3977 * under XP if font and graphics units differ then GdipTransformPoints
3978 * followed by GdipSetPageUnit to change the graphics units breaks region
3979 * scaling in GdipMeasureCharacterRanges called later.
3981 status
= GdipSetPageUnit(graphics
, UnitDocument
);
3986 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3989 status
= GdipSetPageUnit(graphics
, UnitInch
);
3992 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
3995 set_rect_empty(&rect
);
3996 set_rect_empty(&bounds
);
3997 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3999 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4001 set_rect_empty(&rect
);
4002 rect
.Width
= 32000.0;
4003 rect
.Height
= 32000.0;
4004 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4007 set_rect_empty(&rect
);
4008 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4010 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4012 GdipDeleteFont(font
);
4014 scale
= rect
.Height
/ bounds
.Height
;
4015 if (fabs(scale
- 1.0) > 0.1)
4017 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4021 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4024 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4025 /* UnitPixel as a font base unit is not tested because it drastically
4026 differs in behaviour */
4027 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4029 /* create a font for the final text height of 100 pixels */
4030 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4031 status
= GdipSetPageUnit(graphics
, font_unit
);
4035 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4038 /*trace("height %f units\n", height);*/
4039 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4042 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4043 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4045 static const WCHAR doubleW
[2] = { 'W','W' };
4046 RectF bounds_1
, bounds_2
;
4047 REAL margin
, margin_y
, font_height
;
4050 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4053 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4054 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4056 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4059 set_rect_empty(&rect
);
4060 set_rect_empty(&bounds
);
4061 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4063 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4065 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4068 ptf
.Y
= bounds
.Height
;
4069 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4071 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4073 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4075 /* verify the result */
4076 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4078 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4080 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4082 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4083 set_rect_empty(&rect
);
4084 set_rect_empty(&bounds_1
);
4085 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4087 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4088 set_rect_empty(&rect
);
4089 set_rect_empty(&bounds_2
);
4090 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4093 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4094 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4095 /*trace("margin %f\n", margin);*/
4096 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4098 set_rect_empty(&rect
);
4099 rect
.Width
= 320000.0;
4100 rect
.Height
= 320000.0;
4101 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4103 set_rect_empty(&rect
);
4104 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4106 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4107 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4108 expectf(0.0, rect
.Y
);
4109 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4110 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4111 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4112 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4113 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4114 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4117 GdipDeleteFont(font
);
4121 status
= GdipDeleteGraphics(graphics
);
4125 GdipDeleteFontFamily(family
);
4126 GdipDeleteRegion(region
);
4127 GdipDeleteStringFormat(format
);
4130 static void test_measure_string(void)
4132 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4133 static const WCHAR string
[] = { 'A','0','1',0 };
4135 GpStringFormat
*format
;
4136 CharacterRange range
;
4138 GpGraphics
*graphics
;
4139 GpFontFamily
*family
;
4143 REAL width
, height
, width_1
, width_2
;
4144 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4147 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4151 status
= GdipCreateRegion(®ion
);
4154 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4157 hdc
= CreateCompatibleDC(0);
4158 status
= GdipCreateFromHDC(hdc
, &graphics
);
4160 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4163 margin_x
= 20.0 / 6.0;
4164 margin_y
= 20.0 / 8.0;
4166 set_rect_empty(&rect
);
4167 set_rect_empty(&bounds
);
4168 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4172 expectf(0.0, bounds
.X
);
4173 expectf(0.0, bounds
.Y
);
4174 width
= bounds
.Width
;
4175 height
= bounds
.Height
;
4177 set_rect_empty(&rect
);
4178 rect
.Height
= height
/ 2.0;
4179 set_rect_empty(&bounds
);
4180 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4184 expectf(0.0, bounds
.X
);
4185 expectf(0.0, bounds
.Y
);
4186 expectf(width
, bounds
.Width
);
4188 expectf(height
/ 2.0, bounds
.Height
);
4191 range
.Length
= lstrlenW(string
);
4192 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4197 rect
.Width
= 32000.0;
4198 rect
.Height
= 32000.0;
4199 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4201 set_rect_empty(&bounds
);
4202 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4204 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4205 expectf(5.0, bounds
.Y
);
4206 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4208 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4210 width_rgn
= bounds
.Width
;
4211 height_rgn
= bounds
.Height
;
4215 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4218 set_rect_empty(&rect
);
4219 rect
.Width
= 32000.0;
4220 rect
.Height
= 32000.0;
4221 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4223 set_rect_empty(&bounds
);
4224 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4226 expectf_(margin_x
, bounds
.X
, 1.0);
4227 expectf(0.0, bounds
.Y
);
4228 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4229 expectf(height_rgn
, bounds
.Height
);
4230 width_1
= bounds
.Width
;
4233 range
.Length
= lstrlenW(string
);
4234 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4241 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4243 set_rect_empty(&bounds
);
4244 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4246 expectf(0.0, bounds
.X
);
4247 expectf(0.0, bounds
.Y
);
4248 expectf(0.0, bounds
.Width
);
4249 expectf(0.0, bounds
.Height
);
4253 rect
.Width
= width_rgn
/ 2.0;
4254 rect
.Height
= 32000.0;
4255 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4257 set_rect_empty(&bounds
);
4258 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4260 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4261 expectf(5.0, bounds
.Y
);
4262 expectf_(width_1
, bounds
.Width
, 1.0);
4264 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4266 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4272 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4274 set_rect_empty(&bounds
);
4275 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4277 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4278 expectf(5.0, bounds
.Y
);
4279 expectf(width_rgn
, bounds
.Width
);
4280 expectf(height_rgn
, bounds
.Height
);
4284 rect
.Width
= width_rgn
/ 2.0;
4285 rect
.Height
= 32000.0;
4286 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4288 set_rect_empty(&bounds
);
4289 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4291 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4292 expectf(5.0, bounds
.Y
);
4293 expectf_(width_1
, bounds
.Width
, 1.0);
4294 expectf(height_rgn
, bounds
.Height
);
4296 set_rect_empty(&rect
);
4297 rect
.Height
= height
/ 2.0;
4298 set_rect_empty(&bounds
);
4299 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4303 expectf(0.0, bounds
.X
);
4304 expectf(0.0, bounds
.Y
);
4305 expectf_(width
, bounds
.Width
, 0.01);
4307 expectf(height
, bounds
.Height
);
4309 set_rect_empty(&rect
);
4310 set_rect_empty(&bounds
);
4311 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4315 expectf(0.0, bounds
.X
);
4316 expectf(0.0, bounds
.Y
);
4317 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4318 expectf(height
, bounds
.Height
);
4319 width_1
= bounds
.Width
;
4321 set_rect_empty(&rect
);
4322 set_rect_empty(&bounds
);
4323 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4327 expectf(0.0, bounds
.X
);
4328 expectf(0.0, bounds
.Y
);
4329 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4330 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4331 expectf(height
, bounds
.Height
);
4332 width_2
= bounds
.Width
;
4334 set_rect_empty(&rect
);
4335 rect
.Width
= width
/ 2.0;
4336 set_rect_empty(&bounds
);
4337 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4341 expectf(0.0, bounds
.X
);
4342 expectf(0.0, bounds
.Y
);
4343 expectf_(width_1
, bounds
.Width
, 0.01);
4344 expectf(height
, bounds
.Height
);
4346 set_rect_empty(&rect
);
4347 rect
.Height
= height
;
4348 rect
.Width
= width
- 0.05;
4349 set_rect_empty(&bounds
);
4350 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4354 expectf(0.0, bounds
.X
);
4355 expectf(0.0, bounds
.Y
);
4356 expectf_(width_2
, bounds
.Width
, 0.01);
4357 expectf(height
, bounds
.Height
);
4359 set_rect_empty(&rect
);
4360 rect
.Height
= height
;
4361 rect
.Width
= width_2
- 0.05;
4362 set_rect_empty(&bounds
);
4363 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4367 expectf(0.0, bounds
.X
);
4368 expectf(0.0, bounds
.Y
);
4369 expectf_(width_1
, bounds
.Width
, 0.01);
4370 expectf(height
, bounds
.Height
);
4372 /* Default (Near) alignment */
4375 rect
.Width
= width
* 2.0;
4376 rect
.Height
= height
* 2.0;
4377 set_rect_empty(&bounds
);
4378 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4382 expectf(5.0, bounds
.X
);
4383 expectf(5.0, bounds
.Y
);
4384 expectf_(width
, bounds
.Width
, 0.01);
4385 expectf(height
, bounds
.Height
);
4389 rect
.Width
= 32000.0;
4390 rect
.Height
= 32000.0;
4391 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4393 set_rect_empty(&bounds
);
4394 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4396 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4397 expectf(5.0, bounds
.Y
);
4398 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4400 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4402 width_rgn
= bounds
.Width
;
4403 height_rgn
= bounds
.Height
;
4405 /* Center alignment */
4406 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4407 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4411 rect
.Width
= width
* 2.0;
4412 rect
.Height
= height
* 2.0;
4413 set_rect_empty(&bounds
);
4414 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4419 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4421 expectf(5.0 + height
/2.0, bounds
.Y
);
4422 expectf_(width
, bounds
.Width
, 0.01);
4423 expectf(height
, bounds
.Height
);
4429 set_rect_empty(&bounds
);
4430 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4435 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4437 expectf(5.0 - height
/2.0, bounds
.Y
);
4438 expectf_(width
, bounds
.Width
, 0.01);
4439 expectf(height
, bounds
.Height
);
4443 rect
.Width
= width_rgn
* 2.0;
4444 rect
.Height
= height_rgn
* 2.0;
4445 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4447 set_rect_empty(&bounds
);
4448 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4451 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4453 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4454 expectf_(width_rgn
, bounds
.Width
, 1.0);
4455 expectf_(height_rgn
, bounds
.Height
, 1.0);
4461 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4463 set_rect_empty(&bounds
);
4464 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4467 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4469 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4470 expectf_(width_rgn
, bounds
.Width
, 1.0);
4471 expectf_(height_rgn
, bounds
.Height
, 1.0);
4474 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4475 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4479 rect
.Width
= width
* 2.0;
4480 rect
.Height
= height
* 2.0;
4481 set_rect_empty(&bounds
);
4482 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4487 expectf_(5.0 + width
, bounds
.X
, 0.01);
4489 expectf(5.0 + height
, bounds
.Y
);
4490 expectf_(width
, bounds
.Width
, 0.01);
4491 expectf(height
, bounds
.Height
);
4497 set_rect_empty(&bounds
);
4498 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4503 expectf_(5.0 - width
, bounds
.X
, 0.01);
4505 expectf(5.0 - height
, bounds
.Y
);
4506 expectf_(width
, bounds
.Width
, 0.01);
4507 expectf(height
, bounds
.Height
);
4511 rect
.Width
= width_rgn
* 2.0;
4512 rect
.Height
= height_rgn
* 2.0;
4513 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4515 set_rect_empty(&bounds
);
4516 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4519 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4521 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4522 expectf_(width_rgn
, bounds
.Width
, 1.0);
4523 expectf_(height_rgn
, bounds
.Height
, 1.0);
4529 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4531 set_rect_empty(&bounds
);
4532 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4535 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4537 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4538 expectf_(width_rgn
, bounds
.Width
, 1.0);
4539 expectf_(height_rgn
, bounds
.Height
, 1.0);
4541 status
= GdipDeleteFont(font
);
4544 status
= GdipDeleteGraphics(graphics
);
4548 GdipDeleteFontFamily(family
);
4549 GdipDeleteRegion(region
);
4550 GdipDeleteStringFormat(format
);
4553 static void test_measured_extra_space(void)
4555 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4556 static const WCHAR string
[2] = { 'W','W' };
4557 GpStringFormat
*format
;
4559 GpGraphics
*graphics
;
4560 GpFontFamily
*family
;
4563 GpUnit gfx_unit
, font_unit
;
4564 RectF bounds_1
, bounds_2
, rect
;
4565 REAL margin
, font_size
, dpi
;
4567 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4570 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4572 hdc
= CreateCompatibleDC(0);
4573 status
= GdipCreateFromHDC(hdc
, &graphics
);
4576 status
= GdipGetDpiX(graphics
, &dpi
);
4579 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4580 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4581 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4583 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4586 status
= GdipGetFontSize(font
, &font_size
);
4588 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4589 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4591 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4592 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4594 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4597 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4598 set_rect_empty(&rect
);
4599 set_rect_empty(&bounds_1
);
4600 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4602 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4603 set_rect_empty(&rect
);
4604 set_rect_empty(&bounds_2
);
4605 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4608 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4609 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4610 /*trace("margin %f pixels\n", margin);*/
4611 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4614 GdipDeleteFont(font
);
4617 GdipDeleteGraphics(graphics
);
4619 GdipDeleteFontFamily(family
);
4620 GdipDeleteStringFormat(format
);
4623 static void test_alpha_hdc(void)
4627 HBITMAP hbm
, old_hbm
;
4628 GpGraphics
*graphics
;
4634 hdc
= CreateCompatibleDC(0);
4635 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4636 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4637 bmi
.bmiHeader
.biHeight
= 5;
4638 bmi
.bmiHeader
.biWidth
= 5;
4639 bmi
.bmiHeader
.biBitCount
= 32;
4640 bmi
.bmiHeader
.biPlanes
= 1;
4641 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4642 bmi
.bmiHeader
.biClrUsed
= 0;
4644 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4645 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4647 old_hbm
= SelectObject(hdc
, hbm
);
4649 status
= GdipCreateFromHDC(hdc
, &graphics
);
4652 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4654 expectf(0.0, bounds
.X
);
4655 expectf(0.0, bounds
.Y
);
4656 expectf(5.0, bounds
.Width
);
4657 expectf(5.0, bounds
.Height
);
4659 bits
[0] = 0xdeadbeef;
4661 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4664 expect(0xffaaaaaa, bits
[0]);
4666 bits
[0] = 0xdeadbeef;
4668 status
= GdipGetDC(graphics
, &gp_hdc
);
4671 colorref
= GetPixel(gp_hdc
, 0, 4);
4672 expect(0xefbead, colorref
);
4674 SetPixel(gp_hdc
, 0, 4, 0xffffff);
4676 expect(0xffffff, bits
[0]);
4678 status
= GdipReleaseDC(graphics
, gp_hdc
);
4681 SelectObject(hdc
, old_hbm
);
4683 bits
[0] = 0xdeadbeef;
4685 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4688 todo_wine
expect(0xffbbbbbb, bits
[0]);
4690 GdipDeleteGraphics(graphics
);
4696 static void test_bitmapfromgraphics(void)
4699 GpGraphics
*graphics
= NULL
;
4700 HDC hdc
= GetDC( hwnd
);
4701 GpBitmap
*bitmap
= NULL
;
4703 REAL imageres
, graphicsres
;
4706 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4709 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4710 expect(InvalidParameter
, stat
);
4712 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4713 expect(InvalidParameter
, stat
);
4715 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4718 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4720 expect(PixelFormat32bppPARGB
, format
);
4722 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4725 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4727 expectf(graphicsres
, imageres
);
4729 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4732 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4734 expectf(graphicsres
, imageres
);
4736 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4740 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4744 GdipDeleteGraphics(graphics
);
4745 GdipDisposeImage((GpImage
*)bitmap
);
4748 static void test_clipping(void)
4752 GpGraphics
*graphics
;
4753 GpRegion
*region
, *region100x100
;
4762 hdc
= CreateCompatibleDC(0);
4763 status
= GdipCreateFromHDC(hdc
, &graphics
);
4766 status
= GdipGetPageUnit(graphics
, &unit
);
4768 expect(UnitDisplay
, unit
);
4770 status
= GdipCreateRegion(®ion
);
4772 status
= GdipSetEmpty(region
);
4775 status
= GdipCreateRegion(®ion100x100
);
4777 status
= GdipSetEmpty(region100x100
);
4780 rect
.X
= rect
.Y
= 100.0;
4781 rect
.Width
= rect
.Height
= 100.0;
4782 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4784 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4787 status
= GdipGetClipBounds(graphics
, &rect
);
4789 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4790 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4792 status
= GdipSetEmpty(region
);
4794 status
= GdipGetClip(graphics
, region
);
4796 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4798 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4799 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4805 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4807 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4808 "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
);
4810 status
= GdipCreateMatrix(&matrix
);
4812 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4814 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4816 status
= GdipSetWorldTransform(graphics
, matrix
);
4819 status
= GdipGetClipBounds(graphics
, &rect
);
4821 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4822 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4824 status
= GdipSetEmpty(region
);
4826 status
= GdipGetClip(graphics
, region
);
4828 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4830 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4831 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4833 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4835 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4836 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4838 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4840 ret
= GetRgnBox(hrgn
, &rc
);
4841 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4842 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4843 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4846 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4848 ret
= GetRgnBox(hrgn
, &rc
);
4849 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4850 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4851 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4858 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4860 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4861 "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
);
4863 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4865 ret
= GetRgnBox(hrgn
, &rc
);
4866 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4867 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4868 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4871 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4873 ret
= GetRgnBox(hrgn
, &rc
);
4874 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4875 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4876 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4883 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4885 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4886 "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
);
4888 status
= GdipSetPageScale(graphics
, 2.0);
4891 status
= GdipGetClipBounds(graphics
, &rect
);
4893 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4894 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4896 status
= GdipSetEmpty(region
);
4898 status
= GdipGetClip(graphics
, region
);
4900 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4902 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4903 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4905 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4907 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4908 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4910 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4912 ret
= GetRgnBox(hrgn
, &rc
);
4913 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4914 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4915 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4918 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4920 ret
= GetRgnBox(hrgn
, &rc
);
4921 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4922 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4923 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4930 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4932 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4933 "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
);
4935 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4937 ret
= GetRgnBox(hrgn
, &rc
);
4938 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4939 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4940 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4943 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4945 ret
= GetRgnBox(hrgn
, &rc
);
4946 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4947 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4948 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4955 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4957 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4958 "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
);
4960 GdipSetPageUnit(graphics
, UnitPoint
);
4963 status
= GdipGetClipBounds(graphics
, &rect
);
4965 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4966 /* rounding under Wine is slightly different */
4967 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4968 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4969 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4971 status
= GdipSetEmpty(region
);
4973 status
= GdipGetClip(graphics
, region
);
4975 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4977 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4978 /* rounding under Wine is slightly different */
4979 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4980 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4981 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4983 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4985 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4986 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4988 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4990 ret
= GetRgnBox(hrgn
, &rc
);
4991 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4992 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
4993 /* rounding under Wine is slightly different */
4994 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
4995 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
4996 "expected 14,5-33,14, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4999 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5001 ret
= GetRgnBox(hrgn
, &rc
);
5002 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5003 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5004 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5005 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5012 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5014 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5015 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5016 "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
);
5018 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5020 ret
= GetRgnBox(hrgn
, &rc
);
5021 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5022 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5023 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5026 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5028 ret
= GetRgnBox(hrgn
, &rc
);
5029 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5030 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5031 /* rounding under Wine is slightly different */
5032 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5033 "expected 560,1120-1094,2187, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5040 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5042 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5044 expectf(100.0, ptf
[0].X
);
5045 expectf(100.0, ptf
[0].Y
);
5046 expectf(200.125, ptf
[1].X
);
5047 expectf(200.03125, ptf
[1].Y
);
5049 else /* before Win7 */
5051 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5052 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5053 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5054 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5057 status
= GdipTransformRegion(region100x100
, matrix
);
5060 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5062 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5063 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5065 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5067 ret
= GetRgnBox(hrgn
, &rc
);
5068 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5069 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5070 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5073 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5075 ret
= GetRgnBox(hrgn
, &rc
);
5076 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5077 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5078 /* rounding under Wine is slightly different */
5079 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5080 "expected 1147,4534-2214,8800, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5087 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5089 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5091 expectf(210.0625, ptf
[0].X
);
5092 expectf(420.0625, ptf
[0].Y
);
5093 expectf(410.125, ptf
[1].X
);
5094 expectf(820.0, ptf
[1].Y
);
5096 else /* before Win7 */
5098 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5099 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5100 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5101 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5104 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5106 status
= GdipSetWorldTransform(graphics
, matrix
);
5109 status
= GdipGetClipBounds(graphics
, &rect
);
5111 expectf_(20.612978, rect
.X
, 1.0);
5112 expectf_(-6.256012, rect
.Y
, 1.5);
5113 expectf_(25.612978, rect
.Width
, 1.0);
5114 expectf_(12.806489, rect
.Height
, 1.0);
5116 status
= GdipSetEmpty(region
);
5118 status
= GdipGetClip(graphics
, region
);
5120 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5122 /* rounding under Wine is slightly different */
5123 expectf_(20.612978, rect
.X
, 1.0);
5124 expectf_(-6.256012, rect
.Y
, 1.5);
5125 expectf_(25.612978, rect
.Width
, 1.0);
5126 expectf_(12.806489, rect
.Height
, 1.0);
5128 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5130 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5131 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5133 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5135 ret
= GetRgnBox(hrgn
, &rc
);
5136 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5137 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5138 /* rounding under Wine is slightly different */
5139 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5140 "expected (22,-6)-(46,7), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5143 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5145 ret
= GetRgnBox(hrgn
, &rc
);
5146 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5147 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5148 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5159 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5161 expectf(20.612978, ptf
[0].X
);
5162 expectf(-1.568512, ptf
[0].Y
);
5163 expectf(46.225956, ptf
[1].X
);
5164 expectf(1.862977, ptf
[1].Y
);
5165 expectf(36.850956, ptf
[2].X
);
5166 expectf(-6.256012, ptf
[2].Y
);
5167 expectf(29.987980, ptf
[3].X
);
5168 expectf(6.550478, ptf
[3].Y
);
5170 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5172 ret
= GetRgnBox(hrgn
, &rc
);
5173 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5174 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5175 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5178 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5180 ret
= GetRgnBox(hrgn
, &rc
);
5181 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5182 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5183 /* rounding under Wine is slightly different */
5184 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5185 "expected (-3406,4500)-(-350,8728), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5196 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5198 expectf(-136.190491, ptf
[0].X
);
5199 expectf(520.010742, ptf
[0].Y
);
5200 expectf(756.417175, ptf
[1].X
);
5201 expectf(720.031616, ptf
[1].Y
);
5202 expectf(360.042114, ptf
[2].X
);
5203 expectf(376.760742, ptf
[2].Y
);
5204 expectf(260.184570, ptf
[3].X
);
5205 expectf(863.281616, ptf
[3].Y
);
5207 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5209 status
= GdipSetWorldTransform(graphics
, matrix
);
5212 status
= GdipGetClipBounds(graphics
, &rect
);
5214 expectf_(-28.100956, rect
.X
, 1.0);
5215 expectf_(7.806488, rect
.Y
, 1.5);
5216 expectf_(25.612978, rect
.Width
, 1.0);
5217 expectf_(12.806489, rect
.Height
, 1.0);
5219 status
= GdipSetEmpty(region
);
5221 status
= GdipGetClip(graphics
, region
);
5223 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5225 /* rounding under Wine is slightly different */
5226 expectf_(-28.100956, rect
.X
, 1.0);
5227 expectf_(7.806488, rect
.Y
, 1.5);
5228 expectf_(25.612978, rect
.Width
, 1.0);
5229 expectf_(12.806489, rect
.Height
, 1.0);
5231 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5233 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5234 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5236 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5238 ret
= GetRgnBox(hrgn
, &rc
);
5239 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5240 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5241 /* rounding under Wine is slightly different */
5242 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5243 "expected (-27,8)-(-2,21), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5246 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5248 ret
= GetRgnBox(hrgn
, &rc
);
5249 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5250 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5251 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5262 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5264 expectf(-11.862979, ptf
[0].X
);
5265 expectf(7.806488, ptf
[0].Y
);
5266 expectf(-18.725958, ptf
[1].X
);
5267 expectf(20.612976, ptf
[1].Y
);
5268 expectf(-2.487981, ptf
[2].X
);
5269 expectf(15.925477, ptf
[2].Y
);
5270 expectf(-28.100956, ptf
[3].X
);
5271 expectf(12.493987, ptf
[3].Y
);
5273 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5275 ret
= GetRgnBox(hrgn
, &rc
);
5276 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5277 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5278 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5281 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5283 ret
= GetRgnBox(hrgn
, &rc
);
5284 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5285 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5286 /* rounding under Wine is slightly different */
5287 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5288 "expected (4500,351)-(8728,3407), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5299 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5301 expectf(-1055.021484, ptf
[0].X
);
5302 expectf(-70.595329, ptf
[0].Y
);
5303 expectf(-1455.063232, ptf
[1].X
);
5304 expectf(375.708435, ptf
[1].Y
);
5305 expectf(-768.521484, ptf
[2].X
);
5306 expectf(177.520981, ptf
[2].Y
);
5307 expectf(-1741.563110, ptf
[3].X
);
5308 expectf(127.592125, ptf
[3].Y
);
5310 GdipDeleteMatrix(matrix
);
5311 GdipDeleteRegion(region
);
5312 GdipDeleteRegion(region100x100
);
5313 GdipDeleteGraphics(graphics
);
5317 static void test_clipping_2(void)
5322 GpGraphics
*graphics
;
5332 hdc
= CreateCompatibleDC(0);
5333 status
= GdipCreateFromHDC(hdc
, &graphics
);
5336 status
= GdipGetPageUnit(graphics
, &unit
);
5338 expect(UnitDisplay
, unit
);
5340 GdipSetPageUnit(graphics
, UnitInch
);
5342 status
= GdipCreateRegion(®ion
);
5344 status
= GdipSetEmpty(region
);
5346 rect
.X
= rect
.Y
= 100.0;
5347 rect
.Width
= rect
.Height
= 100.0;
5348 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5350 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5353 status
= GdipGetClip(graphics
, region
);
5355 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5357 ret
= GetRgnBox(hrgn
, &rc
);
5358 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5359 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5360 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5362 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5364 ret
= GetRgnBox(hrgn
, &rc
);
5365 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5366 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5367 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5374 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5376 expectf(100.0, ptf
[0].X
);
5377 expectf(100.0, ptf
[0].Y
);
5378 expectf(200.0, ptf
[1].X
);
5379 expectf(200.0, ptf
[1].X
);
5381 GdipSetPageUnit(graphics
, UnitPoint
);
5383 status
= GdipGetClip(graphics
, region
);
5385 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5387 ret
= GetRgnBox(hrgn
, &rc
);
5388 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5389 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5390 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5391 "expected 7200,7200-14400,14400, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5393 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5395 ret
= GetRgnBox(hrgn
, &rc
);
5396 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5397 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5398 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5399 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5406 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5408 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5409 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5410 "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
);
5411 else /* before Win7 */
5413 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5414 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5415 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5416 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5419 GdipDeleteRegion(region
);
5421 GdipSetPageUnit(graphics
, UnitPixel
);
5423 status
= GdipCreateRegion(®ion
);
5425 status
= GdipSetEmpty(region
);
5427 rect
.X
= rect
.Y
= 100.0;
5428 rect
.Width
= rect
.Height
= 100.0;
5429 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5431 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5434 status
= GdipGetClip(graphics
, region
);
5436 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5438 ret
= GetRgnBox(hrgn
, &rc
);
5439 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5440 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5441 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5442 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5444 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5446 ret
= GetRgnBox(hrgn
, &rc
);
5447 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5448 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5449 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5450 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5457 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5459 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5460 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5461 "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
);
5462 else /* before Win7 */
5464 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5465 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5466 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5467 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5470 GdipSetPageUnit(graphics
, UnitPoint
);
5472 status
= GdipGetClip(graphics
, region
);
5474 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5476 ret
= GetRgnBox(hrgn
, &rc
);
5477 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5478 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5479 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5480 "expected 75,75-150,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5482 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5484 ret
= GetRgnBox(hrgn
, &rc
);
5485 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5486 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5487 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5488 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5495 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5497 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5498 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5499 "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
);
5500 else /* before Win7 */
5502 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5503 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5504 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5505 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5508 status
= GdipCreateMatrix(&matrix
);
5510 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5512 status
= GdipSetWorldTransform(graphics
, matrix
);
5514 GdipDeleteMatrix(matrix
);
5516 status
= GdipGetClip(graphics
, region
);
5518 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5520 ret
= GetRgnBox(hrgn
, &rc
);
5521 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5522 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5523 "expected 65,65-140,140, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5525 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5527 ret
= GetRgnBox(hrgn
, &rc
);
5528 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5529 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5530 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5537 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5539 expectf(65.0, ptf
[0].X
);
5540 expectf(65.0, ptf
[0].Y
);
5541 expectf(140.0, ptf
[1].X
);
5542 expectf(140.0, ptf
[1].X
);
5544 status
= GdipCreateMatrix(&matrix
);
5546 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5548 status
= GdipSetWorldTransform(graphics
, matrix
);
5550 GdipDeleteMatrix(matrix
);
5552 status
= GdipGetClip(graphics
, region
);
5554 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5556 ret
= GetRgnBox(hrgn
, &rc
);
5557 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5558 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5559 "expected 300,150-600,300, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5561 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5563 ret
= GetRgnBox(hrgn
, &rc
);
5564 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5565 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5566 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5573 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5575 expectf(300.0, ptf
[0].X
);
5576 expectf(150.0, ptf
[0].Y
);
5577 expectf(600.0, ptf
[1].X
);
5578 expectf(300.0, ptf
[1].Y
);
5580 status
= GdipSetPageScale(graphics
, 2.0);
5583 status
= GdipGetClip(graphics
, region
);
5585 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5587 ret
= GetRgnBox(hrgn
, &rc
);
5588 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5589 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5590 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5591 "expected 150,75-300,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5593 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5595 ret
= GetRgnBox(hrgn
, &rc
);
5596 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5597 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5598 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5599 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5606 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5608 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5610 expectf(150.0, ptf
[0].X
);
5611 expectf(75.0, ptf
[0].Y
);
5612 expectf(300.0, ptf
[1].X
);
5613 expectf(150.0, ptf
[1].Y
);
5615 else /* before Win7 */
5617 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5618 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5619 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5620 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5623 status
= GdipCreateMatrix(&matrix
);
5625 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5627 status
= GdipSetWorldTransform(graphics
, matrix
);
5629 GdipDeleteMatrix(matrix
);
5631 status
= GdipGetClip(graphics
, region
);
5633 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5635 ret
= GetRgnBox(hrgn
, &rc
);
5636 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5637 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5638 /* rounding under Wine is slightly different */
5639 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5640 "expected 54,-26-107,27, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5642 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5644 ret
= GetRgnBox(hrgn
, &rc
);
5645 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5646 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5647 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5658 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5660 expectf(53.033016, ptf
[0].X
);
5661 expectf(0.0, ptf
[0].Y
);
5662 expectf(106.066032, ptf
[1].X
);
5663 expectf(0.0, ptf
[1].Y
);
5664 expectf(79.549522, ptf
[2].X
);
5665 expectf(-26.516510, ptf
[2].Y
);
5666 expectf(79.549522, ptf
[3].X
);
5667 expectf(26.516508, ptf
[3].Y
);
5669 status
= GdipCreateMatrix(&matrix
);
5671 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5673 status
= GdipSetWorldTransform(graphics
, matrix
);
5675 GdipDeleteMatrix(matrix
);
5677 status
= GdipGetClip(graphics
, region
);
5679 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5681 ret
= GetRgnBox(hrgn
, &rc
);
5682 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5683 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5684 /* rounding under Wine is slightly different */
5685 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5686 "expected -26,54-27,107, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5688 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5690 ret
= GetRgnBox(hrgn
, &rc
);
5691 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5692 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5693 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5704 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5706 expectf(0.0, ptf
[0].X
);
5707 expectf(53.033005, ptf
[0].Y
);
5708 expectf(0.0, ptf
[1].X
);
5709 expectf(106.066010, ptf
[1].Y
);
5710 expectf(26.516491, ptf
[2].X
);
5711 expectf(79.549507, ptf
[2].Y
);
5712 expectf(-26.516520, ptf
[3].X
);
5713 expectf(79.549500, ptf
[3].Y
);
5715 GdipDeleteRegion(region
);
5716 GdipDeleteGraphics(graphics
);
5721 static void test_GdipFillRectangles(void)
5724 GpGraphics
*graphics
= NULL
;
5725 GpBrush
*brush
= NULL
;
5726 HDC hdc
= GetDC( hwnd
);
5727 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5729 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5731 status
= GdipCreateFromHDC(hdc
, &graphics
);
5733 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5735 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5737 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5739 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5740 expect(InvalidParameter
, status
);
5742 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5743 expect(InvalidParameter
, status
);
5745 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5746 expect(InvalidParameter
, status
);
5748 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5749 expect(InvalidParameter
, status
);
5751 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5752 expect(InvalidParameter
, status
);
5754 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5757 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5760 GdipDeleteBrush(brush
);
5761 GdipDeleteGraphics(graphics
);
5763 ReleaseDC(hwnd
, hdc
);
5766 static void test_GdipGetVisibleClipBounds_memoryDC(void)
5775 GpGraphics
* graphics
= NULL
;
5779 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
5780 width
= rect
.right
- rect
.left
;
5781 height
= rect
.bottom
- rect
.top
;
5784 hdc
= CreateCompatibleDC ( dc
);
5785 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
5786 old
= SelectObject (hdc
, bmp
);
5788 /*change the window origin is the key test point*/
5789 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
5791 status
= GdipCreateFromHDC(hdc
, &graphics
);
5794 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5797 ok(boundRect
.X
==rect
.left
+10 &&
5798 boundRect
.Y
==rect
.top
+10 &&
5799 boundRect
.Width
==width
&&
5800 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
5802 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
5805 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5808 ok(boundRect
.X
==rect
.left
+10 &&
5809 boundRect
.Y
==rect
.top
+10 &&
5810 boundRect
.Width
==width
-10 &&
5811 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
5813 GdipDeleteGraphics(graphics
);
5815 SelectObject (hdc
, old
);
5818 ReleaseDC(hwnd
, dc
);
5821 START_TEST(graphics
)
5823 struct GdiplusStartupInput gdiplusStartupInput
;
5824 ULONG_PTR gdiplusToken
;
5827 memset( &class, 0, sizeof(class) );
5828 class.lpszClassName
= "gdiplus_test";
5829 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5830 class.lpfnWndProc
= DefWindowProcA
;
5831 class.hInstance
= GetModuleHandleA(0);
5832 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5833 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5834 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
5835 RegisterClassA( &class );
5836 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5837 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
5838 ok(hwnd
!= NULL
, "Expected window to be created\n");
5840 gdiplusStartupInput
.GdiplusVersion
= 1;
5841 gdiplusStartupInput
.DebugEventCallback
= NULL
;
5842 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
5843 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
5845 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
5849 test_measured_extra_space();
5850 test_measure_string();
5851 test_font_height_scaling();
5853 test_pen_thickness();
5854 test_GdipMeasureString();
5855 test_constructor_destructor();
5856 test_save_restore();
5857 test_GdipFillClosedCurve2();
5858 test_GdipFillClosedCurve2I();
5859 test_GdipDrawBezierI();
5861 test_GdipDrawArcI();
5862 test_GdipDrawCurve();
5863 test_GdipDrawCurveI();
5864 test_GdipDrawCurve2();
5865 test_GdipDrawCurve2I();
5866 test_GdipDrawCurve3();
5867 test_GdipDrawCurve3I();
5868 test_GdipDrawLineI();
5869 test_GdipDrawLinesI();
5870 test_GdipDrawImagePointsRect();
5871 test_GdipFillClosedCurve();
5872 test_GdipFillClosedCurveI();
5873 test_GdipDrawString();
5874 test_GdipGetNearestColor();
5875 test_GdipGetVisibleClipBounds();
5876 test_GdipIsVisiblePoint();
5877 test_GdipIsVisibleRect();
5878 test_Get_Release_DC();
5879 test_BeginContainer2();
5880 test_transformpoints();
5881 test_get_set_clip();
5884 test_textcontrast();
5885 test_fromMemoryBitmap();
5886 test_string_functions();
5887 test_get_set_interpolation();
5888 test_get_set_textrenderinghint();
5889 test_getdc_scaled();
5891 test_bitmapfromgraphics();
5892 test_GdipFillRectangles();
5893 test_GdipGetVisibleClipBounds_memoryDC();
5895 GdiplusShutdown(gdiplusToken
);
5896 DestroyWindow( hwnd
);