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
25 #define WIN32_NO_STATUS
27 #define COM_NO_WINDOWS_H
29 //#include "windows.h"
30 #include <wine/test.h>
35 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
36 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
37 #define expectf(expected, got) expectf_((expected), (got), 0.001)
38 #define TABLE_LEN (23)
40 static const REAL mm_per_inch
= 25.4;
41 static const REAL point_per_inch
= 72.0;
44 static void set_rect_empty(RectF
*rc
)
52 /* converts a given unit to its value in pixels */
53 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
61 return units
* dpi
/ point_per_inch
;
65 return units
* dpi
/ 300.0; /* Per MSDN */
67 return units
* dpi
/ mm_per_inch
;
74 /* converts value in pixels to a given unit */
75 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
83 return pixels
* point_per_inch
/ dpi
;
87 return pixels
* 300.0 / dpi
;
89 return pixels
* mm_per_inch
/ dpi
;
96 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
98 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
99 return pixels_to_units(pixels
, to
, dpi
);
102 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
)
110 GpGraphics
*graphics
= NULL
;
113 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
116 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
118 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
121 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
125 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
127 /* image is intentionally leaked to make sure that there is no
128 side effects after its destruction.
129 status = GdipDisposeImage(u.image);
133 status
= GdipGetDpiX(graphics
, &res
);
136 status
= GdipGetDpiY(graphics
, &res
);
140 status
= GdipSetPageUnit(graphics
, unit
);
142 status
= GdipSetPageScale(graphics
, scale
);
148 static void test_constructor_destructor(void)
151 GpGraphics
*graphics
= NULL
;
152 HDC hdc
= GetDC( hwnd
);
154 stat
= GdipCreateFromHDC(NULL
, &graphics
);
155 expect(OutOfMemory
, stat
);
156 stat
= GdipDeleteGraphics(graphics
);
157 expect(InvalidParameter
, stat
);
159 stat
= GdipCreateFromHDC(hdc
, &graphics
);
161 stat
= GdipDeleteGraphics(graphics
);
164 stat
= GdipCreateFromHWND(NULL
, &graphics
);
166 stat
= GdipDeleteGraphics(graphics
);
169 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
171 stat
= GdipDeleteGraphics(graphics
);
174 stat
= GdipDeleteGraphics(NULL
);
175 expect(InvalidParameter
, stat
);
176 ReleaseDC(hwnd
, hdc
);
184 /* Linked list prepend function. */
185 static void log_state(GraphicsState data
, node
** log
)
187 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
189 new_entry
->data
= data
;
190 new_entry
->next
= *log
;
194 /* Checks if there are duplicates in the list, and frees it. */
195 static void check_no_duplicates(node
* log
)
207 while((temp
= temp
->next
)){
208 if(log
->data
== temp
->data
){
215 }while((log
= log
->next
));
220 HeapFree(GetProcessHeap(), 0, temp
);
228 static void test_save_restore(void)
231 GraphicsState state_a
, state_b
, state_c
;
232 InterpolationMode mode
;
233 GpGraphics
*graphics1
, *graphics2
;
234 node
* state_log
= NULL
;
235 HDC hdc
= GetDC( hwnd
);
236 state_a
= state_b
= state_c
= 0xdeadbeef;
238 /* Invalid saving. */
239 GdipCreateFromHDC(hdc
, &graphics1
);
240 stat
= GdipSaveGraphics(graphics1
, NULL
);
241 expect(InvalidParameter
, stat
);
242 stat
= GdipSaveGraphics(NULL
, &state_a
);
243 expect(InvalidParameter
, stat
);
244 GdipDeleteGraphics(graphics1
);
246 log_state(state_a
, &state_log
);
248 /* Basic save/restore. */
249 GdipCreateFromHDC(hdc
, &graphics1
);
250 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
251 stat
= GdipSaveGraphics(graphics1
, &state_a
);
253 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
254 stat
= GdipRestoreGraphics(graphics1
, state_a
);
256 GdipGetInterpolationMode(graphics1
, &mode
);
257 expect(InterpolationModeBilinear
, mode
);
258 GdipDeleteGraphics(graphics1
);
260 log_state(state_a
, &state_log
);
262 /* Restoring garbage doesn't affect saves. */
263 GdipCreateFromHDC(hdc
, &graphics1
);
264 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
265 GdipSaveGraphics(graphics1
, &state_a
);
266 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
267 GdipSaveGraphics(graphics1
, &state_b
);
268 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
269 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
271 GdipRestoreGraphics(graphics1
, state_b
);
272 GdipGetInterpolationMode(graphics1
, &mode
);
273 expect(InterpolationModeBicubic
, mode
);
274 GdipRestoreGraphics(graphics1
, state_a
);
275 GdipGetInterpolationMode(graphics1
, &mode
);
276 expect(InterpolationModeBilinear
, mode
);
277 GdipDeleteGraphics(graphics1
);
279 log_state(state_a
, &state_log
);
280 log_state(state_b
, &state_log
);
282 /* Restoring older state invalidates newer saves (but not older saves). */
283 GdipCreateFromHDC(hdc
, &graphics1
);
284 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
285 GdipSaveGraphics(graphics1
, &state_a
);
286 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
287 GdipSaveGraphics(graphics1
, &state_b
);
288 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
289 GdipSaveGraphics(graphics1
, &state_c
);
290 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
291 GdipRestoreGraphics(graphics1
, state_b
);
292 GdipGetInterpolationMode(graphics1
, &mode
);
293 expect(InterpolationModeBicubic
, mode
);
294 GdipRestoreGraphics(graphics1
, state_c
);
295 GdipGetInterpolationMode(graphics1
, &mode
);
296 expect(InterpolationModeBicubic
, mode
);
297 GdipRestoreGraphics(graphics1
, state_a
);
298 GdipGetInterpolationMode(graphics1
, &mode
);
299 expect(InterpolationModeBilinear
, mode
);
300 GdipDeleteGraphics(graphics1
);
302 log_state(state_a
, &state_log
);
303 log_state(state_b
, &state_log
);
304 log_state(state_c
, &state_log
);
306 /* Restoring older save from one graphics object does not invalidate
307 * newer save from other graphics object. */
308 GdipCreateFromHDC(hdc
, &graphics1
);
309 GdipCreateFromHDC(hdc
, &graphics2
);
310 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
311 GdipSaveGraphics(graphics1
, &state_a
);
312 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
313 GdipSaveGraphics(graphics2
, &state_b
);
314 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
315 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
316 GdipRestoreGraphics(graphics1
, state_a
);
317 GdipGetInterpolationMode(graphics1
, &mode
);
318 expect(InterpolationModeBilinear
, mode
);
319 GdipRestoreGraphics(graphics2
, state_b
);
320 GdipGetInterpolationMode(graphics2
, &mode
);
321 expect(InterpolationModeBicubic
, mode
);
322 GdipDeleteGraphics(graphics1
);
323 GdipDeleteGraphics(graphics2
);
325 /* You can't restore a state to a graphics object that didn't save it. */
326 GdipCreateFromHDC(hdc
, &graphics1
);
327 GdipCreateFromHDC(hdc
, &graphics2
);
328 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
329 GdipSaveGraphics(graphics1
, &state_a
);
330 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
331 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
332 GdipRestoreGraphics(graphics2
, state_a
);
333 GdipGetInterpolationMode(graphics2
, &mode
);
334 expect(InterpolationModeNearestNeighbor
, mode
);
335 GdipDeleteGraphics(graphics1
);
336 GdipDeleteGraphics(graphics2
);
338 log_state(state_a
, &state_log
);
340 /* The same state value should never be returned twice. */
342 check_no_duplicates(state_log
);
344 ReleaseDC(hwnd
, hdc
);
347 static void test_GdipFillClosedCurve2(void)
350 GpGraphics
*graphics
= NULL
;
351 GpSolidFill
*brush
= NULL
;
352 HDC hdc
= GetDC( hwnd
);
364 /* make a graphics object and brush object */
365 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
367 status
= GdipCreateFromHDC(hdc
, &graphics
);
369 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
371 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
373 /* InvalidParameter cases: null graphics, null brush, null points */
374 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
375 expect(InvalidParameter
, status
);
377 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
378 expect(InvalidParameter
, status
);
380 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
381 expect(InvalidParameter
, status
);
383 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
384 expect(InvalidParameter
, status
);
386 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
387 expect(InvalidParameter
, status
);
389 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
390 expect(InvalidParameter
, status
);
392 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
393 expect(InvalidParameter
, status
);
395 /* InvalidParameter cases: invalid count */
396 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
397 expect(InvalidParameter
, status
);
399 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
400 expect(InvalidParameter
, status
);
402 /* Valid test cases */
403 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
406 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
409 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
412 GdipDeleteGraphics(graphics
);
413 GdipDeleteBrush((GpBrush
*)brush
);
415 ReleaseDC(hwnd
, hdc
);
418 static void test_GdipFillClosedCurve2I(void)
421 GpGraphics
*graphics
= NULL
;
422 GpSolidFill
*brush
= NULL
;
423 HDC hdc
= GetDC( hwnd
);
435 /* make a graphics object and brush object */
436 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
438 status
= GdipCreateFromHDC(hdc
, &graphics
);
440 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
442 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
444 /* InvalidParameter cases: null graphics, null brush */
445 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
446 when points == NULL, so don't test this condition */
447 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
448 expect(InvalidParameter
, status
);
450 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
451 expect(InvalidParameter
, status
);
453 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
454 expect(InvalidParameter
, status
);
456 /* InvalidParameter cases: invalid count */
457 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
458 expect(InvalidParameter
, status
);
460 /* OutOfMemory cases: large (unsigned) int */
461 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
462 expect(OutOfMemory
, status
);
464 /* Valid test cases */
465 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
468 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
471 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
474 GdipDeleteGraphics(graphics
);
475 GdipDeleteBrush((GpBrush
*)brush
);
477 ReleaseDC(hwnd
, hdc
);
480 static void test_GdipDrawArc(void)
483 GpGraphics
*graphics
= NULL
;
485 HDC hdc
= GetDC( hwnd
);
487 /* make a graphics object and pen object */
488 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
490 status
= GdipCreateFromHDC(hdc
, &graphics
);
492 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
494 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
496 ok(pen
!= NULL
, "Expected pen to be initialized\n");
498 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
499 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
500 expect(InvalidParameter
, status
);
502 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
503 expect(InvalidParameter
, status
);
505 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
506 expect(InvalidParameter
, status
);
508 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
509 expect(InvalidParameter
, status
);
511 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
512 expect(InvalidParameter
, status
);
514 /* successful case */
515 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
519 GdipDeleteGraphics(graphics
);
521 ReleaseDC(hwnd
, hdc
);
524 static void test_GdipDrawArcI(void)
527 GpGraphics
*graphics
= NULL
;
529 HDC hdc
= GetDC( hwnd
);
531 /* make a graphics object and pen object */
532 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
534 status
= GdipCreateFromHDC(hdc
, &graphics
);
536 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
538 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
540 ok(pen
!= NULL
, "Expected pen to be initialized\n");
542 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
543 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
544 expect(InvalidParameter
, status
);
546 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
547 expect(InvalidParameter
, status
);
549 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
550 expect(InvalidParameter
, status
);
552 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
553 expect(InvalidParameter
, status
);
555 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
556 expect(InvalidParameter
, status
);
558 /* successful case */
559 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
563 GdipDeleteGraphics(graphics
);
565 ReleaseDC(hwnd
, hdc
);
568 static void test_BeginContainer2(void)
572 REAL defClip
[] = {5, 10, 15, 20};
573 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
574 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
575 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
576 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
577 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
578 REAL scale
, defScale
= 17;
579 GpUnit unit
, defUnit
= UnitPixel
;
580 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
581 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
582 UINT contrast
, defContrast
= 5;
583 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
586 GpGraphics
*graphics
= NULL
;
587 HDC hdc
= GetDC( hwnd
);
589 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
591 status
= GdipCreateFromHDC(hdc
, &graphics
);
593 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
595 /* null graphics, null container */
596 status
= GdipBeginContainer2(NULL
, &cont1
);
597 expect(InvalidParameter
, status
);
599 status
= GdipBeginContainer2(graphics
, NULL
);
600 expect(InvalidParameter
, status
);
602 status
= GdipEndContainer(NULL
, cont1
);
603 expect(InvalidParameter
, status
);
605 /* test all quality-related values */
606 GdipSetCompositingMode(graphics
, defCompmode
);
607 GdipSetCompositingQuality(graphics
, defCompqual
);
608 GdipSetInterpolationMode(graphics
, defInterp
);
609 GdipSetPageScale(graphics
, defScale
);
610 GdipSetPageUnit(graphics
, defUnit
);
611 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
612 GdipSetSmoothingMode(graphics
, defSmoothmode
);
613 GdipSetTextContrast(graphics
, defContrast
);
614 GdipSetTextRenderingHint(graphics
, defTexthint
);
616 status
= GdipBeginContainer2(graphics
, &cont1
);
619 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
620 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
621 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
622 GdipSetPageScale(graphics
, 10);
623 GdipSetPageUnit(graphics
, UnitDocument
);
624 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
625 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
626 GdipSetTextContrast(graphics
, 7);
627 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
629 status
= GdipEndContainer(graphics
, cont1
);
632 GdipGetCompositingMode(graphics
, &compmode
);
633 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
635 GdipGetCompositingQuality(graphics
, &compqual
);
636 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
638 GdipGetInterpolationMode(graphics
, &interp
);
639 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
641 GdipGetPageScale(graphics
, &scale
);
642 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
644 GdipGetPageUnit(graphics
, &unit
);
645 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
647 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
648 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
650 GdipGetSmoothingMode(graphics
, &smoothmode
);
651 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
653 GdipGetTextContrast(graphics
, &contrast
);
654 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
656 GdipGetTextRenderingHint(graphics
, &texthint
);
657 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
659 /* test world transform */
660 status
= GdipBeginContainer2(graphics
, &cont1
);
663 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
664 defTrans
[4], defTrans
[5], &transform
);
666 GdipSetWorldTransform(graphics
, transform
);
667 GdipDeleteMatrix(transform
);
670 status
= GdipBeginContainer2(graphics
, &cont2
);
673 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
675 GdipSetWorldTransform(graphics
, transform
);
676 GdipDeleteMatrix(transform
);
679 status
= GdipEndContainer(graphics
, cont2
);
682 status
= GdipCreateMatrix(&transform
);
684 GdipGetWorldTransform(graphics
, transform
);
685 GdipGetMatrixElements(transform
, elems
);
686 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
687 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
688 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
689 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
690 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
691 fabs(defTrans
[5] - elems
[5]) < 0.0001,
692 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
693 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
694 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
695 GdipDeleteMatrix(transform
);
698 status
= GdipEndContainer(graphics
, cont1
);
702 status
= GdipBeginContainer2(graphics
, &cont1
);
705 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
707 status
= GdipBeginContainer2(graphics
, &cont2
);
710 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
712 status
= GdipEndContainer(graphics
, cont2
);
715 status
= GdipGetClipBounds(graphics
, &clip
);
718 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
719 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
720 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
721 fabs(defClip
[3] - clip
.Height
) < 0.0001,
722 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
723 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
724 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
726 status
= GdipEndContainer(graphics
, cont1
);
730 status
= GdipBeginContainer2(graphics
, &cont1
);
733 status
= GdipBeginContainer2(graphics
, &cont2
);
736 status
= GdipBeginContainer2(graphics
, &cont3
);
739 status
= GdipEndContainer(graphics
, cont3
);
742 status
= GdipBeginContainer2(graphics
, &cont4
);
745 status
= GdipEndContainer(graphics
, cont4
);
749 status
= GdipEndContainer(graphics
, cont1
);
752 /* end an already-ended container */
753 status
= GdipEndContainer(graphics
, cont1
);
756 GdipDeleteGraphics(graphics
);
757 ReleaseDC(hwnd
, hdc
);
760 static void test_GdipDrawBezierI(void)
763 GpGraphics
*graphics
= NULL
;
765 HDC hdc
= GetDC( hwnd
);
767 /* make a graphics object and pen object */
768 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
770 status
= GdipCreateFromHDC(hdc
, &graphics
);
772 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
774 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
776 ok(pen
!= NULL
, "Expected pen to be initialized\n");
778 /* InvalidParameter cases: null graphics, null pen */
779 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
780 expect(InvalidParameter
, status
);
782 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
783 expect(InvalidParameter
, status
);
785 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
786 expect(InvalidParameter
, status
);
788 /* successful case */
789 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
793 GdipDeleteGraphics(graphics
);
795 ReleaseDC(hwnd
, hdc
);
798 static void test_GdipDrawCurve3(void)
801 GpGraphics
*graphics
= NULL
;
803 HDC hdc
= GetDC( hwnd
);
815 /* make a graphics object and pen object */
816 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
818 status
= GdipCreateFromHDC(hdc
, &graphics
);
820 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
822 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
824 ok(pen
!= NULL
, "Expected pen to be initialized\n");
826 /* InvalidParameter cases: null graphics, null pen */
827 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
828 expect(InvalidParameter
, status
);
830 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
831 expect(InvalidParameter
, status
);
833 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
834 expect(InvalidParameter
, status
);
836 /* InvalidParameter cases: invalid count */
837 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
838 expect(InvalidParameter
, status
);
840 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
841 expect(InvalidParameter
, status
);
843 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
844 expect(InvalidParameter
, status
);
846 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
847 expect(InvalidParameter
, status
);
849 /* InvalidParameter cases: invalid number of segments */
850 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
851 expect(InvalidParameter
, status
);
853 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
854 expect(InvalidParameter
, status
);
856 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
857 expect(InvalidParameter
, status
);
859 /* Valid test cases */
860 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
863 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
866 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
869 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
873 GdipDeleteGraphics(graphics
);
875 ReleaseDC(hwnd
, hdc
);
878 static void test_GdipDrawCurve3I(void)
881 GpGraphics
*graphics
= NULL
;
883 HDC hdc
= GetDC( hwnd
);
895 /* make a graphics object and pen object */
896 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
898 status
= GdipCreateFromHDC(hdc
, &graphics
);
900 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
902 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
904 ok(pen
!= NULL
, "Expected pen to be initialized\n");
906 /* InvalidParameter cases: null graphics, null pen */
907 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
908 expect(InvalidParameter
, status
);
910 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
911 expect(InvalidParameter
, status
);
913 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
914 expect(InvalidParameter
, status
);
916 /* InvalidParameter cases: invalid count */
917 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
918 expect(OutOfMemory
, status
);
920 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
921 expect(InvalidParameter
, status
);
923 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
924 expect(InvalidParameter
, status
);
926 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
927 expect(InvalidParameter
, status
);
929 /* InvalidParameter cases: invalid number of segments */
930 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
931 expect(InvalidParameter
, status
);
933 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
934 expect(InvalidParameter
, status
);
936 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
937 expect(InvalidParameter
, status
);
939 /* Valid test cases */
940 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
943 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
946 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
949 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
953 GdipDeleteGraphics(graphics
);
955 ReleaseDC(hwnd
, hdc
);
958 static void test_GdipDrawCurve2(void)
961 GpGraphics
*graphics
= NULL
;
963 HDC hdc
= GetDC( hwnd
);
975 /* make a graphics object and pen object */
976 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
978 status
= GdipCreateFromHDC(hdc
, &graphics
);
980 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
982 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
984 ok(pen
!= NULL
, "Expected pen to be initialized\n");
986 /* InvalidParameter cases: null graphics, null pen */
987 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
988 expect(InvalidParameter
, status
);
990 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
991 expect(InvalidParameter
, status
);
993 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
994 expect(InvalidParameter
, status
);
996 /* InvalidParameter cases: invalid count */
997 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
998 expect(InvalidParameter
, status
);
1000 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
1001 expect(InvalidParameter
, status
);
1003 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
1004 expect(InvalidParameter
, status
);
1006 /* Valid test cases */
1007 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1010 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1013 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1016 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1020 GdipDeleteGraphics(graphics
);
1022 ReleaseDC(hwnd
, hdc
);
1025 static void test_GdipDrawCurve2I(void)
1028 GpGraphics
*graphics
= NULL
;
1030 HDC hdc
= GetDC( hwnd
);
1042 /* make a graphics object and pen object */
1043 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1045 status
= GdipCreateFromHDC(hdc
, &graphics
);
1047 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1049 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1051 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1053 /* InvalidParameter cases: null graphics, null pen */
1054 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1055 expect(InvalidParameter
, status
);
1057 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1058 expect(InvalidParameter
, status
);
1060 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1061 expect(InvalidParameter
, status
);
1063 /* InvalidParameter cases: invalid count */
1064 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1065 expect(OutOfMemory
, status
);
1067 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1068 expect(InvalidParameter
, status
);
1070 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1071 expect(InvalidParameter
, status
);
1073 /* Valid test cases */
1074 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1077 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1080 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1083 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1087 GdipDeleteGraphics(graphics
);
1089 ReleaseDC(hwnd
, hdc
);
1092 static void test_GdipDrawCurve(void)
1095 GpGraphics
*graphics
= NULL
;
1097 HDC hdc
= GetDC( hwnd
);
1109 /* make a graphics object and pen object */
1110 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1112 status
= GdipCreateFromHDC(hdc
, &graphics
);
1114 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1116 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1118 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1120 /* InvalidParameter cases: null graphics, null pen */
1121 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1122 expect(InvalidParameter
, status
);
1124 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1125 expect(InvalidParameter
, status
);
1127 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1128 expect(InvalidParameter
, status
);
1130 /* InvalidParameter cases: invalid count */
1131 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1132 expect(InvalidParameter
, status
);
1134 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1135 expect(InvalidParameter
, status
);
1137 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1138 expect(InvalidParameter
, status
);
1140 /* Valid test cases */
1141 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1144 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1148 GdipDeleteGraphics(graphics
);
1150 ReleaseDC(hwnd
, hdc
);
1153 static void test_GdipDrawCurveI(void)
1156 GpGraphics
*graphics
= NULL
;
1158 HDC hdc
= GetDC( hwnd
);
1170 /* make a graphics object and pen object */
1171 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1173 status
= GdipCreateFromHDC(hdc
, &graphics
);
1175 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1177 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1179 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1181 /* InvalidParameter cases: null graphics, null pen */
1182 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1183 expect(InvalidParameter
, status
);
1185 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1186 expect(InvalidParameter
, status
);
1188 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1189 expect(InvalidParameter
, status
);
1191 /* InvalidParameter cases: invalid count */
1192 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1193 expect(OutOfMemory
, status
);
1195 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1196 expect(InvalidParameter
, status
);
1198 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1199 expect(InvalidParameter
, status
);
1201 /* Valid test cases */
1202 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1205 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1209 GdipDeleteGraphics(graphics
);
1211 ReleaseDC(hwnd
, hdc
);
1214 static void test_GdipDrawLineI(void)
1217 GpGraphics
*graphics
= NULL
;
1219 HDC hdc
= GetDC( hwnd
);
1221 /* make a graphics object and pen object */
1222 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1224 status
= GdipCreateFromHDC(hdc
, &graphics
);
1226 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1228 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1230 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1232 /* InvalidParameter cases: null graphics, null pen */
1233 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1234 expect(InvalidParameter
, status
);
1236 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1237 expect(InvalidParameter
, status
);
1239 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1240 expect(InvalidParameter
, status
);
1242 /* successful case */
1243 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1247 GdipDeleteGraphics(graphics
);
1249 ReleaseDC(hwnd
, hdc
);
1252 static void test_GdipDrawImagePointsRect(void)
1255 GpGraphics
*graphics
= NULL
;
1257 GpBitmap
*bm
= NULL
;
1258 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1260 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1261 HDC hdc
= GetDC( hwnd
);
1265 memset(rbmi
, 0, sizeof(rbmi
));
1266 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1267 bmi
->bmiHeader
.biWidth
= 10;
1268 bmi
->bmiHeader
.biHeight
= 10;
1269 bmi
->bmiHeader
.biPlanes
= 1;
1270 bmi
->bmiHeader
.biBitCount
= 32;
1271 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1272 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1274 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1275 status
= GdipCreateFromHDC(hdc
, &graphics
);
1285 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1286 expect(NotImplemented
, status
);
1287 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1288 expect(InvalidParameter
, status
);
1289 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1291 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1292 expect(InvalidParameter
, status
);
1293 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1294 expect(InvalidParameter
, status
);
1295 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1297 memset(ptf
, 0, sizeof(ptf
));
1298 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1301 GdipDisposeImage((GpImage
*)bm
);
1302 GdipDeleteGraphics(graphics
);
1303 ReleaseDC(hwnd
, hdc
);
1306 static void test_GdipDrawLinesI(void)
1309 GpGraphics
*graphics
= NULL
;
1311 GpPoint
*ptf
= NULL
;
1312 HDC hdc
= GetDC( hwnd
);
1314 /* make a graphics object and pen object */
1315 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1317 status
= GdipCreateFromHDC(hdc
, &graphics
);
1319 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1321 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1323 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1325 /* make some arbitrary valid points*/
1326 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1334 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1335 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1336 expect(InvalidParameter
, status
);
1338 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1339 expect(InvalidParameter
, status
);
1341 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1342 expect(InvalidParameter
, status
);
1344 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1345 expect(InvalidParameter
, status
);
1347 /* successful case */
1348 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1353 GdipDeleteGraphics(graphics
);
1355 ReleaseDC(hwnd
, hdc
);
1358 static void test_GdipFillClosedCurve(void)
1361 GpGraphics
*graphics
= NULL
;
1362 GpSolidFill
*brush
= NULL
;
1363 HDC hdc
= GetDC( hwnd
);
1375 /* make a graphics object and brush object */
1376 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1378 status
= GdipCreateFromHDC(hdc
, &graphics
);
1380 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1382 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1384 /* InvalidParameter cases: null graphics, null brush, null points */
1385 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1386 expect(InvalidParameter
, status
);
1388 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1389 expect(InvalidParameter
, status
);
1391 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1392 expect(InvalidParameter
, status
);
1394 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1395 expect(InvalidParameter
, status
);
1397 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1398 expect(InvalidParameter
, status
);
1400 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1401 expect(InvalidParameter
, status
);
1403 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1404 expect(InvalidParameter
, status
);
1406 /* InvalidParameter cases: invalid count */
1407 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1408 expect(InvalidParameter
, status
);
1410 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1411 expect(InvalidParameter
, status
);
1413 /* Valid test cases */
1414 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1417 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1420 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1423 GdipDeleteGraphics(graphics
);
1424 GdipDeleteBrush((GpBrush
*)brush
);
1426 ReleaseDC(hwnd
, hdc
);
1429 static void test_GdipFillClosedCurveI(void)
1432 GpGraphics
*graphics
= NULL
;
1433 GpSolidFill
*brush
= NULL
;
1434 HDC hdc
= GetDC( hwnd
);
1446 /* make a graphics object and brush object */
1447 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1449 status
= GdipCreateFromHDC(hdc
, &graphics
);
1451 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1453 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1455 /* InvalidParameter cases: null graphics, null brush */
1456 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1457 when points == NULL, so don't test this condition */
1458 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1459 expect(InvalidParameter
, status
);
1461 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1462 expect(InvalidParameter
, status
);
1464 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1465 expect(InvalidParameter
, status
);
1467 /* InvalidParameter cases: invalid count */
1468 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1469 expect(InvalidParameter
, status
);
1471 /* OutOfMemory cases: large (unsigned) int */
1472 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1473 expect(OutOfMemory
, status
);
1475 /* Valid test cases */
1476 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1479 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1482 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1485 GdipDeleteGraphics(graphics
);
1486 GdipDeleteBrush((GpBrush
*)brush
);
1488 ReleaseDC(hwnd
, hdc
);
1491 static void test_Get_Release_DC(void)
1494 GpGraphics
*graphics
= NULL
;
1498 HDC hdc
= GetDC( hwnd
);
1501 CompositingQuality quality
;
1502 CompositingMode compmode
;
1503 InterpolationMode intmode
;
1507 PixelOffsetMode offsetmode
;
1508 SmoothingMode smoothmode
;
1509 TextRenderingHint texthint
;
1517 ARGB color
= 0x00000000;
1518 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1531 for(i
= 0; i
< 5;i
++){
1532 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1533 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1539 rect
[0].Height
= 70;
1543 rect
[1].Height
= 20;
1545 for(i
= 0; i
< 2;i
++){
1546 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1547 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1548 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1549 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1552 status
= GdipCreateMatrix(&m
);
1554 GdipCreateRegion(®ion
);
1555 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1556 GdipCreatePath(FillModeAlternate
, &path
);
1557 GdipCreateRegion(&clip
);
1559 status
= GdipCreateFromHDC(hdc
, &graphics
);
1561 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1562 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1565 /* NULL arguments */
1566 status
= GdipGetDC(NULL
, NULL
);
1567 expect(InvalidParameter
, status
);
1568 status
= GdipGetDC(graphics
, NULL
);
1569 expect(InvalidParameter
, status
);
1570 status
= GdipGetDC(NULL
, &retdc
);
1571 expect(InvalidParameter
, status
);
1573 status
= GdipReleaseDC(NULL
, NULL
);
1574 expect(InvalidParameter
, status
);
1575 status
= GdipReleaseDC(graphics
, NULL
);
1576 expect(InvalidParameter
, status
);
1577 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1578 expect(InvalidParameter
, status
);
1580 /* Release without Get */
1581 status
= GdipReleaseDC(graphics
, hdc
);
1582 expect(InvalidParameter
, status
);
1585 status
= GdipGetDC(graphics
, &retdc
);
1587 ok(retdc
== hdc
, "Invalid HDC returned\n");
1588 /* call it once more */
1589 status
= GdipGetDC(graphics
, &retdc
);
1590 expect(ObjectBusy
, status
);
1592 /* try all Graphics calls here */
1593 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1594 expect(ObjectBusy
, status
);
1595 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1596 expect(ObjectBusy
, status
);
1597 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1598 expect(ObjectBusy
, status
);
1599 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1600 expect(ObjectBusy
, status
);
1601 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1602 expect(ObjectBusy
, status
);
1603 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1604 expect(ObjectBusy
, status
);
1605 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1606 expect(ObjectBusy
, status
);
1607 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1608 expect(ObjectBusy
, status
);
1609 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1610 expect(ObjectBusy
, status
);
1611 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1612 expect(ObjectBusy
, status
);
1613 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1614 expect(ObjectBusy
, status
);
1615 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1616 expect(ObjectBusy
, status
);
1617 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1618 expect(ObjectBusy
, status
);
1619 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1620 expect(ObjectBusy
, status
);
1621 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1622 expect(ObjectBusy
, status
);
1623 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1624 expect(ObjectBusy
, status
);
1625 /* GdipDrawImage/GdipDrawImageI */
1626 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1627 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1628 /* GdipDrawImageRect/GdipDrawImageRectI */
1629 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1630 expect(ObjectBusy
, status
);
1631 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1632 expect(ObjectBusy
, status
);
1633 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1634 expect(ObjectBusy
, status
);
1635 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1636 expect(ObjectBusy
, status
);
1637 status
= GdipDrawPath(graphics
, pen
, path
);
1638 expect(ObjectBusy
, status
);
1639 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1640 expect(ObjectBusy
, status
);
1641 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1642 expect(ObjectBusy
, status
);
1643 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1644 expect(ObjectBusy
, status
);
1645 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1646 expect(ObjectBusy
, status
);
1647 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1648 expect(ObjectBusy
, status
);
1649 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1650 expect(ObjectBusy
, status
);
1651 /* GdipDrawString */
1652 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1653 expect(ObjectBusy
, status
);
1654 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1655 expect(ObjectBusy
, status
);
1656 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1657 expect(ObjectBusy
, status
);
1658 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1659 expect(ObjectBusy
, status
);
1660 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1661 expect(ObjectBusy
, status
);
1662 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1663 expect(ObjectBusy
, status
);
1664 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1665 expect(ObjectBusy
, status
);
1666 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1667 expect(ObjectBusy
, status
);
1668 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1669 expect(ObjectBusy
, status
);
1670 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1671 expect(ObjectBusy
, status
);
1672 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1673 expect(ObjectBusy
, status
);
1674 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1675 expect(ObjectBusy
, status
);
1676 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1677 expect(ObjectBusy
, status
);
1678 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1679 expect(ObjectBusy
, status
);
1680 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1681 expect(ObjectBusy
, status
);
1682 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1683 expect(ObjectBusy
, status
);
1684 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1685 expect(ObjectBusy
, status
);
1686 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1687 expect(ObjectBusy
, status
);
1688 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1689 expect(ObjectBusy
, status
);
1690 status
= GdipGetClipBounds(graphics
, rectf
);
1691 expect(ObjectBusy
, status
);
1692 status
= GdipGetClipBoundsI(graphics
, rect
);
1693 expect(ObjectBusy
, status
);
1694 status
= GdipGetCompositingMode(graphics
, &compmode
);
1695 expect(ObjectBusy
, status
);
1696 status
= GdipGetCompositingQuality(graphics
, &quality
);
1697 expect(ObjectBusy
, status
);
1698 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1699 expect(ObjectBusy
, status
);
1700 status
= GdipGetNearestColor(graphics
, &color
);
1701 expect(ObjectBusy
, status
);
1702 status
= GdipGetPageScale(graphics
, &r
);
1703 expect(ObjectBusy
, status
);
1704 status
= GdipGetPageUnit(graphics
, &unit
);
1705 expect(ObjectBusy
, status
);
1706 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1707 expect(ObjectBusy
, status
);
1708 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1709 expect(ObjectBusy
, status
);
1710 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1711 expect(ObjectBusy
, status
);
1712 status
= GdipGetWorldTransform(graphics
, m
);
1713 expect(ObjectBusy
, status
);
1714 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1715 expect(ObjectBusy
, status
);
1716 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1717 expect(ObjectBusy
, status
);
1718 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1719 expect(ObjectBusy
, status
);
1720 /* GdipMeasureCharacterRanges */
1721 /* GdipMeasureString */
1722 status
= GdipResetClip(graphics
);
1723 expect(ObjectBusy
, status
);
1724 status
= GdipResetWorldTransform(graphics
);
1725 expect(ObjectBusy
, status
);
1726 /* GdipRestoreGraphics */
1727 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1728 expect(ObjectBusy
, status
);
1729 /* GdipSaveGraphics */
1730 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1731 expect(ObjectBusy
, status
);
1732 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1733 expect(ObjectBusy
, status
);
1734 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1735 expect(ObjectBusy
, status
);
1736 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1737 expect(ObjectBusy
, status
);
1738 status
= GdipSetPageScale(graphics
, 1.0);
1739 expect(ObjectBusy
, status
);
1740 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1741 expect(ObjectBusy
, status
);
1742 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1743 expect(ObjectBusy
, status
);
1744 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1745 expect(ObjectBusy
, status
);
1746 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1747 expect(ObjectBusy
, status
);
1748 status
= GdipSetWorldTransform(graphics
, m
);
1749 expect(ObjectBusy
, status
);
1750 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1751 expect(ObjectBusy
, status
);
1752 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1753 expect(ObjectBusy
, status
);
1754 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1755 expect(ObjectBusy
, status
);
1756 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1757 expect(ObjectBusy
, status
);
1758 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1759 expect(ObjectBusy
, status
);
1760 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1761 expect(ObjectBusy
, status
);
1762 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1763 expect(ObjectBusy
, status
);
1764 status
= GdipTranslateClipI(graphics
, 0, 0);
1765 expect(ObjectBusy
, status
);
1766 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1767 expect(ObjectBusy
, status
);
1768 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1769 expect(ObjectBusy
, status
);
1770 status
= GdipGetDpiX(graphics
, &r
);
1771 expect(ObjectBusy
, status
);
1772 status
= GdipGetDpiY(graphics
, &r
);
1773 expect(ObjectBusy
, status
);
1774 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1775 expect(ObjectBusy
, status
);
1776 status
= GdipGetClip(graphics
, region
);
1777 expect(ObjectBusy
, status
);
1778 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1779 expect(ObjectBusy
, status
);
1781 /* try to delete before release */
1782 status
= GdipDeleteGraphics(graphics
);
1783 expect(ObjectBusy
, status
);
1785 status
= GdipReleaseDC(graphics
, retdc
);
1789 GdipDeleteGraphics(graphics
);
1791 GdipDeleteRegion(clip
);
1792 GdipDeletePath(path
);
1793 GdipDeleteBrush((GpBrush
*)brush
);
1794 GdipDeleteRegion(region
);
1795 GdipDeleteMatrix(m
);
1798 ReleaseDC(hwnd
, hdc
);
1801 static void test_transformpoints(void)
1804 GpGraphics
*graphics
= NULL
;
1805 HDC hdc
= GetDC( hwnd
);
1809 status
= GdipCreateFromHDC(hdc
, &graphics
);
1812 /* NULL arguments */
1813 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1814 expect(InvalidParameter
, status
);
1815 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1816 expect(InvalidParameter
, status
);
1817 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1818 expect(InvalidParameter
, status
);
1819 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1820 expect(InvalidParameter
, status
);
1826 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1828 expectf(1.0, ptf
[0].X
);
1829 expectf(0.0, ptf
[0].Y
);
1830 expectf(0.0, ptf
[1].X
);
1831 expectf(1.0, ptf
[1].Y
);
1833 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1835 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1837 status
= GdipSetPageScale(graphics
, 3.0);
1844 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1846 expectf(18.0, ptf
[0].X
);
1847 expectf(15.0, ptf
[0].Y
);
1848 expectf(15.0, ptf
[1].X
);
1849 expectf(18.0, ptf
[1].Y
);
1855 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1857 expectf(6.0, ptf
[0].X
);
1858 expectf(5.0, ptf
[0].Y
);
1859 expectf(5.0, ptf
[1].X
);
1860 expectf(6.0, ptf
[1].Y
);
1866 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1868 expectf(3.0, ptf
[0].X
);
1869 expectf(0.0, ptf
[0].Y
);
1870 expectf(0.0, ptf
[1].X
);
1871 expectf(3.0, ptf
[1].Y
);
1877 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, 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
, CoordinateSpaceWorld
, CoordinateSpacePage
, 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
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1901 expectf(1.0, ptf
[0].X
);
1902 expectf(0.0, ptf
[0].Y
);
1903 expectf(0.0, ptf
[1].X
);
1904 expectf(1.0, ptf
[1].Y
);
1910 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1912 expect(18, pt
[0].X
);
1913 expect(15, pt
[0].Y
);
1914 expect(15, pt
[1].X
);
1915 expect(18, pt
[1].Y
);
1917 GdipDeleteGraphics(graphics
);
1918 ReleaseDC(hwnd
, hdc
);
1921 static void test_get_set_clip(void)
1924 GpGraphics
*graphics
= NULL
;
1925 HDC hdc
= GetDC( hwnd
);
1930 status
= GdipCreateFromHDC(hdc
, &graphics
);
1933 rect
.X
= rect
.Y
= 0.0;
1934 rect
.Height
= rect
.Width
= 100.0;
1936 status
= GdipCreateRegionRect(&rect
, &clip
);
1939 /* NULL arguments */
1940 status
= GdipGetClip(NULL
, NULL
);
1941 expect(InvalidParameter
, status
);
1942 status
= GdipGetClip(graphics
, NULL
);
1943 expect(InvalidParameter
, status
);
1944 status
= GdipGetClip(NULL
, clip
);
1945 expect(InvalidParameter
, status
);
1947 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1948 expect(InvalidParameter
, status
);
1949 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1950 expect(InvalidParameter
, status
);
1952 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1953 expect(InvalidParameter
, status
);
1954 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1955 expect(InvalidParameter
, status
);
1958 status
= GdipGetClip(graphics
, clip
);
1960 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1964 /* remains infinite after reset */
1966 status
= GdipResetClip(graphics
);
1968 status
= GdipGetClip(graphics
, clip
);
1970 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1974 /* set to empty and then reset to infinite */
1975 status
= GdipSetEmpty(clip
);
1977 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1980 status
= GdipGetClip(graphics
, clip
);
1983 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1986 status
= GdipResetClip(graphics
);
1988 status
= GdipGetClip(graphics
, clip
);
1991 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1995 GdipDeleteRegion(clip
);
1997 GdipDeleteGraphics(graphics
);
1998 ReleaseDC(hwnd
, hdc
);
2001 static void test_isempty(void)
2004 GpGraphics
*graphics
= NULL
;
2005 HDC hdc
= GetDC( hwnd
);
2009 status
= GdipCreateFromHDC(hdc
, &graphics
);
2012 status
= GdipCreateRegion(&clip
);
2016 status
= GdipIsClipEmpty(NULL
, NULL
);
2017 expect(InvalidParameter
, status
);
2018 status
= GdipIsClipEmpty(graphics
, NULL
);
2019 expect(InvalidParameter
, status
);
2020 status
= GdipIsClipEmpty(NULL
, &res
);
2021 expect(InvalidParameter
, status
);
2023 /* default is infinite */
2025 status
= GdipIsClipEmpty(graphics
, &res
);
2029 GdipDeleteRegion(clip
);
2031 GdipDeleteGraphics(graphics
);
2032 ReleaseDC(hwnd
, hdc
);
2035 static void test_clear(void)
2039 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2040 expect(InvalidParameter
, status
);
2043 static void test_textcontrast(void)
2046 HDC hdc
= GetDC( hwnd
);
2047 GpGraphics
*graphics
;
2050 status
= GdipGetTextContrast(NULL
, NULL
);
2051 expect(InvalidParameter
, status
);
2053 status
= GdipCreateFromHDC(hdc
, &graphics
);
2056 status
= GdipGetTextContrast(graphics
, NULL
);
2057 expect(InvalidParameter
, status
);
2058 status
= GdipGetTextContrast(graphics
, &contrast
);
2060 expect(4, contrast
);
2062 GdipDeleteGraphics(graphics
);
2063 ReleaseDC(hwnd
, hdc
);
2066 static void test_GdipDrawString(void)
2069 GpGraphics
*graphics
= NULL
;
2072 GpStringFormat
*format
;
2075 HDC hdc
= GetDC( hwnd
);
2076 static const WCHAR string
[] = {'T','e','s','t',0};
2077 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2080 memset(&logfont
,0,sizeof(logfont
));
2081 strcpy(logfont
.lfFaceName
,"Arial");
2082 logfont
.lfHeight
= 12;
2083 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2085 status
= GdipCreateFromHDC(hdc
, &graphics
);
2088 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2089 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2091 skip("Arial not installed.\n");
2096 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2099 status
= GdipCreateStringFormat(0,0,&format
);
2107 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2110 status
= GdipCreateMatrix(&matrix
);
2113 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2114 expect(InvalidParameter
, status
);
2116 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2117 expect(InvalidParameter
, status
);
2119 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2120 expect(InvalidParameter
, status
);
2122 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2123 expect(InvalidParameter
, status
);
2125 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2126 expect(InvalidParameter
, status
);
2128 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2131 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2134 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2137 GdipDeleteMatrix(matrix
);
2138 GdipDeleteGraphics(graphics
);
2139 GdipDeleteBrush(brush
);
2140 GdipDeleteFont(fnt
);
2141 GdipDeleteStringFormat(format
);
2143 ReleaseDC(hwnd
, hdc
);
2146 static void test_GdipGetVisibleClipBounds_screen(void)
2149 GpGraphics
*graphics
= NULL
;
2151 GpRectF rectf
, exp
, clipr
;
2154 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2156 status
= GdipCreateFromHDC(hdc
, &graphics
);
2158 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2160 /* no clipping rect */
2163 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2164 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2166 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2168 ok(rectf
.X
== exp
.X
&&
2170 rectf
.Width
== exp
.Width
&&
2171 rectf
.Height
== exp
.Height
,
2172 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2173 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2174 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2175 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2177 /* clipping rect entirely within window */
2178 exp
.X
= clipr
.X
= 10;
2179 exp
.Y
= clipr
.Y
= 12;
2180 exp
.Width
= clipr
.Width
= 14;
2181 exp
.Height
= clipr
.Height
= 16;
2183 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2186 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2188 ok(rectf
.X
== exp
.X
&&
2190 rectf
.Width
== exp
.Width
&&
2191 rectf
.Height
== exp
.Height
,
2192 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2193 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2194 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2195 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2197 /* clipping rect partially outside of screen */
2203 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2211 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2213 ok(rectf
.X
== exp
.X
&&
2215 rectf
.Width
== exp
.Width
&&
2216 rectf
.Height
== exp
.Height
,
2217 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2218 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2219 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2220 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2222 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2224 ok(recti
.X
== exp
.X
&&
2226 recti
.Width
== exp
.Width
&&
2227 recti
.Height
== exp
.Height
,
2228 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2229 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2230 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2231 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2233 GdipDeleteGraphics(graphics
);
2237 static void test_GdipGetVisibleClipBounds_window(void)
2240 GpGraphics
*graphics
= NULL
;
2241 GpRectF rectf
, window
, exp
, clipr
;
2247 /* get client area size */
2248 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2249 window
.X
= wnd_rect
.left
;
2250 window
.Y
= wnd_rect
.top
;
2251 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2252 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2254 hdc
= BeginPaint(hwnd
, &ps
);
2256 status
= GdipCreateFromHDC(hdc
, &graphics
);
2258 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2260 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2262 ok(rectf
.X
== window
.X
&&
2263 rectf
.Y
== window
.Y
&&
2264 rectf
.Width
== window
.Width
&&
2265 rectf
.Height
== window
.Height
,
2266 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2267 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2268 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2269 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2271 /* clipping rect entirely within window */
2272 exp
.X
= clipr
.X
= 20;
2273 exp
.Y
= clipr
.Y
= 8;
2274 exp
.Width
= clipr
.Width
= 30;
2275 exp
.Height
= clipr
.Height
= 20;
2277 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2280 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2282 ok(rectf
.X
== exp
.X
&&
2284 rectf
.Width
== exp
.Width
&&
2285 rectf
.Height
== exp
.Height
,
2286 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2287 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2288 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2289 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2291 /* clipping rect partially outside of window */
2292 clipr
.X
= window
.Width
- 10;
2293 clipr
.Y
= window
.Height
- 15;
2297 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2300 exp
.X
= window
.Width
- 10;
2301 exp
.Y
= window
.Height
- 15;
2305 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2307 ok(rectf
.X
== exp
.X
&&
2309 rectf
.Width
== exp
.Width
&&
2310 rectf
.Height
== exp
.Height
,
2311 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2312 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2313 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2314 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2316 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2318 ok(recti
.X
== exp
.X
&&
2320 recti
.Width
== exp
.Width
&&
2321 recti
.Height
== exp
.Height
,
2322 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2323 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2324 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2325 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2327 GdipDeleteGraphics(graphics
);
2328 EndPaint(hwnd
, &ps
);
2331 static void test_GdipGetVisibleClipBounds(void)
2333 GpGraphics
* graphics
= NULL
;
2336 HDC hdc
= GetDC( hwnd
);
2339 status
= GdipCreateFromHDC(hdc
, &graphics
);
2341 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2343 /* test null parameters */
2344 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2345 expect(InvalidParameter
, status
);
2347 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2348 expect(InvalidParameter
, status
);
2350 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2351 expect(InvalidParameter
, status
);
2353 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2354 expect(InvalidParameter
, status
);
2356 GdipDeleteGraphics(graphics
);
2357 ReleaseDC(hwnd
, hdc
);
2359 test_GdipGetVisibleClipBounds_screen();
2360 test_GdipGetVisibleClipBounds_window();
2363 static void test_fromMemoryBitmap(void)
2366 GpGraphics
*graphics
= NULL
;
2367 GpBitmap
*bitmap
= NULL
;
2368 BYTE bits
[48] = {0};
2372 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2375 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2378 status
= GdipGraphicsClear(graphics
, 0xff686868);
2381 GdipDeleteGraphics(graphics
);
2383 /* drawing writes to the memory provided */
2384 expect(0x68, bits
[10]);
2386 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2389 status
= GdipGetDC(graphics
, &hdc
);
2391 ok(hdc
!= NULL
, "got NULL hdc\n");
2393 color
= GetPixel(hdc
, 0, 0);
2394 /* The HDC is write-only, and native fills with a solid color to figure out
2395 * which pixels have changed. */
2396 todo_wine
expect(0x0c0b0d, color
);
2398 SetPixel(hdc
, 0, 0, 0x797979);
2399 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2401 status
= GdipReleaseDC(graphics
, hdc
);
2404 GdipDeleteGraphics(graphics
);
2406 expect(0x79, bits
[0]);
2407 todo_wine
expect(0x68, bits
[3]);
2409 GdipDisposeImage((GpImage
*)bitmap
);
2411 /* We get the same kind of write-only HDC for a "normal" bitmap */
2412 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2415 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2418 status
= GdipGetDC(graphics
, &hdc
);
2420 ok(hdc
!= NULL
, "got NULL hdc\n");
2422 color
= GetPixel(hdc
, 0, 0);
2423 todo_wine
expect(0x0c0b0d, color
);
2425 status
= GdipReleaseDC(graphics
, hdc
);
2428 GdipDeleteGraphics(graphics
);
2430 GdipDisposeImage((GpImage
*)bitmap
);
2433 static void test_GdipIsVisiblePoint(void)
2436 GpGraphics
*graphics
= NULL
;
2437 HDC hdc
= GetDC( hwnd
);
2441 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2443 status
= GdipCreateFromHDC(hdc
, &graphics
);
2445 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2447 /* null parameters */
2448 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2449 expect(InvalidParameter
, status
);
2451 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2452 expect(InvalidParameter
, status
);
2454 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2455 expect(InvalidParameter
, status
);
2457 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2458 expect(InvalidParameter
, status
);
2462 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2464 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2468 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2470 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2474 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2476 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2480 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2482 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2484 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2489 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2491 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2495 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2497 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2499 /* translate into the center of the rect */
2500 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2504 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2506 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2510 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2512 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2514 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2519 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2521 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2525 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2527 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2531 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2533 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2537 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2539 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2543 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2545 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2549 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2551 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2555 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2557 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2561 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2563 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2567 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2569 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2573 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2575 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2579 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2581 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2585 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2587 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2591 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2593 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2595 /* integer version */
2598 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2600 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2604 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2606 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2608 GdipDeleteGraphics(graphics
);
2609 ReleaseDC(hwnd
, hdc
);
2612 static void test_GdipIsVisibleRect(void)
2615 GpGraphics
*graphics
= NULL
;
2616 HDC hdc
= GetDC( hwnd
);
2617 REAL x
, y
, width
, height
;
2620 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2622 status
= GdipCreateFromHDC(hdc
, &graphics
);
2624 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2626 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2627 expect(InvalidParameter
, status
);
2629 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2630 expect(InvalidParameter
, status
);
2632 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2633 expect(InvalidParameter
, status
);
2635 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2636 expect(InvalidParameter
, status
);
2638 /* entirely within the visible region */
2641 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2643 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2645 /* partially outside */
2646 x
= -10; width
= 20;
2647 y
= -10; height
= 20;
2648 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2650 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2652 /* entirely outside */
2654 y
= -10; height
= 5;
2655 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2657 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2659 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2662 /* entirely within the visible region */
2664 y
= 22; height
= 10;
2665 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2667 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2669 /* partially outside */
2671 y
= 55; height
= 10;
2672 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2674 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2676 /* entirely outside */
2679 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2681 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2683 /* translate into center of clipping rect */
2684 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2688 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2690 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2694 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2696 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2698 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2700 /* corners entirely outside, but some intersections */
2703 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2705 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2709 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2711 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2715 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2717 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2721 y
= 20; height
= 40;
2722 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2724 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2728 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2730 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2733 y
= 20; height
= 40;
2734 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2736 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2739 y
= 60; height
= 10;
2740 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2742 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2744 /* rounding tests */
2745 x
= 0.4; width
= 10.4;
2746 y
= 20; height
= 40;
2747 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2749 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2752 y
= 0.4; height
= 20.4;
2753 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2755 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2757 /* integer version */
2760 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2762 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2765 y
= 22; height
= 10;
2766 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2768 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2770 GdipDeleteGraphics(graphics
);
2771 ReleaseDC(hwnd
, hdc
);
2774 static void test_GdipGetNearestColor(void)
2777 GpGraphics
*graphics
;
2779 ARGB color
= 0xdeadbeef;
2780 HDC hdc
= GetDC( hwnd
);
2782 /* create a graphics object */
2783 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2785 status
= GdipCreateFromHDC(hdc
, &graphics
);
2787 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2789 status
= GdipGetNearestColor(graphics
, NULL
);
2790 expect(InvalidParameter
, status
);
2792 status
= GdipGetNearestColor(NULL
, &color
);
2793 expect(InvalidParameter
, status
);
2794 GdipDeleteGraphics(graphics
);
2796 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2798 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2799 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2802 status
= GdipGetNearestColor(graphics
, &color
);
2804 expect(0xdeadbeef, color
);
2805 GdipDeleteGraphics(graphics
);
2807 GdipDisposeImage((GpImage
*)bitmap
);
2809 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2811 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2812 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2815 status
= GdipGetNearestColor(graphics
, &color
);
2817 expect(0xdeadbeef, color
);
2818 GdipDeleteGraphics(graphics
);
2820 GdipDisposeImage((GpImage
*)bitmap
);
2822 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2824 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2825 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2828 status
= GdipGetNearestColor(graphics
, &color
);
2830 expect(0xdeadbeef, color
);
2831 GdipDeleteGraphics(graphics
);
2833 GdipDisposeImage((GpImage
*)bitmap
);
2835 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2837 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2838 todo_wine
expect(OutOfMemory
, status
);
2840 GdipDeleteGraphics(graphics
);
2841 GdipDisposeImage((GpImage
*)bitmap
);
2843 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2845 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2847 status
= GdipGetNearestColor(graphics
, &color
);
2849 expect(0xdeadbeef, color
);
2850 GdipDeleteGraphics(graphics
);
2851 GdipDisposeImage((GpImage
*)bitmap
);
2853 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, 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, PixelFormat32bppARGB
, 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, PixelFormat48bppRGB
, NULL
, &bitmap
);
2877 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2879 status
= GdipGetNearestColor(graphics
, &color
);
2881 expect(0xdeadbeef, color
);
2882 GdipDeleteGraphics(graphics
);
2883 GdipDisposeImage((GpImage
*)bitmap
);
2886 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2890 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2892 status
= GdipGetNearestColor(graphics
, &color
);
2894 expect(0xdeadbeef, color
);
2895 GdipDeleteGraphics(graphics
);
2896 GdipDisposeImage((GpImage
*)bitmap
);
2899 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
2903 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2905 status
= GdipGetNearestColor(graphics
, &color
);
2907 expect(0xdeadbeef, color
);
2908 GdipDeleteGraphics(graphics
);
2909 GdipDisposeImage((GpImage
*)bitmap
);
2912 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
2914 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2916 status
= GdipGetNearestColor(graphics
, &color
);
2918 todo_wine
expect(0xffa8bce8, color
);
2919 GdipDeleteGraphics(graphics
);
2920 GdipDisposeImage((GpImage
*)bitmap
);
2922 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
2924 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2926 status
= GdipGetNearestColor(graphics
, &color
);
2929 ok(color
== 0xffa8b8e8 ||
2930 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
2931 "Expected ffa8b8e8, got %.8x\n", color
);
2932 GdipDeleteGraphics(graphics
);
2933 GdipDisposeImage((GpImage
*)bitmap
);
2935 ReleaseDC(hwnd
, hdc
);
2938 #if CORE_6659_IS_FIXED
2939 static void test_string_functions(void)
2942 GpGraphics
*graphics
;
2943 GpFontFamily
*family
;
2945 RectF rc
, char_bounds
, bounds
;
2947 ARGB color
= 0xff000000;
2948 HDC hdc
= GetDC( hwnd
);
2949 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
2950 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
2951 const WCHAR teststring2
[] = {'j',0};
2952 REAL char_width
, char_height
;
2953 INT codepointsfitted
, linesfilled
;
2954 GpStringFormat
*format
;
2955 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
2956 GpRegion
*regions
[4];
2957 BOOL region_isempty
[4];
2959 PointF positions
[8];
2962 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2963 status
= GdipCreateFromHDC(hdc
, &graphics
);
2965 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2967 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
2970 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
2973 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
2976 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
2984 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
2985 expect(InvalidParameter
, status
);
2987 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
2988 expect(InvalidParameter
, status
);
2990 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
2991 expect(InvalidParameter
, status
);
2993 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
2994 expect(InvalidParameter
, status
);
2996 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
2997 expect(InvalidParameter
, status
);
2999 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3002 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3003 expect(InvalidParameter
, status
);
3005 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3006 expect(InvalidParameter
, status
);
3008 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3009 expect(InvalidParameter
, status
);
3011 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3012 expect(InvalidParameter
, status
);
3014 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3015 expect(InvalidParameter
, status
);
3017 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3020 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3023 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3025 expectf(0.0, char_bounds
.X
);
3026 expectf(0.0, char_bounds
.Y
);
3027 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3028 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3029 expect(1, codepointsfitted
);
3030 expect(1, linesfilled
);
3032 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3034 expectf(0.0, bounds
.X
);
3035 expectf(0.0, bounds
.Y
);
3036 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3037 expectf(char_bounds
.Height
, bounds
.Height
);
3038 expect(2, codepointsfitted
);
3039 expect(1, linesfilled
);
3040 char_width
= bounds
.Width
- char_bounds
.Width
;
3042 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3044 expectf(0.0, bounds
.X
);
3045 expectf(0.0, bounds
.Y
);
3046 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3047 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3048 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3049 expect(6, codepointsfitted
);
3050 expect(2, linesfilled
);
3051 char_height
= bounds
.Height
- char_bounds
.Height
;
3053 /* Measure the first line. */
3054 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3056 expectf(0.0, bounds
.X
);
3057 expectf(0.0, bounds
.Y
);
3058 expect(4, codepointsfitted
);
3059 expect(1, linesfilled
);
3061 /* Give just enough space to fit the first line. */
3062 rc
.Width
= bounds
.Width
;
3063 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3065 expectf(0.0, bounds
.X
);
3066 expectf(0.0, bounds
.Y
);
3067 todo_wine
expect(5, codepointsfitted
);
3068 todo_wine
expect(1, linesfilled
);
3070 /* Cut off everything after the first space. */
3071 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3073 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3075 expectf(0.0, bounds
.X
);
3076 expectf(0.0, bounds
.Y
);
3077 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3078 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3079 expect(6, codepointsfitted
);
3080 expect(3, linesfilled
);
3082 /* Cut off everything including the first space. */
3083 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3085 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3087 expectf(0.0, bounds
.X
);
3088 expectf(0.0, bounds
.Y
);
3089 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3090 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3091 expect(6, codepointsfitted
);
3092 expect(3, linesfilled
);
3094 /* Cut off everything after the first character. */
3095 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3097 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3099 expectf(0.0, bounds
.X
);
3100 expectf(0.0, bounds
.Y
);
3101 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3102 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3103 expect(6, codepointsfitted
);
3104 todo_wine
expect(4, linesfilled
);
3106 for (i
= 0; i
< 4; i
++)
3107 regions
[i
] = (GpRegion
*)0xdeadbeef;
3109 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3112 for (i
= 0; i
< 4; i
++)
3113 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3115 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3118 for (i
= 0; i
< 4; i
++)
3119 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3121 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3124 set_rect_empty(&rc
);
3128 status
= GdipCreateRegion(®ions
[i
]);
3130 status
= GdipSetEmpty(regions
[i
]);
3134 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3135 expect(InvalidParameter
, status
);
3137 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3138 expect(InvalidParameter
, status
);
3140 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3141 expect(InvalidParameter
, status
);
3143 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3144 expect(InvalidParameter
, status
);
3148 /* Crashes on Windows XP */
3149 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3150 expect(InvalidParameter
, status
);
3153 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3154 expect(InvalidParameter
, status
);
3156 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3157 expect(InvalidParameter
, status
);
3159 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3162 for (i
= 0; i
< 4; i
++)
3164 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3168 ok(region_isempty
[0], "region should be empty\n");
3169 ok(region_isempty
[1], "region should be empty\n");
3170 ok(region_isempty
[2], "region should be empty\n");
3171 ok(region_isempty
[3], "region should be empty\n");
3176 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3181 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3185 ok(!region_isempty
[0], "region shouldn't be empty\n");
3186 ok(!region_isempty
[1], "region shouldn't be empty\n");
3187 ok(!region_isempty
[2], "region shouldn't be empty\n");
3188 ok(region_isempty
[3], "region should be empty\n");
3190 /* Cut off everything after the first space, and the second line. */
3191 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3192 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3194 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3199 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3203 ok(!region_isempty
[0], "region shouldn't be empty\n");
3204 ok(!region_isempty
[1], "region shouldn't be empty\n");
3205 ok(region_isempty
[2], "region should be empty\n");
3206 ok(region_isempty
[3], "region should be empty\n");
3209 GdipDeleteRegion(regions
[i
]);
3211 status
= GdipCreateMatrix(&identity
);
3218 memset(positions
, 0, sizeof(positions
));
3219 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3220 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3222 expect(InvalidParameter
, status
);
3224 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3225 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3227 expect(InvalidParameter
, status
);
3229 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3230 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3232 expect(InvalidParameter
, status
);
3234 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3235 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3237 expect(InvalidParameter
, status
);
3239 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3240 0x100, identity
, &rc
);
3243 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3244 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3248 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3249 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3251 expect(InvalidParameter
, status
);
3257 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3258 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3263 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3264 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3265 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3267 char_width
= rc
.Width
;
3268 char_height
= rc
.Height
;
3274 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3275 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3280 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3281 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3282 expectf(char_height
, rc
.Height
);
3288 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3289 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3294 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3295 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3296 expectf(rc
.Height
, char_height
);
3298 GdipDeleteMatrix(identity
);
3299 GdipDeleteStringFormat(format
);
3300 GdipDeleteBrush(brush
);
3301 GdipDeleteFont(font
);
3302 GdipDeleteFontFamily(family
);
3303 GdipDeleteGraphics(graphics
);
3305 ReleaseDC(hwnd
, hdc
);
3307 #endif /* CORE_6659_IS_FIXED */
3309 static void test_get_set_interpolation(void)
3311 GpGraphics
*graphics
;
3312 HDC hdc
= GetDC( hwnd
);
3314 InterpolationMode mode
;
3316 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3317 status
= GdipCreateFromHDC(hdc
, &graphics
);
3319 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3321 status
= GdipGetInterpolationMode(NULL
, &mode
);
3322 expect(InvalidParameter
, status
);
3326 /* Crashes on Windows XP */
3327 status
= GdipGetInterpolationMode(graphics
, NULL
);
3328 expect(InvalidParameter
, status
);
3331 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3332 expect(InvalidParameter
, status
);
3335 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3336 expect(InvalidParameter
, status
);
3338 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3339 expect(InvalidParameter
, status
);
3341 status
= GdipGetInterpolationMode(graphics
, &mode
);
3343 expect(InterpolationModeBilinear
, mode
);
3345 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3348 status
= GdipGetInterpolationMode(graphics
, &mode
);
3350 expect(InterpolationModeNearestNeighbor
, mode
);
3352 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3355 status
= GdipGetInterpolationMode(graphics
, &mode
);
3357 expect(InterpolationModeBilinear
, mode
);
3359 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3362 status
= GdipGetInterpolationMode(graphics
, &mode
);
3364 expect(InterpolationModeBilinear
, mode
);
3366 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3369 status
= GdipGetInterpolationMode(graphics
, &mode
);
3371 expect(InterpolationModeHighQualityBicubic
, mode
);
3373 GdipDeleteGraphics(graphics
);
3375 ReleaseDC(hwnd
, hdc
);
3378 static void test_get_set_textrenderinghint(void)
3380 GpGraphics
*graphics
;
3381 HDC hdc
= GetDC( hwnd
);
3383 TextRenderingHint hint
;
3385 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3386 status
= GdipCreateFromHDC(hdc
, &graphics
);
3388 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3390 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3391 expect(InvalidParameter
, status
);
3393 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3394 expect(InvalidParameter
, status
);
3396 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3397 expect(InvalidParameter
, status
);
3400 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3401 expect(InvalidParameter
, status
);
3403 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3405 expect(TextRenderingHintSystemDefault
, hint
);
3407 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3410 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3412 expect(TextRenderingHintSystemDefault
, hint
);
3414 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3417 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3419 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3421 GdipDeleteGraphics(graphics
);
3423 ReleaseDC(hwnd
, hdc
);
3426 static void test_getdc_scaled(void)
3429 GpGraphics
*graphics
= NULL
;
3430 GpBitmap
*bitmap
= NULL
;
3432 HBRUSH hbrush
, holdbrush
;
3435 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3438 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3441 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3444 status
= GdipGetDC(graphics
, &hdc
);
3446 ok(hdc
!= NULL
, "got NULL hdc\n");
3448 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3450 holdbrush
= SelectObject(hdc
, hbrush
);
3452 Rectangle(hdc
, 2, 2, 6, 6);
3454 SelectObject(hdc
, holdbrush
);
3456 DeleteObject(hbrush
);
3458 status
= GdipReleaseDC(graphics
, hdc
);
3461 GdipDeleteGraphics(graphics
);
3463 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3465 expect(0xffff0000, color
);
3467 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3469 expect(0xff000000, color
);
3471 GdipDisposeImage((GpImage
*)bitmap
);
3474 static void test_GdipMeasureString(void)
3476 static const struct test_data
3478 REAL res_x
, res_y
, page_scale
;
3482 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3483 { 200.0, 200.0, 2.0, UnitPixel
},
3484 { 200.0, 200.0, 1.0, UnitDisplay
},
3485 { 200.0, 200.0, 2.0, UnitDisplay
},
3486 { 200.0, 200.0, 1.0, UnitInch
},
3487 { 200.0, 200.0, 2.0, UnitInch
},
3488 { 200.0, 600.0, 1.0, UnitPoint
},
3489 { 200.0, 600.0, 2.0, UnitPoint
},
3490 { 200.0, 600.0, 1.0, UnitDocument
},
3491 { 200.0, 600.0, 2.0, UnitDocument
},
3492 { 200.0, 600.0, 1.0, UnitMillimeter
},
3493 { 200.0, 600.0, 2.0, UnitMillimeter
},
3494 { 200.0, 600.0, 1.0, UnitDisplay
},
3495 { 200.0, 600.0, 2.0, UnitDisplay
},
3496 { 200.0, 600.0, 1.0, UnitPixel
},
3497 { 200.0, 600.0, 2.0, UnitPixel
},
3499 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3500 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3502 GpGraphics
*graphics
;
3503 GpFontFamily
*family
;
3505 GpStringFormat
*format
;
3507 REAL base_cx
= 0, base_cy
= 0, height
;
3512 GpUnit font_unit
, unit
;
3514 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3516 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3519 /* font size in pixels */
3520 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3522 status
= GdipGetFontSize(font
, &font_size
);
3524 expectf(100.0, font_size
);
3525 status
= GdipGetFontUnit(font
, &font_unit
);
3527 expect(UnitPixel
, font_unit
);
3529 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3531 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
);
3533 lf
.lfHeight
= 0xdeadbeef;
3534 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3536 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3537 if (td
[i
].unit
!= UnitDisplay
)
3538 height
*= td
[i
].page_scale
;
3539 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3540 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3542 height
= font_size
+ 2.0 * font_size
/ 6.0;
3544 set_rect_empty(&rc
);
3545 set_rect_empty(&bounds
);
3546 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3551 base_cx
= bounds
.Width
;
3552 base_cy
= bounds
.Height
;
3555 expectf(0.0, bounds
.X
);
3556 expectf(0.0, bounds
.Y
);
3558 expectf_(height
, bounds
.Height
, height
/ 100.0);
3559 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3563 /* make sure it really fits */
3564 bounds
.Width
+= 1.0;
3565 bounds
.Height
+= 1.0;
3569 set_rect_empty(&bounds
);
3570 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3572 expectf(50.0, bounds
.X
);
3573 expectf(50.0, bounds
.Y
);
3575 expectf_(height
, bounds
.Height
, height
/ 100.0);
3576 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3580 status
= GdipDeleteGraphics(graphics
);
3584 GdipDeleteFont(font
);
3586 /* font size in logical units */
3587 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3588 for (unit
= 3; unit
<= 6; unit
++)
3590 /* create a font which final height is 100.0 pixels with 200 dpi device */
3591 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3592 height
= pixels_to_units(75.0, unit
, 200.0);
3593 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3595 status
= GdipGetFontSize(font
, &font_size
);
3597 expectf(height
, font_size
);
3598 status
= GdipGetFontUnit(font
, &font_unit
);
3600 expect(unit
, font_unit
);
3602 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3606 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
);
3608 lf
.lfHeight
= 0xdeadbeef;
3609 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3611 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3612 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3614 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3615 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3616 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3617 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3619 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3620 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3622 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3623 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3624 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3625 if (td
[i
].unit
!= UnitDisplay
)
3626 height
/= td
[i
].page_scale
;
3627 /*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);*/
3629 set_rect_empty(&rc
);
3630 set_rect_empty(&bounds
);
3631 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3636 base_cx
= bounds
.Width
;
3637 base_cy
= bounds
.Height
;
3640 expectf(0.0, bounds
.X
);
3641 expectf(0.0, bounds
.Y
);
3643 expectf_(height
, bounds
.Height
, height
/ 85.0);
3644 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3648 /* make sure it really fits */
3649 bounds
.Width
+= 1.0;
3650 bounds
.Height
+= 1.0;
3654 set_rect_empty(&bounds
);
3655 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3657 expectf(50.0, bounds
.X
);
3658 expectf(50.0, bounds
.Y
);
3660 expectf_(height
, bounds
.Height
, height
/ 85.0);
3661 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3665 /* verify the result */
3666 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3667 if (td
[i
].unit
!= UnitDisplay
)
3668 height
*= td
[i
].page_scale
;
3669 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3670 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3672 expectf_(100.0, height
, 1.1);
3674 status
= GdipDeleteGraphics(graphics
);
3678 GdipDeleteFont(font
);
3681 GdipDeleteFontFamily(family
);
3682 GdipDeleteStringFormat(format
);
3685 static void test_transform(void)
3687 static const struct test_data
3689 REAL res_x
, res_y
, scale
;
3691 GpPointF in
[2], out
[2];
3694 { 96.0, 96.0, 1.0, UnitPixel
,
3695 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3696 { 96.0, 96.0, 1.0, UnitDisplay
,
3697 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3698 { 96.0, 96.0, 1.0, UnitInch
,
3699 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3700 { 123.0, 456.0, 1.0, UnitPoint
,
3701 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3702 { 123.0, 456.0, 1.0, UnitDocument
,
3703 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3704 { 123.0, 456.0, 2.0, UnitMillimeter
,
3705 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3706 { 196.0, 296.0, 1.0, UnitDisplay
,
3707 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3708 { 196.0, 296.0, 1.0, UnitPixel
,
3709 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3712 GpGraphics
*graphics
;
3716 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3718 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
);
3719 ptf
[0].X
= td
[i
].in
[0].X
;
3720 ptf
[0].Y
= td
[i
].in
[0].Y
;
3721 ptf
[1].X
= td
[i
].in
[1].X
;
3722 ptf
[1].Y
= td
[i
].in
[1].Y
;
3723 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3725 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3726 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3727 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3728 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3729 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3731 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3732 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3733 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3734 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3735 status
= GdipDeleteGraphics(graphics
);
3740 /* Many people on the net ask why there is so much difference in rendered
3741 * text height between gdiplus and gdi32, this test suggests an answer to
3742 * that question. Important: this test assumes that font dpi == device dpi.
3744 static void test_font_height_scaling(void)
3746 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3747 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3749 GpStringFormat
*format
;
3750 CharacterRange range
= { 0, 7 };
3752 GpGraphics
*graphics
;
3753 GpFontFamily
*family
;
3757 REAL height
, dpi
, scale
;
3759 GpUnit gfx_unit
, font_unit
;
3761 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3763 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3765 status
= GdipCreateRegion(®ion
);
3768 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3771 hdc
= CreateCompatibleDC(0);
3772 status
= GdipCreateFromHDC(hdc
, &graphics
);
3774 status
= GdipGetDpiY(graphics
, &dpi
);
3777 /* First check if tested functionality works:
3778 * under XP if font and graphics units differ then GdipTransformPoints
3779 * followed by GdipSetPageUnit to change the graphics units breaks region
3780 * scaling in GdipMeasureCharacterRanges called later.
3782 status
= GdipSetPageUnit(graphics
, UnitDocument
);
3787 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3790 status
= GdipSetPageUnit(graphics
, UnitInch
);
3793 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
3796 set_rect_empty(&rect
);
3797 set_rect_empty(&bounds
);
3798 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3800 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
3802 set_rect_empty(&rect
);
3803 rect
.Width
= 32000.0;
3804 rect
.Height
= 32000.0;
3805 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3808 set_rect_empty(&rect
);
3809 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3811 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
3813 GdipDeleteFont(font
);
3815 scale
= rect
.Height
/ bounds
.Height
;
3816 if (fabs(scale
- 1.0) > 0.1)
3818 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
3822 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
3825 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3826 /* UnitPixel as a font base unit is not tested because it drastically
3827 differs in behaviour */
3828 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
3830 /* create a font for the final text height of 100 pixels */
3831 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3832 status
= GdipSetPageUnit(graphics
, font_unit
);
3836 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
3839 /*trace("height %f units\n", height);*/
3840 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
3843 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3844 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
3846 static const WCHAR doubleW
[2] = { 'W','W' };
3847 RectF bounds_1
, bounds_2
;
3848 REAL margin
, margin_y
, font_height
;
3851 status
= GdipSetPageUnit(graphics
, gfx_unit
);
3854 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
3855 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
3857 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
3860 set_rect_empty(&rect
);
3861 set_rect_empty(&bounds
);
3862 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
3864 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
3866 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
3869 ptf
.Y
= bounds
.Height
;
3870 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
3872 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3874 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3876 /* verify the result */
3877 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
3879 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
3881 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
3883 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
3884 set_rect_empty(&rect
);
3885 set_rect_empty(&bounds_1
);
3886 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
3888 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
3889 set_rect_empty(&rect
);
3890 set_rect_empty(&bounds_2
);
3891 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
3894 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
3895 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
3896 /*trace("margin %f\n", margin);*/
3897 ok(margin
> 0.0, "wrong margin %f\n", margin
);
3899 set_rect_empty(&rect
);
3900 rect
.Width
= 320000.0;
3901 rect
.Height
= 320000.0;
3902 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
3904 set_rect_empty(&rect
);
3905 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
3907 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
3908 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
3909 expectf(0.0, rect
.Y
);
3910 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
3911 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
3912 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
3913 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
3914 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
3915 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
3918 GdipDeleteFont(font
);
3922 status
= GdipDeleteGraphics(graphics
);
3926 GdipDeleteFontFamily(family
);
3927 GdipDeleteRegion(region
);
3928 GdipDeleteStringFormat(format
);
3931 static void test_measure_string(void)
3933 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3934 static const WCHAR string
[] = { 'A','0','1',0 };
3936 GpStringFormat
*format
;
3937 CharacterRange range
;
3939 GpGraphics
*graphics
;
3940 GpFontFamily
*family
;
3944 REAL width
, height
, width_1
, width_2
;
3945 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
3948 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
3952 status
= GdipCreateRegion(®ion
);
3955 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3958 hdc
= CreateCompatibleDC(0);
3959 status
= GdipCreateFromHDC(hdc
, &graphics
);
3961 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
3964 margin_x
= 20.0 / 6.0;
3965 margin_y
= 20.0 / 8.0;
3967 set_rect_empty(&rect
);
3968 set_rect_empty(&bounds
);
3969 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3973 expectf(0.0, bounds
.X
);
3974 expectf(0.0, bounds
.Y
);
3975 width
= bounds
.Width
;
3976 height
= bounds
.Height
;
3978 set_rect_empty(&rect
);
3979 rect
.Height
= height
/ 2.0;
3980 set_rect_empty(&bounds
);
3981 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
3985 expectf(0.0, bounds
.X
);
3986 expectf(0.0, bounds
.Y
);
3987 expectf(width
, bounds
.Width
);
3989 expectf(height
/ 2.0, bounds
.Height
);
3992 range
.Length
= lstrlenW(string
);
3993 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
3998 rect
.Width
= 32000.0;
3999 rect
.Height
= 32000.0;
4000 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4002 set_rect_empty(&bounds
);
4003 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4005 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4006 expectf(5.0, bounds
.Y
);
4007 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4009 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4011 width_rgn
= bounds
.Width
;
4012 height_rgn
= bounds
.Height
;
4016 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4019 set_rect_empty(&rect
);
4020 rect
.Width
= 32000.0;
4021 rect
.Height
= 32000.0;
4022 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4024 set_rect_empty(&bounds
);
4025 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4027 expectf_(margin_x
, bounds
.X
, 1.0);
4028 expectf(0.0, bounds
.Y
);
4029 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4030 expectf(height_rgn
, bounds
.Height
);
4031 width_1
= bounds
.Width
;
4034 range
.Length
= lstrlenW(string
);
4035 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4042 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4044 set_rect_empty(&bounds
);
4045 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4047 expectf(0.0, bounds
.X
);
4048 expectf(0.0, bounds
.Y
);
4049 expectf(0.0, bounds
.Width
);
4050 expectf(0.0, bounds
.Height
);
4054 rect
.Width
= width_rgn
/ 2.0;
4055 rect
.Height
= 32000.0;
4056 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4058 set_rect_empty(&bounds
);
4059 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4061 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4062 expectf(5.0, bounds
.Y
);
4063 expectf_(width_1
, bounds
.Width
, 1.0);
4065 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4067 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4073 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4075 set_rect_empty(&bounds
);
4076 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4078 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4079 expectf(5.0, bounds
.Y
);
4080 expectf(width_rgn
, bounds
.Width
);
4081 expectf(height_rgn
, bounds
.Height
);
4085 rect
.Width
= width_rgn
/ 2.0;
4086 rect
.Height
= 32000.0;
4087 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4089 set_rect_empty(&bounds
);
4090 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4092 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4093 expectf(5.0, bounds
.Y
);
4094 expectf_(width_1
, bounds
.Width
, 1.0);
4095 expectf(height_rgn
, bounds
.Height
);
4097 set_rect_empty(&rect
);
4098 rect
.Height
= height
/ 2.0;
4099 set_rect_empty(&bounds
);
4100 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4104 expectf(0.0, bounds
.X
);
4105 expectf(0.0, bounds
.Y
);
4106 expectf_(width
, bounds
.Width
, 0.01);
4108 expectf(height
, bounds
.Height
);
4110 set_rect_empty(&rect
);
4111 set_rect_empty(&bounds
);
4112 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4116 expectf(0.0, bounds
.X
);
4117 expectf(0.0, bounds
.Y
);
4118 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4119 expectf(height
, bounds
.Height
);
4120 width_1
= bounds
.Width
;
4122 set_rect_empty(&rect
);
4123 set_rect_empty(&bounds
);
4124 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4128 expectf(0.0, bounds
.X
);
4129 expectf(0.0, bounds
.Y
);
4130 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4131 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4132 expectf(height
, bounds
.Height
);
4133 width_2
= bounds
.Width
;
4135 set_rect_empty(&rect
);
4136 rect
.Width
= width
/ 2.0;
4137 set_rect_empty(&bounds
);
4138 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4142 expectf(0.0, bounds
.X
);
4143 expectf(0.0, bounds
.Y
);
4144 expectf_(width_1
, bounds
.Width
, 0.01);
4145 expectf(height
, bounds
.Height
);
4147 set_rect_empty(&rect
);
4148 rect
.Height
= height
;
4149 rect
.Width
= width
- 0.05;
4150 set_rect_empty(&bounds
);
4151 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4155 expectf(0.0, bounds
.X
);
4156 expectf(0.0, bounds
.Y
);
4157 expectf_(width_2
, bounds
.Width
, 0.01);
4158 expectf(height
, bounds
.Height
);
4160 set_rect_empty(&rect
);
4161 rect
.Height
= height
;
4162 rect
.Width
= width_2
- 0.05;
4163 set_rect_empty(&bounds
);
4164 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4168 expectf(0.0, bounds
.X
);
4169 expectf(0.0, bounds
.Y
);
4170 expectf_(width_1
, bounds
.Width
, 0.01);
4171 expectf(height
, bounds
.Height
);
4173 /* Default (Near) alignment */
4176 rect
.Width
= width
* 2.0;
4177 rect
.Height
= height
* 2.0;
4178 set_rect_empty(&bounds
);
4179 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4183 expectf(5.0, bounds
.X
);
4184 expectf(5.0, bounds
.Y
);
4185 expectf_(width
, bounds
.Width
, 0.01);
4186 expectf(height
, bounds
.Height
);
4190 rect
.Width
= 32000.0;
4191 rect
.Height
= 32000.0;
4192 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4194 set_rect_empty(&bounds
);
4195 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4197 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4198 expectf(5.0, bounds
.Y
);
4199 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4201 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4203 width_rgn
= bounds
.Width
;
4204 height_rgn
= bounds
.Height
;
4206 /* Center alignment */
4207 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4208 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4212 rect
.Width
= width
* 2.0;
4213 rect
.Height
= height
* 2.0;
4214 set_rect_empty(&bounds
);
4215 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4220 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4222 expectf(5.0 + height
/2.0, bounds
.Y
);
4223 expectf_(width
, bounds
.Width
, 0.01);
4224 expectf(height
, bounds
.Height
);
4230 set_rect_empty(&bounds
);
4231 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4236 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4238 expectf(5.0 - height
/2.0, bounds
.Y
);
4239 expectf_(width
, bounds
.Width
, 0.01);
4240 expectf(height
, bounds
.Height
);
4244 rect
.Width
= width_rgn
* 2.0;
4245 rect
.Height
= height_rgn
* 2.0;
4246 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4248 set_rect_empty(&bounds
);
4249 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4252 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4254 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4255 expectf_(width_rgn
, bounds
.Width
, 1.0);
4256 expectf_(height_rgn
, bounds
.Height
, 1.0);
4262 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4264 set_rect_empty(&bounds
);
4265 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4268 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4270 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4271 expectf_(width_rgn
, bounds
.Width
, 1.0);
4272 expectf_(height_rgn
, bounds
.Height
, 1.0);
4275 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4276 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4280 rect
.Width
= width
* 2.0;
4281 rect
.Height
= height
* 2.0;
4282 set_rect_empty(&bounds
);
4283 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4288 expectf_(5.0 + width
, bounds
.X
, 0.01);
4290 expectf(5.0 + height
, bounds
.Y
);
4291 expectf_(width
, bounds
.Width
, 0.01);
4292 expectf(height
, bounds
.Height
);
4298 set_rect_empty(&bounds
);
4299 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4304 expectf_(5.0 - width
, bounds
.X
, 0.01);
4306 expectf(5.0 - height
, bounds
.Y
);
4307 expectf_(width
, bounds
.Width
, 0.01);
4308 expectf(height
, bounds
.Height
);
4312 rect
.Width
= width_rgn
* 2.0;
4313 rect
.Height
= height_rgn
* 2.0;
4314 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4316 set_rect_empty(&bounds
);
4317 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4320 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4322 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4323 expectf_(width_rgn
, bounds
.Width
, 1.0);
4324 expectf_(height_rgn
, bounds
.Height
, 1.0);
4330 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4332 set_rect_empty(&bounds
);
4333 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4336 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4338 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4339 expectf_(width_rgn
, bounds
.Width
, 1.0);
4340 expectf_(height_rgn
, bounds
.Height
, 1.0);
4342 status
= GdipDeleteFont(font
);
4345 status
= GdipDeleteGraphics(graphics
);
4349 GdipDeleteFontFamily(family
);
4350 GdipDeleteRegion(region
);
4351 GdipDeleteStringFormat(format
);
4354 static void test_measured_extra_space(void)
4356 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4357 static const WCHAR string
[2] = { 'W','W' };
4358 GpStringFormat
*format
;
4360 GpGraphics
*graphics
;
4361 GpFontFamily
*family
;
4364 GpUnit gfx_unit
, font_unit
;
4365 RectF bounds_1
, bounds_2
, rect
;
4366 REAL margin
, font_size
, dpi
;
4368 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4371 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4373 hdc
= CreateCompatibleDC(0);
4374 status
= GdipCreateFromHDC(hdc
, &graphics
);
4377 status
= GdipGetDpiX(graphics
, &dpi
);
4380 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4381 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4382 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4384 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4387 status
= GdipGetFontSize(font
, &font_size
);
4389 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4390 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4392 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4393 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4395 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4398 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4399 set_rect_empty(&rect
);
4400 set_rect_empty(&bounds_1
);
4401 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4403 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4404 set_rect_empty(&rect
);
4405 set_rect_empty(&bounds_2
);
4406 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4409 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4410 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4411 /*trace("margin %f pixels\n", margin);*/
4412 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4415 GdipDeleteFont(font
);
4418 GdipDeleteGraphics(graphics
);
4420 GdipDeleteFontFamily(family
);
4421 GdipDeleteStringFormat(format
);
4424 static void test_alpha_hdc(void)
4428 HBITMAP hbm
, old_hbm
;
4429 GpGraphics
*graphics
;
4434 hdc
= CreateCompatibleDC(0);
4435 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4436 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4437 bmi
.bmiHeader
.biHeight
= 5;
4438 bmi
.bmiHeader
.biWidth
= 5;
4439 bmi
.bmiHeader
.biBitCount
= 32;
4440 bmi
.bmiHeader
.biPlanes
= 1;
4441 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4442 bmi
.bmiHeader
.biClrUsed
= 0;
4444 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4445 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4447 old_hbm
= SelectObject(hdc
, hbm
);
4449 status
= GdipCreateFromHDC(hdc
, &graphics
);
4452 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4454 expectf(0.0, bounds
.X
);
4455 expectf(0.0, bounds
.Y
);
4456 expectf(5.0, bounds
.Width
);
4457 expectf(5.0, bounds
.Height
);
4459 bits
[0] = 0xdeadbeef;
4461 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4464 expect(0xffaaaaaa, bits
[0]);
4466 SelectObject(hdc
, old_hbm
);
4468 bits
[0] = 0xdeadbeef;
4470 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4473 todo_wine
expect(0xffbbbbbb, bits
[0]);
4475 GdipDeleteGraphics(graphics
);
4481 static void test_bitmapfromgraphics(void)
4484 GpGraphics
*graphics
= NULL
;
4485 HDC hdc
= GetDC( hwnd
);
4486 GpBitmap
*bitmap
= NULL
;
4488 REAL imageres
, graphicsres
;
4491 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4494 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4495 expect(InvalidParameter
, stat
);
4497 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4498 expect(InvalidParameter
, stat
);
4500 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4503 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4505 expect(PixelFormat32bppPARGB
, format
);
4507 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4510 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4512 expectf(graphicsres
, imageres
);
4514 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4517 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4519 expectf(graphicsres
, imageres
);
4521 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4525 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4529 GdipDeleteGraphics(graphics
);
4530 GdipDisposeImage((GpImage
*)bitmap
);
4533 static void test_clipping(void)
4537 GpGraphics
*graphics
;
4538 GpRegion
*region
, *region100x100
;
4547 hdc
= CreateCompatibleDC(0);
4548 status
= GdipCreateFromHDC(hdc
, &graphics
);
4551 status
= GdipGetPageUnit(graphics
, &unit
);
4553 expect(UnitDisplay
, unit
);
4555 status
= GdipCreateRegion(®ion
);
4557 status
= GdipSetEmpty(region
);
4560 status
= GdipCreateRegion(®ion100x100
);
4562 status
= GdipSetEmpty(region100x100
);
4565 rect
.X
= rect
.Y
= 100.0;
4566 rect
.Width
= rect
.Height
= 100.0;
4567 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4569 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4572 status
= GdipGetClipBounds(graphics
, &rect
);
4574 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4575 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4577 status
= GdipSetEmpty(region
);
4579 status
= GdipGetClip(graphics
, region
);
4581 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4583 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4584 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4590 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4592 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4593 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
4595 status
= GdipCreateMatrix(&matrix
);
4597 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4599 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4601 status
= GdipSetWorldTransform(graphics
, matrix
);
4604 status
= GdipGetClipBounds(graphics
, &rect
);
4606 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4607 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4609 status
= GdipSetEmpty(region
);
4611 status
= GdipGetClip(graphics
, region
);
4613 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4615 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4616 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4618 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4620 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4621 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4623 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4625 ret
= GetRgnBox(hrgn
, &rc
);
4626 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4627 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4628 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4631 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4633 ret
= GetRgnBox(hrgn
, &rc
);
4634 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4635 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4636 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4643 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4645 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4646 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
4648 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4650 ret
= GetRgnBox(hrgn
, &rc
);
4651 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4652 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4653 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4656 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4658 ret
= GetRgnBox(hrgn
, &rc
);
4659 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4660 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4661 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4668 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4670 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4671 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
4673 status
= GdipSetPageScale(graphics
, 2.0);
4676 status
= GdipGetClipBounds(graphics
, &rect
);
4678 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4679 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4681 status
= GdipSetEmpty(region
);
4683 status
= GdipGetClip(graphics
, region
);
4685 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4687 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4688 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4690 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4692 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4693 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4695 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4697 ret
= GetRgnBox(hrgn
, &rc
);
4698 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4699 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
4700 "expected 45,20-95,45, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4703 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4705 ret
= GetRgnBox(hrgn
, &rc
);
4706 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4707 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4708 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4715 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4717 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
4718 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
4720 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4722 ret
= GetRgnBox(hrgn
, &rc
);
4723 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4724 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4725 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4728 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4730 ret
= GetRgnBox(hrgn
, &rc
);
4731 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4732 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4733 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4740 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4742 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4743 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
4745 GdipSetPageUnit(graphics
, UnitPoint
);
4748 status
= GdipGetClipBounds(graphics
, &rect
);
4750 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4751 /* rounding under Wine is slightly different */
4752 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4753 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4754 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4756 status
= GdipSetEmpty(region
);
4758 status
= GdipGetClip(graphics
, region
);
4760 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4762 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
4763 /* rounding under Wine is slightly different */
4764 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
4765 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
4766 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4768 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4770 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4771 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4773 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4775 ret
= GetRgnBox(hrgn
, &rc
);
4776 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4777 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
4778 /* rounding under Wine is slightly different */
4779 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
4780 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
4781 "expected 14,5-33,14, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4784 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4786 ret
= GetRgnBox(hrgn
, &rc
);
4787 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4788 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
4789 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
4790 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4797 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4799 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
4800 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
4801 "expected 13.75,4.375-32.5,13.75, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
4803 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4805 ret
= GetRgnBox(hrgn
, &rc
);
4806 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4807 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4808 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4811 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4813 ret
= GetRgnBox(hrgn
, &rc
);
4814 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4815 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
4816 /* rounding under Wine is slightly different */
4817 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
4818 "expected 560,1120-1094,2187, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4825 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4827 if (fabs(ptf
[0].X
- 100.0) < 0.001)
4829 expectf(100.0, ptf
[0].X
);
4830 expectf(100.0, ptf
[0].Y
);
4831 expectf(200.125, ptf
[1].X
);
4832 expectf(200.03125, ptf
[1].Y
);
4834 else /* before Win7 */
4836 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
4837 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
4838 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
4839 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
4842 status
= GdipTransformRegion(region100x100
, matrix
);
4845 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4847 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4848 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4850 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4852 ret
= GetRgnBox(hrgn
, &rc
);
4853 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4854 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4855 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4858 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4860 ret
= GetRgnBox(hrgn
, &rc
);
4861 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4862 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
4863 /* rounding under Wine is slightly different */
4864 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
4865 "expected 1147,4534-2214,8800, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4872 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4874 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
4876 expectf(210.0625, ptf
[0].X
);
4877 expectf(420.0625, ptf
[0].Y
);
4878 expectf(410.125, ptf
[1].X
);
4879 expectf(820.0, ptf
[1].Y
);
4881 else /* before Win7 */
4883 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
4884 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
4885 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
4886 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
4889 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
4891 status
= GdipSetWorldTransform(graphics
, matrix
);
4894 status
= GdipGetClipBounds(graphics
, &rect
);
4896 expectf_(20.612978, rect
.X
, 1.0);
4897 expectf_(-6.256012, rect
.Y
, 1.5);
4898 expectf_(25.612978, rect
.Width
, 1.0);
4899 expectf_(12.806489, rect
.Height
, 1.0);
4901 status
= GdipSetEmpty(region
);
4903 status
= GdipGetClip(graphics
, region
);
4905 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4907 /* rounding under Wine is slightly different */
4908 expectf_(20.612978, rect
.X
, 1.0);
4909 expectf_(-6.256012, rect
.Y
, 1.5);
4910 expectf_(25.612978, rect
.Width
, 1.0);
4911 expectf_(12.806489, rect
.Height
, 1.0);
4913 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
4915 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
4916 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4918 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
4920 ret
= GetRgnBox(hrgn
, &rc
);
4921 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4922 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
4923 /* rounding under Wine is slightly different */
4924 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
4925 "expected (22,-6)-(46,7), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4928 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
4930 ret
= GetRgnBox(hrgn
, &rc
);
4931 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4932 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
4933 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4944 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4946 expectf(20.612978, ptf
[0].X
);
4947 expectf(-1.568512, ptf
[0].Y
);
4948 expectf(46.225956, ptf
[1].X
);
4949 expectf(1.862977, ptf
[1].Y
);
4950 expectf(36.850956, ptf
[2].X
);
4951 expectf(-6.256012, ptf
[2].Y
);
4952 expectf(29.987980, ptf
[3].X
);
4953 expectf(6.550478, ptf
[3].Y
);
4955 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
4957 ret
= GetRgnBox(hrgn
, &rc
);
4958 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
4959 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
4960 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4963 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
4965 ret
= GetRgnBox(hrgn
, &rc
);
4966 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
4967 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
4968 /* rounding under Wine is slightly different */
4969 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
4970 "expected (-3406,4500)-(-350,8728), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4981 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
4983 expectf(-136.190491, ptf
[0].X
);
4984 expectf(520.010742, ptf
[0].Y
);
4985 expectf(756.417175, ptf
[1].X
);
4986 expectf(720.031616, ptf
[1].Y
);
4987 expectf(360.042114, ptf
[2].X
);
4988 expectf(376.760742, ptf
[2].Y
);
4989 expectf(260.184570, ptf
[3].X
);
4990 expectf(863.281616, ptf
[3].Y
);
4992 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
4994 status
= GdipSetWorldTransform(graphics
, matrix
);
4997 status
= GdipGetClipBounds(graphics
, &rect
);
4999 expectf_(-28.100956, rect
.X
, 1.0);
5000 expectf_(7.806488, rect
.Y
, 1.5);
5001 expectf_(25.612978, rect
.Width
, 1.0);
5002 expectf_(12.806489, rect
.Height
, 1.0);
5004 status
= GdipSetEmpty(region
);
5006 status
= GdipGetClip(graphics
, region
);
5008 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5010 /* rounding under Wine is slightly different */
5011 expectf_(-28.100956, rect
.X
, 1.0);
5012 expectf_(7.806488, rect
.Y
, 1.5);
5013 expectf_(25.612978, rect
.Width
, 1.0);
5014 expectf_(12.806489, rect
.Height
, 1.0);
5016 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5018 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5019 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5021 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5023 ret
= GetRgnBox(hrgn
, &rc
);
5024 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5025 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5026 /* rounding under Wine is slightly different */
5027 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5028 "expected (-27,8)-(-2,21), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5031 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5033 ret
= GetRgnBox(hrgn
, &rc
);
5034 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5035 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5036 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5047 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5049 expectf(-11.862979, ptf
[0].X
);
5050 expectf(7.806488, ptf
[0].Y
);
5051 expectf(-18.725958, ptf
[1].X
);
5052 expectf(20.612976, ptf
[1].Y
);
5053 expectf(-2.487981, ptf
[2].X
);
5054 expectf(15.925477, ptf
[2].Y
);
5055 expectf(-28.100956, ptf
[3].X
);
5056 expectf(12.493987, ptf
[3].Y
);
5058 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5060 ret
= GetRgnBox(hrgn
, &rc
);
5061 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5062 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5063 "expected 210,420-410,820, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5066 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5068 ret
= GetRgnBox(hrgn
, &rc
);
5069 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5070 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5071 /* rounding under Wine is slightly different */
5072 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5073 "expected (4500,351)-(8728,3407), got (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5084 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5086 expectf(-1055.021484, ptf
[0].X
);
5087 expectf(-70.595329, ptf
[0].Y
);
5088 expectf(-1455.063232, ptf
[1].X
);
5089 expectf(375.708435, ptf
[1].Y
);
5090 expectf(-768.521484, ptf
[2].X
);
5091 expectf(177.520981, ptf
[2].Y
);
5092 expectf(-1741.563110, ptf
[3].X
);
5093 expectf(127.592125, ptf
[3].Y
);
5095 GdipDeleteMatrix(matrix
);
5096 GdipDeleteRegion(region
);
5097 GdipDeleteRegion(region100x100
);
5098 GdipDeleteGraphics(graphics
);
5102 static void test_clipping_2(void)
5107 GpGraphics
*graphics
;
5117 hdc
= CreateCompatibleDC(0);
5118 status
= GdipCreateFromHDC(hdc
, &graphics
);
5121 status
= GdipGetPageUnit(graphics
, &unit
);
5123 expect(UnitDisplay
, unit
);
5125 GdipSetPageUnit(graphics
, UnitInch
);
5127 status
= GdipCreateRegion(®ion
);
5129 status
= GdipSetEmpty(region
);
5131 rect
.X
= rect
.Y
= 100.0;
5132 rect
.Width
= rect
.Height
= 100.0;
5133 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5135 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5138 status
= GdipGetClip(graphics
, region
);
5140 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5142 ret
= GetRgnBox(hrgn
, &rc
);
5143 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5144 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5145 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5147 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5149 ret
= GetRgnBox(hrgn
, &rc
);
5150 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5151 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5152 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5159 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5161 expectf(100.0, ptf
[0].X
);
5162 expectf(100.0, ptf
[0].Y
);
5163 expectf(200.0, ptf
[1].X
);
5164 expectf(200.0, ptf
[1].X
);
5166 GdipSetPageUnit(graphics
, UnitPoint
);
5168 status
= GdipGetClip(graphics
, region
);
5170 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5172 ret
= GetRgnBox(hrgn
, &rc
);
5173 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5174 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5175 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5176 "expected 7200,7200-14400,14400, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5178 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5180 ret
= GetRgnBox(hrgn
, &rc
);
5181 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5182 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5183 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5184 "expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5191 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5193 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5194 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5195 "expected 7200.0,7200.0-14400.0,14400.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5196 else /* before Win7 */
5198 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5199 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5200 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5201 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5204 GdipDeleteRegion(region
);
5206 GdipSetPageUnit(graphics
, UnitPixel
);
5208 status
= GdipCreateRegion(®ion
);
5210 status
= GdipSetEmpty(region
);
5212 rect
.X
= rect
.Y
= 100.0;
5213 rect
.Width
= rect
.Height
= 100.0;
5214 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5216 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5219 status
= GdipGetClip(graphics
, region
);
5221 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5223 ret
= GetRgnBox(hrgn
, &rc
);
5224 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5225 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5226 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5227 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5229 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5231 ret
= GetRgnBox(hrgn
, &rc
);
5232 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5233 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5234 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5235 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5242 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5244 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5245 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5246 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5247 else /* before Win7 */
5249 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5250 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5251 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5252 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5255 GdipSetPageUnit(graphics
, UnitPoint
);
5257 status
= GdipGetClip(graphics
, region
);
5259 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5261 ret
= GetRgnBox(hrgn
, &rc
);
5262 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5263 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5264 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5265 "expected 75,75-150,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5267 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5269 ret
= GetRgnBox(hrgn
, &rc
);
5270 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5271 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5272 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5273 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5280 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5282 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5283 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5284 "expected 75.0,75.0-150.0,150.0, got %f,%f-%f,%f\n", ptf
[0].X
, ptf
[0].Y
, ptf
[1].X
, ptf
[1].Y
);
5285 else /* before Win7 */
5287 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5288 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5289 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5290 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5293 status
= GdipCreateMatrix(&matrix
);
5295 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5297 status
= GdipSetWorldTransform(graphics
, matrix
);
5299 GdipDeleteMatrix(matrix
);
5301 status
= GdipGetClip(graphics
, region
);
5303 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5305 ret
= GetRgnBox(hrgn
, &rc
);
5306 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5307 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5308 "expected 65,65-140,140, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5310 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5312 ret
= GetRgnBox(hrgn
, &rc
);
5313 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5314 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5315 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5322 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5324 expectf(65.0, ptf
[0].X
);
5325 expectf(65.0, ptf
[0].Y
);
5326 expectf(140.0, ptf
[1].X
);
5327 expectf(140.0, ptf
[1].X
);
5329 status
= GdipCreateMatrix(&matrix
);
5331 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5333 status
= GdipSetWorldTransform(graphics
, matrix
);
5335 GdipDeleteMatrix(matrix
);
5337 status
= GdipGetClip(graphics
, region
);
5339 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5341 ret
= GetRgnBox(hrgn
, &rc
);
5342 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5343 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5344 "expected 300,150-600,300, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5346 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5348 ret
= GetRgnBox(hrgn
, &rc
);
5349 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5350 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5351 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5358 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5360 expectf(300.0, ptf
[0].X
);
5361 expectf(150.0, ptf
[0].Y
);
5362 expectf(600.0, ptf
[1].X
);
5363 expectf(300.0, ptf
[1].Y
);
5365 status
= GdipSetPageScale(graphics
, 2.0);
5368 status
= GdipGetClip(graphics
, region
);
5370 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5372 ret
= GetRgnBox(hrgn
, &rc
);
5373 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5374 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5375 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5376 "expected 150,75-300,150, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5378 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5380 ret
= GetRgnBox(hrgn
, &rc
);
5381 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5382 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5383 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5384 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5391 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5393 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5395 expectf(150.0, ptf
[0].X
);
5396 expectf(75.0, ptf
[0].Y
);
5397 expectf(300.0, ptf
[1].X
);
5398 expectf(150.0, ptf
[1].Y
);
5400 else /* before Win7 */
5402 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5403 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5404 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5405 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5408 status
= GdipCreateMatrix(&matrix
);
5410 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5412 status
= GdipSetWorldTransform(graphics
, matrix
);
5414 GdipDeleteMatrix(matrix
);
5416 status
= GdipGetClip(graphics
, region
);
5418 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5420 ret
= GetRgnBox(hrgn
, &rc
);
5421 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5422 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5423 /* rounding under Wine is slightly different */
5424 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5425 "expected 54,-26-107,27, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5427 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5429 ret
= GetRgnBox(hrgn
, &rc
);
5430 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5431 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5432 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5443 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5445 expectf(53.033016, ptf
[0].X
);
5446 expectf(0.0, ptf
[0].Y
);
5447 expectf(106.066032, ptf
[1].X
);
5448 expectf(0.0, ptf
[1].Y
);
5449 expectf(79.549522, ptf
[2].X
);
5450 expectf(-26.516510, ptf
[2].Y
);
5451 expectf(79.549522, ptf
[3].X
);
5452 expectf(26.516508, ptf
[3].Y
);
5454 status
= GdipCreateMatrix(&matrix
);
5456 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5458 status
= GdipSetWorldTransform(graphics
, matrix
);
5460 GdipDeleteMatrix(matrix
);
5462 status
= GdipGetClip(graphics
, region
);
5464 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5466 ret
= GetRgnBox(hrgn
, &rc
);
5467 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5468 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5469 /* rounding under Wine is slightly different */
5470 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5471 "expected -26,54-27,107, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5473 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5475 ret
= GetRgnBox(hrgn
, &rc
);
5476 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5477 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5478 "expected 100,100-200,200, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5489 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5491 expectf(0.0, ptf
[0].X
);
5492 expectf(53.033005, ptf
[0].Y
);
5493 expectf(0.0, ptf
[1].X
);
5494 expectf(106.066010, ptf
[1].Y
);
5495 expectf(26.516491, ptf
[2].X
);
5496 expectf(79.549507, ptf
[2].Y
);
5497 expectf(-26.516520, ptf
[3].X
);
5498 expectf(79.549500, ptf
[3].Y
);
5500 GdipDeleteRegion(region
);
5501 GdipDeleteGraphics(graphics
);
5505 START_TEST(graphics
)
5507 struct GdiplusStartupInput gdiplusStartupInput
;
5508 ULONG_PTR gdiplusToken
;
5511 memset( &class, 0, sizeof(class) );
5512 class.lpszClassName
= "gdiplus_test";
5513 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5514 class.lpfnWndProc
= DefWindowProcA
;
5515 class.hInstance
= GetModuleHandleA(0);
5516 class.hIcon
= LoadIcon(0, IDI_APPLICATION
);
5517 class.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
5518 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
5519 RegisterClassA( &class );
5520 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5521 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
5522 ok(hwnd
!= NULL
, "Expected window to be created\n");
5524 gdiplusStartupInput
.GdiplusVersion
= 1;
5525 gdiplusStartupInput
.DebugEventCallback
= NULL
;
5526 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
5527 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
5529 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
5533 test_measured_extra_space();
5534 test_measure_string();
5535 test_font_height_scaling();
5537 test_GdipMeasureString();
5538 test_constructor_destructor();
5539 test_save_restore();
5540 test_GdipFillClosedCurve2();
5541 test_GdipFillClosedCurve2I();
5542 test_GdipDrawBezierI();
5544 test_GdipDrawArcI();
5545 test_GdipDrawCurve();
5546 test_GdipDrawCurveI();
5547 test_GdipDrawCurve2();
5548 test_GdipDrawCurve2I();
5549 test_GdipDrawCurve3();
5550 test_GdipDrawCurve3I();
5551 test_GdipDrawLineI();
5552 test_GdipDrawLinesI();
5553 test_GdipDrawImagePointsRect();
5554 test_GdipFillClosedCurve();
5555 test_GdipFillClosedCurveI();
5556 test_GdipDrawString();
5557 test_GdipGetNearestColor();
5558 test_GdipGetVisibleClipBounds();
5559 test_GdipIsVisiblePoint();
5560 test_GdipIsVisibleRect();
5561 test_Get_Release_DC();
5562 test_BeginContainer2();
5563 test_transformpoints();
5564 test_get_set_clip();
5567 test_textcontrast();
5568 test_fromMemoryBitmap();
5569 #if CORE_6659_IS_FIXED
5570 test_string_functions();
5572 test_get_set_interpolation();
5573 test_get_set_textrenderinghint();
5574 test_getdc_scaled();
5576 test_bitmapfromgraphics();
5578 GdiplusShutdown(gdiplusToken
);
5579 DestroyWindow( hwnd
);