2 * Unit test suite for graphics objects
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
29 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
30 #define expectf(expected, got) expectf_((expected), (got), 0.001)
32 static GpStatus (WINAPI
*pGdipGraphicsSetAbort
)(GpGraphics
*,GdiplusAbort
*);
34 static const REAL mm_per_inch
= 25.4;
35 static const REAL point_per_inch
= 72.0;
38 static void set_rect_empty(RectF
*rc
)
46 /* converts a given unit to its value in pixels */
47 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
55 return units
* dpi
/ point_per_inch
;
59 return units
* dpi
/ 300.0; /* Per MSDN */
61 return units
* dpi
/ mm_per_inch
;
63 ok(0, "Unsupported unit: %d\n", unit
);
68 /* converts value in pixels to a given unit */
69 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
77 return pixels
* point_per_inch
/ dpi
;
81 return pixels
* 300.0 / dpi
;
83 return pixels
* mm_per_inch
/ dpi
;
85 ok(0, "Unsupported unit: %d\n", unit
);
90 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
92 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
93 return pixels_to_units(pixels
, to
, dpi
);
96 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
104 GpGraphics
*graphics
= NULL
;
107 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
110 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
112 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
115 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
119 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
124 status
= GdipGetDpiX(graphics
, &res
);
127 status
= GdipGetDpiY(graphics
, &res
);
131 status
= GdipSetPageUnit(graphics
, unit
);
133 status
= GdipSetPageScale(graphics
, scale
);
139 static void test_constructor_destructor(void)
142 GpGraphics
*graphics
= NULL
;
143 HDC hdc
= GetDC( hwnd
);
145 stat
= GdipCreateFromHDC(NULL
, &graphics
);
146 expect(OutOfMemory
, stat
);
147 stat
= GdipDeleteGraphics(graphics
);
148 expect(InvalidParameter
, stat
);
150 stat
= GdipCreateFromHDC(hdc
, &graphics
);
152 stat
= GdipDeleteGraphics(graphics
);
155 stat
= GdipCreateFromHWND(NULL
, &graphics
);
157 stat
= GdipDeleteGraphics(graphics
);
160 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
162 stat
= GdipDeleteGraphics(graphics
);
165 stat
= GdipDeleteGraphics(NULL
);
166 expect(InvalidParameter
, stat
);
167 ReleaseDC(hwnd
, hdc
);
175 /* Linked list prepend function. */
176 static void log_state(GraphicsState data
, node
** log
)
178 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
180 new_entry
->data
= data
;
181 new_entry
->next
= *log
;
185 /* Checks if there are duplicates in the list, and frees it. */
186 static void check_no_duplicates(node
* log
)
198 while((temp
= temp
->next
)){
199 if(log
->data
== temp
->data
){
206 }while((log
= log
->next
));
211 HeapFree(GetProcessHeap(), 0, temp
);
219 static void test_save_restore(void)
222 GraphicsState state_a
, state_b
, state_c
;
223 InterpolationMode mode
;
224 GpGraphics
*graphics1
, *graphics2
;
225 node
* state_log
= NULL
;
226 HDC hdc
= GetDC( hwnd
);
227 state_a
= state_b
= state_c
= 0xdeadbeef;
229 /* Invalid saving. */
230 GdipCreateFromHDC(hdc
, &graphics1
);
231 stat
= GdipSaveGraphics(graphics1
, NULL
);
232 expect(InvalidParameter
, stat
);
233 stat
= GdipSaveGraphics(NULL
, &state_a
);
234 expect(InvalidParameter
, stat
);
235 GdipDeleteGraphics(graphics1
);
237 log_state(state_a
, &state_log
);
239 /* Basic save/restore. */
240 GdipCreateFromHDC(hdc
, &graphics1
);
241 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
242 stat
= GdipSaveGraphics(graphics1
, &state_a
);
244 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
245 stat
= GdipRestoreGraphics(graphics1
, state_a
);
247 GdipGetInterpolationMode(graphics1
, &mode
);
248 expect(InterpolationModeBilinear
, mode
);
249 GdipDeleteGraphics(graphics1
);
251 log_state(state_a
, &state_log
);
253 /* Restoring garbage doesn't affect saves. */
254 GdipCreateFromHDC(hdc
, &graphics1
);
255 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
256 GdipSaveGraphics(graphics1
, &state_a
);
257 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
258 GdipSaveGraphics(graphics1
, &state_b
);
259 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
260 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
262 GdipRestoreGraphics(graphics1
, state_b
);
263 GdipGetInterpolationMode(graphics1
, &mode
);
264 expect(InterpolationModeBicubic
, mode
);
265 GdipRestoreGraphics(graphics1
, state_a
);
266 GdipGetInterpolationMode(graphics1
, &mode
);
267 expect(InterpolationModeBilinear
, mode
);
268 GdipDeleteGraphics(graphics1
);
270 log_state(state_a
, &state_log
);
271 log_state(state_b
, &state_log
);
273 /* Restoring older state invalidates newer saves (but not older saves). */
274 GdipCreateFromHDC(hdc
, &graphics1
);
275 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
276 GdipSaveGraphics(graphics1
, &state_a
);
277 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
278 GdipSaveGraphics(graphics1
, &state_b
);
279 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
280 GdipSaveGraphics(graphics1
, &state_c
);
281 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
282 GdipRestoreGraphics(graphics1
, state_b
);
283 GdipGetInterpolationMode(graphics1
, &mode
);
284 expect(InterpolationModeBicubic
, mode
);
285 GdipRestoreGraphics(graphics1
, state_c
);
286 GdipGetInterpolationMode(graphics1
, &mode
);
287 expect(InterpolationModeBicubic
, mode
);
288 GdipRestoreGraphics(graphics1
, state_a
);
289 GdipGetInterpolationMode(graphics1
, &mode
);
290 expect(InterpolationModeBilinear
, mode
);
291 GdipDeleteGraphics(graphics1
);
293 log_state(state_a
, &state_log
);
294 log_state(state_b
, &state_log
);
295 log_state(state_c
, &state_log
);
297 /* Restoring older save from one graphics object does not invalidate
298 * newer save from other graphics object. */
299 GdipCreateFromHDC(hdc
, &graphics1
);
300 GdipCreateFromHDC(hdc
, &graphics2
);
301 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
302 GdipSaveGraphics(graphics1
, &state_a
);
303 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
304 GdipSaveGraphics(graphics2
, &state_b
);
305 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
306 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
307 GdipRestoreGraphics(graphics1
, state_a
);
308 GdipGetInterpolationMode(graphics1
, &mode
);
309 expect(InterpolationModeBilinear
, mode
);
310 GdipRestoreGraphics(graphics2
, state_b
);
311 GdipGetInterpolationMode(graphics2
, &mode
);
312 expect(InterpolationModeBicubic
, mode
);
313 GdipDeleteGraphics(graphics1
);
314 GdipDeleteGraphics(graphics2
);
316 /* You can't restore a state to a graphics object that didn't save it. */
317 GdipCreateFromHDC(hdc
, &graphics1
);
318 GdipCreateFromHDC(hdc
, &graphics2
);
319 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
320 GdipSaveGraphics(graphics1
, &state_a
);
321 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
322 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
323 GdipRestoreGraphics(graphics2
, state_a
);
324 GdipGetInterpolationMode(graphics2
, &mode
);
325 expect(InterpolationModeNearestNeighbor
, mode
);
326 GdipDeleteGraphics(graphics1
);
327 GdipDeleteGraphics(graphics2
);
329 log_state(state_a
, &state_log
);
331 /* A state created by SaveGraphics cannot be restored with EndContainer. */
332 GdipCreateFromHDC(hdc
, &graphics1
);
333 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
334 stat
= GdipSaveGraphics(graphics1
, &state_a
);
336 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
337 stat
= GdipEndContainer(graphics1
, state_a
);
339 GdipGetInterpolationMode(graphics1
, &mode
);
340 expect(InterpolationModeBicubic
, mode
);
341 stat
= GdipRestoreGraphics(graphics1
, state_a
);
343 GdipGetInterpolationMode(graphics1
, &mode
);
344 expect(InterpolationModeBilinear
, mode
);
345 GdipDeleteGraphics(graphics1
);
347 log_state(state_a
, &state_log
);
349 /* A state created by BeginContainer cannot be restored with RestoreGraphics. */
350 GdipCreateFromHDC(hdc
, &graphics1
);
351 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
352 stat
= GdipBeginContainer2(graphics1
, &state_a
);
354 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
355 stat
= GdipRestoreGraphics(graphics1
, state_a
);
357 GdipGetInterpolationMode(graphics1
, &mode
);
358 expect(InterpolationModeBicubic
, mode
);
359 stat
= GdipEndContainer(graphics1
, state_a
);
361 GdipGetInterpolationMode(graphics1
, &mode
);
362 expect(InterpolationModeBilinear
, mode
);
363 GdipDeleteGraphics(graphics1
);
365 log_state(state_a
, &state_log
);
367 /* BeginContainer and SaveGraphics use the same stack. */
368 stat
= GdipCreateFromHDC(hdc
, &graphics1
);
370 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
371 stat
= GdipBeginContainer2(graphics1
, &state_a
);
373 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
374 stat
= GdipSaveGraphics(graphics1
, &state_b
);
376 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
377 stat
= GdipEndContainer(graphics1
, state_a
);
379 GdipGetInterpolationMode(graphics1
, &mode
);
380 expect(InterpolationModeBilinear
, mode
);
381 stat
= GdipRestoreGraphics(graphics1
, state_b
);
383 GdipGetInterpolationMode(graphics1
, &mode
);
384 expect(InterpolationModeBilinear
, mode
);
385 GdipDeleteGraphics(graphics1
);
387 log_state(state_a
, &state_log
);
388 log_state(state_b
, &state_log
);
390 /* The same state value should never be returned twice. */
392 check_no_duplicates(state_log
);
394 ReleaseDC(hwnd
, hdc
);
397 static void test_GdipFillClosedCurve2(void)
400 GpGraphics
*graphics
= NULL
;
401 GpSolidFill
*brush
= NULL
;
402 HDC hdc
= GetDC( hwnd
);
414 /* make a graphics object and brush object */
415 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
417 status
= GdipCreateFromHDC(hdc
, &graphics
);
419 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
421 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
423 /* InvalidParameter cases: null graphics, null brush, null points */
424 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
425 expect(InvalidParameter
, status
);
427 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
428 expect(InvalidParameter
, status
);
430 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
431 expect(InvalidParameter
, status
);
433 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
434 expect(InvalidParameter
, status
);
436 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
437 expect(InvalidParameter
, status
);
439 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
440 expect(InvalidParameter
, status
);
442 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
443 expect(InvalidParameter
, status
);
445 /* InvalidParameter cases: invalid count */
446 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
447 expect(InvalidParameter
, status
);
449 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
450 expect(InvalidParameter
, status
);
452 /* Valid test cases */
453 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
456 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
459 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
462 GdipDeleteGraphics(graphics
);
463 GdipDeleteBrush((GpBrush
*)brush
);
465 ReleaseDC(hwnd
, hdc
);
468 static void test_GdipFillClosedCurve2I(void)
471 GpGraphics
*graphics
= NULL
;
472 GpSolidFill
*brush
= NULL
;
473 HDC hdc
= GetDC( hwnd
);
485 /* make a graphics object and brush object */
486 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
488 status
= GdipCreateFromHDC(hdc
, &graphics
);
490 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
492 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
494 /* InvalidParameter cases: null graphics, null brush */
495 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
496 when points == NULL, so don't test this condition */
497 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
498 expect(InvalidParameter
, status
);
500 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
501 expect(InvalidParameter
, status
);
503 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
504 expect(InvalidParameter
, status
);
506 /* InvalidParameter cases: invalid count */
507 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
508 expect(InvalidParameter
, status
);
510 /* OutOfMemory cases: large (unsigned) int */
511 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
512 expect(OutOfMemory
, status
);
514 /* Valid test cases */
515 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
518 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
521 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
524 GdipDeleteGraphics(graphics
);
525 GdipDeleteBrush((GpBrush
*)brush
);
527 ReleaseDC(hwnd
, hdc
);
530 static void test_GdipDrawArc(void)
533 GpGraphics
*graphics
= NULL
;
535 HDC hdc
= GetDC( hwnd
);
537 /* make a graphics object and pen object */
538 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
540 status
= GdipCreateFromHDC(hdc
, &graphics
);
542 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
544 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
546 ok(pen
!= NULL
, "Expected pen to be initialized\n");
548 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
549 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
550 expect(InvalidParameter
, status
);
552 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
553 expect(InvalidParameter
, status
);
555 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
556 expect(InvalidParameter
, status
);
558 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
559 expect(InvalidParameter
, status
);
561 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
562 expect(InvalidParameter
, status
);
564 /* successful case */
565 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
569 GdipDeleteGraphics(graphics
);
571 ReleaseDC(hwnd
, hdc
);
574 static void test_GdipDrawArcI(void)
577 GpGraphics
*graphics
= NULL
;
579 HDC hdc
= GetDC( hwnd
);
581 /* make a graphics object and pen object */
582 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
584 status
= GdipCreateFromHDC(hdc
, &graphics
);
586 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
588 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
590 ok(pen
!= NULL
, "Expected pen to be initialized\n");
592 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
593 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
594 expect(InvalidParameter
, status
);
596 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
597 expect(InvalidParameter
, status
);
599 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
600 expect(InvalidParameter
, status
);
602 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
603 expect(InvalidParameter
, status
);
605 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
606 expect(InvalidParameter
, status
);
608 /* successful case */
609 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
613 GdipDeleteGraphics(graphics
);
615 ReleaseDC(hwnd
, hdc
);
618 static void test_BeginContainer2(void)
622 REAL defClip
[] = {5, 10, 15, 20};
623 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
624 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
625 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
626 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
627 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
628 REAL scale
, defScale
= 17;
629 GpUnit unit
, defUnit
= UnitPixel
;
630 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
631 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
632 UINT contrast
, defContrast
= 5;
633 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
636 GpGraphics
*graphics
= NULL
;
637 HDC hdc
= GetDC( hwnd
);
639 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
641 status
= GdipCreateFromHDC(hdc
, &graphics
);
643 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
645 /* null graphics, null container */
646 status
= GdipBeginContainer2(NULL
, &cont1
);
647 expect(InvalidParameter
, status
);
649 status
= GdipBeginContainer2(graphics
, NULL
);
650 expect(InvalidParameter
, status
);
652 status
= GdipEndContainer(NULL
, cont1
);
653 expect(InvalidParameter
, status
);
655 /* test all quality-related values */
656 GdipSetCompositingMode(graphics
, defCompmode
);
657 GdipSetCompositingQuality(graphics
, defCompqual
);
658 GdipSetInterpolationMode(graphics
, defInterp
);
659 GdipSetPageScale(graphics
, defScale
);
660 GdipSetPageUnit(graphics
, defUnit
);
661 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
662 GdipSetSmoothingMode(graphics
, defSmoothmode
);
663 GdipSetTextContrast(graphics
, defContrast
);
664 GdipSetTextRenderingHint(graphics
, defTexthint
);
666 status
= GdipBeginContainer2(graphics
, &cont1
);
669 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
670 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
671 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
672 GdipSetPageScale(graphics
, 10);
673 GdipSetPageUnit(graphics
, UnitDocument
);
674 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
675 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
676 GdipSetTextContrast(graphics
, 7);
677 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
679 status
= GdipEndContainer(graphics
, cont1
);
682 GdipGetCompositingMode(graphics
, &compmode
);
683 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
685 GdipGetCompositingQuality(graphics
, &compqual
);
686 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
688 GdipGetInterpolationMode(graphics
, &interp
);
689 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
691 GdipGetPageScale(graphics
, &scale
);
692 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
694 GdipGetPageUnit(graphics
, &unit
);
695 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
697 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
698 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
700 GdipGetSmoothingMode(graphics
, &smoothmode
);
701 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
703 GdipGetTextContrast(graphics
, &contrast
);
704 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
706 GdipGetTextRenderingHint(graphics
, &texthint
);
707 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
709 /* test world transform */
710 status
= GdipBeginContainer2(graphics
, &cont1
);
713 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
714 defTrans
[4], defTrans
[5], &transform
);
716 GdipSetWorldTransform(graphics
, transform
);
717 GdipDeleteMatrix(transform
);
720 status
= GdipBeginContainer2(graphics
, &cont2
);
723 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
725 GdipSetWorldTransform(graphics
, transform
);
726 GdipDeleteMatrix(transform
);
729 status
= GdipEndContainer(graphics
, cont2
);
732 status
= GdipCreateMatrix(&transform
);
734 GdipGetWorldTransform(graphics
, transform
);
735 status
= GdipGetMatrixElements(transform
, elems
);
737 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
738 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
739 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
740 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
741 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
742 fabs(defTrans
[5] - elems
[5]) < 0.0001,
743 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
744 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
745 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
746 GdipDeleteMatrix(transform
);
749 status
= GdipEndContainer(graphics
, cont1
);
753 status
= GdipBeginContainer2(graphics
, &cont1
);
756 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
758 status
= GdipBeginContainer2(graphics
, &cont2
);
761 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
763 status
= GdipEndContainer(graphics
, cont2
);
766 status
= GdipGetClipBounds(graphics
, &clip
);
769 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
770 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
771 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
772 fabs(defClip
[3] - clip
.Height
) < 0.0001,
773 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
774 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
775 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
777 status
= GdipEndContainer(graphics
, cont1
);
781 status
= GdipBeginContainer2(graphics
, &cont1
);
784 status
= GdipBeginContainer2(graphics
, &cont2
);
787 status
= GdipBeginContainer2(graphics
, &cont3
);
790 status
= GdipEndContainer(graphics
, cont3
);
793 status
= GdipBeginContainer2(graphics
, &cont4
);
796 status
= GdipEndContainer(graphics
, cont4
);
800 status
= GdipEndContainer(graphics
, cont1
);
803 /* end an already-ended container */
804 status
= GdipEndContainer(graphics
, cont1
);
807 GdipDeleteGraphics(graphics
);
808 ReleaseDC(hwnd
, hdc
);
811 static void test_GdipDrawBezierI(void)
814 GpGraphics
*graphics
= NULL
;
816 HDC hdc
= GetDC( hwnd
);
818 /* make a graphics object and pen object */
819 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
821 status
= GdipCreateFromHDC(hdc
, &graphics
);
823 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
825 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
827 ok(pen
!= NULL
, "Expected pen to be initialized\n");
829 /* InvalidParameter cases: null graphics, null pen */
830 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
831 expect(InvalidParameter
, status
);
833 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
834 expect(InvalidParameter
, status
);
836 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
837 expect(InvalidParameter
, status
);
839 /* successful case */
840 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
844 GdipDeleteGraphics(graphics
);
846 ReleaseDC(hwnd
, hdc
);
849 static void test_GdipDrawCurve3(void)
852 GpGraphics
*graphics
= NULL
;
854 HDC hdc
= GetDC( hwnd
);
866 /* make a graphics object and pen object */
867 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
869 status
= GdipCreateFromHDC(hdc
, &graphics
);
871 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
873 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
875 ok(pen
!= NULL
, "Expected pen to be initialized\n");
877 /* InvalidParameter cases: null graphics, null pen */
878 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
879 expect(InvalidParameter
, status
);
881 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
882 expect(InvalidParameter
, status
);
884 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
885 expect(InvalidParameter
, status
);
887 /* InvalidParameter cases: invalid count */
888 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
889 expect(InvalidParameter
, status
);
891 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
892 expect(InvalidParameter
, status
);
894 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
895 expect(InvalidParameter
, status
);
897 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
898 expect(InvalidParameter
, status
);
900 /* InvalidParameter cases: invalid number of segments */
901 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
902 expect(InvalidParameter
, status
);
904 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
905 expect(InvalidParameter
, status
);
907 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
908 expect(InvalidParameter
, status
);
910 /* Valid test cases */
911 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
914 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
917 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
920 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
924 GdipDeleteGraphics(graphics
);
926 ReleaseDC(hwnd
, hdc
);
929 static void test_GdipDrawCurve3I(void)
932 GpGraphics
*graphics
= NULL
;
934 HDC hdc
= GetDC( hwnd
);
946 /* make a graphics object and pen object */
947 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
949 status
= GdipCreateFromHDC(hdc
, &graphics
);
951 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
953 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
955 ok(pen
!= NULL
, "Expected pen to be initialized\n");
957 /* InvalidParameter cases: null graphics, null pen */
958 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
959 expect(InvalidParameter
, status
);
961 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
962 expect(InvalidParameter
, status
);
964 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
965 expect(InvalidParameter
, status
);
967 /* InvalidParameter cases: invalid count */
968 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
969 expect(OutOfMemory
, status
);
971 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
972 expect(InvalidParameter
, status
);
974 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
975 expect(InvalidParameter
, status
);
977 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
978 expect(InvalidParameter
, status
);
980 /* InvalidParameter cases: invalid number of segments */
981 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
982 expect(InvalidParameter
, status
);
984 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
985 expect(InvalidParameter
, status
);
987 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
988 expect(InvalidParameter
, status
);
990 /* Valid test cases */
991 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
994 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
997 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
1000 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
1004 GdipDeleteGraphics(graphics
);
1006 ReleaseDC(hwnd
, hdc
);
1009 static void test_GdipDrawCurve2(void)
1012 GpGraphics
*graphics
= NULL
;
1014 HDC hdc
= GetDC( hwnd
);
1026 /* make a graphics object and pen object */
1027 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1029 status
= GdipCreateFromHDC(hdc
, &graphics
);
1031 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1033 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1035 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1037 /* InvalidParameter cases: null graphics, null pen */
1038 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
1039 expect(InvalidParameter
, status
);
1041 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
1042 expect(InvalidParameter
, status
);
1044 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
1045 expect(InvalidParameter
, status
);
1047 /* InvalidParameter cases: invalid count */
1048 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
1049 expect(InvalidParameter
, status
);
1051 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
1052 expect(InvalidParameter
, status
);
1054 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
1055 expect(InvalidParameter
, status
);
1057 /* Valid test cases */
1058 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1061 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1064 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1067 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1071 GdipDeleteGraphics(graphics
);
1073 ReleaseDC(hwnd
, hdc
);
1076 static void test_GdipDrawCurve2I(void)
1079 GpGraphics
*graphics
= NULL
;
1081 HDC hdc
= GetDC( hwnd
);
1093 /* make a graphics object and pen object */
1094 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1096 status
= GdipCreateFromHDC(hdc
, &graphics
);
1098 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1100 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1102 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1104 /* InvalidParameter cases: null graphics, null pen */
1105 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1106 expect(InvalidParameter
, status
);
1108 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1109 expect(InvalidParameter
, status
);
1111 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1112 expect(InvalidParameter
, status
);
1114 /* InvalidParameter cases: invalid count */
1115 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1116 expect(OutOfMemory
, status
);
1118 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1119 expect(InvalidParameter
, status
);
1121 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1122 expect(InvalidParameter
, status
);
1124 /* Valid test cases */
1125 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1128 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1131 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1134 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1138 GdipDeleteGraphics(graphics
);
1140 ReleaseDC(hwnd
, hdc
);
1143 static void test_GdipDrawCurve(void)
1146 GpGraphics
*graphics
= NULL
;
1148 HDC hdc
= GetDC( hwnd
);
1160 /* make a graphics object and pen object */
1161 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1163 status
= GdipCreateFromHDC(hdc
, &graphics
);
1165 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1167 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1169 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1171 /* InvalidParameter cases: null graphics, null pen */
1172 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1173 expect(InvalidParameter
, status
);
1175 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1176 expect(InvalidParameter
, status
);
1178 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1179 expect(InvalidParameter
, status
);
1181 /* InvalidParameter cases: invalid count */
1182 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1183 expect(InvalidParameter
, status
);
1185 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1186 expect(InvalidParameter
, status
);
1188 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1189 expect(InvalidParameter
, status
);
1191 /* Valid test cases */
1192 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1195 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1199 GdipDeleteGraphics(graphics
);
1201 ReleaseDC(hwnd
, hdc
);
1204 static void test_GdipDrawCurveI(void)
1207 GpGraphics
*graphics
= NULL
;
1209 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
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1234 expect(InvalidParameter
, status
);
1236 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1237 expect(InvalidParameter
, status
);
1239 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1240 expect(InvalidParameter
, status
);
1242 /* InvalidParameter cases: invalid count */
1243 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1244 expect(OutOfMemory
, status
);
1246 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1247 expect(InvalidParameter
, status
);
1249 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1250 expect(InvalidParameter
, status
);
1252 /* Valid test cases */
1253 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1256 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1260 GdipDeleteGraphics(graphics
);
1262 ReleaseDC(hwnd
, hdc
);
1265 static void test_GdipDrawLineI(void)
1268 GpGraphics
*graphics
= NULL
;
1270 HDC hdc
= GetDC( hwnd
);
1272 /* make a graphics object and pen object */
1273 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1275 status
= GdipCreateFromHDC(hdc
, &graphics
);
1277 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1279 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1281 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1283 /* InvalidParameter cases: null graphics, null pen */
1284 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1285 expect(InvalidParameter
, status
);
1287 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1288 expect(InvalidParameter
, status
);
1290 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1291 expect(InvalidParameter
, status
);
1293 /* successful case */
1294 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1298 GdipDeleteGraphics(graphics
);
1300 ReleaseDC(hwnd
, hdc
);
1303 static void test_GdipDrawImagePointsRect(void)
1306 GpGraphics
*graphics
= NULL
;
1308 GpBitmap
*bm
= NULL
;
1309 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1311 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1312 HDC hdc
= GetDC( hwnd
);
1316 memset(rbmi
, 0, sizeof(rbmi
));
1317 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1318 bmi
->bmiHeader
.biWidth
= 10;
1319 bmi
->bmiHeader
.biHeight
= 10;
1320 bmi
->bmiHeader
.biPlanes
= 1;
1321 bmi
->bmiHeader
.biBitCount
= 32;
1322 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1323 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1325 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1326 status
= GdipCreateFromHDC(hdc
, &graphics
);
1336 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1337 expect(NotImplemented
, status
);
1338 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1339 expect(InvalidParameter
, status
);
1340 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1342 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1343 expect(InvalidParameter
, status
);
1344 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1345 expect(InvalidParameter
, status
);
1346 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1348 memset(ptf
, 0, sizeof(ptf
));
1349 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1352 GdipDisposeImage((GpImage
*)bm
);
1353 GdipDeleteGraphics(graphics
);
1354 ReleaseDC(hwnd
, hdc
);
1357 static void test_GdipDrawLinesI(void)
1360 GpGraphics
*graphics
= NULL
;
1362 GpPoint
*ptf
= NULL
;
1363 HDC hdc
= GetDC( hwnd
);
1365 /* make a graphics object and pen object */
1366 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1368 status
= GdipCreateFromHDC(hdc
, &graphics
);
1370 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1372 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1374 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1376 /* make some arbitrary valid points*/
1377 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1385 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1386 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1387 expect(InvalidParameter
, status
);
1389 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1390 expect(InvalidParameter
, status
);
1392 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1393 expect(InvalidParameter
, status
);
1395 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1396 expect(InvalidParameter
, status
);
1398 /* successful case */
1399 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1404 GdipDeleteGraphics(graphics
);
1406 ReleaseDC(hwnd
, hdc
);
1409 static void test_GdipFillClosedCurve(void)
1412 GpGraphics
*graphics
= NULL
;
1413 GpSolidFill
*brush
= NULL
;
1414 HDC hdc
= GetDC( hwnd
);
1426 /* make a graphics object and brush object */
1427 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1429 status
= GdipCreateFromHDC(hdc
, &graphics
);
1431 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1433 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1435 /* InvalidParameter cases: null graphics, null brush, null points */
1436 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1437 expect(InvalidParameter
, status
);
1439 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1440 expect(InvalidParameter
, status
);
1442 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1443 expect(InvalidParameter
, status
);
1445 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1446 expect(InvalidParameter
, status
);
1448 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1449 expect(InvalidParameter
, status
);
1451 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1452 expect(InvalidParameter
, status
);
1454 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1455 expect(InvalidParameter
, status
);
1457 /* InvalidParameter cases: invalid count */
1458 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1459 expect(InvalidParameter
, status
);
1461 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1462 expect(InvalidParameter
, status
);
1464 /* Valid test cases */
1465 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1468 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1471 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1474 GdipDeleteGraphics(graphics
);
1475 GdipDeleteBrush((GpBrush
*)brush
);
1477 ReleaseDC(hwnd
, hdc
);
1480 static void test_GdipFillClosedCurveI(void)
1483 GpGraphics
*graphics
= NULL
;
1484 GpSolidFill
*brush
= NULL
;
1485 HDC hdc
= GetDC( hwnd
);
1497 /* make a graphics object and brush object */
1498 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1500 status
= GdipCreateFromHDC(hdc
, &graphics
);
1502 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1504 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1506 /* InvalidParameter cases: null graphics, null brush */
1507 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1508 when points == NULL, so don't test this condition */
1509 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1510 expect(InvalidParameter
, status
);
1512 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1513 expect(InvalidParameter
, status
);
1515 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1516 expect(InvalidParameter
, status
);
1518 /* InvalidParameter cases: invalid count */
1519 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1520 expect(InvalidParameter
, status
);
1522 /* OutOfMemory cases: large (unsigned) int */
1523 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1524 expect(OutOfMemory
, status
);
1526 /* Valid test cases */
1527 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1530 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1533 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1536 GdipDeleteGraphics(graphics
);
1537 GdipDeleteBrush((GpBrush
*)brush
);
1539 ReleaseDC(hwnd
, hdc
);
1542 static void test_GdipFillPath(void)
1545 GpGraphics
*graphics
;
1548 HDC hdc
= GetDC(hwnd
);
1550 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1551 status
= GdipCreateFromHDC(hdc
, &graphics
);
1553 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1554 status
= GdipCreateSolidFill((ARGB
)0xffffffff, &brush
);
1556 ok(brush
!= NULL
, "Expected brush to be initialized\n");
1557 status
= GdipCreatePath(FillModeAlternate
, &path
);
1559 ok(path
!= NULL
, "Expected path to be initialized\n");
1562 GdipResetPath(path
);
1563 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1566 /* Not closed path */
1567 GdipResetPath(path
);
1568 status
= GdipAddPathLineI(path
, 0, 0, 2, 2);
1570 status
= GdipAddPathLineI(path
, 2, 2, 4, 0);
1572 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1576 GdipResetPath(path
);
1577 status
= GdipAddPathRectangle(path
, 0, 0, 4, 4);
1579 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1582 GdipDeletePath(path
);
1583 GdipDeleteBrush((GpBrush
*)brush
);
1584 GdipDeleteGraphics(graphics
);
1585 ReleaseDC(hwnd
, hdc
);
1588 static void test_Get_Release_DC(void)
1591 GpGraphics
*graphics
= NULL
;
1595 HDC hdc
= GetDC( hwnd
);
1598 CompositingQuality quality
;
1599 CompositingMode compmode
;
1600 InterpolationMode intmode
;
1604 PixelOffsetMode offsetmode
;
1605 SmoothingMode smoothmode
;
1606 TextRenderingHint texthint
;
1614 ARGB color
= 0x00000000;
1615 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1628 for(i
= 0; i
< 5;i
++){
1629 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1630 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1636 rect
[0].Height
= 70;
1640 rect
[1].Height
= 20;
1642 for(i
= 0; i
< 2;i
++){
1643 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1644 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1645 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1646 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1649 status
= GdipCreateMatrix(&m
);
1651 status
= GdipCreateRegion(®ion
);
1653 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1654 GdipCreatePath(FillModeAlternate
, &path
);
1655 status
= GdipCreateRegion(&clip
);
1658 status
= GdipCreateFromHDC(hdc
, &graphics
);
1660 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1661 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1664 /* NULL arguments */
1665 status
= GdipGetDC(NULL
, NULL
);
1666 expect(InvalidParameter
, status
);
1667 status
= GdipGetDC(graphics
, NULL
);
1668 expect(InvalidParameter
, status
);
1669 status
= GdipGetDC(NULL
, &retdc
);
1670 expect(InvalidParameter
, status
);
1672 status
= GdipReleaseDC(NULL
, NULL
);
1673 expect(InvalidParameter
, status
);
1674 status
= GdipReleaseDC(graphics
, NULL
);
1675 expect(InvalidParameter
, status
);
1676 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1677 expect(InvalidParameter
, status
);
1679 /* Release without Get */
1680 status
= GdipReleaseDC(graphics
, hdc
);
1681 expect(InvalidParameter
, status
);
1684 status
= GdipGetDC(graphics
, &retdc
);
1686 ok(retdc
== hdc
, "Invalid HDC returned\n");
1687 /* call it once more */
1688 status
= GdipGetDC(graphics
, &retdc
);
1689 expect(ObjectBusy
, status
);
1691 /* try all Graphics calls here */
1692 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1693 expect(ObjectBusy
, status
);
1694 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1695 expect(ObjectBusy
, status
);
1696 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1697 expect(ObjectBusy
, status
);
1698 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1699 expect(ObjectBusy
, status
);
1700 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1701 expect(ObjectBusy
, status
);
1702 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1703 expect(ObjectBusy
, status
);
1704 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1705 expect(ObjectBusy
, status
);
1706 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1707 expect(ObjectBusy
, status
);
1708 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1709 expect(ObjectBusy
, status
);
1710 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1711 expect(ObjectBusy
, status
);
1712 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1713 expect(ObjectBusy
, status
);
1714 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1715 expect(ObjectBusy
, status
);
1716 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1717 expect(ObjectBusy
, status
);
1718 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1719 expect(ObjectBusy
, status
);
1720 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1721 expect(ObjectBusy
, status
);
1722 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1723 expect(ObjectBusy
, status
);
1724 /* GdipDrawImage/GdipDrawImageI */
1725 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1726 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1727 /* GdipDrawImageRect/GdipDrawImageRectI */
1728 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1729 expect(ObjectBusy
, status
);
1730 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1731 expect(ObjectBusy
, status
);
1732 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1733 expect(ObjectBusy
, status
);
1734 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1735 expect(ObjectBusy
, status
);
1736 status
= GdipDrawPath(graphics
, pen
, path
);
1737 expect(ObjectBusy
, status
);
1738 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1739 expect(ObjectBusy
, status
);
1740 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1741 expect(ObjectBusy
, status
);
1742 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1743 expect(ObjectBusy
, status
);
1744 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1745 expect(ObjectBusy
, status
);
1746 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1747 expect(ObjectBusy
, status
);
1748 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1749 expect(ObjectBusy
, status
);
1750 /* GdipDrawString */
1751 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1752 expect(ObjectBusy
, status
);
1753 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1754 expect(ObjectBusy
, status
);
1755 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1756 expect(ObjectBusy
, status
);
1757 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1758 expect(ObjectBusy
, status
);
1759 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1764 expect(ObjectBusy
, status
);
1765 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1766 expect(ObjectBusy
, status
);
1767 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1768 expect(ObjectBusy
, status
);
1769 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1770 expect(ObjectBusy
, status
);
1771 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1772 expect(ObjectBusy
, status
);
1773 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1774 expect(ObjectBusy
, status
);
1775 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1776 expect(ObjectBusy
, status
);
1777 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1778 expect(ObjectBusy
, status
);
1779 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1780 expect(ObjectBusy
, status
);
1781 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1782 expect(ObjectBusy
, status
);
1783 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1784 expect(ObjectBusy
, status
);
1785 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1786 expect(ObjectBusy
, status
);
1787 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1788 expect(ObjectBusy
, status
);
1789 status
= GdipGetClipBounds(graphics
, rectf
);
1790 expect(ObjectBusy
, status
);
1791 status
= GdipGetClipBoundsI(graphics
, rect
);
1792 expect(ObjectBusy
, status
);
1793 status
= GdipGetCompositingMode(graphics
, &compmode
);
1794 expect(ObjectBusy
, status
);
1795 status
= GdipGetCompositingQuality(graphics
, &quality
);
1796 expect(ObjectBusy
, status
);
1797 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1798 expect(ObjectBusy
, status
);
1799 status
= GdipGetNearestColor(graphics
, &color
);
1800 expect(ObjectBusy
, status
);
1801 status
= GdipGetPageScale(graphics
, &r
);
1802 expect(ObjectBusy
, status
);
1803 status
= GdipGetPageUnit(graphics
, &unit
);
1804 expect(ObjectBusy
, status
);
1805 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1806 expect(ObjectBusy
, status
);
1807 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1808 expect(ObjectBusy
, status
);
1809 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1810 expect(ObjectBusy
, status
);
1811 status
= GdipGetWorldTransform(graphics
, m
);
1812 expect(ObjectBusy
, status
);
1813 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1814 expect(ObjectBusy
, status
);
1815 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1816 expect(ObjectBusy
, status
);
1817 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1818 expect(ObjectBusy
, status
);
1819 /* GdipMeasureCharacterRanges */
1820 /* GdipMeasureString */
1821 status
= GdipResetClip(graphics
);
1822 expect(ObjectBusy
, status
);
1823 status
= GdipResetWorldTransform(graphics
);
1824 expect(ObjectBusy
, status
);
1825 /* GdipRestoreGraphics */
1826 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1827 expect(ObjectBusy
, status
);
1828 /* GdipSaveGraphics */
1829 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1830 expect(ObjectBusy
, status
);
1831 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1832 expect(ObjectBusy
, status
);
1833 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1834 expect(ObjectBusy
, status
);
1835 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1836 expect(ObjectBusy
, status
);
1837 status
= GdipSetPageScale(graphics
, 1.0);
1838 expect(ObjectBusy
, status
);
1839 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1840 expect(ObjectBusy
, status
);
1841 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1842 expect(ObjectBusy
, status
);
1843 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1844 expect(ObjectBusy
, status
);
1845 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1846 expect(ObjectBusy
, status
);
1847 status
= GdipSetWorldTransform(graphics
, m
);
1848 expect(ObjectBusy
, status
);
1849 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1850 expect(ObjectBusy
, status
);
1851 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1852 expect(ObjectBusy
, status
);
1853 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1854 expect(ObjectBusy
, status
);
1855 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1856 expect(ObjectBusy
, status
);
1857 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1858 expect(ObjectBusy
, status
);
1859 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1860 expect(ObjectBusy
, status
);
1861 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1862 expect(ObjectBusy
, status
);
1863 status
= GdipTranslateClipI(graphics
, 0, 0);
1864 expect(ObjectBusy
, status
);
1865 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1866 expect(ObjectBusy
, status
);
1867 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1868 expect(ObjectBusy
, status
);
1869 status
= GdipGetDpiX(graphics
, &r
);
1870 expect(ObjectBusy
, status
);
1871 status
= GdipGetDpiY(graphics
, &r
);
1872 expect(ObjectBusy
, status
);
1873 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1874 expect(ObjectBusy
, status
);
1875 status
= GdipGetClip(graphics
, region
);
1876 expect(ObjectBusy
, status
);
1877 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1878 expect(ObjectBusy
, status
);
1880 /* try to delete before release */
1881 status
= GdipDeleteGraphics(graphics
);
1882 expect(ObjectBusy
, status
);
1884 status
= GdipReleaseDC(graphics
, retdc
);
1888 GdipDeleteGraphics(graphics
);
1890 GdipDeleteRegion(clip
);
1891 GdipDeletePath(path
);
1892 GdipDeleteBrush((GpBrush
*)brush
);
1893 GdipDeleteRegion(region
);
1894 GdipDeleteMatrix(m
);
1897 ReleaseDC(hwnd
, hdc
);
1900 static void test_transformpoints(void)
1903 GpGraphics
*graphics
= NULL
;
1904 HDC hdc
= GetDC( hwnd
);
1908 status
= GdipCreateFromHDC(hdc
, &graphics
);
1911 /* NULL arguments */
1912 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1913 expect(InvalidParameter
, status
);
1914 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1915 expect(InvalidParameter
, status
);
1916 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1917 expect(InvalidParameter
, status
);
1918 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1919 expect(InvalidParameter
, status
);
1921 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
+1, CoordinateSpaceWorld
, ptf
, 2);
1922 expect(InvalidParameter
, status
);
1923 status
= GdipTransformPoints(graphics
, -1, CoordinateSpaceWorld
, ptf
, 2);
1924 expect(InvalidParameter
, status
);
1925 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceDevice
+1, ptf
, 2);
1926 expect(InvalidParameter
, status
);
1927 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, -1, ptf
, 2);
1928 expect(InvalidParameter
, status
);
1934 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1936 expectf(1.0, ptf
[0].X
);
1937 expectf(0.0, ptf
[0].Y
);
1938 expectf(0.0, ptf
[1].X
);
1939 expectf(1.0, ptf
[1].Y
);
1941 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1943 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1945 status
= GdipSetPageScale(graphics
, 3.0);
1952 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1954 expectf(18.0, ptf
[0].X
);
1955 expectf(15.0, ptf
[0].Y
);
1956 expectf(15.0, ptf
[1].X
);
1957 expectf(18.0, ptf
[1].Y
);
1963 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1965 expectf(6.0, ptf
[0].X
);
1966 expectf(5.0, ptf
[0].Y
);
1967 expectf(5.0, ptf
[1].X
);
1968 expectf(6.0, ptf
[1].Y
);
1974 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1976 expectf(3.0, ptf
[0].X
);
1977 expectf(0.0, ptf
[0].Y
);
1978 expectf(0.0, ptf
[1].X
);
1979 expectf(3.0, ptf
[1].Y
);
1985 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1987 expectf(1.0, ptf
[0].X
);
1988 expectf(0.0, ptf
[0].Y
);
1989 expectf(0.0, ptf
[1].X
);
1990 expectf(1.0, ptf
[1].Y
);
1996 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1998 expectf(1.0, ptf
[0].X
);
1999 expectf(0.0, ptf
[0].Y
);
2000 expectf(0.0, ptf
[1].X
);
2001 expectf(1.0, ptf
[1].Y
);
2007 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
2009 expectf(1.0, ptf
[0].X
);
2010 expectf(0.0, ptf
[0].Y
);
2011 expectf(0.0, ptf
[1].X
);
2012 expectf(1.0, ptf
[1].Y
);
2018 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
2020 expect(18, pt
[0].X
);
2021 expect(15, pt
[0].Y
);
2022 expect(15, pt
[1].X
);
2023 expect(18, pt
[1].Y
);
2025 GdipDeleteGraphics(graphics
);
2026 ReleaseDC(hwnd
, hdc
);
2029 static void test_get_set_clip(void)
2032 GpGraphics
*graphics
= NULL
;
2033 HDC hdc
= GetDC( hwnd
);
2038 status
= GdipCreateFromHDC(hdc
, &graphics
);
2041 rect
.X
= rect
.Y
= 0.0;
2042 rect
.Height
= rect
.Width
= 100.0;
2044 status
= GdipCreateRegionRect(&rect
, &clip
);
2047 /* NULL arguments */
2048 status
= GdipGetClip(NULL
, NULL
);
2049 expect(InvalidParameter
, status
);
2050 status
= GdipGetClip(graphics
, NULL
);
2051 expect(InvalidParameter
, status
);
2052 status
= GdipGetClip(NULL
, clip
);
2053 expect(InvalidParameter
, status
);
2055 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
2056 expect(InvalidParameter
, status
);
2057 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
2058 expect(InvalidParameter
, status
);
2060 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
2061 expect(InvalidParameter
, status
);
2062 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
2063 expect(InvalidParameter
, status
);
2066 status
= GdipGetClip(graphics
, clip
);
2068 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2072 /* remains infinite after reset */
2074 status
= GdipResetClip(graphics
);
2076 status
= GdipGetClip(graphics
, clip
);
2078 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2082 /* set to empty and then reset to infinite */
2083 status
= GdipSetEmpty(clip
);
2085 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
2088 status
= GdipGetClip(graphics
, clip
);
2091 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
2094 status
= GdipResetClip(graphics
);
2096 status
= GdipGetClip(graphics
, clip
);
2099 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2103 GdipDeleteRegion(clip
);
2105 GdipDeleteGraphics(graphics
);
2106 ReleaseDC(hwnd
, hdc
);
2109 static void test_clip_xform(void)
2112 GpGraphics
*graphics
= NULL
;
2113 HDC hdc
= GetDC( hwnd
);
2116 UINT region_data_size
;
2129 status
= GdipCreateFromHDC(hdc
, &graphics
);
2131 status
= GdipCreateRegion(&clip
);
2134 status
= GdipGraphicsClear(graphics
, 0xff000000);
2137 status
= GdipSetClipRect(graphics
, 10, 10, -10, -10, CombineModeReplace
);
2139 status
= GdipGetClip(graphics
, clip
);
2141 status
= GdipGetRegionData(clip
, (BYTE
*)®ion_data
, sizeof(region_data
), ®ion_data_size
);
2143 expect(36, region_data_size
);
2144 expect(28, region_data
.size
);
2145 expect(0, region_data
.num_children
);
2146 expect(0x10000000 /* RegionDataRect */, region_data
.element_type
);
2147 expectf(0.0, region_data
.x
);
2148 expectf(0.0, region_data
.y
);
2149 expectf(10.0, region_data
.width
);
2150 expectf(10.0, region_data
.height
);
2152 /* No effect with negative width/height */
2153 status
= GdipGraphicsClear(graphics
, 0xffff0000);
2155 color
= GetPixel(hdc
, 5, 5);
2158 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderAppend
);
2161 status
= GdipGraphicsClear(graphics
, 0xffff0000);
2163 color
= GetPixel(hdc
, 5, 5);
2166 status
= GdipResetClip(graphics
);
2168 status
= GdipResetWorldTransform(graphics
);
2170 status
= GdipGraphicsClear(graphics
, 0xff000000);
2173 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderAppend
);
2176 status
= GdipSetClipRect(graphics
, 5, 5, -5, -5, CombineModeReplace
);
2178 status
= GdipGetClip(graphics
, clip
);
2180 status
= GdipGetRegionData(clip
, (BYTE
*)®ion_data
, sizeof(region_data
), ®ion_data_size
);
2182 expect(36, region_data_size
);
2183 expect(28, region_data
.size
);
2184 expect(0, region_data
.num_children
);
2185 expect(0x10000000 /* RegionDataRect */, region_data
.element_type
);
2186 expectf(0.0, region_data
.x
);
2187 expectf(0.0, region_data
.y
);
2188 expectf(5.0, region_data
.width
);
2189 expectf(5.0, region_data
.height
);
2191 status
= GdipGraphicsClear(graphics
, 0xffff0000);
2193 color
= GetPixel(hdc
, 5, 5);
2194 expect(0xff, color
);
2196 GdipDeleteGraphics(graphics
);
2197 GdipDeleteRegion(clip
);
2198 ReleaseDC(hwnd
, hdc
);
2201 static void test_isempty(void)
2204 GpGraphics
*graphics
= NULL
;
2205 HDC hdc
= GetDC( hwnd
);
2209 status
= GdipCreateFromHDC(hdc
, &graphics
);
2212 status
= GdipCreateRegion(&clip
);
2216 status
= GdipIsClipEmpty(NULL
, NULL
);
2217 expect(InvalidParameter
, status
);
2218 status
= GdipIsClipEmpty(graphics
, NULL
);
2219 expect(InvalidParameter
, status
);
2220 status
= GdipIsClipEmpty(NULL
, &res
);
2221 expect(InvalidParameter
, status
);
2223 /* default is infinite */
2225 status
= GdipIsClipEmpty(graphics
, &res
);
2229 GdipDeleteRegion(clip
);
2231 GdipDeleteGraphics(graphics
);
2232 ReleaseDC(hwnd
, hdc
);
2235 static void test_clear(void)
2239 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2240 expect(InvalidParameter
, status
);
2243 static void test_textcontrast(void)
2246 HDC hdc
= GetDC( hwnd
);
2247 GpGraphics
*graphics
;
2250 status
= GdipGetTextContrast(NULL
, NULL
);
2251 expect(InvalidParameter
, status
);
2253 status
= GdipCreateFromHDC(hdc
, &graphics
);
2256 status
= GdipGetTextContrast(graphics
, NULL
);
2257 expect(InvalidParameter
, status
);
2258 status
= GdipGetTextContrast(graphics
, &contrast
);
2260 expect(4, contrast
);
2262 GdipDeleteGraphics(graphics
);
2263 ReleaseDC(hwnd
, hdc
);
2266 static void test_GdipDrawString(void)
2269 GpGraphics
*graphics
= NULL
;
2272 GpStringFormat
*format
;
2275 HDC hdc
= GetDC( hwnd
);
2276 static const WCHAR string
[] = {'T','e','s','t',0};
2277 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2280 memset(&logfont
,0,sizeof(logfont
));
2281 strcpy(logfont
.lfFaceName
,"Arial");
2282 logfont
.lfHeight
= 12;
2283 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2285 status
= GdipCreateFromHDC(hdc
, &graphics
);
2288 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2289 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2291 skip("Arial not installed.\n");
2296 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2299 status
= GdipCreateStringFormat(0,0,&format
);
2307 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2310 status
= GdipCreateMatrix(&matrix
);
2313 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2314 expect(InvalidParameter
, status
);
2316 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2317 expect(InvalidParameter
, status
);
2319 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2320 expect(InvalidParameter
, status
);
2322 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2323 expect(InvalidParameter
, status
);
2325 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2326 expect(InvalidParameter
, status
);
2328 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2331 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2334 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2337 GdipDeleteMatrix(matrix
);
2338 GdipDeleteGraphics(graphics
);
2339 GdipDeleteBrush(brush
);
2340 GdipDeleteFont(fnt
);
2341 GdipDeleteStringFormat(format
);
2343 ReleaseDC(hwnd
, hdc
);
2346 static void test_GdipGetVisibleClipBounds_screen(void)
2349 GpGraphics
*graphics
= NULL
;
2351 GpRectF rectf
, exp
, clipr
;
2354 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2356 status
= GdipCreateFromHDC(hdc
, &graphics
);
2358 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2360 /* no clipping rect */
2363 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2364 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2366 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2368 ok(rectf
.X
== exp
.X
&&
2370 rectf
.Width
== exp
.Width
&&
2371 rectf
.Height
== exp
.Height
,
2372 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2373 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2374 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2375 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2377 /* clipping rect entirely within window */
2378 exp
.X
= clipr
.X
= 10;
2379 exp
.Y
= clipr
.Y
= 12;
2380 exp
.Width
= clipr
.Width
= 14;
2381 exp
.Height
= clipr
.Height
= 16;
2383 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2386 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2388 ok(rectf
.X
== exp
.X
&&
2390 rectf
.Width
== exp
.Width
&&
2391 rectf
.Height
== exp
.Height
,
2392 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2393 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2394 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2395 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2397 /* clipping rect partially outside of screen */
2403 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2411 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2413 ok(rectf
.X
== exp
.X
&&
2415 rectf
.Width
== exp
.Width
&&
2416 rectf
.Height
== exp
.Height
,
2417 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2418 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2419 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2420 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2422 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2424 ok(recti
.X
== exp
.X
&&
2426 recti
.Width
== exp
.Width
&&
2427 recti
.Height
== exp
.Height
,
2428 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2429 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2430 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2431 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2433 GdipDeleteGraphics(graphics
);
2437 static void test_GdipGetVisibleClipBounds_window(void)
2440 GpGraphics
*graphics
= NULL
;
2441 GpRectF rectf
, window
, exp
, clipr
;
2447 /* get client area size */
2448 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2449 window
.X
= wnd_rect
.left
;
2450 window
.Y
= wnd_rect
.top
;
2451 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2452 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2454 hdc
= BeginPaint(hwnd
, &ps
);
2456 status
= GdipCreateFromHDC(hdc
, &graphics
);
2458 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2460 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2462 ok(rectf
.X
== window
.X
&&
2463 rectf
.Y
== window
.Y
&&
2464 rectf
.Width
== window
.Width
&&
2465 rectf
.Height
== window
.Height
,
2466 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2467 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2468 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2469 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2471 /* clipping rect entirely within window */
2472 exp
.X
= clipr
.X
= 20;
2473 exp
.Y
= clipr
.Y
= 8;
2474 exp
.Width
= clipr
.Width
= 30;
2475 exp
.Height
= clipr
.Height
= 20;
2477 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2480 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2482 ok(rectf
.X
== exp
.X
&&
2484 rectf
.Width
== exp
.Width
&&
2485 rectf
.Height
== exp
.Height
,
2486 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2487 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2488 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2489 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2491 /* clipping rect partially outside of window */
2492 clipr
.X
= window
.Width
- 10;
2493 clipr
.Y
= window
.Height
- 15;
2497 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2500 exp
.X
= window
.Width
- 10;
2501 exp
.Y
= window
.Height
- 15;
2505 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2507 ok(rectf
.X
== exp
.X
&&
2509 rectf
.Width
== exp
.Width
&&
2510 rectf
.Height
== exp
.Height
,
2511 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2512 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2513 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2514 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2516 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2518 ok(recti
.X
== exp
.X
&&
2520 recti
.Width
== exp
.Width
&&
2521 recti
.Height
== exp
.Height
,
2522 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2523 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2524 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2525 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2527 /* window bounds with transform applied */
2528 status
= GdipResetClip(graphics
);
2531 status
= GdipScaleWorldTransform(graphics
, 0.5, 0.5, MatrixOrderPrepend
);
2534 exp
.X
= window
.X
* 2.0;
2535 exp
.Y
= window
.Y
* 2.0;
2536 exp
.Width
= window
.Width
* 2.0;
2537 exp
.Height
= window
.Height
* 2.0;
2539 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2541 ok(rectf
.X
== exp
.X
&&
2543 rectf
.Width
== exp
.Width
&&
2544 rectf
.Height
== exp
.Height
,
2545 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2546 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2547 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2548 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2550 GdipDeleteGraphics(graphics
);
2551 EndPaint(hwnd
, &ps
);
2554 static void test_GdipGetVisibleClipBounds(void)
2556 GpGraphics
* graphics
= NULL
;
2559 HDC hdc
= GetDC( hwnd
);
2562 status
= GdipCreateFromHDC(hdc
, &graphics
);
2564 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2566 /* test null parameters */
2567 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2568 expect(InvalidParameter
, status
);
2570 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2571 expect(InvalidParameter
, status
);
2573 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2574 expect(InvalidParameter
, status
);
2576 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2577 expect(InvalidParameter
, status
);
2579 GdipDeleteGraphics(graphics
);
2580 ReleaseDC(hwnd
, hdc
);
2582 test_GdipGetVisibleClipBounds_screen();
2583 test_GdipGetVisibleClipBounds_window();
2586 static void test_fromMemoryBitmap(void)
2589 GpGraphics
*graphics
= NULL
;
2590 GpBitmap
*bitmap
= NULL
;
2591 BYTE bits
[48] = {0};
2595 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2598 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2601 status
= GdipGraphicsClear(graphics
, 0xff686868);
2604 GdipDeleteGraphics(graphics
);
2606 /* drawing writes to the memory provided */
2607 expect(0x68, bits
[10]);
2609 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2612 status
= GdipGetDC(graphics
, &hdc
);
2614 ok(hdc
!= NULL
, "got NULL hdc\n");
2616 color
= GetPixel(hdc
, 0, 0);
2617 /* The HDC is write-only, and native fills with a solid color to figure out
2618 * which pixels have changed. */
2619 todo_wine
expect(0x0c0b0d, color
);
2621 SetPixel(hdc
, 0, 0, 0x797979);
2622 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2624 status
= GdipReleaseDC(graphics
, hdc
);
2627 GdipDeleteGraphics(graphics
);
2629 expect(0x79, bits
[0]);
2630 todo_wine
expect(0x68, bits
[3]);
2632 GdipDisposeImage((GpImage
*)bitmap
);
2634 /* We get the same kind of write-only HDC for a "normal" bitmap */
2635 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2638 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2641 status
= GdipGetDC(graphics
, &hdc
);
2643 ok(hdc
!= NULL
, "got NULL hdc\n");
2645 color
= GetPixel(hdc
, 0, 0);
2646 todo_wine
expect(0x0c0b0d, color
);
2648 status
= GdipReleaseDC(graphics
, hdc
);
2651 GdipDeleteGraphics(graphics
);
2653 GdipDisposeImage((GpImage
*)bitmap
);
2655 /* If we don't draw to the HDC, the bits are never accessed */
2656 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2659 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2662 status
= GdipGetDC(graphics
, &hdc
);
2664 ok(hdc
!= NULL
, "got NULL hdc\n");
2666 color
= GetPixel(hdc
, 0, 0);
2667 todo_wine
expect(0x0c0b0d, color
);
2669 status
= GdipReleaseDC(graphics
, hdc
);
2672 GdipDeleteGraphics(graphics
);
2674 GdipDisposeImage((GpImage
*)bitmap
);
2677 static void test_GdipIsVisiblePoint(void)
2680 GpGraphics
*graphics
= NULL
;
2681 HDC hdc
= GetDC( hwnd
);
2685 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2687 status
= GdipCreateFromHDC(hdc
, &graphics
);
2689 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2691 /* null parameters */
2692 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2693 expect(InvalidParameter
, status
);
2695 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2696 expect(InvalidParameter
, status
);
2698 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2699 expect(InvalidParameter
, status
);
2701 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2702 expect(InvalidParameter
, status
);
2706 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2708 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2712 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2714 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2718 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2720 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2724 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2726 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2728 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2733 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2735 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2739 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2741 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2743 /* translate into the center of the rect */
2744 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2748 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2750 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2754 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2756 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2758 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2763 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2765 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2769 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2771 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2775 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2777 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2781 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2783 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2787 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2789 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2793 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2795 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2799 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2801 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2805 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2807 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2811 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2813 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2817 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2819 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2823 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2825 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2829 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2831 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2835 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2837 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2839 /* integer version */
2842 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2844 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2848 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2850 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2852 GdipDeleteGraphics(graphics
);
2853 ReleaseDC(hwnd
, hdc
);
2856 static void test_GdipIsVisibleRect(void)
2859 GpGraphics
*graphics
= NULL
;
2860 HDC hdc
= GetDC( hwnd
);
2861 REAL x
, y
, width
, height
;
2864 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2866 status
= GdipCreateFromHDC(hdc
, &graphics
);
2868 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2870 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2871 expect(InvalidParameter
, status
);
2873 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2874 expect(InvalidParameter
, status
);
2876 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2877 expect(InvalidParameter
, status
);
2879 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2880 expect(InvalidParameter
, status
);
2882 /* entirely within the visible region */
2885 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2887 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2889 /* partially outside */
2890 x
= -10; width
= 20;
2891 y
= -10; height
= 20;
2892 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2894 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2896 /* entirely outside */
2898 y
= -10; height
= 5;
2899 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2901 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2903 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2906 /* entirely within the visible region */
2908 y
= 22; height
= 10;
2909 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2911 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2913 /* partially outside */
2915 y
= 55; height
= 10;
2916 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2918 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2920 /* entirely outside */
2923 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2925 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2927 /* translate into center of clipping rect */
2928 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2932 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2934 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2938 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2940 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2942 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2944 /* corners entirely outside, but some intersections */
2947 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2949 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2953 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2955 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2959 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2961 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2965 y
= 20; height
= 40;
2966 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2968 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2972 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2974 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2977 y
= 20; height
= 40;
2978 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2980 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2983 y
= 60; height
= 10;
2984 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2986 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2988 /* rounding tests */
2989 x
= 0.4; width
= 10.4;
2990 y
= 20; height
= 40;
2991 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2993 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2996 y
= 0.4; height
= 20.4;
2997 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2999 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3001 /* integer version */
3004 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
3006 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3009 y
= 22; height
= 10;
3010 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
3012 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3014 GdipDeleteGraphics(graphics
);
3015 ReleaseDC(hwnd
, hdc
);
3018 static void test_GdipGetNearestColor(void)
3021 GpGraphics
*graphics
;
3023 ARGB color
= 0xdeadbeef;
3024 HDC hdc
= GetDC( hwnd
);
3026 /* create a graphics object */
3027 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3029 status
= GdipCreateFromHDC(hdc
, &graphics
);
3031 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3033 status
= GdipGetNearestColor(graphics
, NULL
);
3034 expect(InvalidParameter
, status
);
3036 status
= GdipGetNearestColor(NULL
, &color
);
3037 expect(InvalidParameter
, status
);
3038 GdipDeleteGraphics(graphics
);
3040 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
3042 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3043 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3046 status
= GdipGetNearestColor(graphics
, &color
);
3048 expect(0xdeadbeef, color
);
3049 GdipDeleteGraphics(graphics
);
3051 GdipDisposeImage((GpImage
*)bitmap
);
3053 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
3055 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3056 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3059 status
= GdipGetNearestColor(graphics
, &color
);
3061 expect(0xdeadbeef, color
);
3062 GdipDeleteGraphics(graphics
);
3064 GdipDisposeImage((GpImage
*)bitmap
);
3066 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
3068 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3069 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3072 status
= GdipGetNearestColor(graphics
, &color
);
3074 expect(0xdeadbeef, color
);
3075 GdipDeleteGraphics(graphics
);
3077 GdipDisposeImage((GpImage
*)bitmap
);
3079 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
3081 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3082 todo_wine
expect(OutOfMemory
, status
);
3084 GdipDeleteGraphics(graphics
);
3085 GdipDisposeImage((GpImage
*)bitmap
);
3087 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
3089 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3091 status
= GdipGetNearestColor(graphics
, &color
);
3093 expect(0xdeadbeef, color
);
3094 GdipDeleteGraphics(graphics
);
3095 GdipDisposeImage((GpImage
*)bitmap
);
3097 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
3099 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3101 status
= GdipGetNearestColor(graphics
, &color
);
3103 expect(0xdeadbeef, color
);
3104 GdipDeleteGraphics(graphics
);
3105 GdipDisposeImage((GpImage
*)bitmap
);
3107 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
3109 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3111 status
= GdipGetNearestColor(graphics
, &color
);
3113 expect(0xdeadbeef, color
);
3114 GdipDeleteGraphics(graphics
);
3115 GdipDisposeImage((GpImage
*)bitmap
);
3117 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
3121 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3123 status
= GdipGetNearestColor(graphics
, &color
);
3125 expect(0xdeadbeef, color
);
3126 GdipDeleteGraphics(graphics
);
3127 GdipDisposeImage((GpImage
*)bitmap
);
3130 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
3134 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3136 status
= GdipGetNearestColor(graphics
, &color
);
3138 expect(0xdeadbeef, color
);
3139 GdipDeleteGraphics(graphics
);
3140 GdipDisposeImage((GpImage
*)bitmap
);
3143 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
3147 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3149 status
= GdipGetNearestColor(graphics
, &color
);
3151 expect(0xdeadbeef, color
);
3152 GdipDeleteGraphics(graphics
);
3153 GdipDisposeImage((GpImage
*)bitmap
);
3156 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
3158 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3160 status
= GdipGetNearestColor(graphics
, &color
);
3162 todo_wine
expect(0xffa8bce8, color
);
3163 GdipDeleteGraphics(graphics
);
3164 GdipDisposeImage((GpImage
*)bitmap
);
3166 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
3168 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3170 status
= GdipGetNearestColor(graphics
, &color
);
3173 ok(color
== 0xffa8b8e8 ||
3174 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
3175 "Expected ffa8b8e8, got %.8x\n", color
);
3176 GdipDeleteGraphics(graphics
);
3177 GdipDisposeImage((GpImage
*)bitmap
);
3179 ReleaseDC(hwnd
, hdc
);
3182 static void test_string_functions(void)
3185 GpGraphics
*graphics
;
3186 GpFontFamily
*family
;
3188 RectF rc
, char_bounds
, bounds
;
3190 ARGB color
= 0xff000000;
3191 HDC hdc
= GetDC( hwnd
);
3192 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
3193 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
3194 const WCHAR teststring2
[] = {'j',0};
3195 REAL char_width
, char_height
;
3196 INT codepointsfitted
, linesfilled
;
3197 GpStringFormat
*format
;
3198 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
3199 GpRegion
*regions
[4];
3200 BOOL region_isempty
[4];
3202 PointF positions
[8];
3205 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3206 status
= GdipCreateFromHDC(hdc
, &graphics
);
3208 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3210 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
3213 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
3216 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
3219 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3227 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
3228 expect(InvalidParameter
, status
);
3230 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
3231 expect(InvalidParameter
, status
);
3233 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3234 expect(InvalidParameter
, status
);
3236 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3237 expect(InvalidParameter
, status
);
3239 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3240 expect(InvalidParameter
, status
);
3242 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3245 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3246 expect(InvalidParameter
, status
);
3248 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3249 expect(InvalidParameter
, status
);
3251 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3252 expect(InvalidParameter
, status
);
3254 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3255 expect(InvalidParameter
, status
);
3257 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3258 expect(InvalidParameter
, status
);
3260 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3263 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3266 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3268 expectf(0.0, char_bounds
.X
);
3269 expectf(0.0, char_bounds
.Y
);
3270 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3271 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3272 expect(1, codepointsfitted
);
3273 expect(1, linesfilled
);
3275 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3277 expectf(0.0, bounds
.X
);
3278 expectf(0.0, bounds
.Y
);
3279 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3280 expectf(char_bounds
.Height
, bounds
.Height
);
3281 expect(2, codepointsfitted
);
3282 expect(1, linesfilled
);
3283 char_width
= bounds
.Width
- char_bounds
.Width
;
3285 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3287 expectf(0.0, bounds
.X
);
3288 expectf(0.0, bounds
.Y
);
3289 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3290 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3291 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3292 expect(6, codepointsfitted
);
3293 expect(2, linesfilled
);
3294 char_height
= bounds
.Height
- char_bounds
.Height
;
3296 /* Measure the first line. */
3297 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3299 expectf(0.0, bounds
.X
);
3300 expectf(0.0, bounds
.Y
);
3301 expect(4, codepointsfitted
);
3302 expect(1, linesfilled
);
3304 /* Give just enough space to fit the first line. */
3305 rc
.Width
= bounds
.Width
;
3306 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3308 expectf(0.0, bounds
.X
);
3309 expectf(0.0, bounds
.Y
);
3310 todo_wine
expect(5, codepointsfitted
);
3311 todo_wine
expect(1, linesfilled
);
3313 /* Cut off everything after the first space. */
3314 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3316 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3318 expectf(0.0, bounds
.X
);
3319 expectf(0.0, bounds
.Y
);
3320 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3321 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3322 expect(6, codepointsfitted
);
3323 expect(3, linesfilled
);
3325 /* Cut off everything including the first space. */
3326 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3328 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3330 expectf(0.0, bounds
.X
);
3331 expectf(0.0, bounds
.Y
);
3332 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3333 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3334 expect(6, codepointsfitted
);
3335 expect(3, linesfilled
);
3337 /* Cut off everything after the first character. */
3338 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3340 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3342 expectf(0.0, bounds
.X
);
3343 expectf(0.0, bounds
.Y
);
3344 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3345 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3346 expect(6, codepointsfitted
);
3347 todo_wine
expect(4, linesfilled
);
3349 for (i
= 0; i
< 4; i
++)
3350 regions
[i
] = (GpRegion
*)0xdeadbeef;
3352 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3355 for (i
= 0; i
< 4; i
++)
3356 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3358 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3361 for (i
= 0; i
< 4; i
++)
3362 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3364 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3367 set_rect_empty(&rc
);
3371 status
= GdipCreateRegion(®ions
[i
]);
3373 status
= GdipSetEmpty(regions
[i
]);
3377 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3378 expect(InvalidParameter
, status
);
3380 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3381 expect(InvalidParameter
, status
);
3383 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3384 expect(InvalidParameter
, status
);
3386 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3387 expect(InvalidParameter
, status
);
3391 /* Crashes on Windows XP */
3392 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3393 expect(InvalidParameter
, status
);
3396 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3397 expect(InvalidParameter
, status
);
3399 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3400 expect(InvalidParameter
, status
);
3402 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3405 for (i
= 0; i
< 4; i
++)
3407 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3411 ok(region_isempty
[0], "region should be empty\n");
3412 ok(region_isempty
[1], "region should be empty\n");
3413 ok(region_isempty
[2], "region should be empty\n");
3414 ok(region_isempty
[3], "region should be empty\n");
3419 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3424 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3428 ok(!region_isempty
[0], "region shouldn't be empty\n");
3429 ok(!region_isempty
[1], "region shouldn't be empty\n");
3430 ok(!region_isempty
[2], "region shouldn't be empty\n");
3431 ok(region_isempty
[3], "region should be empty\n");
3433 /* Cut off everything after the first space, and the second line. */
3434 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3435 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3437 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3442 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3446 ok(!region_isempty
[0], "region shouldn't be empty\n");
3447 ok(!region_isempty
[1], "region shouldn't be empty\n");
3448 ok(region_isempty
[2], "region should be empty\n");
3449 ok(region_isempty
[3], "region should be empty\n");
3452 GdipDeleteRegion(regions
[i
]);
3454 status
= GdipCreateMatrix(&identity
);
3461 memset(positions
, 0, sizeof(positions
));
3462 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3463 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3465 expect(InvalidParameter
, status
);
3467 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3468 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3470 expect(InvalidParameter
, status
);
3472 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3473 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3475 expect(InvalidParameter
, status
);
3477 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3478 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3480 expect(InvalidParameter
, status
);
3482 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3483 0x100, identity
, &rc
);
3486 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3487 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3491 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3492 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3494 expect(InvalidParameter
, status
);
3500 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3501 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3506 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3507 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3508 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3510 char_width
= rc
.Width
;
3511 char_height
= rc
.Height
;
3517 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3518 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3523 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3524 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3525 expectf(char_height
, rc
.Height
);
3531 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3532 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3537 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3538 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3539 expectf(rc
.Height
, char_height
);
3541 GdipDeleteMatrix(identity
);
3542 GdipDeleteStringFormat(format
);
3543 GdipDeleteBrush(brush
);
3544 GdipDeleteFont(font
);
3545 GdipDeleteFontFamily(family
);
3546 GdipDeleteGraphics(graphics
);
3548 ReleaseDC(hwnd
, hdc
);
3551 static void test_get_set_interpolation(void)
3553 GpGraphics
*graphics
;
3554 HDC hdc
= GetDC( hwnd
);
3556 InterpolationMode mode
;
3558 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3559 status
= GdipCreateFromHDC(hdc
, &graphics
);
3561 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3563 status
= GdipGetInterpolationMode(NULL
, &mode
);
3564 expect(InvalidParameter
, status
);
3568 /* Crashes on Windows XP */
3569 status
= GdipGetInterpolationMode(graphics
, NULL
);
3570 expect(InvalidParameter
, status
);
3573 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3574 expect(InvalidParameter
, status
);
3577 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3578 expect(InvalidParameter
, status
);
3580 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3581 expect(InvalidParameter
, status
);
3583 status
= GdipGetInterpolationMode(graphics
, &mode
);
3585 expect(InterpolationModeBilinear
, mode
);
3587 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3590 status
= GdipGetInterpolationMode(graphics
, &mode
);
3592 expect(InterpolationModeNearestNeighbor
, mode
);
3594 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3597 status
= GdipGetInterpolationMode(graphics
, &mode
);
3599 expect(InterpolationModeBilinear
, mode
);
3601 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3604 status
= GdipGetInterpolationMode(graphics
, &mode
);
3606 expect(InterpolationModeBilinear
, mode
);
3608 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3611 status
= GdipGetInterpolationMode(graphics
, &mode
);
3613 expect(InterpolationModeHighQualityBicubic
, mode
);
3615 GdipDeleteGraphics(graphics
);
3617 ReleaseDC(hwnd
, hdc
);
3620 static void test_get_set_textrenderinghint(void)
3622 GpGraphics
*graphics
;
3623 HDC hdc
= GetDC( hwnd
);
3625 TextRenderingHint hint
;
3627 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3628 status
= GdipCreateFromHDC(hdc
, &graphics
);
3630 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3632 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3633 expect(InvalidParameter
, status
);
3635 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3636 expect(InvalidParameter
, status
);
3638 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3639 expect(InvalidParameter
, status
);
3642 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3643 expect(InvalidParameter
, status
);
3645 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3647 expect(TextRenderingHintSystemDefault
, hint
);
3649 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3652 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3654 expect(TextRenderingHintSystemDefault
, hint
);
3656 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3659 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3661 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3663 GdipDeleteGraphics(graphics
);
3665 ReleaseDC(hwnd
, hdc
);
3668 static void test_getdc_scaled(void)
3671 GpGraphics
*graphics
= NULL
;
3672 GpBitmap
*bitmap
= NULL
;
3674 HBRUSH hbrush
, holdbrush
;
3677 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3680 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3683 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3686 status
= GdipGetDC(graphics
, &hdc
);
3688 ok(hdc
!= NULL
, "got NULL hdc\n");
3690 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3692 holdbrush
= SelectObject(hdc
, hbrush
);
3694 Rectangle(hdc
, 2, 2, 6, 6);
3696 SelectObject(hdc
, holdbrush
);
3698 DeleteObject(hbrush
);
3700 status
= GdipReleaseDC(graphics
, hdc
);
3703 GdipDeleteGraphics(graphics
);
3705 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3707 expect(0xffff0000, color
);
3709 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3711 expect(0xff000000, color
);
3713 GdipDisposeImage((GpImage
*)bitmap
);
3716 static void test_GdipMeasureString(void)
3718 static const struct test_data
3720 REAL res_x
, res_y
, page_scale
;
3724 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3725 { 200.0, 200.0, 2.0, UnitPixel
},
3726 { 200.0, 200.0, 1.0, UnitDisplay
},
3727 { 200.0, 200.0, 2.0, UnitDisplay
},
3728 { 200.0, 200.0, 1.0, UnitInch
},
3729 { 200.0, 200.0, 2.0, UnitInch
},
3730 { 200.0, 600.0, 1.0, UnitPoint
},
3731 { 200.0, 600.0, 2.0, UnitPoint
},
3732 { 200.0, 600.0, 1.0, UnitDocument
},
3733 { 200.0, 600.0, 2.0, UnitDocument
},
3734 { 200.0, 600.0, 1.0, UnitMillimeter
},
3735 { 200.0, 600.0, 2.0, UnitMillimeter
},
3736 { 200.0, 600.0, 1.0, UnitDisplay
},
3737 { 200.0, 600.0, 2.0, UnitDisplay
},
3738 { 200.0, 600.0, 1.0, UnitPixel
},
3739 { 200.0, 600.0, 2.0, UnitPixel
},
3741 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3742 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3744 GpGraphics
*graphics
;
3745 GpFontFamily
*family
;
3747 GpStringFormat
*format
;
3749 REAL base_cx
= 0, base_cy
= 0, height
;
3754 GpUnit font_unit
, unit
;
3756 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3758 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3761 /* font size in pixels */
3762 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3764 status
= GdipGetFontSize(font
, &font_size
);
3766 expectf(100.0, font_size
);
3767 status
= GdipGetFontUnit(font
, &font_unit
);
3769 expect(UnitPixel
, font_unit
);
3771 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3775 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3777 lf
.lfHeight
= 0xdeadbeef;
3778 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3780 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3781 if (td
[i
].unit
!= UnitDisplay
)
3782 height
*= td
[i
].page_scale
;
3783 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3784 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3786 height
= font_size
+ 2.0 * font_size
/ 6.0;
3788 set_rect_empty(&rc
);
3789 set_rect_empty(&bounds
);
3790 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3795 base_cx
= bounds
.Width
;
3796 base_cy
= bounds
.Height
;
3799 expectf(0.0, bounds
.X
);
3800 expectf(0.0, bounds
.Y
);
3802 expectf_(height
, bounds
.Height
, height
/ 100.0);
3803 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3807 /* make sure it really fits */
3808 bounds
.Width
+= 1.0;
3809 bounds
.Height
+= 1.0;
3813 set_rect_empty(&bounds
);
3814 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3816 expectf(50.0, bounds
.X
);
3817 expectf(50.0, bounds
.Y
);
3819 expectf_(height
, bounds
.Height
, height
/ 100.0);
3820 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3824 status
= GdipDeleteGraphics(graphics
);
3827 status
= GdipDisposeImage(image
);
3831 GdipDeleteFont(font
);
3833 /* font size in logical units */
3834 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3835 for (unit
= 3; unit
<= 6; unit
++)
3837 /* create a font which final height is 100.0 pixels with 200 dpi device */
3838 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3839 height
= pixels_to_units(75.0, unit
, 200.0);
3840 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3842 status
= GdipGetFontSize(font
, &font_size
);
3844 expectf(height
, font_size
);
3845 status
= GdipGetFontUnit(font
, &font_unit
);
3847 expect(unit
, font_unit
);
3849 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3854 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3856 lf
.lfHeight
= 0xdeadbeef;
3857 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3859 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3860 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3862 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3863 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3864 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3865 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3867 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3868 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3870 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3871 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3872 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3873 if (td
[i
].unit
!= UnitDisplay
)
3874 height
/= td
[i
].page_scale
;
3875 /*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);*/
3877 set_rect_empty(&rc
);
3878 set_rect_empty(&bounds
);
3879 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3884 base_cx
= bounds
.Width
;
3885 base_cy
= bounds
.Height
;
3888 expectf(0.0, bounds
.X
);
3889 expectf(0.0, bounds
.Y
);
3891 expectf_(height
, bounds
.Height
, height
/ 85.0);
3892 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3896 /* make sure it really fits */
3897 bounds
.Width
+= 1.0;
3898 bounds
.Height
+= 1.0;
3902 set_rect_empty(&bounds
);
3903 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3905 expectf(50.0, bounds
.X
);
3906 expectf(50.0, bounds
.Y
);
3908 expectf_(height
, bounds
.Height
, height
/ 85.0);
3909 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3913 /* verify the result */
3914 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3915 if (td
[i
].unit
!= UnitDisplay
)
3916 height
*= td
[i
].page_scale
;
3917 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3918 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3920 expectf_(100.0, height
, 1.1);
3922 status
= GdipDeleteGraphics(graphics
);
3925 status
= GdipDisposeImage(image
);
3929 GdipDeleteFont(font
);
3932 /* Font with units = UnitWorld */
3933 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3935 GpPointF pt
= {0.0, 100.0};
3937 REAL expected_width
, expected_height
;
3939 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3941 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3944 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3947 status
= GdipGetFontUnit(font
, &font_unit
);
3949 expect(UnitWorld
, font_unit
);
3951 lf
.lfHeight
= 0xdeadbeef;
3952 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3954 ok(lf
.lfHeight
== -100, "%u: expected -100, got %d\n", i
, lf
.lfHeight
);
3956 set_rect_empty(&rc
);
3957 set_rect_empty(&bounds
);
3958 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3963 base_cx
= bounds
.Width
;
3964 base_cy
= bounds
.Height
;
3970 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3973 /* height is constant in device space, width is proportional to height in world space */
3974 expected_width
= base_cx
* pt
.Y
;
3975 expected_height
= base_cy
* pt
.Y
;
3977 todo_wine_if(td
[i
].unit
!= UnitDisplay
&& td
[i
].unit
!= UnitPixel
)
3978 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3979 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3981 GdipDeleteGraphics(graphics
);
3982 GdipDisposeImage(image
);
3983 GdipDeleteFont(font
);
3986 GdipDeleteFontFamily(family
);
3987 GdipDeleteStringFormat(format
);
3990 static void test_transform(void)
3992 static const struct test_data
3994 REAL res_x
, res_y
, scale
;
3996 GpPointF in
[2], out
[2];
3999 { 96.0, 96.0, 1.0, UnitPixel
,
4000 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4001 { 96.0, 96.0, 1.0, UnitDisplay
,
4002 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4003 { 96.0, 96.0, 1.0, UnitInch
,
4004 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
4005 { 123.0, 456.0, 1.0, UnitPoint
,
4006 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
4007 { 123.0, 456.0, 1.0, UnitDocument
,
4008 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
4009 { 123.0, 456.0, 2.0, UnitMillimeter
,
4010 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
4011 { 196.0, 296.0, 1.0, UnitDisplay
,
4012 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4013 { 196.0, 296.0, 1.0, UnitPixel
,
4014 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4017 GpGraphics
*graphics
;
4022 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
4024 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
4025 ptf
[0].X
= td
[i
].in
[0].X
;
4026 ptf
[0].Y
= td
[i
].in
[0].Y
;
4027 ptf
[1].X
= td
[i
].in
[1].X
;
4028 ptf
[1].Y
= td
[i
].in
[1].Y
;
4029 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
4031 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
4032 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
4033 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
4034 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
4035 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4037 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
4038 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
4039 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
4040 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
4041 status
= GdipDeleteGraphics(graphics
);
4043 status
= GdipDisposeImage(image
);
4048 static void test_pen_thickness(void)
4050 static const struct test_data
4052 REAL res_x
, res_y
, scale
;
4053 GpUnit pen_unit
, page_unit
;
4055 INT cx
, cy
, path_cx
, path_cy
;
4058 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1, 1, 1 },
4059 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.0, 0, 0, 1, 1 },
4060 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.1, 1, 1, 1, 1 },
4061 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2, 2, 2 },
4062 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1, 1, 1 },
4063 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1, 1, 1 },
4064 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 0.0, 1, 1, 1, 1 },
4065 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6, 6, 6 },
4066 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20, 20, 20 },
4070 GpGraphics
*graphics
;
4082 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
4084 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
4087 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
4090 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
4093 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
4096 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
4099 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
4102 corner
.X
= corner
.Y
= 100.0;
4103 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
4106 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4109 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4112 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4118 for (j
=0; j
<100; j
++)
4120 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4127 for (j
=99; j
>=0; j
--)
4129 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4138 ok(size
== td
[i
].cx
, "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
4143 for (j
=0; j
<100; j
++)
4145 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4152 for (j
=99; j
>=0; j
--)
4154 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4163 ok(size
== td
[i
].cy
, "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
4165 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4168 status
= GdipGraphicsClear(graphics
, 0xff000000);
4171 status
= GdipCreatePath(FillModeAlternate
, &path
);
4174 status
= GdipAddPathLine(path
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4177 status
= GdipClosePathFigure(path
);
4180 status
= GdipAddPathLine(path
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4183 status
= GdipDrawPath(graphics
, pen
, path
);
4186 GdipDeletePath(path
);
4188 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4194 for (j
=0; j
<100; j
++)
4196 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4203 for (j
=99; j
>=0; j
--)
4205 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4214 ok(size
== td
[i
].path_cx
, "%u: expected %d, got %d\n", i
, td
[i
].path_cx
, size
);
4219 for (j
=0; j
<100; j
++)
4221 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4228 for (j
=99; j
>=0; j
--)
4230 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4239 ok(size
== td
[i
].path_cy
, "%u: expected %d, got %d\n", i
, td
[i
].path_cy
, size
);
4241 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4245 GdipDeleteGraphics(graphics
);
4246 GdipDisposeImage(u
.image
);
4250 /* Many people on the net ask why there is so much difference in rendered
4251 * text height between gdiplus and gdi32, this test suggests an answer to
4252 * that question. Important: this test assumes that font dpi == device dpi.
4254 static void test_font_height_scaling(void)
4256 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4257 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
4259 GpStringFormat
*format
;
4260 CharacterRange range
= { 0, 7 };
4262 GpGraphics
*graphics
;
4263 GpFontFamily
*family
;
4267 REAL height
, dpi
, scale
;
4269 GpUnit gfx_unit
, font_unit
;
4271 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4273 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4275 status
= GdipCreateRegion(®ion
);
4278 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4281 hdc
= CreateCompatibleDC(0);
4282 status
= GdipCreateFromHDC(hdc
, &graphics
);
4285 status
= GdipGetDpiY(graphics
, &dpi
);
4288 /* First check if tested functionality works:
4289 * under XP if font and graphics units differ then GdipTransformPoints
4290 * followed by GdipSetPageUnit to change the graphics units breaks region
4291 * scaling in GdipMeasureCharacterRanges called later.
4293 status
= GdipSetPageUnit(graphics
, UnitDocument
);
4298 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4301 status
= GdipSetPageUnit(graphics
, UnitInch
);
4304 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
4307 set_rect_empty(&rect
);
4308 set_rect_empty(&bounds
);
4309 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4311 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4313 set_rect_empty(&rect
);
4314 rect
.Width
= 32000.0;
4315 rect
.Height
= 32000.0;
4316 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4319 set_rect_empty(&rect
);
4320 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4322 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4324 GdipDeleteFont(font
);
4326 scale
= rect
.Height
/ bounds
.Height
;
4327 if (fabs(scale
- 1.0) > 0.1)
4329 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4333 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4336 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4337 /* UnitPixel as a font base unit is not tested because it drastically
4338 differs in behaviour */
4339 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4341 /* create a font for the final text height of 100 pixels */
4342 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4343 status
= GdipSetPageUnit(graphics
, font_unit
);
4347 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4350 /*trace("height %f units\n", height);*/
4351 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4354 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4355 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4357 static const WCHAR doubleW
[2] = { 'W','W' };
4358 RectF bounds_1
, bounds_2
;
4359 REAL margin
, margin_y
, font_height
;
4362 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4365 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4366 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4368 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4371 set_rect_empty(&rect
);
4372 set_rect_empty(&bounds
);
4373 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4375 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4377 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4380 ptf
.Y
= bounds
.Height
;
4381 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4383 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4385 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4387 /* verify the result */
4388 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4390 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4392 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4394 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4395 set_rect_empty(&rect
);
4396 set_rect_empty(&bounds_1
);
4397 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4399 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4400 set_rect_empty(&rect
);
4401 set_rect_empty(&bounds_2
);
4402 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4405 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4406 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4407 /*trace("margin %f\n", margin);*/
4408 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4410 set_rect_empty(&rect
);
4411 rect
.Width
= 320000.0;
4412 rect
.Height
= 320000.0;
4413 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4415 set_rect_empty(&rect
);
4416 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4418 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4419 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4420 expectf(0.0, rect
.Y
);
4421 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4422 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4423 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4424 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4425 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4426 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4429 GdipDeleteFont(font
);
4433 status
= GdipDeleteGraphics(graphics
);
4437 GdipDeleteFontFamily(family
);
4438 GdipDeleteRegion(region
);
4439 GdipDeleteStringFormat(format
);
4442 static void test_measure_string(void)
4444 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4445 static const WCHAR string
[] = { 'A','0','1',0 };
4447 GpStringFormat
*format
;
4448 CharacterRange range
;
4450 GpGraphics
*graphics
;
4451 GpFontFamily
*family
;
4455 REAL width
, height
, width_1
, width_2
;
4456 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4459 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4463 status
= GdipCreateRegion(®ion
);
4466 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4469 hdc
= CreateCompatibleDC(0);
4470 status
= GdipCreateFromHDC(hdc
, &graphics
);
4472 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4475 margin_x
= 20.0 / 6.0;
4476 margin_y
= 20.0 / 8.0;
4478 set_rect_empty(&rect
);
4479 set_rect_empty(&bounds
);
4480 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4484 expectf(0.0, bounds
.X
);
4485 expectf(0.0, bounds
.Y
);
4486 width
= bounds
.Width
;
4487 height
= bounds
.Height
;
4489 set_rect_empty(&rect
);
4490 rect
.Height
= height
/ 2.0;
4491 set_rect_empty(&bounds
);
4492 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4496 expectf(0.0, bounds
.X
);
4497 expectf(0.0, bounds
.Y
);
4498 expectf(width
, bounds
.Width
);
4500 expectf(height
/ 2.0, bounds
.Height
);
4503 range
.Length
= lstrlenW(string
);
4504 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4509 rect
.Width
= 32000.0;
4510 rect
.Height
= 32000.0;
4511 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4513 set_rect_empty(&bounds
);
4514 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4516 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4517 expectf(5.0, bounds
.Y
);
4518 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4520 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4522 width_rgn
= bounds
.Width
;
4523 height_rgn
= bounds
.Height
;
4527 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4530 set_rect_empty(&rect
);
4531 rect
.Width
= 32000.0;
4532 rect
.Height
= 32000.0;
4533 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4535 set_rect_empty(&bounds
);
4536 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4538 expectf_(margin_x
, bounds
.X
, 1.0);
4539 expectf(0.0, bounds
.Y
);
4540 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4541 expectf(height_rgn
, bounds
.Height
);
4542 width_1
= bounds
.Width
;
4545 range
.Length
= lstrlenW(string
);
4546 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4553 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4555 set_rect_empty(&bounds
);
4556 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4558 expectf(0.0, bounds
.X
);
4559 expectf(0.0, bounds
.Y
);
4560 expectf(0.0, bounds
.Width
);
4561 expectf(0.0, bounds
.Height
);
4565 rect
.Width
= width_rgn
/ 2.0;
4566 rect
.Height
= 32000.0;
4567 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4569 set_rect_empty(&bounds
);
4570 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4572 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4573 expectf(5.0, bounds
.Y
);
4574 expectf_(width_1
, bounds
.Width
, 1.0);
4576 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4578 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4584 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4586 set_rect_empty(&bounds
);
4587 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4589 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4590 expectf(5.0, bounds
.Y
);
4591 expectf(width_rgn
, bounds
.Width
);
4592 expectf(height_rgn
, bounds
.Height
);
4596 rect
.Width
= width_rgn
/ 2.0;
4597 rect
.Height
= 32000.0;
4598 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4600 set_rect_empty(&bounds
);
4601 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4603 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4604 expectf(5.0, bounds
.Y
);
4605 expectf_(width_1
, bounds
.Width
, 1.0);
4606 expectf(height_rgn
, bounds
.Height
);
4608 set_rect_empty(&rect
);
4609 rect
.Height
= height
/ 2.0;
4610 set_rect_empty(&bounds
);
4611 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4615 expectf(0.0, bounds
.X
);
4616 expectf(0.0, bounds
.Y
);
4617 expectf_(width
, bounds
.Width
, 0.01);
4619 expectf(height
, bounds
.Height
);
4621 set_rect_empty(&rect
);
4622 set_rect_empty(&bounds
);
4623 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4627 expectf(0.0, bounds
.X
);
4628 expectf(0.0, bounds
.Y
);
4629 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4630 expectf(height
, bounds
.Height
);
4631 width_1
= bounds
.Width
;
4633 set_rect_empty(&rect
);
4634 set_rect_empty(&bounds
);
4635 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4639 expectf(0.0, bounds
.X
);
4640 expectf(0.0, bounds
.Y
);
4641 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4642 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4643 expectf(height
, bounds
.Height
);
4644 width_2
= bounds
.Width
;
4646 set_rect_empty(&rect
);
4647 rect
.Width
= width
/ 2.0;
4648 set_rect_empty(&bounds
);
4649 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4653 expectf(0.0, bounds
.X
);
4654 expectf(0.0, bounds
.Y
);
4655 expectf_(width_1
, bounds
.Width
, 0.01);
4656 expectf(height
, bounds
.Height
);
4658 set_rect_empty(&rect
);
4659 rect
.Height
= height
;
4660 rect
.Width
= width
- 0.05;
4661 set_rect_empty(&bounds
);
4662 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4666 expectf(0.0, bounds
.X
);
4667 expectf(0.0, bounds
.Y
);
4668 expectf_(width_2
, bounds
.Width
, 0.01);
4669 expectf(height
, bounds
.Height
);
4671 set_rect_empty(&rect
);
4672 rect
.Height
= height
;
4673 rect
.Width
= width_2
- 0.05;
4674 set_rect_empty(&bounds
);
4675 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4679 expectf(0.0, bounds
.X
);
4680 expectf(0.0, bounds
.Y
);
4681 expectf_(width_1
, bounds
.Width
, 0.01);
4682 expectf(height
, bounds
.Height
);
4684 /* Default (Near) alignment */
4687 rect
.Width
= width
* 2.0;
4688 rect
.Height
= height
* 2.0;
4689 set_rect_empty(&bounds
);
4690 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4694 expectf(5.0, bounds
.X
);
4695 expectf(5.0, bounds
.Y
);
4696 expectf_(width
, bounds
.Width
, 0.01);
4697 expectf(height
, bounds
.Height
);
4701 rect
.Width
= 32000.0;
4702 rect
.Height
= 32000.0;
4703 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4705 set_rect_empty(&bounds
);
4706 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4708 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4709 expectf(5.0, bounds
.Y
);
4710 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4712 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4714 width_rgn
= bounds
.Width
;
4715 height_rgn
= bounds
.Height
;
4717 /* Center alignment */
4718 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4719 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4723 rect
.Width
= width
* 2.0;
4724 rect
.Height
= height
* 2.0;
4725 set_rect_empty(&bounds
);
4726 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4731 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4733 expectf(5.0 + height
/2.0, bounds
.Y
);
4734 expectf_(width
, bounds
.Width
, 0.01);
4735 expectf(height
, bounds
.Height
);
4741 set_rect_empty(&bounds
);
4742 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4747 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4749 expectf(5.0 - height
/2.0, bounds
.Y
);
4750 expectf_(width
, bounds
.Width
, 0.01);
4751 expectf(height
, bounds
.Height
);
4755 rect
.Width
= width_rgn
* 2.0;
4756 rect
.Height
= height_rgn
* 2.0;
4757 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4759 set_rect_empty(&bounds
);
4760 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4763 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4765 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4766 expectf_(width_rgn
, bounds
.Width
, 1.0);
4767 expectf_(height_rgn
, bounds
.Height
, 1.0);
4773 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4775 set_rect_empty(&bounds
);
4776 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4779 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4781 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4782 expectf_(width_rgn
, bounds
.Width
, 1.0);
4783 expectf_(height_rgn
, bounds
.Height
, 1.0);
4786 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4787 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4791 rect
.Width
= width
* 2.0;
4792 rect
.Height
= height
* 2.0;
4793 set_rect_empty(&bounds
);
4794 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4799 expectf_(5.0 + width
, bounds
.X
, 0.01);
4801 expectf(5.0 + height
, bounds
.Y
);
4802 expectf_(width
, bounds
.Width
, 0.01);
4803 expectf(height
, bounds
.Height
);
4809 set_rect_empty(&bounds
);
4810 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4815 expectf_(5.0 - width
, bounds
.X
, 0.01);
4817 expectf(5.0 - height
, bounds
.Y
);
4818 expectf_(width
, bounds
.Width
, 0.01);
4819 expectf(height
, bounds
.Height
);
4823 rect
.Width
= width_rgn
* 2.0;
4824 rect
.Height
= height_rgn
* 2.0;
4825 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4827 set_rect_empty(&bounds
);
4828 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4831 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4833 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4834 expectf_(width_rgn
, bounds
.Width
, 1.0);
4835 expectf_(height_rgn
, bounds
.Height
, 1.0);
4841 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4843 set_rect_empty(&bounds
);
4844 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4847 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4849 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4850 expectf_(width_rgn
, bounds
.Width
, 1.0);
4851 expectf_(height_rgn
, bounds
.Height
, 1.0);
4853 status
= GdipDeleteFont(font
);
4856 status
= GdipDeleteGraphics(graphics
);
4860 GdipDeleteFontFamily(family
);
4861 GdipDeleteRegion(region
);
4862 GdipDeleteStringFormat(format
);
4865 static void test_measured_extra_space(void)
4867 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4868 static const WCHAR string
[2] = { 'W','W' };
4869 GpStringFormat
*format
;
4871 GpGraphics
*graphics
;
4872 GpFontFamily
*family
;
4875 GpUnit gfx_unit
, font_unit
;
4876 RectF bounds_1
, bounds_2
, rect
;
4877 REAL margin
, font_size
, dpi
;
4879 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4882 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4884 hdc
= CreateCompatibleDC(0);
4885 status
= GdipCreateFromHDC(hdc
, &graphics
);
4888 status
= GdipGetDpiX(graphics
, &dpi
);
4891 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4892 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4893 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4895 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4898 status
= GdipGetFontSize(font
, &font_size
);
4900 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4901 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4903 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4904 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4906 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4909 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4910 set_rect_empty(&rect
);
4911 set_rect_empty(&bounds_1
);
4912 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4914 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4915 set_rect_empty(&rect
);
4916 set_rect_empty(&bounds_2
);
4917 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4920 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4921 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4922 /*trace("margin %f pixels\n", margin);*/
4923 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4926 GdipDeleteFont(font
);
4929 GdipDeleteGraphics(graphics
);
4931 GdipDeleteFontFamily(family
);
4932 GdipDeleteStringFormat(format
);
4935 static void test_alpha_hdc(void)
4939 HBITMAP hbm
, old_hbm
;
4940 GpGraphics
*graphics
;
4946 hdc
= CreateCompatibleDC(0);
4947 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4948 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4949 bmi
.bmiHeader
.biHeight
= 5;
4950 bmi
.bmiHeader
.biWidth
= 5;
4951 bmi
.bmiHeader
.biBitCount
= 32;
4952 bmi
.bmiHeader
.biPlanes
= 1;
4953 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4954 bmi
.bmiHeader
.biClrUsed
= 0;
4956 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4957 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4959 old_hbm
= SelectObject(hdc
, hbm
);
4961 status
= GdipCreateFromHDC(hdc
, &graphics
);
4964 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4966 expectf(0.0, bounds
.X
);
4967 expectf(0.0, bounds
.Y
);
4968 expectf(5.0, bounds
.Width
);
4969 expectf(5.0, bounds
.Height
);
4971 bits
[0] = 0xdeadbeef;
4973 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4976 expect(0xffaaaaaa, bits
[0]);
4978 bits
[0] = 0xdeadbeef;
4980 status
= GdipGetDC(graphics
, &gp_hdc
);
4983 colorref
= GetPixel(gp_hdc
, 0, 4);
4984 expect(0xefbead, colorref
);
4986 SetPixel(gp_hdc
, 0, 4, 0xffffff);
4988 expect(0xffffff, bits
[0]);
4990 status
= GdipReleaseDC(graphics
, gp_hdc
);
4993 SelectObject(hdc
, old_hbm
);
4995 bits
[0] = 0xdeadbeef;
4997 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
5000 todo_wine
expect(0xffbbbbbb, bits
[0]);
5002 GdipDeleteGraphics(graphics
);
5008 static void test_bitmapfromgraphics(void)
5011 GpGraphics
*graphics
= NULL
;
5012 HDC hdc
= GetDC( hwnd
);
5013 GpBitmap
*bitmap
= NULL
;
5015 REAL imageres
, graphicsres
;
5018 stat
= GdipCreateFromHDC(hdc
, &graphics
);
5021 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
5022 expect(InvalidParameter
, stat
);
5024 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
5025 expect(InvalidParameter
, stat
);
5027 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
5030 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
5032 expect(PixelFormat32bppPARGB
, format
);
5034 stat
= GdipGetDpiX(graphics
, &graphicsres
);
5037 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
5039 expectf(graphicsres
, imageres
);
5041 stat
= GdipGetDpiY(graphics
, &graphicsres
);
5044 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
5046 expectf(graphicsres
, imageres
);
5048 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
5052 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
5056 GdipDeleteGraphics(graphics
);
5057 GdipDisposeImage((GpImage
*)bitmap
);
5060 static void test_clipping(void)
5064 GpGraphics
*graphics
;
5065 GpRegion
*region
, *region100x100
;
5074 hdc
= CreateCompatibleDC(0);
5075 status
= GdipCreateFromHDC(hdc
, &graphics
);
5078 status
= GdipGetPageUnit(graphics
, &unit
);
5080 expect(UnitDisplay
, unit
);
5082 status
= GdipCreateRegion(®ion
);
5084 status
= GdipSetEmpty(region
);
5087 status
= GdipCreateRegion(®ion100x100
);
5089 status
= GdipSetEmpty(region100x100
);
5092 rect
.X
= rect
.Y
= 100.0;
5093 rect
.Width
= rect
.Height
= 100.0;
5094 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
5096 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
5099 status
= GdipGetClipBounds(graphics
, &rect
);
5101 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5102 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5104 /* Clip region does not account for changes to gdi32 transform */
5105 SetViewportOrgEx(hdc
, 10, 10, NULL
);
5107 status
= GdipGetClipBounds(graphics
, &rect
);
5109 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5110 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5112 SetViewportOrgEx(hdc
, 0, 0, NULL
);
5114 status
= GdipSetEmpty(region
);
5116 status
= GdipGetClip(graphics
, region
);
5118 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5120 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5121 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5127 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5129 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5130 "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
);
5132 status
= GdipCreateMatrix(&matrix
);
5134 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
5136 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
5138 status
= GdipSetWorldTransform(graphics
, matrix
);
5141 status
= GdipGetClipBounds(graphics
, &rect
);
5143 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5144 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5146 status
= GdipSetEmpty(region
);
5148 status
= GdipGetClip(graphics
, region
);
5150 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5152 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5153 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5155 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5157 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5158 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5160 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5162 ret
= GetRgnBox(hrgn
, &rc
);
5163 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5164 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5165 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5168 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5170 ret
= GetRgnBox(hrgn
, &rc
);
5171 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5172 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5173 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5180 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5182 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5183 "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
);
5185 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5187 ret
= GetRgnBox(hrgn
, &rc
);
5188 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5189 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5190 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5193 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5195 ret
= GetRgnBox(hrgn
, &rc
);
5196 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5197 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5198 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5205 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5207 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5208 "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
);
5210 status
= GdipSetPageScale(graphics
, 2.0);
5213 status
= GdipGetClipBounds(graphics
, &rect
);
5215 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5216 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5218 status
= GdipSetEmpty(region
);
5220 status
= GdipGetClip(graphics
, region
);
5222 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5224 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5225 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5227 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5229 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5230 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5232 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5234 ret
= GetRgnBox(hrgn
, &rc
);
5235 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5236 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5237 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5240 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5242 ret
= GetRgnBox(hrgn
, &rc
);
5243 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5244 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5245 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5252 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5254 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5255 "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
);
5257 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5259 ret
= GetRgnBox(hrgn
, &rc
);
5260 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5261 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5262 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5265 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5267 ret
= GetRgnBox(hrgn
, &rc
);
5268 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5269 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5270 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5277 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5279 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5280 "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
);
5282 GdipSetPageUnit(graphics
, UnitPoint
);
5285 status
= GdipGetClipBounds(graphics
, &rect
);
5287 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5288 /* rounding under Wine is slightly different */
5289 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5290 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5291 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5293 status
= GdipSetEmpty(region
);
5295 status
= GdipGetClip(graphics
, region
);
5297 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5299 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5300 /* rounding under Wine is slightly different */
5301 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5302 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5303 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5305 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5307 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5308 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5310 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5312 ret
= GetRgnBox(hrgn
, &rc
);
5313 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5314 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
5315 /* rounding under Wine is slightly different */
5316 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
5317 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
5318 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc
));
5321 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5323 ret
= GetRgnBox(hrgn
, &rc
);
5324 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5325 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5326 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5327 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5334 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5336 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5337 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5338 "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
);
5340 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5342 ret
= GetRgnBox(hrgn
, &rc
);
5343 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5344 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5345 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5348 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5350 ret
= GetRgnBox(hrgn
, &rc
);
5351 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5352 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5353 /* rounding under Wine is slightly different */
5354 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5355 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc
));
5362 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5364 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5366 expectf(100.0, ptf
[0].X
);
5367 expectf(100.0, ptf
[0].Y
);
5368 expectf(200.125, ptf
[1].X
);
5369 expectf(200.03125, ptf
[1].Y
);
5371 else /* before Win7 */
5373 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5374 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5375 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5376 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5379 status
= GdipTransformRegion(region100x100
, matrix
);
5382 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5384 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5385 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5387 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5389 ret
= GetRgnBox(hrgn
, &rc
);
5390 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5391 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5392 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5395 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5397 ret
= GetRgnBox(hrgn
, &rc
);
5398 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5399 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5400 /* rounding under Wine is slightly different */
5401 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5402 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc
));
5409 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5411 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5413 expectf(210.0625, ptf
[0].X
);
5414 expectf(420.0625, ptf
[0].Y
);
5415 expectf(410.125, ptf
[1].X
);
5416 expectf(820.0, ptf
[1].Y
);
5418 else /* before Win7 */
5420 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5421 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5422 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5423 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5426 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5428 status
= GdipSetWorldTransform(graphics
, matrix
);
5431 status
= GdipGetClipBounds(graphics
, &rect
);
5433 expectf_(20.612978, rect
.X
, 1.0);
5434 expectf_(-6.256012, rect
.Y
, 1.5);
5435 expectf_(25.612978, rect
.Width
, 1.0);
5436 expectf_(12.806489, rect
.Height
, 1.0);
5438 status
= GdipSetEmpty(region
);
5440 status
= GdipGetClip(graphics
, region
);
5442 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5444 /* rounding under Wine is slightly different */
5445 expectf_(20.612978, rect
.X
, 1.0);
5446 expectf_(-6.256012, rect
.Y
, 1.5);
5447 expectf_(25.612978, rect
.Width
, 1.0);
5448 expectf_(12.806489, rect
.Height
, 1.0);
5450 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5452 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5453 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5455 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5457 ret
= GetRgnBox(hrgn
, &rc
);
5458 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5459 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5460 /* rounding under Wine is slightly different */
5461 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5462 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc
));
5465 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5467 ret
= GetRgnBox(hrgn
, &rc
);
5468 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5469 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5470 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5481 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5483 expectf(20.612978, ptf
[0].X
);
5484 expectf(-1.568512, ptf
[0].Y
);
5485 expectf(46.225956, ptf
[1].X
);
5486 expectf(1.862977, ptf
[1].Y
);
5487 expectf(36.850956, ptf
[2].X
);
5488 expectf(-6.256012, ptf
[2].Y
);
5489 expectf(29.987980, ptf
[3].X
);
5490 expectf(6.550478, ptf
[3].Y
);
5492 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5494 ret
= GetRgnBox(hrgn
, &rc
);
5495 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5496 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5497 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5500 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5502 ret
= GetRgnBox(hrgn
, &rc
);
5503 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5504 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5505 /* rounding under Wine is slightly different */
5506 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5507 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc
));
5518 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5520 expectf(-136.190491, ptf
[0].X
);
5521 expectf(520.010742, ptf
[0].Y
);
5522 expectf(756.417175, ptf
[1].X
);
5523 expectf(720.031616, ptf
[1].Y
);
5524 expectf(360.042114, ptf
[2].X
);
5525 expectf(376.760742, ptf
[2].Y
);
5526 expectf(260.184570, ptf
[3].X
);
5527 expectf(863.281616, ptf
[3].Y
);
5529 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5531 status
= GdipSetWorldTransform(graphics
, matrix
);
5534 status
= GdipGetClipBounds(graphics
, &rect
);
5536 expectf_(-28.100956, rect
.X
, 1.0);
5537 expectf_(7.806488, rect
.Y
, 1.5);
5538 expectf_(25.612978, rect
.Width
, 1.0);
5539 expectf_(12.806489, rect
.Height
, 1.0);
5541 status
= GdipSetEmpty(region
);
5543 status
= GdipGetClip(graphics
, region
);
5545 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5547 /* rounding under Wine is slightly different */
5548 expectf_(-28.100956, rect
.X
, 1.0);
5549 expectf_(7.806488, rect
.Y
, 1.5);
5550 expectf_(25.612978, rect
.Width
, 1.0);
5551 expectf_(12.806489, rect
.Height
, 1.0);
5553 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5555 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5556 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5558 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5560 ret
= GetRgnBox(hrgn
, &rc
);
5561 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5562 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5563 /* rounding under Wine is slightly different */
5564 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5565 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc
));
5568 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5570 ret
= GetRgnBox(hrgn
, &rc
);
5571 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5572 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5573 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5584 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5586 expectf(-11.862979, ptf
[0].X
);
5587 expectf(7.806488, ptf
[0].Y
);
5588 expectf(-18.725958, ptf
[1].X
);
5589 expectf(20.612976, ptf
[1].Y
);
5590 expectf(-2.487981, ptf
[2].X
);
5591 expectf(15.925477, ptf
[2].Y
);
5592 expectf(-28.100956, ptf
[3].X
);
5593 expectf(12.493987, ptf
[3].Y
);
5595 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5597 ret
= GetRgnBox(hrgn
, &rc
);
5598 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5599 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5600 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5603 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5605 ret
= GetRgnBox(hrgn
, &rc
);
5606 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5607 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5608 /* rounding under Wine is slightly different */
5609 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5610 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc
));
5621 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5623 expectf(-1055.021484, ptf
[0].X
);
5624 expectf(-70.595329, ptf
[0].Y
);
5625 expectf(-1455.063232, ptf
[1].X
);
5626 expectf(375.708435, ptf
[1].Y
);
5627 expectf(-768.521484, ptf
[2].X
);
5628 expectf(177.520981, ptf
[2].Y
);
5629 expectf(-1741.563110, ptf
[3].X
);
5630 expectf(127.592125, ptf
[3].Y
);
5632 GdipDeleteMatrix(matrix
);
5633 GdipDeleteRegion(region
);
5634 GdipDeleteRegion(region100x100
);
5635 GdipDeleteGraphics(graphics
);
5639 static void test_clipping_2(void)
5644 GpGraphics
*graphics
;
5654 hdc
= CreateCompatibleDC(0);
5655 status
= GdipCreateFromHDC(hdc
, &graphics
);
5658 status
= GdipGetPageUnit(graphics
, &unit
);
5660 expect(UnitDisplay
, unit
);
5662 GdipSetPageUnit(graphics
, UnitInch
);
5664 status
= GdipCreateRegion(®ion
);
5666 status
= GdipSetEmpty(region
);
5668 rect
.X
= rect
.Y
= 100.0;
5669 rect
.Width
= rect
.Height
= 100.0;
5670 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5672 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5675 status
= GdipGetClip(graphics
, region
);
5677 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5679 ret
= GetRgnBox(hrgn
, &rc
);
5680 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5681 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5682 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5684 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5686 ret
= GetRgnBox(hrgn
, &rc
);
5687 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5688 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5689 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5696 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5698 expectf(100.0, ptf
[0].X
);
5699 expectf(100.0, ptf
[0].Y
);
5700 expectf(200.0, ptf
[1].X
);
5701 expectf(200.0, ptf
[1].X
);
5703 GdipSetPageUnit(graphics
, UnitPoint
);
5705 status
= GdipGetClip(graphics
, region
);
5707 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5709 ret
= GetRgnBox(hrgn
, &rc
);
5710 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5711 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5712 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5713 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc
));
5715 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5717 ret
= GetRgnBox(hrgn
, &rc
);
5718 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5719 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5720 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5721 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5728 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5730 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5731 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5732 "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
);
5733 else /* before Win7 */
5735 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5736 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5737 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5738 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5741 GdipDeleteRegion(region
);
5743 GdipSetPageUnit(graphics
, UnitPixel
);
5745 status
= GdipCreateRegion(®ion
);
5747 status
= GdipSetEmpty(region
);
5749 rect
.X
= rect
.Y
= 100.0;
5750 rect
.Width
= rect
.Height
= 100.0;
5751 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5753 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5756 status
= GdipGetClip(graphics
, region
);
5758 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5760 ret
= GetRgnBox(hrgn
, &rc
);
5761 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5762 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5763 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5764 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5766 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5768 ret
= GetRgnBox(hrgn
, &rc
);
5769 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5770 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5771 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5772 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5779 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5781 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5782 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5783 "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
);
5784 else /* before Win7 */
5786 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5787 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5788 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5789 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5792 GdipSetPageUnit(graphics
, UnitPoint
);
5794 status
= GdipGetClip(graphics
, region
);
5796 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5798 ret
= GetRgnBox(hrgn
, &rc
);
5799 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5800 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5801 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5802 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc
));
5804 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5806 ret
= GetRgnBox(hrgn
, &rc
);
5807 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5808 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5809 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5810 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5817 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5819 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5820 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5821 "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
);
5822 else /* before Win7 */
5824 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5825 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5826 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5827 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5830 status
= GdipCreateMatrix(&matrix
);
5832 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5834 status
= GdipSetWorldTransform(graphics
, matrix
);
5836 GdipDeleteMatrix(matrix
);
5838 status
= GdipGetClip(graphics
, region
);
5840 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5842 ret
= GetRgnBox(hrgn
, &rc
);
5843 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5844 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5845 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc
));
5847 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5849 ret
= GetRgnBox(hrgn
, &rc
);
5850 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5851 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5852 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5859 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5861 expectf(65.0, ptf
[0].X
);
5862 expectf(65.0, ptf
[0].Y
);
5863 expectf(140.0, ptf
[1].X
);
5864 expectf(140.0, ptf
[1].X
);
5866 status
= GdipCreateMatrix(&matrix
);
5868 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5870 status
= GdipSetWorldTransform(graphics
, matrix
);
5872 GdipDeleteMatrix(matrix
);
5874 status
= GdipGetClip(graphics
, region
);
5876 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5878 ret
= GetRgnBox(hrgn
, &rc
);
5879 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5880 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5881 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc
));
5883 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5885 ret
= GetRgnBox(hrgn
, &rc
);
5886 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5887 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5888 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5895 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5897 expectf(300.0, ptf
[0].X
);
5898 expectf(150.0, ptf
[0].Y
);
5899 expectf(600.0, ptf
[1].X
);
5900 expectf(300.0, ptf
[1].Y
);
5902 status
= GdipSetPageScale(graphics
, 2.0);
5905 status
= GdipGetClip(graphics
, region
);
5907 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5909 ret
= GetRgnBox(hrgn
, &rc
);
5910 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5911 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5912 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5913 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc
));
5915 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5917 ret
= GetRgnBox(hrgn
, &rc
);
5918 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5919 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5920 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5921 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5928 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5930 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5932 expectf(150.0, ptf
[0].X
);
5933 expectf(75.0, ptf
[0].Y
);
5934 expectf(300.0, ptf
[1].X
);
5935 expectf(150.0, ptf
[1].Y
);
5937 else /* before Win7 */
5939 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5940 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5941 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5942 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5945 status
= GdipCreateMatrix(&matrix
);
5947 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5949 status
= GdipSetWorldTransform(graphics
, matrix
);
5951 GdipDeleteMatrix(matrix
);
5953 status
= GdipGetClip(graphics
, region
);
5955 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5957 ret
= GetRgnBox(hrgn
, &rc
);
5958 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5959 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5960 /* rounding under Wine is slightly different */
5961 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5962 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc
));
5964 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5966 ret
= GetRgnBox(hrgn
, &rc
);
5967 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5968 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5969 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5980 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5982 expectf(53.033016, ptf
[0].X
);
5983 expectf(0.0, ptf
[0].Y
);
5984 expectf(106.066032, ptf
[1].X
);
5985 expectf(0.0, ptf
[1].Y
);
5986 expectf(79.549522, ptf
[2].X
);
5987 expectf(-26.516510, ptf
[2].Y
);
5988 expectf(79.549522, ptf
[3].X
);
5989 expectf(26.516508, ptf
[3].Y
);
5991 status
= GdipCreateMatrix(&matrix
);
5993 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5995 status
= GdipSetWorldTransform(graphics
, matrix
);
5997 GdipDeleteMatrix(matrix
);
5999 status
= GdipGetClip(graphics
, region
);
6001 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6003 ret
= GetRgnBox(hrgn
, &rc
);
6004 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
6005 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
6006 /* rounding under Wine is slightly different */
6007 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
6008 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc
));
6010 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6012 ret
= GetRgnBox(hrgn
, &rc
);
6013 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6014 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
6015 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6026 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
6028 expectf(0.0, ptf
[0].X
);
6029 expectf(53.033005, ptf
[0].Y
);
6030 expectf(0.0, ptf
[1].X
);
6031 expectf(106.066010, ptf
[1].Y
);
6032 expectf(26.516491, ptf
[2].X
);
6033 expectf(79.549507, ptf
[2].Y
);
6034 expectf(-26.516520, ptf
[3].X
);
6035 expectf(79.549500, ptf
[3].Y
);
6037 GdipDeleteRegion(region
);
6038 GdipDeleteGraphics(graphics
);
6043 static void test_GdipFillRectangles(void)
6046 GpGraphics
*graphics
= NULL
;
6047 GpBrush
*brush
= NULL
;
6048 HDC hdc
= GetDC( hwnd
);
6049 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
6051 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
6053 status
= GdipCreateFromHDC(hdc
, &graphics
);
6055 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
6057 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
6059 ok(brush
!= NULL
, "Expected brush to be initialized\n");
6061 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
6062 expect(InvalidParameter
, status
);
6064 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
6065 expect(InvalidParameter
, status
);
6067 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
6068 expect(InvalidParameter
, status
);
6070 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
6071 expect(InvalidParameter
, status
);
6073 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
6074 expect(InvalidParameter
, status
);
6076 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
6079 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
6082 GdipDeleteBrush(brush
);
6083 GdipDeleteGraphics(graphics
);
6085 ReleaseDC(hwnd
, hdc
);
6088 static void test_GdipGetVisibleClipBounds_memoryDC(void)
6097 GpGraphics
* graphics
= NULL
;
6101 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
6102 width
= rect
.right
- rect
.left
;
6103 height
= rect
.bottom
- rect
.top
;
6106 hdc
= CreateCompatibleDC ( dc
);
6107 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
6108 old
= SelectObject (hdc
, bmp
);
6110 /*change the window origin is the key test point*/
6111 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
6113 status
= GdipCreateFromHDC(hdc
, &graphics
);
6116 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
6119 ok(boundRect
.X
==rect
.left
+10 &&
6120 boundRect
.Y
==rect
.top
+10 &&
6121 boundRect
.Width
==width
&&
6122 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
6124 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6127 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
6130 ok(boundRect
.X
==rect
.left
+10 &&
6131 boundRect
.Y
==rect
.top
+10 &&
6132 boundRect
.Width
==width
-10 &&
6133 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
6135 GdipDeleteGraphics(graphics
);
6137 SelectObject (hdc
, old
);
6140 ReleaseDC(hwnd
, dc
);
6143 static void test_container_rects(void)
6146 GpGraphics
*graphics
;
6147 HDC hdc
= GetDC( hwnd
);
6148 GpRectF dstrect
, srcrect
;
6149 GraphicsContainer state
;
6150 static const GpPointF test_points
[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
6154 status
= GdipCreateFromHDC(hdc
, &graphics
);
6159 dstrect
.Width
= 1.0;
6160 dstrect
.Height
= 1.0;
6163 status
= GdipGetDpiX(graphics
, &dpix
);
6166 status
= GdipGetDpiY(graphics
, &dpiy
);
6169 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitWorld
, &state
);
6170 expect(InvalidParameter
, status
);
6172 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitDisplay
, &state
);
6173 expect(InvalidParameter
, status
);
6175 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitMillimeter
+1, &state
);
6176 expect(InvalidParameter
, status
);
6178 status
= GdipBeginContainer(NULL
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6179 expect(InvalidParameter
, status
);
6181 status
= GdipBeginContainer(graphics
, NULL
, &srcrect
, UnitPixel
, &state
);
6182 expect(InvalidParameter
, status
);
6184 status
= GdipBeginContainer(graphics
, &dstrect
, NULL
, UnitPixel
, &state
);
6185 expect(InvalidParameter
, status
);
6187 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, -1, &state
);
6188 expect(InvalidParameter
, status
);
6190 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, NULL
);
6191 expect(InvalidParameter
, status
);
6193 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6196 memcpy(points
, test_points
, sizeof(points
));
6197 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6199 expectf(0.0, points
[0].X
);
6200 expectf(0.0, points
[0].Y
);
6201 expectf(1.0, points
[1].X
);
6202 expectf(0.0, points
[1].Y
);
6203 expectf(0.0, points
[2].X
);
6204 expectf(1.0, points
[2].Y
);
6206 status
= GdipEndContainer(graphics
, state
);
6209 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6212 memcpy(points
, test_points
, sizeof(points
));
6213 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6215 expectf(0.0, points
[0].X
);
6216 expectf(0.0, points
[0].Y
);
6217 expectf(1.0/dpix
, points
[1].X
);
6218 expectf(0.0, points
[1].Y
);
6219 expectf(0.0, points
[2].X
);
6220 expectf(1.0/dpiy
, points
[2].Y
);
6222 status
= GdipEndContainer(graphics
, state
);
6225 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
6229 dstrect
.Height
= 3.0;
6230 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6233 memcpy(points
, test_points
, sizeof(points
));
6234 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6236 expectf(2.0, points
[0].X
);
6237 expectf(0.0, points
[0].Y
);
6238 expectf(4.0, points
[1].X
);
6239 expectf(0.0, points
[1].Y
);
6240 expectf(2.0, points
[2].X
);
6241 expectf(6.0, points
[2].Y
);
6243 status
= GdipEndContainer(graphics
, state
);
6246 memcpy(points
, test_points
, sizeof(points
));
6247 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6249 expectf(0.0, points
[0].X
);
6250 expectf(0.0, points
[0].Y
);
6251 expectf(2.0, points
[1].X
);
6252 expectf(0.0, points
[1].Y
);
6253 expectf(0.0, points
[2].X
);
6254 expectf(2.0, points
[2].Y
);
6256 status
= GdipResetWorldTransform(graphics
);
6259 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6262 memcpy(points
, test_points
, sizeof(points
));
6263 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6265 expectf(1.0, points
[0].X
);
6266 expectf(0.0, points
[0].Y
);
6267 expectf((dpix
+1.0)/dpix
, points
[1].X
);
6268 expectf(0.0, points
[1].Y
);
6269 expectf(1.0, points
[2].X
);
6270 expectf(3.0/dpiy
, points
[2].Y
);
6272 status
= GdipEndContainer(graphics
, state
);
6275 status
= GdipSetPageUnit(graphics
, UnitInch
);
6278 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6281 memcpy(points
, test_points
, sizeof(points
));
6282 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6284 expectf(dpix
, points
[0].X
);
6285 expectf(0.0, points
[0].Y
);
6286 expectf(dpix
*2, points
[1].X
);
6287 expectf(0.0, points
[1].Y
);
6288 expectf(dpix
, points
[2].X
);
6289 expectf(dpiy
*3, points
[2].Y
);
6291 status
= GdipEndContainer(graphics
, state
);
6294 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6297 memcpy(points
, test_points
, sizeof(points
));
6298 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6300 expectf(dpix
, points
[0].X
);
6301 expectf(0.0, points
[0].Y
);
6302 expectf(dpix
+1.0, points
[1].X
);
6303 expectf(0.0, points
[1].Y
);
6304 expectf(dpix
, points
[2].X
);
6305 expectf(3.0, points
[2].Y
);
6307 status
= GdipEndContainer(graphics
, state
);
6310 GdipDeleteGraphics(graphics
);
6312 ReleaseDC(hwnd
, hdc
);
6315 static void test_GdipGraphicsSetAbort(void)
6319 GpGraphics
*graphics
;
6321 if (!pGdipGraphicsSetAbort
)
6323 win_skip("GdipGraphicsSetAbort() is not supported.\n");
6329 status
= GdipCreateFromHDC(hdc
, &graphics
);
6332 status
= pGdipGraphicsSetAbort(NULL
, NULL
);
6333 expect(InvalidParameter
, status
);
6335 status
= pGdipGraphicsSetAbort(graphics
, NULL
);
6338 GdipDeleteGraphics(graphics
);
6340 ReleaseDC(hwnd
, hdc
);
6343 #define BLUE_COLOR (0xff0000ff)
6344 #define is_blue_color(color) ( ((color) & 0x00ffffff) == 0xff )
6345 #define get_bitmap_pixel(x,y) pixel[(y)*(width) + (x)]
6346 static DWORD
* GetBitmapPixelBuffer(HDC hdc
, HBITMAP hbmp
, int width
, int height
)
6348 BITMAPINFOHEADER bi
;
6350 DWORD
*buffer
= (DWORD
*)GdipAlloc(width
*height
*4);
6352 bi
.biSize
= sizeof(BITMAPINFOHEADER
);
6354 bi
.biHeight
= -height
; /*very Important, set negative, indicating a top-down DIB*/
6357 bi
.biCompression
= BI_RGB
;
6359 bi
.biXPelsPerMeter
= 0;
6360 bi
.biYPelsPerMeter
= 0;
6362 bi
.biClrImportant
= 0;
6364 lines
= GetDIBits(hdc
, hbmp
, 0, height
, buffer
, (BITMAPINFO
*)&bi
, DIB_RGB_COLORS
);
6365 ok(lines
== height
, "Expected GetDIBits:%p,%d->%d,%d\n", buffer
, height
, lines
, GetLastError());
6370 static void test_GdipFillRectanglesOnMemoryDCSolidBrush(void)
6372 ARGB color
[6] = {0,0,0,0,0,0};
6374 RECT rect
= {100, 100, 180, 180};
6375 UINT width
= rect
.right
- rect
.left
;
6376 UINT height
= rect
.bottom
- rect
.top
;
6377 GpStatus status
= 0;
6378 GpSolidFill
*brush
= NULL
;
6379 GpGraphics
*graphics
= NULL
;
6380 HDC dc
= GetDC( hwnd
);
6381 HDC hdc
= CreateCompatibleDC(dc
);
6382 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6383 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6384 DWORD
* pixel
= NULL
;
6386 /*Change the window origin is the key test point*/
6387 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6389 status
= GdipCreateSolidFill(BLUE_COLOR
, &brush
);
6392 status
= GdipCreateFromHDC(hdc
, &graphics
);
6395 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6396 width
, height
, CombineModeReplace
);
6399 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6402 GdipDeleteBrush((GpBrush
*)brush
);
6403 GdipDeleteGraphics(graphics
);
6405 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6408 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6409 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6410 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6411 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6412 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6413 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6416 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6417 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6418 "Expected GdipFillRectangleI take effect!\n" );
6421 SelectObject(hdc
, old
);
6424 ReleaseDC(hwnd
, dc
);
6427 static void test_GdipFillRectanglesOnMemoryDCTextureBrush(void)
6429 ARGB color
[6] = {0,0,0,0,0,0};
6431 RECT rect
= {100, 100, 180, 180};
6432 UINT width
= rect
.right
- rect
.left
;
6433 UINT height
= rect
.bottom
- rect
.top
;
6434 GpStatus status
= 0;
6440 GpTexture
*brush
= NULL
;
6441 GpGraphics
*graphics
= NULL
;
6442 HDC dc
= GetDC( hwnd
);
6443 HDC hdc
= CreateCompatibleDC(dc
);
6444 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6445 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6449 UINT src_img_width
= width
/2;
6450 UINT src_img_height
= height
/2;
6451 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6452 DWORD
*pixel
= (DWORD
*)src_img_data
;
6453 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6455 /*Change the window origin is the key test point*/
6456 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6458 /*build a blue solid image!*/
6459 for(y
= 0; y
< src_img_height
; ++y
)
6461 for(x
= 0; x
< src_img_width
; ++x
)
6463 pixel
[x
] = BLUE_COLOR
;
6466 pixel
+= src_img_width
;
6469 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6470 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6473 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6476 status
= GdipCreateFromHDC(hdc
, &graphics
);
6479 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6480 width
, height
, CombineModeReplace
);
6483 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6486 GdipDisposeImage(src_img
.image
);
6487 GdipDeleteBrush((GpBrush
*)brush
);
6488 GdipDeleteGraphics(graphics
);
6489 GdipFree(src_img_data
);
6491 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6494 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6495 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6496 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6497 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6498 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6499 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6501 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6502 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6503 "Expected GdipFillRectangleI take effect!\n" );
6506 SelectObject(hdc
, old
);
6509 ReleaseDC(hwnd
, dc
);
6512 static void test_GdipFillRectanglesOnBitmapTextureBrush(void)
6514 ARGB color
[6] = {0,0,0,0,0,0};
6517 RECT rect
= {100, 100, 180, 180};
6518 UINT width
= rect
.right
- rect
.left
;
6519 UINT height
= rect
.bottom
- rect
.top
;
6520 UINT src_img_width
= width
/2;
6521 UINT src_img_height
= height
/2;
6523 GpStatus status
= 0;
6535 GpTexture
*brush
= NULL
;
6536 GpGraphics
*graphics
= NULL
;
6537 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6538 DWORD
*pixel
= (DWORD
*)src_img_data
;
6539 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6541 status
= GdipCreateBitmapFromScan0(width
, height
, width
*4,
6542 PixelFormat32bppARGB
, NULL
, &dst_img
.bitmap
);
6545 /*build a blue solid image!*/
6546 for(y
= 0; y
< src_img_height
; ++y
)
6548 for(x
= 0; x
< src_img_width
; ++x
)
6550 pixel
[x
] = BLUE_COLOR
;
6553 pixel
+= src_img_width
;
6556 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6557 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6560 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6563 status
= GdipGetImageGraphicsContext(dst_img
.image
, &graphics
);
6566 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6569 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, width
/2, height
/2);
6572 GdipDeleteBrush((GpBrush
*)brush
);
6573 GdipDeleteGraphics(graphics
);
6575 GdipBitmapGetPixel(dst_img
.bitmap
, 0, 0, &color
[0]);
6576 GdipBitmapGetPixel(dst_img
.bitmap
, 0, 1, &color
[1]);
6577 GdipBitmapGetPixel(dst_img
.bitmap
, 1, 0, &color
[2]);
6578 GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, 0, &color
[3]);
6579 GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, height
/2, &color
[4]);
6580 GdipBitmapGetPixel(dst_img
.bitmap
, 0, height
/2, &color
[5]);
6582 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6583 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6584 "Expected GdipFillRectangleI take effect!\n" );
6586 GdipDisposeImage(src_img
.image
);
6587 GdipDisposeImage(dst_img
.image
);
6588 GdipFree(src_img_data
);
6591 static void test_GdipDrawImagePointsRectOnMemoryDC(void)
6593 ARGB color
[6] = {0,0,0,0,0,0};
6595 RECT rect
= {100, 100, 180, 180};
6596 UINT width
= rect
.right
- rect
.left
;
6597 UINT height
= rect
.bottom
- rect
.top
;
6598 GpStatus status
= 0;
6604 GpGraphics
*graphics
= NULL
;
6605 HDC dc
= GetDC( hwnd
);
6606 HDC hdc
= CreateCompatibleDC(dc
);
6607 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6608 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6612 UINT src_img_width
= width
/2;
6613 UINT src_img_height
= height
/2;
6614 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6615 DWORD
*pixel
= (DWORD
*)src_img_data
;
6616 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6618 /*Change the window origin is the key test point*/
6619 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6621 /*build a blue solid image!*/
6622 for(y
= 0; y
< src_img_height
; ++y
)
6624 for(x
= 0; x
< src_img_width
; ++x
)
6626 pixel
[x
] = BLUE_COLOR
;
6629 pixel
+= src_img_width
;
6632 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6633 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6636 status
= GdipCreateFromHDC(hdc
, &graphics
);
6639 status
= GdipDrawImageRectRectI(graphics
, src_img
.image
,
6640 rect
.left
+width
/2, rect
.top
+height
/2, width
/2, height
/2,
6641 0, 0, src_img_width
, src_img_height
, UnitPixel
, NULL
, NULL
, NULL
);
6644 GdipDisposeImage(src_img
.image
);
6645 GdipDeleteGraphics(graphics
);
6646 GdipFree(src_img_data
);
6648 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6651 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6652 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6653 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6654 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6655 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6656 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6658 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6659 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6660 "Expected GdipDrawImageRectRectI take effect!\n" );
6663 SelectObject(hdc
, old
);
6666 ReleaseDC(hwnd
, dc
);
6669 static void test_cliphrgn_transform(void)
6673 GpGraphics
*graphics
;
6680 SetViewportOrgEx(hdc
, 10, 10, NULL
);
6682 status
= GdipCreateFromHDC(hdc
, &graphics
);
6685 rgn
= CreateRectRgn(0, 0, 100, 100);
6687 status
= GdipSetClipHrgn(graphics
, rgn
, CombineModeReplace
);
6690 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
6692 expectf(-10.0, rectf
.X
);
6693 expectf(-10.0, rectf
.Y
);
6694 expectf(100.0, rectf
.Width
);
6695 expectf(100.0, rectf
.Height
);
6697 status
= GdipIsVisiblePoint(graphics
, 95, 95, &res
);
6701 status
= GdipIsVisiblePoint(graphics
, -5, -5, &res
);
6707 GdipDeleteGraphics(graphics
);
6709 SetViewportOrgEx(hdc
, 0, 0, NULL
);
6711 ReleaseDC(hwnd
, hdc
);
6714 static void test_hdc_caching(void)
6719 GpGraphics
*graphics
;
6725 hdc
= CreateCompatibleDC(0);
6726 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
6727 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
6728 bmi
.bmiHeader
.biHeight
= -5;
6729 bmi
.bmiHeader
.biWidth
= 5;
6730 bmi
.bmiHeader
.biBitCount
= 32;
6731 bmi
.bmiHeader
.biPlanes
= 1;
6732 bmi
.bmiHeader
.biCompression
= BI_RGB
;
6733 bmi
.bmiHeader
.biClrUsed
= 0;
6735 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
6736 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
6738 SelectObject(hdc
, hbm
);
6740 SetViewportOrgEx(hdc
, 1, 1, NULL
);
6742 hrgn
= CreateRectRgn(0, 0, 3, 3);
6743 SelectClipRgn(hdc
, hrgn
);
6746 status
= GdipCreateSolidFill((ARGB
)0xffaaaaaa, (GpSolidFill
**)&brush
);
6749 status
= GdipCreateFromHDC(hdc
, &graphics
);
6752 memset(bits
, 0, sizeof(*bits
) * 25);
6753 status
= GdipFillRectangleI(graphics
, brush
, 0, 0, 4, 4);
6757 expect(0xffaaaaaa, bits
[6]);
6758 expect(0xffaaaaaa, bits
[12]);
6759 expect(0, bits
[18]);
6760 expect(0, bits
[24]);
6762 SetViewportOrgEx(hdc
, 0, 0, NULL
);
6763 OffsetClipRgn(hdc
, 2, 2);
6765 memset(bits
, 0, sizeof(*bits
) * 25);
6766 status
= GdipFillRectangleI(graphics
, brush
, 0, 0, 4, 4);
6770 expect(0xffaaaaaa, bits
[6]);
6771 expect(0xffaaaaaa, bits
[12]);
6772 expect(0, bits
[18]);
6773 expect(0, bits
[24]);
6775 GdipDeleteGraphics(graphics
);
6777 GdipDeleteBrush(brush
);
6783 START_TEST(graphics
)
6785 struct GdiplusStartupInput gdiplusStartupInput
;
6786 ULONG_PTR gdiplusToken
;
6788 HMODULE gdiplus_mod
= GetModuleHandleA("gdiplus.dll");
6790 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
6792 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
6793 hmsvcrt
= LoadLibraryA("msvcrt");
6794 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
6795 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
6797 pGdipGraphicsSetAbort
= (void*)GetProcAddress(gdiplus_mod
, "GdipGraphicsSetAbort");
6799 memset( &class, 0, sizeof(class) );
6800 class.lpszClassName
= "gdiplus_test";
6801 class.style
= CS_HREDRAW
| CS_VREDRAW
;
6802 class.lpfnWndProc
= DefWindowProcA
;
6803 class.hInstance
= GetModuleHandleA(0);
6804 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
6805 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6806 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
6807 RegisterClassA( &class );
6808 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6809 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
6810 ok(hwnd
!= NULL
, "Expected window to be created\n");
6812 gdiplusStartupInput
.GdiplusVersion
= 1;
6813 gdiplusStartupInput
.DebugEventCallback
= NULL
;
6814 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
6815 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
6817 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
6821 test_measured_extra_space();
6822 test_measure_string();
6823 test_font_height_scaling();
6825 test_pen_thickness();
6826 test_GdipMeasureString();
6827 test_constructor_destructor();
6828 test_save_restore();
6829 test_GdipFillClosedCurve2();
6830 test_GdipFillClosedCurve2I();
6831 test_GdipDrawBezierI();
6833 test_GdipDrawArcI();
6834 test_GdipDrawCurve();
6835 test_GdipDrawCurveI();
6836 test_GdipDrawCurve2();
6837 test_GdipDrawCurve2I();
6838 test_GdipDrawCurve3();
6839 test_GdipDrawCurve3I();
6840 test_GdipDrawLineI();
6841 test_GdipDrawLinesI();
6842 test_GdipDrawImagePointsRect();
6843 test_GdipFillClosedCurve();
6844 test_GdipFillClosedCurveI();
6845 test_GdipFillPath();
6846 test_GdipDrawString();
6847 test_GdipGetNearestColor();
6848 test_GdipGetVisibleClipBounds();
6849 test_GdipIsVisiblePoint();
6850 test_GdipIsVisibleRect();
6851 test_Get_Release_DC();
6852 test_BeginContainer2();
6853 test_transformpoints();
6854 test_get_set_clip();
6858 test_textcontrast();
6859 test_fromMemoryBitmap();
6860 test_string_functions();
6861 test_get_set_interpolation();
6862 test_get_set_textrenderinghint();
6863 test_getdc_scaled();
6865 test_bitmapfromgraphics();
6866 test_GdipFillRectangles();
6867 test_GdipGetVisibleClipBounds_memoryDC();
6868 test_GdipFillRectanglesOnMemoryDCSolidBrush();
6869 test_GdipFillRectanglesOnMemoryDCTextureBrush();
6870 test_GdipFillRectanglesOnBitmapTextureBrush();
6871 test_GdipDrawImagePointsRectOnMemoryDC();
6872 test_container_rects();
6873 test_GdipGraphicsSetAbort();
6874 test_cliphrgn_transform();
6877 GdiplusShutdown(gdiplusToken
);
6878 DestroyWindow( hwnd
);