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 ReleaseDC(hwnd
, hdc
);
2200 static void test_isempty(void)
2203 GpGraphics
*graphics
= NULL
;
2204 HDC hdc
= GetDC( hwnd
);
2208 status
= GdipCreateFromHDC(hdc
, &graphics
);
2211 status
= GdipCreateRegion(&clip
);
2215 status
= GdipIsClipEmpty(NULL
, NULL
);
2216 expect(InvalidParameter
, status
);
2217 status
= GdipIsClipEmpty(graphics
, NULL
);
2218 expect(InvalidParameter
, status
);
2219 status
= GdipIsClipEmpty(NULL
, &res
);
2220 expect(InvalidParameter
, status
);
2222 /* default is infinite */
2224 status
= GdipIsClipEmpty(graphics
, &res
);
2228 GdipDeleteRegion(clip
);
2230 GdipDeleteGraphics(graphics
);
2231 ReleaseDC(hwnd
, hdc
);
2234 static void test_clear(void)
2238 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2239 expect(InvalidParameter
, status
);
2242 static void test_textcontrast(void)
2245 HDC hdc
= GetDC( hwnd
);
2246 GpGraphics
*graphics
;
2249 status
= GdipGetTextContrast(NULL
, NULL
);
2250 expect(InvalidParameter
, status
);
2252 status
= GdipCreateFromHDC(hdc
, &graphics
);
2255 status
= GdipGetTextContrast(graphics
, NULL
);
2256 expect(InvalidParameter
, status
);
2257 status
= GdipGetTextContrast(graphics
, &contrast
);
2259 expect(4, contrast
);
2261 GdipDeleteGraphics(graphics
);
2262 ReleaseDC(hwnd
, hdc
);
2265 static void test_GdipDrawString(void)
2268 GpGraphics
*graphics
= NULL
;
2271 GpStringFormat
*format
;
2274 HDC hdc
= GetDC( hwnd
);
2275 static const WCHAR string
[] = {'T','e','s','t',0};
2276 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2279 memset(&logfont
,0,sizeof(logfont
));
2280 strcpy(logfont
.lfFaceName
,"Arial");
2281 logfont
.lfHeight
= 12;
2282 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2284 status
= GdipCreateFromHDC(hdc
, &graphics
);
2287 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2288 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2290 skip("Arial not installed.\n");
2295 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2298 status
= GdipCreateStringFormat(0,0,&format
);
2306 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2309 status
= GdipCreateMatrix(&matrix
);
2312 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2313 expect(InvalidParameter
, status
);
2315 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2316 expect(InvalidParameter
, status
);
2318 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2319 expect(InvalidParameter
, status
);
2321 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2322 expect(InvalidParameter
, status
);
2324 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2325 expect(InvalidParameter
, status
);
2327 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2330 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2333 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2336 GdipDeleteMatrix(matrix
);
2337 GdipDeleteGraphics(graphics
);
2338 GdipDeleteBrush(brush
);
2339 GdipDeleteFont(fnt
);
2340 GdipDeleteStringFormat(format
);
2342 ReleaseDC(hwnd
, hdc
);
2345 static void test_GdipGetVisibleClipBounds_screen(void)
2348 GpGraphics
*graphics
= NULL
;
2350 GpRectF rectf
, exp
, clipr
;
2353 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2355 status
= GdipCreateFromHDC(hdc
, &graphics
);
2357 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2359 /* no clipping rect */
2362 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2363 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2365 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2367 ok(rectf
.X
== exp
.X
&&
2369 rectf
.Width
== exp
.Width
&&
2370 rectf
.Height
== exp
.Height
,
2371 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2372 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2373 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2374 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2376 /* clipping rect entirely within window */
2377 exp
.X
= clipr
.X
= 10;
2378 exp
.Y
= clipr
.Y
= 12;
2379 exp
.Width
= clipr
.Width
= 14;
2380 exp
.Height
= clipr
.Height
= 16;
2382 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2385 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2387 ok(rectf
.X
== exp
.X
&&
2389 rectf
.Width
== exp
.Width
&&
2390 rectf
.Height
== exp
.Height
,
2391 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2392 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2393 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2394 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2396 /* clipping rect partially outside of screen */
2402 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2410 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2412 ok(rectf
.X
== exp
.X
&&
2414 rectf
.Width
== exp
.Width
&&
2415 rectf
.Height
== exp
.Height
,
2416 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2417 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2418 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2419 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2421 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2423 ok(recti
.X
== exp
.X
&&
2425 recti
.Width
== exp
.Width
&&
2426 recti
.Height
== exp
.Height
,
2427 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2428 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2429 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2430 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2432 GdipDeleteGraphics(graphics
);
2436 static void test_GdipGetVisibleClipBounds_window(void)
2439 GpGraphics
*graphics
= NULL
;
2440 GpRectF rectf
, window
, exp
, clipr
;
2446 /* get client area size */
2447 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2448 window
.X
= wnd_rect
.left
;
2449 window
.Y
= wnd_rect
.top
;
2450 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2451 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2453 hdc
= BeginPaint(hwnd
, &ps
);
2455 status
= GdipCreateFromHDC(hdc
, &graphics
);
2457 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2459 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2461 ok(rectf
.X
== window
.X
&&
2462 rectf
.Y
== window
.Y
&&
2463 rectf
.Width
== window
.Width
&&
2464 rectf
.Height
== window
.Height
,
2465 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2466 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2467 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2468 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2470 /* clipping rect entirely within window */
2471 exp
.X
= clipr
.X
= 20;
2472 exp
.Y
= clipr
.Y
= 8;
2473 exp
.Width
= clipr
.Width
= 30;
2474 exp
.Height
= clipr
.Height
= 20;
2476 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2479 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2481 ok(rectf
.X
== exp
.X
&&
2483 rectf
.Width
== exp
.Width
&&
2484 rectf
.Height
== exp
.Height
,
2485 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2486 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2487 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2488 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2490 /* clipping rect partially outside of window */
2491 clipr
.X
= window
.Width
- 10;
2492 clipr
.Y
= window
.Height
- 15;
2496 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2499 exp
.X
= window
.Width
- 10;
2500 exp
.Y
= window
.Height
- 15;
2504 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2506 ok(rectf
.X
== exp
.X
&&
2508 rectf
.Width
== exp
.Width
&&
2509 rectf
.Height
== exp
.Height
,
2510 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2511 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2512 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2513 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2515 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2517 ok(recti
.X
== exp
.X
&&
2519 recti
.Width
== exp
.Width
&&
2520 recti
.Height
== exp
.Height
,
2521 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2522 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2523 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2524 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2526 /* window bounds with transform applied */
2527 status
= GdipResetClip(graphics
);
2530 status
= GdipScaleWorldTransform(graphics
, 0.5, 0.5, MatrixOrderPrepend
);
2533 exp
.X
= window
.X
* 2.0;
2534 exp
.Y
= window
.Y
* 2.0;
2535 exp
.Width
= window
.Width
* 2.0;
2536 exp
.Height
= window
.Height
* 2.0;
2538 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2540 ok(rectf
.X
== exp
.X
&&
2542 rectf
.Width
== exp
.Width
&&
2543 rectf
.Height
== exp
.Height
,
2544 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2545 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2546 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2547 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2549 GdipDeleteGraphics(graphics
);
2550 EndPaint(hwnd
, &ps
);
2553 static void test_GdipGetVisibleClipBounds(void)
2555 GpGraphics
* graphics
= NULL
;
2558 HDC hdc
= GetDC( hwnd
);
2561 status
= GdipCreateFromHDC(hdc
, &graphics
);
2563 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2565 /* test null parameters */
2566 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2567 expect(InvalidParameter
, status
);
2569 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2570 expect(InvalidParameter
, status
);
2572 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2573 expect(InvalidParameter
, status
);
2575 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2576 expect(InvalidParameter
, status
);
2578 GdipDeleteGraphics(graphics
);
2579 ReleaseDC(hwnd
, hdc
);
2581 test_GdipGetVisibleClipBounds_screen();
2582 test_GdipGetVisibleClipBounds_window();
2585 static void test_fromMemoryBitmap(void)
2588 GpGraphics
*graphics
= NULL
;
2589 GpBitmap
*bitmap
= NULL
;
2590 BYTE bits
[48] = {0};
2594 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2597 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2600 status
= GdipGraphicsClear(graphics
, 0xff686868);
2603 GdipDeleteGraphics(graphics
);
2605 /* drawing writes to the memory provided */
2606 expect(0x68, bits
[10]);
2608 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2611 status
= GdipGetDC(graphics
, &hdc
);
2613 ok(hdc
!= NULL
, "got NULL hdc\n");
2615 color
= GetPixel(hdc
, 0, 0);
2616 /* The HDC is write-only, and native fills with a solid color to figure out
2617 * which pixels have changed. */
2618 todo_wine
expect(0x0c0b0d, color
);
2620 SetPixel(hdc
, 0, 0, 0x797979);
2621 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2623 status
= GdipReleaseDC(graphics
, hdc
);
2626 GdipDeleteGraphics(graphics
);
2628 expect(0x79, bits
[0]);
2629 todo_wine
expect(0x68, bits
[3]);
2631 GdipDisposeImage((GpImage
*)bitmap
);
2633 /* We get the same kind of write-only HDC for a "normal" bitmap */
2634 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2637 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2640 status
= GdipGetDC(graphics
, &hdc
);
2642 ok(hdc
!= NULL
, "got NULL hdc\n");
2644 color
= GetPixel(hdc
, 0, 0);
2645 todo_wine
expect(0x0c0b0d, color
);
2647 status
= GdipReleaseDC(graphics
, hdc
);
2650 GdipDeleteGraphics(graphics
);
2652 GdipDisposeImage((GpImage
*)bitmap
);
2654 /* If we don't draw to the HDC, the bits are never accessed */
2655 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2658 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2661 status
= GdipGetDC(graphics
, &hdc
);
2663 ok(hdc
!= NULL
, "got NULL hdc\n");
2665 color
= GetPixel(hdc
, 0, 0);
2666 todo_wine
expect(0x0c0b0d, color
);
2668 status
= GdipReleaseDC(graphics
, hdc
);
2671 GdipDeleteGraphics(graphics
);
2673 GdipDisposeImage((GpImage
*)bitmap
);
2676 static void test_GdipIsVisiblePoint(void)
2679 GpGraphics
*graphics
= NULL
;
2680 HDC hdc
= GetDC( hwnd
);
2684 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2686 status
= GdipCreateFromHDC(hdc
, &graphics
);
2688 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2690 /* null parameters */
2691 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2692 expect(InvalidParameter
, status
);
2694 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2695 expect(InvalidParameter
, status
);
2697 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2698 expect(InvalidParameter
, status
);
2700 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2701 expect(InvalidParameter
, status
);
2705 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2707 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2711 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2713 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2717 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2719 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2723 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2725 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2727 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2732 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2734 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2738 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2740 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2742 /* translate into the center of the rect */
2743 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2747 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2749 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2753 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2755 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2757 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2762 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2764 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2768 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2770 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2774 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2776 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2780 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2782 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2786 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2788 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2792 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2794 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2798 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2800 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2804 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2806 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2810 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2812 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2816 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2818 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2822 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2824 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2828 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2830 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2834 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2836 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2838 /* integer version */
2841 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2843 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2847 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2849 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2851 GdipDeleteGraphics(graphics
);
2852 ReleaseDC(hwnd
, hdc
);
2855 static void test_GdipIsVisibleRect(void)
2858 GpGraphics
*graphics
= NULL
;
2859 HDC hdc
= GetDC( hwnd
);
2860 REAL x
, y
, width
, height
;
2863 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2865 status
= GdipCreateFromHDC(hdc
, &graphics
);
2867 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2869 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2870 expect(InvalidParameter
, status
);
2872 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2873 expect(InvalidParameter
, status
);
2875 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2876 expect(InvalidParameter
, status
);
2878 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2879 expect(InvalidParameter
, status
);
2881 /* entirely within the visible region */
2884 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2886 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2888 /* partially outside */
2889 x
= -10; width
= 20;
2890 y
= -10; height
= 20;
2891 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2893 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2895 /* entirely outside */
2897 y
= -10; height
= 5;
2898 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2900 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2902 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2905 /* entirely within the visible region */
2907 y
= 22; height
= 10;
2908 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2910 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2912 /* partially outside */
2914 y
= 55; height
= 10;
2915 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2917 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2919 /* entirely outside */
2922 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2924 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2926 /* translate into center of clipping rect */
2927 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2931 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2933 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2937 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2939 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2941 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2943 /* corners entirely outside, but some intersections */
2946 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2948 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2952 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2954 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2958 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2960 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2964 y
= 20; height
= 40;
2965 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2967 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2971 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2973 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2976 y
= 20; height
= 40;
2977 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2979 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2982 y
= 60; height
= 10;
2983 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2985 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2987 /* rounding tests */
2988 x
= 0.4; width
= 10.4;
2989 y
= 20; height
= 40;
2990 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2992 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2995 y
= 0.4; height
= 20.4;
2996 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2998 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3000 /* integer version */
3003 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
3005 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3008 y
= 22; height
= 10;
3009 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
3011 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
3013 GdipDeleteGraphics(graphics
);
3014 ReleaseDC(hwnd
, hdc
);
3017 static void test_GdipGetNearestColor(void)
3020 GpGraphics
*graphics
;
3022 ARGB color
= 0xdeadbeef;
3023 HDC hdc
= GetDC( hwnd
);
3025 /* create a graphics object */
3026 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3028 status
= GdipCreateFromHDC(hdc
, &graphics
);
3030 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3032 status
= GdipGetNearestColor(graphics
, NULL
);
3033 expect(InvalidParameter
, status
);
3035 status
= GdipGetNearestColor(NULL
, &color
);
3036 expect(InvalidParameter
, status
);
3037 GdipDeleteGraphics(graphics
);
3039 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
3041 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3042 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3045 status
= GdipGetNearestColor(graphics
, &color
);
3047 expect(0xdeadbeef, color
);
3048 GdipDeleteGraphics(graphics
);
3050 GdipDisposeImage((GpImage
*)bitmap
);
3052 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
3054 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3055 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3058 status
= GdipGetNearestColor(graphics
, &color
);
3060 expect(0xdeadbeef, color
);
3061 GdipDeleteGraphics(graphics
);
3063 GdipDisposeImage((GpImage
*)bitmap
);
3065 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
3067 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3068 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
3071 status
= GdipGetNearestColor(graphics
, &color
);
3073 expect(0xdeadbeef, color
);
3074 GdipDeleteGraphics(graphics
);
3076 GdipDisposeImage((GpImage
*)bitmap
);
3078 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
3080 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3081 todo_wine
expect(OutOfMemory
, status
);
3083 GdipDeleteGraphics(graphics
);
3084 GdipDisposeImage((GpImage
*)bitmap
);
3086 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
3088 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3090 status
= GdipGetNearestColor(graphics
, &color
);
3092 expect(0xdeadbeef, color
);
3093 GdipDeleteGraphics(graphics
);
3094 GdipDisposeImage((GpImage
*)bitmap
);
3096 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
3098 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3100 status
= GdipGetNearestColor(graphics
, &color
);
3102 expect(0xdeadbeef, color
);
3103 GdipDeleteGraphics(graphics
);
3104 GdipDisposeImage((GpImage
*)bitmap
);
3106 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
3108 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3110 status
= GdipGetNearestColor(graphics
, &color
);
3112 expect(0xdeadbeef, color
);
3113 GdipDeleteGraphics(graphics
);
3114 GdipDisposeImage((GpImage
*)bitmap
);
3116 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
3120 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3122 status
= GdipGetNearestColor(graphics
, &color
);
3124 expect(0xdeadbeef, color
);
3125 GdipDeleteGraphics(graphics
);
3126 GdipDisposeImage((GpImage
*)bitmap
);
3129 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
3133 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3135 status
= GdipGetNearestColor(graphics
, &color
);
3137 expect(0xdeadbeef, color
);
3138 GdipDeleteGraphics(graphics
);
3139 GdipDisposeImage((GpImage
*)bitmap
);
3142 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
3146 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3148 status
= GdipGetNearestColor(graphics
, &color
);
3150 expect(0xdeadbeef, color
);
3151 GdipDeleteGraphics(graphics
);
3152 GdipDisposeImage((GpImage
*)bitmap
);
3155 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
3157 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3159 status
= GdipGetNearestColor(graphics
, &color
);
3161 todo_wine
expect(0xffa8bce8, color
);
3162 GdipDeleteGraphics(graphics
);
3163 GdipDisposeImage((GpImage
*)bitmap
);
3165 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
3167 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3169 status
= GdipGetNearestColor(graphics
, &color
);
3172 ok(color
== 0xffa8b8e8 ||
3173 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
3174 "Expected ffa8b8e8, got %.8x\n", color
);
3175 GdipDeleteGraphics(graphics
);
3176 GdipDisposeImage((GpImage
*)bitmap
);
3178 ReleaseDC(hwnd
, hdc
);
3181 static void test_string_functions(void)
3184 GpGraphics
*graphics
;
3185 GpFontFamily
*family
;
3187 RectF rc
, char_bounds
, bounds
;
3189 ARGB color
= 0xff000000;
3190 HDC hdc
= GetDC( hwnd
);
3191 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
3192 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
3193 const WCHAR teststring2
[] = {'j',0};
3194 REAL char_width
, char_height
;
3195 INT codepointsfitted
, linesfilled
;
3196 GpStringFormat
*format
;
3197 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
3198 GpRegion
*regions
[4];
3199 BOOL region_isempty
[4];
3201 PointF positions
[8];
3204 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3205 status
= GdipCreateFromHDC(hdc
, &graphics
);
3207 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3209 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
3212 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
3215 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
3218 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3226 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
3227 expect(InvalidParameter
, status
);
3229 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
3230 expect(InvalidParameter
, status
);
3232 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3233 expect(InvalidParameter
, status
);
3235 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3236 expect(InvalidParameter
, status
);
3238 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3239 expect(InvalidParameter
, status
);
3241 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3244 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3245 expect(InvalidParameter
, status
);
3247 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3248 expect(InvalidParameter
, status
);
3250 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3251 expect(InvalidParameter
, status
);
3253 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3254 expect(InvalidParameter
, status
);
3256 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3257 expect(InvalidParameter
, status
);
3259 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3262 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3265 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3267 expectf(0.0, char_bounds
.X
);
3268 expectf(0.0, char_bounds
.Y
);
3269 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3270 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3271 expect(1, codepointsfitted
);
3272 expect(1, linesfilled
);
3274 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3276 expectf(0.0, bounds
.X
);
3277 expectf(0.0, bounds
.Y
);
3278 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3279 expectf(char_bounds
.Height
, bounds
.Height
);
3280 expect(2, codepointsfitted
);
3281 expect(1, linesfilled
);
3282 char_width
= bounds
.Width
- char_bounds
.Width
;
3284 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3286 expectf(0.0, bounds
.X
);
3287 expectf(0.0, bounds
.Y
);
3288 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3289 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3290 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3291 expect(6, codepointsfitted
);
3292 expect(2, linesfilled
);
3293 char_height
= bounds
.Height
- char_bounds
.Height
;
3295 /* Measure the first line. */
3296 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3298 expectf(0.0, bounds
.X
);
3299 expectf(0.0, bounds
.Y
);
3300 expect(4, codepointsfitted
);
3301 expect(1, linesfilled
);
3303 /* Give just enough space to fit the first line. */
3304 rc
.Width
= bounds
.Width
;
3305 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3307 expectf(0.0, bounds
.X
);
3308 expectf(0.0, bounds
.Y
);
3309 todo_wine
expect(5, codepointsfitted
);
3310 todo_wine
expect(1, linesfilled
);
3312 /* Cut off everything after the first space. */
3313 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3315 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3317 expectf(0.0, bounds
.X
);
3318 expectf(0.0, bounds
.Y
);
3319 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3320 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3321 expect(6, codepointsfitted
);
3322 expect(3, linesfilled
);
3324 /* Cut off everything including the first space. */
3325 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3327 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3329 expectf(0.0, bounds
.X
);
3330 expectf(0.0, bounds
.Y
);
3331 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3332 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3333 expect(6, codepointsfitted
);
3334 expect(3, linesfilled
);
3336 /* Cut off everything after the first character. */
3337 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3339 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3341 expectf(0.0, bounds
.X
);
3342 expectf(0.0, bounds
.Y
);
3343 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3344 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3345 expect(6, codepointsfitted
);
3346 todo_wine
expect(4, linesfilled
);
3348 for (i
= 0; i
< 4; i
++)
3349 regions
[i
] = (GpRegion
*)0xdeadbeef;
3351 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3354 for (i
= 0; i
< 4; i
++)
3355 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3357 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3360 for (i
= 0; i
< 4; i
++)
3361 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3363 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3366 set_rect_empty(&rc
);
3370 status
= GdipCreateRegion(®ions
[i
]);
3372 status
= GdipSetEmpty(regions
[i
]);
3376 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3377 expect(InvalidParameter
, status
);
3379 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3380 expect(InvalidParameter
, status
);
3382 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3383 expect(InvalidParameter
, status
);
3385 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3386 expect(InvalidParameter
, status
);
3390 /* Crashes on Windows XP */
3391 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3392 expect(InvalidParameter
, status
);
3395 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3396 expect(InvalidParameter
, status
);
3398 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3399 expect(InvalidParameter
, status
);
3401 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3404 for (i
= 0; i
< 4; i
++)
3406 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3410 ok(region_isempty
[0], "region should be empty\n");
3411 ok(region_isempty
[1], "region should be empty\n");
3412 ok(region_isempty
[2], "region should be empty\n");
3413 ok(region_isempty
[3], "region should be empty\n");
3418 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3423 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3427 ok(!region_isempty
[0], "region shouldn't be empty\n");
3428 ok(!region_isempty
[1], "region shouldn't be empty\n");
3429 ok(!region_isempty
[2], "region shouldn't be empty\n");
3430 ok(region_isempty
[3], "region should be empty\n");
3432 /* Cut off everything after the first space, and the second line. */
3433 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3434 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3436 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3441 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3445 ok(!region_isempty
[0], "region shouldn't be empty\n");
3446 ok(!region_isempty
[1], "region shouldn't be empty\n");
3447 ok(region_isempty
[2], "region should be empty\n");
3448 ok(region_isempty
[3], "region should be empty\n");
3451 GdipDeleteRegion(regions
[i
]);
3453 status
= GdipCreateMatrix(&identity
);
3460 memset(positions
, 0, sizeof(positions
));
3461 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3462 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3464 expect(InvalidParameter
, status
);
3466 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3467 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3469 expect(InvalidParameter
, status
);
3471 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3472 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3474 expect(InvalidParameter
, status
);
3476 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3477 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3479 expect(InvalidParameter
, status
);
3481 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3482 0x100, identity
, &rc
);
3485 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3486 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3490 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3491 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3493 expect(InvalidParameter
, status
);
3499 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3500 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3505 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3506 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3507 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3509 char_width
= rc
.Width
;
3510 char_height
= rc
.Height
;
3516 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3517 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3522 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3523 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3524 expectf(char_height
, rc
.Height
);
3530 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3531 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3536 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3537 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3538 expectf(rc
.Height
, char_height
);
3540 GdipDeleteMatrix(identity
);
3541 GdipDeleteStringFormat(format
);
3542 GdipDeleteBrush(brush
);
3543 GdipDeleteFont(font
);
3544 GdipDeleteFontFamily(family
);
3545 GdipDeleteGraphics(graphics
);
3547 ReleaseDC(hwnd
, hdc
);
3550 static void test_get_set_interpolation(void)
3552 GpGraphics
*graphics
;
3553 HDC hdc
= GetDC( hwnd
);
3555 InterpolationMode mode
;
3557 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3558 status
= GdipCreateFromHDC(hdc
, &graphics
);
3560 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3562 status
= GdipGetInterpolationMode(NULL
, &mode
);
3563 expect(InvalidParameter
, status
);
3567 /* Crashes on Windows XP */
3568 status
= GdipGetInterpolationMode(graphics
, NULL
);
3569 expect(InvalidParameter
, status
);
3572 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3573 expect(InvalidParameter
, status
);
3576 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3577 expect(InvalidParameter
, status
);
3579 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3580 expect(InvalidParameter
, status
);
3582 status
= GdipGetInterpolationMode(graphics
, &mode
);
3584 expect(InterpolationModeBilinear
, mode
);
3586 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3589 status
= GdipGetInterpolationMode(graphics
, &mode
);
3591 expect(InterpolationModeNearestNeighbor
, mode
);
3593 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3596 status
= GdipGetInterpolationMode(graphics
, &mode
);
3598 expect(InterpolationModeBilinear
, mode
);
3600 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3603 status
= GdipGetInterpolationMode(graphics
, &mode
);
3605 expect(InterpolationModeBilinear
, mode
);
3607 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3610 status
= GdipGetInterpolationMode(graphics
, &mode
);
3612 expect(InterpolationModeHighQualityBicubic
, mode
);
3614 GdipDeleteGraphics(graphics
);
3616 ReleaseDC(hwnd
, hdc
);
3619 static void test_get_set_textrenderinghint(void)
3621 GpGraphics
*graphics
;
3622 HDC hdc
= GetDC( hwnd
);
3624 TextRenderingHint hint
;
3626 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3627 status
= GdipCreateFromHDC(hdc
, &graphics
);
3629 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3631 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3632 expect(InvalidParameter
, status
);
3634 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3635 expect(InvalidParameter
, status
);
3637 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3638 expect(InvalidParameter
, status
);
3641 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3642 expect(InvalidParameter
, status
);
3644 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3646 expect(TextRenderingHintSystemDefault
, hint
);
3648 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3651 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3653 expect(TextRenderingHintSystemDefault
, hint
);
3655 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3658 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3660 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3662 GdipDeleteGraphics(graphics
);
3664 ReleaseDC(hwnd
, hdc
);
3667 static void test_getdc_scaled(void)
3670 GpGraphics
*graphics
= NULL
;
3671 GpBitmap
*bitmap
= NULL
;
3673 HBRUSH hbrush
, holdbrush
;
3676 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3679 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3682 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3685 status
= GdipGetDC(graphics
, &hdc
);
3687 ok(hdc
!= NULL
, "got NULL hdc\n");
3689 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3691 holdbrush
= SelectObject(hdc
, hbrush
);
3693 Rectangle(hdc
, 2, 2, 6, 6);
3695 SelectObject(hdc
, holdbrush
);
3697 DeleteObject(hbrush
);
3699 status
= GdipReleaseDC(graphics
, hdc
);
3702 GdipDeleteGraphics(graphics
);
3704 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3706 expect(0xffff0000, color
);
3708 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3710 expect(0xff000000, color
);
3712 GdipDisposeImage((GpImage
*)bitmap
);
3715 static void test_GdipMeasureString(void)
3717 static const struct test_data
3719 REAL res_x
, res_y
, page_scale
;
3723 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3724 { 200.0, 200.0, 2.0, UnitPixel
},
3725 { 200.0, 200.0, 1.0, UnitDisplay
},
3726 { 200.0, 200.0, 2.0, UnitDisplay
},
3727 { 200.0, 200.0, 1.0, UnitInch
},
3728 { 200.0, 200.0, 2.0, UnitInch
},
3729 { 200.0, 600.0, 1.0, UnitPoint
},
3730 { 200.0, 600.0, 2.0, UnitPoint
},
3731 { 200.0, 600.0, 1.0, UnitDocument
},
3732 { 200.0, 600.0, 2.0, UnitDocument
},
3733 { 200.0, 600.0, 1.0, UnitMillimeter
},
3734 { 200.0, 600.0, 2.0, UnitMillimeter
},
3735 { 200.0, 600.0, 1.0, UnitDisplay
},
3736 { 200.0, 600.0, 2.0, UnitDisplay
},
3737 { 200.0, 600.0, 1.0, UnitPixel
},
3738 { 200.0, 600.0, 2.0, UnitPixel
},
3740 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3741 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3743 GpGraphics
*graphics
;
3744 GpFontFamily
*family
;
3746 GpStringFormat
*format
;
3748 REAL base_cx
= 0, base_cy
= 0, height
;
3753 GpUnit font_unit
, unit
;
3755 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3757 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3760 /* font size in pixels */
3761 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3763 status
= GdipGetFontSize(font
, &font_size
);
3765 expectf(100.0, font_size
);
3766 status
= GdipGetFontUnit(font
, &font_unit
);
3768 expect(UnitPixel
, font_unit
);
3770 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3774 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3776 lf
.lfHeight
= 0xdeadbeef;
3777 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3779 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3780 if (td
[i
].unit
!= UnitDisplay
)
3781 height
*= td
[i
].page_scale
;
3782 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3783 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3785 height
= font_size
+ 2.0 * font_size
/ 6.0;
3787 set_rect_empty(&rc
);
3788 set_rect_empty(&bounds
);
3789 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3794 base_cx
= bounds
.Width
;
3795 base_cy
= bounds
.Height
;
3798 expectf(0.0, bounds
.X
);
3799 expectf(0.0, bounds
.Y
);
3801 expectf_(height
, bounds
.Height
, height
/ 100.0);
3802 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3806 /* make sure it really fits */
3807 bounds
.Width
+= 1.0;
3808 bounds
.Height
+= 1.0;
3812 set_rect_empty(&bounds
);
3813 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3815 expectf(50.0, bounds
.X
);
3816 expectf(50.0, bounds
.Y
);
3818 expectf_(height
, bounds
.Height
, height
/ 100.0);
3819 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3823 status
= GdipDeleteGraphics(graphics
);
3826 status
= GdipDisposeImage(image
);
3830 GdipDeleteFont(font
);
3832 /* font size in logical units */
3833 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3834 for (unit
= 3; unit
<= 6; unit
++)
3836 /* create a font which final height is 100.0 pixels with 200 dpi device */
3837 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3838 height
= pixels_to_units(75.0, unit
, 200.0);
3839 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3841 status
= GdipGetFontSize(font
, &font_size
);
3843 expectf(height
, font_size
);
3844 status
= GdipGetFontUnit(font
, &font_unit
);
3846 expect(unit
, font_unit
);
3848 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3853 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3855 lf
.lfHeight
= 0xdeadbeef;
3856 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3858 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3859 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3861 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3862 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3863 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3864 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3866 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3867 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3869 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3870 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3871 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3872 if (td
[i
].unit
!= UnitDisplay
)
3873 height
/= td
[i
].page_scale
;
3874 /*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);*/
3876 set_rect_empty(&rc
);
3877 set_rect_empty(&bounds
);
3878 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3883 base_cx
= bounds
.Width
;
3884 base_cy
= bounds
.Height
;
3887 expectf(0.0, bounds
.X
);
3888 expectf(0.0, bounds
.Y
);
3890 expectf_(height
, bounds
.Height
, height
/ 85.0);
3891 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3895 /* make sure it really fits */
3896 bounds
.Width
+= 1.0;
3897 bounds
.Height
+= 1.0;
3901 set_rect_empty(&bounds
);
3902 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3904 expectf(50.0, bounds
.X
);
3905 expectf(50.0, bounds
.Y
);
3907 expectf_(height
, bounds
.Height
, height
/ 85.0);
3908 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3912 /* verify the result */
3913 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3914 if (td
[i
].unit
!= UnitDisplay
)
3915 height
*= td
[i
].page_scale
;
3916 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3917 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3919 expectf_(100.0, height
, 1.1);
3921 status
= GdipDeleteGraphics(graphics
);
3924 status
= GdipDisposeImage(image
);
3928 GdipDeleteFont(font
);
3931 /* Font with units = UnitWorld */
3932 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
3934 GpPointF pt
= {0.0, 100.0};
3936 REAL expected_width
, expected_height
;
3938 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3940 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3943 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3946 status
= GdipGetFontUnit(font
, &font_unit
);
3948 expect(UnitWorld
, font_unit
);
3950 lf
.lfHeight
= 0xdeadbeef;
3951 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3953 ok(lf
.lfHeight
== -100, "%u: expected -100, got %d\n", i
, lf
.lfHeight
);
3955 set_rect_empty(&rc
);
3956 set_rect_empty(&bounds
);
3957 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3962 base_cx
= bounds
.Width
;
3963 base_cy
= bounds
.Height
;
3969 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3972 /* height is constant in device space, width is proportional to height in world space */
3973 expected_width
= base_cx
* pt
.Y
;
3974 expected_height
= base_cy
* pt
.Y
;
3976 todo_wine_if(td
[i
].unit
!= UnitDisplay
&& td
[i
].unit
!= UnitPixel
)
3977 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3978 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3980 GdipDeleteGraphics(graphics
);
3981 GdipDisposeImage(image
);
3982 GdipDeleteFont(font
);
3985 GdipDeleteFontFamily(family
);
3986 GdipDeleteStringFormat(format
);
3989 static void test_transform(void)
3991 static const struct test_data
3993 REAL res_x
, res_y
, scale
;
3995 GpPointF in
[2], out
[2];
3998 { 96.0, 96.0, 1.0, UnitPixel
,
3999 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4000 { 96.0, 96.0, 1.0, UnitDisplay
,
4001 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4002 { 96.0, 96.0, 1.0, UnitInch
,
4003 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
4004 { 123.0, 456.0, 1.0, UnitPoint
,
4005 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
4006 { 123.0, 456.0, 1.0, UnitDocument
,
4007 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
4008 { 123.0, 456.0, 2.0, UnitMillimeter
,
4009 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
4010 { 196.0, 296.0, 1.0, UnitDisplay
,
4011 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4012 { 196.0, 296.0, 1.0, UnitPixel
,
4013 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
4016 GpGraphics
*graphics
;
4021 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
4023 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
4024 ptf
[0].X
= td
[i
].in
[0].X
;
4025 ptf
[0].Y
= td
[i
].in
[0].Y
;
4026 ptf
[1].X
= td
[i
].in
[1].X
;
4027 ptf
[1].Y
= td
[i
].in
[1].Y
;
4028 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
4030 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
4031 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
4032 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
4033 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
4034 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4036 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
4037 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
4038 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
4039 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
4040 status
= GdipDeleteGraphics(graphics
);
4042 status
= GdipDisposeImage(image
);
4047 static void test_pen_thickness(void)
4049 static const struct test_data
4051 REAL res_x
, res_y
, scale
;
4052 GpUnit pen_unit
, page_unit
;
4054 INT cx
, cy
, path_cx
, path_cy
;
4057 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1, 1, 1 },
4058 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.0, 0, 0, 1, 1 },
4059 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.1, 1, 1, 1, 1 },
4060 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2, 2, 2 },
4061 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1, 1, 1 },
4062 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1, 1, 1 },
4063 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 0.0, 1, 1, 1, 1 },
4064 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6, 6, 6 },
4065 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20, 20, 20 },
4069 GpGraphics
*graphics
;
4081 for (i
= 0; i
< ARRAY_SIZE(td
); i
++)
4083 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
4086 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
4089 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
4092 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
4095 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
4098 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
4101 corner
.X
= corner
.Y
= 100.0;
4102 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
4105 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4108 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4111 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4117 for (j
=0; j
<100; j
++)
4119 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4126 for (j
=99; j
>=0; j
--)
4128 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4137 ok(size
== td
[i
].cx
, "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
4142 for (j
=0; j
<100; j
++)
4144 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4151 for (j
=99; j
>=0; j
--)
4153 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4162 ok(size
== td
[i
].cy
, "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
4164 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4167 status
= GdipGraphicsClear(graphics
, 0xff000000);
4170 status
= GdipCreatePath(FillModeAlternate
, &path
);
4173 status
= GdipAddPathLine(path
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4176 status
= GdipClosePathFigure(path
);
4179 status
= GdipAddPathLine(path
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4182 status
= GdipDrawPath(graphics
, pen
, path
);
4185 GdipDeletePath(path
);
4187 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4193 for (j
=0; j
<100; j
++)
4195 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4202 for (j
=99; j
>=0; j
--)
4204 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4213 ok(size
== td
[i
].path_cx
, "%u: expected %d, got %d\n", i
, td
[i
].path_cx
, size
);
4218 for (j
=0; j
<100; j
++)
4220 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4227 for (j
=99; j
>=0; j
--)
4229 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4238 ok(size
== td
[i
].path_cy
, "%u: expected %d, got %d\n", i
, td
[i
].path_cy
, size
);
4240 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4244 GdipDeleteGraphics(graphics
);
4245 GdipDisposeImage(u
.image
);
4249 /* Many people on the net ask why there is so much difference in rendered
4250 * text height between gdiplus and gdi32, this test suggests an answer to
4251 * that question. Important: this test assumes that font dpi == device dpi.
4253 static void test_font_height_scaling(void)
4255 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4256 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
4258 GpStringFormat
*format
;
4259 CharacterRange range
= { 0, 7 };
4261 GpGraphics
*graphics
;
4262 GpFontFamily
*family
;
4266 REAL height
, dpi
, scale
;
4268 GpUnit gfx_unit
, font_unit
;
4270 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4272 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4274 status
= GdipCreateRegion(®ion
);
4277 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4280 hdc
= CreateCompatibleDC(0);
4281 status
= GdipCreateFromHDC(hdc
, &graphics
);
4284 status
= GdipGetDpiY(graphics
, &dpi
);
4287 /* First check if tested functionality works:
4288 * under XP if font and graphics units differ then GdipTransformPoints
4289 * followed by GdipSetPageUnit to change the graphics units breaks region
4290 * scaling in GdipMeasureCharacterRanges called later.
4292 status
= GdipSetPageUnit(graphics
, UnitDocument
);
4297 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4300 status
= GdipSetPageUnit(graphics
, UnitInch
);
4303 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
4306 set_rect_empty(&rect
);
4307 set_rect_empty(&bounds
);
4308 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4310 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4312 set_rect_empty(&rect
);
4313 rect
.Width
= 32000.0;
4314 rect
.Height
= 32000.0;
4315 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4318 set_rect_empty(&rect
);
4319 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4321 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4323 GdipDeleteFont(font
);
4325 scale
= rect
.Height
/ bounds
.Height
;
4326 if (fabs(scale
- 1.0) > 0.1)
4328 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4332 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4335 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4336 /* UnitPixel as a font base unit is not tested because it drastically
4337 differs in behaviour */
4338 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4340 /* create a font for the final text height of 100 pixels */
4341 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4342 status
= GdipSetPageUnit(graphics
, font_unit
);
4346 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4349 /*trace("height %f units\n", height);*/
4350 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4353 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4354 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4356 static const WCHAR doubleW
[2] = { 'W','W' };
4357 RectF bounds_1
, bounds_2
;
4358 REAL margin
, margin_y
, font_height
;
4361 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4364 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4365 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4367 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4370 set_rect_empty(&rect
);
4371 set_rect_empty(&bounds
);
4372 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4374 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4376 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4379 ptf
.Y
= bounds
.Height
;
4380 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4382 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4384 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4386 /* verify the result */
4387 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4389 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4391 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4393 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4394 set_rect_empty(&rect
);
4395 set_rect_empty(&bounds_1
);
4396 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4398 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4399 set_rect_empty(&rect
);
4400 set_rect_empty(&bounds_2
);
4401 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4404 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4405 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4406 /*trace("margin %f\n", margin);*/
4407 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4409 set_rect_empty(&rect
);
4410 rect
.Width
= 320000.0;
4411 rect
.Height
= 320000.0;
4412 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4414 set_rect_empty(&rect
);
4415 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4417 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4418 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4419 expectf(0.0, rect
.Y
);
4420 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4421 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4422 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4423 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4424 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4425 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4428 GdipDeleteFont(font
);
4432 status
= GdipDeleteGraphics(graphics
);
4436 GdipDeleteFontFamily(family
);
4437 GdipDeleteRegion(region
);
4438 GdipDeleteStringFormat(format
);
4441 static void test_measure_string(void)
4443 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4444 static const WCHAR string
[] = { 'A','0','1',0 };
4446 GpStringFormat
*format
;
4447 CharacterRange range
;
4449 GpGraphics
*graphics
;
4450 GpFontFamily
*family
;
4454 REAL width
, height
, width_1
, width_2
;
4455 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4458 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4462 status
= GdipCreateRegion(®ion
);
4465 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4468 hdc
= CreateCompatibleDC(0);
4469 status
= GdipCreateFromHDC(hdc
, &graphics
);
4471 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4474 margin_x
= 20.0 / 6.0;
4475 margin_y
= 20.0 / 8.0;
4477 set_rect_empty(&rect
);
4478 set_rect_empty(&bounds
);
4479 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4483 expectf(0.0, bounds
.X
);
4484 expectf(0.0, bounds
.Y
);
4485 width
= bounds
.Width
;
4486 height
= bounds
.Height
;
4488 set_rect_empty(&rect
);
4489 rect
.Height
= height
/ 2.0;
4490 set_rect_empty(&bounds
);
4491 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4495 expectf(0.0, bounds
.X
);
4496 expectf(0.0, bounds
.Y
);
4497 expectf(width
, bounds
.Width
);
4499 expectf(height
/ 2.0, bounds
.Height
);
4502 range
.Length
= lstrlenW(string
);
4503 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4508 rect
.Width
= 32000.0;
4509 rect
.Height
= 32000.0;
4510 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4512 set_rect_empty(&bounds
);
4513 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4515 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4516 expectf(5.0, bounds
.Y
);
4517 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4519 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4521 width_rgn
= bounds
.Width
;
4522 height_rgn
= bounds
.Height
;
4526 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4529 set_rect_empty(&rect
);
4530 rect
.Width
= 32000.0;
4531 rect
.Height
= 32000.0;
4532 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4534 set_rect_empty(&bounds
);
4535 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4537 expectf_(margin_x
, bounds
.X
, 1.0);
4538 expectf(0.0, bounds
.Y
);
4539 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4540 expectf(height_rgn
, bounds
.Height
);
4541 width_1
= bounds
.Width
;
4544 range
.Length
= lstrlenW(string
);
4545 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4552 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4554 set_rect_empty(&bounds
);
4555 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4557 expectf(0.0, bounds
.X
);
4558 expectf(0.0, bounds
.Y
);
4559 expectf(0.0, bounds
.Width
);
4560 expectf(0.0, bounds
.Height
);
4564 rect
.Width
= width_rgn
/ 2.0;
4565 rect
.Height
= 32000.0;
4566 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4568 set_rect_empty(&bounds
);
4569 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4571 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4572 expectf(5.0, bounds
.Y
);
4573 expectf_(width_1
, bounds
.Width
, 1.0);
4575 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4577 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4583 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4585 set_rect_empty(&bounds
);
4586 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4588 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4589 expectf(5.0, bounds
.Y
);
4590 expectf(width_rgn
, bounds
.Width
);
4591 expectf(height_rgn
, bounds
.Height
);
4595 rect
.Width
= width_rgn
/ 2.0;
4596 rect
.Height
= 32000.0;
4597 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4599 set_rect_empty(&bounds
);
4600 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4602 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4603 expectf(5.0, bounds
.Y
);
4604 expectf_(width_1
, bounds
.Width
, 1.0);
4605 expectf(height_rgn
, bounds
.Height
);
4607 set_rect_empty(&rect
);
4608 rect
.Height
= height
/ 2.0;
4609 set_rect_empty(&bounds
);
4610 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4614 expectf(0.0, bounds
.X
);
4615 expectf(0.0, bounds
.Y
);
4616 expectf_(width
, bounds
.Width
, 0.01);
4618 expectf(height
, bounds
.Height
);
4620 set_rect_empty(&rect
);
4621 set_rect_empty(&bounds
);
4622 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4626 expectf(0.0, bounds
.X
);
4627 expectf(0.0, bounds
.Y
);
4628 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4629 expectf(height
, bounds
.Height
);
4630 width_1
= bounds
.Width
;
4632 set_rect_empty(&rect
);
4633 set_rect_empty(&bounds
);
4634 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4638 expectf(0.0, bounds
.X
);
4639 expectf(0.0, bounds
.Y
);
4640 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4641 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4642 expectf(height
, bounds
.Height
);
4643 width_2
= bounds
.Width
;
4645 set_rect_empty(&rect
);
4646 rect
.Width
= width
/ 2.0;
4647 set_rect_empty(&bounds
);
4648 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4652 expectf(0.0, bounds
.X
);
4653 expectf(0.0, bounds
.Y
);
4654 expectf_(width_1
, bounds
.Width
, 0.01);
4655 expectf(height
, bounds
.Height
);
4657 set_rect_empty(&rect
);
4658 rect
.Height
= height
;
4659 rect
.Width
= width
- 0.05;
4660 set_rect_empty(&bounds
);
4661 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4665 expectf(0.0, bounds
.X
);
4666 expectf(0.0, bounds
.Y
);
4667 expectf_(width_2
, bounds
.Width
, 0.01);
4668 expectf(height
, bounds
.Height
);
4670 set_rect_empty(&rect
);
4671 rect
.Height
= height
;
4672 rect
.Width
= width_2
- 0.05;
4673 set_rect_empty(&bounds
);
4674 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4678 expectf(0.0, bounds
.X
);
4679 expectf(0.0, bounds
.Y
);
4680 expectf_(width_1
, bounds
.Width
, 0.01);
4681 expectf(height
, bounds
.Height
);
4683 /* Default (Near) alignment */
4686 rect
.Width
= width
* 2.0;
4687 rect
.Height
= height
* 2.0;
4688 set_rect_empty(&bounds
);
4689 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4693 expectf(5.0, bounds
.X
);
4694 expectf(5.0, bounds
.Y
);
4695 expectf_(width
, bounds
.Width
, 0.01);
4696 expectf(height
, bounds
.Height
);
4700 rect
.Width
= 32000.0;
4701 rect
.Height
= 32000.0;
4702 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4704 set_rect_empty(&bounds
);
4705 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4707 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4708 expectf(5.0, bounds
.Y
);
4709 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4711 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4713 width_rgn
= bounds
.Width
;
4714 height_rgn
= bounds
.Height
;
4716 /* Center alignment */
4717 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4718 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4722 rect
.Width
= width
* 2.0;
4723 rect
.Height
= height
* 2.0;
4724 set_rect_empty(&bounds
);
4725 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4730 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4732 expectf(5.0 + height
/2.0, bounds
.Y
);
4733 expectf_(width
, bounds
.Width
, 0.01);
4734 expectf(height
, bounds
.Height
);
4740 set_rect_empty(&bounds
);
4741 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4746 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4748 expectf(5.0 - height
/2.0, bounds
.Y
);
4749 expectf_(width
, bounds
.Width
, 0.01);
4750 expectf(height
, bounds
.Height
);
4754 rect
.Width
= width_rgn
* 2.0;
4755 rect
.Height
= height_rgn
* 2.0;
4756 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4758 set_rect_empty(&bounds
);
4759 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4762 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4764 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4765 expectf_(width_rgn
, bounds
.Width
, 1.0);
4766 expectf_(height_rgn
, bounds
.Height
, 1.0);
4772 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4774 set_rect_empty(&bounds
);
4775 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4778 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4780 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4781 expectf_(width_rgn
, bounds
.Width
, 1.0);
4782 expectf_(height_rgn
, bounds
.Height
, 1.0);
4785 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4786 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4790 rect
.Width
= width
* 2.0;
4791 rect
.Height
= height
* 2.0;
4792 set_rect_empty(&bounds
);
4793 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4798 expectf_(5.0 + width
, bounds
.X
, 0.01);
4800 expectf(5.0 + height
, bounds
.Y
);
4801 expectf_(width
, bounds
.Width
, 0.01);
4802 expectf(height
, bounds
.Height
);
4808 set_rect_empty(&bounds
);
4809 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4814 expectf_(5.0 - width
, bounds
.X
, 0.01);
4816 expectf(5.0 - height
, bounds
.Y
);
4817 expectf_(width
, bounds
.Width
, 0.01);
4818 expectf(height
, bounds
.Height
);
4822 rect
.Width
= width_rgn
* 2.0;
4823 rect
.Height
= height_rgn
* 2.0;
4824 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4826 set_rect_empty(&bounds
);
4827 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4830 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4832 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4833 expectf_(width_rgn
, bounds
.Width
, 1.0);
4834 expectf_(height_rgn
, bounds
.Height
, 1.0);
4840 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4842 set_rect_empty(&bounds
);
4843 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4846 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4848 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4849 expectf_(width_rgn
, bounds
.Width
, 1.0);
4850 expectf_(height_rgn
, bounds
.Height
, 1.0);
4852 status
= GdipDeleteFont(font
);
4855 status
= GdipDeleteGraphics(graphics
);
4859 GdipDeleteFontFamily(family
);
4860 GdipDeleteRegion(region
);
4861 GdipDeleteStringFormat(format
);
4864 static void test_measured_extra_space(void)
4866 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4867 static const WCHAR string
[2] = { 'W','W' };
4868 GpStringFormat
*format
;
4870 GpGraphics
*graphics
;
4871 GpFontFamily
*family
;
4874 GpUnit gfx_unit
, font_unit
;
4875 RectF bounds_1
, bounds_2
, rect
;
4876 REAL margin
, font_size
, dpi
;
4878 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4881 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4883 hdc
= CreateCompatibleDC(0);
4884 status
= GdipCreateFromHDC(hdc
, &graphics
);
4887 status
= GdipGetDpiX(graphics
, &dpi
);
4890 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4891 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4892 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4894 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4897 status
= GdipGetFontSize(font
, &font_size
);
4899 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4900 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4902 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4903 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4905 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4908 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4909 set_rect_empty(&rect
);
4910 set_rect_empty(&bounds_1
);
4911 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4913 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4914 set_rect_empty(&rect
);
4915 set_rect_empty(&bounds_2
);
4916 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4919 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4920 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4921 /*trace("margin %f pixels\n", margin);*/
4922 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4925 GdipDeleteFont(font
);
4928 GdipDeleteGraphics(graphics
);
4930 GdipDeleteFontFamily(family
);
4931 GdipDeleteStringFormat(format
);
4934 static void test_alpha_hdc(void)
4938 HBITMAP hbm
, old_hbm
;
4939 GpGraphics
*graphics
;
4945 hdc
= CreateCompatibleDC(0);
4946 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4947 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4948 bmi
.bmiHeader
.biHeight
= 5;
4949 bmi
.bmiHeader
.biWidth
= 5;
4950 bmi
.bmiHeader
.biBitCount
= 32;
4951 bmi
.bmiHeader
.biPlanes
= 1;
4952 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4953 bmi
.bmiHeader
.biClrUsed
= 0;
4955 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4956 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4958 old_hbm
= SelectObject(hdc
, hbm
);
4960 status
= GdipCreateFromHDC(hdc
, &graphics
);
4963 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4965 expectf(0.0, bounds
.X
);
4966 expectf(0.0, bounds
.Y
);
4967 expectf(5.0, bounds
.Width
);
4968 expectf(5.0, bounds
.Height
);
4970 bits
[0] = 0xdeadbeef;
4972 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4975 expect(0xffaaaaaa, bits
[0]);
4977 bits
[0] = 0xdeadbeef;
4979 status
= GdipGetDC(graphics
, &gp_hdc
);
4982 colorref
= GetPixel(gp_hdc
, 0, 4);
4983 expect(0xefbead, colorref
);
4985 SetPixel(gp_hdc
, 0, 4, 0xffffff);
4987 expect(0xffffff, bits
[0]);
4989 status
= GdipReleaseDC(graphics
, gp_hdc
);
4992 SelectObject(hdc
, old_hbm
);
4994 bits
[0] = 0xdeadbeef;
4996 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4999 todo_wine
expect(0xffbbbbbb, bits
[0]);
5001 GdipDeleteGraphics(graphics
);
5007 static void test_bitmapfromgraphics(void)
5010 GpGraphics
*graphics
= NULL
;
5011 HDC hdc
= GetDC( hwnd
);
5012 GpBitmap
*bitmap
= NULL
;
5014 REAL imageres
, graphicsres
;
5017 stat
= GdipCreateFromHDC(hdc
, &graphics
);
5020 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
5021 expect(InvalidParameter
, stat
);
5023 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
5024 expect(InvalidParameter
, stat
);
5026 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
5029 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
5031 expect(PixelFormat32bppPARGB
, format
);
5033 stat
= GdipGetDpiX(graphics
, &graphicsres
);
5036 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
5038 expectf(graphicsres
, imageres
);
5040 stat
= GdipGetDpiY(graphics
, &graphicsres
);
5043 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
5045 expectf(graphicsres
, imageres
);
5047 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
5051 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
5055 GdipDeleteGraphics(graphics
);
5056 GdipDisposeImage((GpImage
*)bitmap
);
5059 static void test_clipping(void)
5063 GpGraphics
*graphics
;
5064 GpRegion
*region
, *region100x100
;
5073 hdc
= CreateCompatibleDC(0);
5074 status
= GdipCreateFromHDC(hdc
, &graphics
);
5077 status
= GdipGetPageUnit(graphics
, &unit
);
5079 expect(UnitDisplay
, unit
);
5081 status
= GdipCreateRegion(®ion
);
5083 status
= GdipSetEmpty(region
);
5086 status
= GdipCreateRegion(®ion100x100
);
5088 status
= GdipSetEmpty(region100x100
);
5091 rect
.X
= rect
.Y
= 100.0;
5092 rect
.Width
= rect
.Height
= 100.0;
5093 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
5095 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
5098 status
= GdipGetClipBounds(graphics
, &rect
);
5100 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5101 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5103 /* Clip region does not account for changes to gdi32 transform */
5104 SetViewportOrgEx(hdc
, 10, 10, NULL
);
5106 status
= GdipGetClipBounds(graphics
, &rect
);
5108 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5109 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5111 SetViewportOrgEx(hdc
, 0, 0, NULL
);
5113 status
= GdipSetEmpty(region
);
5115 status
= GdipGetClip(graphics
, region
);
5117 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5119 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5120 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5126 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5128 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5129 "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
);
5131 status
= GdipCreateMatrix(&matrix
);
5133 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
5135 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
5137 status
= GdipSetWorldTransform(graphics
, matrix
);
5140 status
= GdipGetClipBounds(graphics
, &rect
);
5142 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5143 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5145 status
= GdipSetEmpty(region
);
5147 status
= GdipGetClip(graphics
, region
);
5149 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5151 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5152 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5154 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5156 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5157 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5159 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5161 ret
= GetRgnBox(hrgn
, &rc
);
5162 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5163 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5164 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5167 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5169 ret
= GetRgnBox(hrgn
, &rc
);
5170 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5171 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5172 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5179 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5181 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5182 "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
);
5184 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5186 ret
= GetRgnBox(hrgn
, &rc
);
5187 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5188 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5189 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5192 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5194 ret
= GetRgnBox(hrgn
, &rc
);
5195 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5196 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5197 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5204 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5206 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5207 "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
);
5209 status
= GdipSetPageScale(graphics
, 2.0);
5212 status
= GdipGetClipBounds(graphics
, &rect
);
5214 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5215 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5217 status
= GdipSetEmpty(region
);
5219 status
= GdipGetClip(graphics
, region
);
5221 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5223 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5224 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5226 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5228 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5229 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5231 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5233 ret
= GetRgnBox(hrgn
, &rc
);
5234 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5235 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5236 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5239 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5241 ret
= GetRgnBox(hrgn
, &rc
);
5242 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5243 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5244 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5251 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5253 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5254 "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
);
5256 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5258 ret
= GetRgnBox(hrgn
, &rc
);
5259 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5260 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5261 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5264 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5266 ret
= GetRgnBox(hrgn
, &rc
);
5267 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5268 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5269 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5276 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5278 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5279 "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
);
5281 GdipSetPageUnit(graphics
, UnitPoint
);
5284 status
= GdipGetClipBounds(graphics
, &rect
);
5286 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5287 /* rounding under Wine is slightly different */
5288 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5289 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5290 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5292 status
= GdipSetEmpty(region
);
5294 status
= GdipGetClip(graphics
, region
);
5296 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5298 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5299 /* rounding under Wine is slightly different */
5300 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5301 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5302 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5304 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5306 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5307 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5309 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5311 ret
= GetRgnBox(hrgn
, &rc
);
5312 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5313 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
5314 /* rounding under Wine is slightly different */
5315 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
5316 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
5317 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc
));
5320 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5322 ret
= GetRgnBox(hrgn
, &rc
);
5323 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5324 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5325 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5326 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5333 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5335 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5336 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5337 "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
);
5339 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5341 ret
= GetRgnBox(hrgn
, &rc
);
5342 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5343 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5344 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5347 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5349 ret
= GetRgnBox(hrgn
, &rc
);
5350 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5351 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5352 /* rounding under Wine is slightly different */
5353 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5354 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc
));
5361 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5363 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5365 expectf(100.0, ptf
[0].X
);
5366 expectf(100.0, ptf
[0].Y
);
5367 expectf(200.125, ptf
[1].X
);
5368 expectf(200.03125, ptf
[1].Y
);
5370 else /* before Win7 */
5372 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5373 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5374 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5375 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5378 status
= GdipTransformRegion(region100x100
, matrix
);
5381 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5383 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5384 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5386 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5388 ret
= GetRgnBox(hrgn
, &rc
);
5389 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5390 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5391 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5394 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5396 ret
= GetRgnBox(hrgn
, &rc
);
5397 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5398 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5399 /* rounding under Wine is slightly different */
5400 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5401 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc
));
5408 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5410 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5412 expectf(210.0625, ptf
[0].X
);
5413 expectf(420.0625, ptf
[0].Y
);
5414 expectf(410.125, ptf
[1].X
);
5415 expectf(820.0, ptf
[1].Y
);
5417 else /* before Win7 */
5419 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5420 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5421 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5422 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5425 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5427 status
= GdipSetWorldTransform(graphics
, matrix
);
5430 status
= GdipGetClipBounds(graphics
, &rect
);
5432 expectf_(20.612978, rect
.X
, 1.0);
5433 expectf_(-6.256012, rect
.Y
, 1.5);
5434 expectf_(25.612978, rect
.Width
, 1.0);
5435 expectf_(12.806489, rect
.Height
, 1.0);
5437 status
= GdipSetEmpty(region
);
5439 status
= GdipGetClip(graphics
, region
);
5441 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5443 /* rounding under Wine is slightly different */
5444 expectf_(20.612978, rect
.X
, 1.0);
5445 expectf_(-6.256012, rect
.Y
, 1.5);
5446 expectf_(25.612978, rect
.Width
, 1.0);
5447 expectf_(12.806489, rect
.Height
, 1.0);
5449 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5451 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5452 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5454 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5456 ret
= GetRgnBox(hrgn
, &rc
);
5457 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5458 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5459 /* rounding under Wine is slightly different */
5460 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5461 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc
));
5464 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5466 ret
= GetRgnBox(hrgn
, &rc
);
5467 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5468 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5469 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5480 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5482 expectf(20.612978, ptf
[0].X
);
5483 expectf(-1.568512, ptf
[0].Y
);
5484 expectf(46.225956, ptf
[1].X
);
5485 expectf(1.862977, ptf
[1].Y
);
5486 expectf(36.850956, ptf
[2].X
);
5487 expectf(-6.256012, ptf
[2].Y
);
5488 expectf(29.987980, ptf
[3].X
);
5489 expectf(6.550478, ptf
[3].Y
);
5491 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5493 ret
= GetRgnBox(hrgn
, &rc
);
5494 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5495 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5496 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5499 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5501 ret
= GetRgnBox(hrgn
, &rc
);
5502 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5503 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5504 /* rounding under Wine is slightly different */
5505 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5506 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc
));
5517 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5519 expectf(-136.190491, ptf
[0].X
);
5520 expectf(520.010742, ptf
[0].Y
);
5521 expectf(756.417175, ptf
[1].X
);
5522 expectf(720.031616, ptf
[1].Y
);
5523 expectf(360.042114, ptf
[2].X
);
5524 expectf(376.760742, ptf
[2].Y
);
5525 expectf(260.184570, ptf
[3].X
);
5526 expectf(863.281616, ptf
[3].Y
);
5528 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5530 status
= GdipSetWorldTransform(graphics
, matrix
);
5533 status
= GdipGetClipBounds(graphics
, &rect
);
5535 expectf_(-28.100956, rect
.X
, 1.0);
5536 expectf_(7.806488, rect
.Y
, 1.5);
5537 expectf_(25.612978, rect
.Width
, 1.0);
5538 expectf_(12.806489, rect
.Height
, 1.0);
5540 status
= GdipSetEmpty(region
);
5542 status
= GdipGetClip(graphics
, region
);
5544 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5546 /* rounding under Wine is slightly different */
5547 expectf_(-28.100956, rect
.X
, 1.0);
5548 expectf_(7.806488, rect
.Y
, 1.5);
5549 expectf_(25.612978, rect
.Width
, 1.0);
5550 expectf_(12.806489, rect
.Height
, 1.0);
5552 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5554 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5555 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5557 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5559 ret
= GetRgnBox(hrgn
, &rc
);
5560 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5561 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5562 /* rounding under Wine is slightly different */
5563 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5564 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc
));
5567 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5569 ret
= GetRgnBox(hrgn
, &rc
);
5570 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5571 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5572 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5583 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5585 expectf(-11.862979, ptf
[0].X
);
5586 expectf(7.806488, ptf
[0].Y
);
5587 expectf(-18.725958, ptf
[1].X
);
5588 expectf(20.612976, ptf
[1].Y
);
5589 expectf(-2.487981, ptf
[2].X
);
5590 expectf(15.925477, ptf
[2].Y
);
5591 expectf(-28.100956, ptf
[3].X
);
5592 expectf(12.493987, ptf
[3].Y
);
5594 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5596 ret
= GetRgnBox(hrgn
, &rc
);
5597 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5598 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5599 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5602 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5604 ret
= GetRgnBox(hrgn
, &rc
);
5605 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5606 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5607 /* rounding under Wine is slightly different */
5608 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5609 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc
));
5620 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5622 expectf(-1055.021484, ptf
[0].X
);
5623 expectf(-70.595329, ptf
[0].Y
);
5624 expectf(-1455.063232, ptf
[1].X
);
5625 expectf(375.708435, ptf
[1].Y
);
5626 expectf(-768.521484, ptf
[2].X
);
5627 expectf(177.520981, ptf
[2].Y
);
5628 expectf(-1741.563110, ptf
[3].X
);
5629 expectf(127.592125, ptf
[3].Y
);
5631 GdipDeleteMatrix(matrix
);
5632 GdipDeleteRegion(region
);
5633 GdipDeleteRegion(region100x100
);
5634 GdipDeleteGraphics(graphics
);
5638 static void test_clipping_2(void)
5643 GpGraphics
*graphics
;
5653 hdc
= CreateCompatibleDC(0);
5654 status
= GdipCreateFromHDC(hdc
, &graphics
);
5657 status
= GdipGetPageUnit(graphics
, &unit
);
5659 expect(UnitDisplay
, unit
);
5661 GdipSetPageUnit(graphics
, UnitInch
);
5663 status
= GdipCreateRegion(®ion
);
5665 status
= GdipSetEmpty(region
);
5667 rect
.X
= rect
.Y
= 100.0;
5668 rect
.Width
= rect
.Height
= 100.0;
5669 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5671 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5674 status
= GdipGetClip(graphics
, region
);
5676 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5678 ret
= GetRgnBox(hrgn
, &rc
);
5679 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5680 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5681 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5683 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5685 ret
= GetRgnBox(hrgn
, &rc
);
5686 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5687 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5688 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5695 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5697 expectf(100.0, ptf
[0].X
);
5698 expectf(100.0, ptf
[0].Y
);
5699 expectf(200.0, ptf
[1].X
);
5700 expectf(200.0, ptf
[1].X
);
5702 GdipSetPageUnit(graphics
, UnitPoint
);
5704 status
= GdipGetClip(graphics
, region
);
5706 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5708 ret
= GetRgnBox(hrgn
, &rc
);
5709 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5710 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5711 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5712 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc
));
5714 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5716 ret
= GetRgnBox(hrgn
, &rc
);
5717 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5718 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5719 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5720 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5727 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5729 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5730 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5731 "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
);
5732 else /* before Win7 */
5734 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5735 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5736 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5737 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5740 GdipDeleteRegion(region
);
5742 GdipSetPageUnit(graphics
, UnitPixel
);
5744 status
= GdipCreateRegion(®ion
);
5746 status
= GdipSetEmpty(region
);
5748 rect
.X
= rect
.Y
= 100.0;
5749 rect
.Width
= rect
.Height
= 100.0;
5750 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5752 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5755 status
= GdipGetClip(graphics
, region
);
5757 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5759 ret
= GetRgnBox(hrgn
, &rc
);
5760 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5761 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5762 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5763 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5765 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5767 ret
= GetRgnBox(hrgn
, &rc
);
5768 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5769 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5770 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5771 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5778 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5780 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5781 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5782 "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
);
5783 else /* before Win7 */
5785 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5786 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5787 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5788 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5791 GdipSetPageUnit(graphics
, UnitPoint
);
5793 status
= GdipGetClip(graphics
, region
);
5795 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5797 ret
= GetRgnBox(hrgn
, &rc
);
5798 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5799 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5800 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5801 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc
));
5803 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5805 ret
= GetRgnBox(hrgn
, &rc
);
5806 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5807 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5808 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5809 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5816 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5818 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5819 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5820 "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
);
5821 else /* before Win7 */
5823 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5824 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5825 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5826 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5829 status
= GdipCreateMatrix(&matrix
);
5831 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5833 status
= GdipSetWorldTransform(graphics
, matrix
);
5835 GdipDeleteMatrix(matrix
);
5837 status
= GdipGetClip(graphics
, region
);
5839 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5841 ret
= GetRgnBox(hrgn
, &rc
);
5842 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5843 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5844 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc
));
5846 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5848 ret
= GetRgnBox(hrgn
, &rc
);
5849 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5850 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5851 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5858 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5860 expectf(65.0, ptf
[0].X
);
5861 expectf(65.0, ptf
[0].Y
);
5862 expectf(140.0, ptf
[1].X
);
5863 expectf(140.0, ptf
[1].X
);
5865 status
= GdipCreateMatrix(&matrix
);
5867 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5869 status
= GdipSetWorldTransform(graphics
, matrix
);
5871 GdipDeleteMatrix(matrix
);
5873 status
= GdipGetClip(graphics
, region
);
5875 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5877 ret
= GetRgnBox(hrgn
, &rc
);
5878 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5879 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5880 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc
));
5882 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5884 ret
= GetRgnBox(hrgn
, &rc
);
5885 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5886 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5887 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5894 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5896 expectf(300.0, ptf
[0].X
);
5897 expectf(150.0, ptf
[0].Y
);
5898 expectf(600.0, ptf
[1].X
);
5899 expectf(300.0, ptf
[1].Y
);
5901 status
= GdipSetPageScale(graphics
, 2.0);
5904 status
= GdipGetClip(graphics
, region
);
5906 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5908 ret
= GetRgnBox(hrgn
, &rc
);
5909 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5910 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5911 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5912 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc
));
5914 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5916 ret
= GetRgnBox(hrgn
, &rc
);
5917 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5918 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5919 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5920 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5927 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5929 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5931 expectf(150.0, ptf
[0].X
);
5932 expectf(75.0, ptf
[0].Y
);
5933 expectf(300.0, ptf
[1].X
);
5934 expectf(150.0, ptf
[1].Y
);
5936 else /* before Win7 */
5938 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5939 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5940 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5941 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5944 status
= GdipCreateMatrix(&matrix
);
5946 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5948 status
= GdipSetWorldTransform(graphics
, matrix
);
5950 GdipDeleteMatrix(matrix
);
5952 status
= GdipGetClip(graphics
, region
);
5954 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5956 ret
= GetRgnBox(hrgn
, &rc
);
5957 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5958 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5959 /* rounding under Wine is slightly different */
5960 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5961 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc
));
5963 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5965 ret
= GetRgnBox(hrgn
, &rc
);
5966 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5967 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5968 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5979 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5981 expectf(53.033016, ptf
[0].X
);
5982 expectf(0.0, ptf
[0].Y
);
5983 expectf(106.066032, ptf
[1].X
);
5984 expectf(0.0, ptf
[1].Y
);
5985 expectf(79.549522, ptf
[2].X
);
5986 expectf(-26.516510, ptf
[2].Y
);
5987 expectf(79.549522, ptf
[3].X
);
5988 expectf(26.516508, ptf
[3].Y
);
5990 status
= GdipCreateMatrix(&matrix
);
5992 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5994 status
= GdipSetWorldTransform(graphics
, matrix
);
5996 GdipDeleteMatrix(matrix
);
5998 status
= GdipGetClip(graphics
, region
);
6000 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
6002 ret
= GetRgnBox(hrgn
, &rc
);
6003 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
6004 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
6005 /* rounding under Wine is slightly different */
6006 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
6007 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc
));
6009 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
6011 ret
= GetRgnBox(hrgn
, &rc
);
6012 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
6013 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
6014 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
6025 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
6027 expectf(0.0, ptf
[0].X
);
6028 expectf(53.033005, ptf
[0].Y
);
6029 expectf(0.0, ptf
[1].X
);
6030 expectf(106.066010, ptf
[1].Y
);
6031 expectf(26.516491, ptf
[2].X
);
6032 expectf(79.549507, ptf
[2].Y
);
6033 expectf(-26.516520, ptf
[3].X
);
6034 expectf(79.549500, ptf
[3].Y
);
6036 GdipDeleteRegion(region
);
6037 GdipDeleteGraphics(graphics
);
6042 static void test_GdipFillRectangles(void)
6045 GpGraphics
*graphics
= NULL
;
6046 GpBrush
*brush
= NULL
;
6047 HDC hdc
= GetDC( hwnd
);
6048 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
6050 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
6052 status
= GdipCreateFromHDC(hdc
, &graphics
);
6054 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
6056 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
6058 ok(brush
!= NULL
, "Expected brush to be initialized\n");
6060 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
6061 expect(InvalidParameter
, status
);
6063 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
6064 expect(InvalidParameter
, status
);
6066 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
6067 expect(InvalidParameter
, status
);
6069 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
6070 expect(InvalidParameter
, status
);
6072 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
6073 expect(InvalidParameter
, status
);
6075 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
6078 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
6081 GdipDeleteBrush(brush
);
6082 GdipDeleteGraphics(graphics
);
6084 ReleaseDC(hwnd
, hdc
);
6087 static void test_GdipGetVisibleClipBounds_memoryDC(void)
6096 GpGraphics
* graphics
= NULL
;
6100 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
6101 width
= rect
.right
- rect
.left
;
6102 height
= rect
.bottom
- rect
.top
;
6105 hdc
= CreateCompatibleDC ( dc
);
6106 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
6107 old
= SelectObject (hdc
, bmp
);
6109 /*change the window origin is the key test point*/
6110 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
6112 status
= GdipCreateFromHDC(hdc
, &graphics
);
6115 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
6118 ok(boundRect
.X
==rect
.left
+10 &&
6119 boundRect
.Y
==rect
.top
+10 &&
6120 boundRect
.Width
==width
&&
6121 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
6123 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6126 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
6129 ok(boundRect
.X
==rect
.left
+10 &&
6130 boundRect
.Y
==rect
.top
+10 &&
6131 boundRect
.Width
==width
-10 &&
6132 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
6134 GdipDeleteGraphics(graphics
);
6136 SelectObject (hdc
, old
);
6139 ReleaseDC(hwnd
, dc
);
6142 static void test_container_rects(void)
6145 GpGraphics
*graphics
;
6146 HDC hdc
= GetDC( hwnd
);
6147 GpRectF dstrect
, srcrect
;
6148 GraphicsContainer state
;
6149 static const GpPointF test_points
[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
6153 status
= GdipCreateFromHDC(hdc
, &graphics
);
6158 dstrect
.Width
= 1.0;
6159 dstrect
.Height
= 1.0;
6162 status
= GdipGetDpiX(graphics
, &dpix
);
6165 status
= GdipGetDpiY(graphics
, &dpiy
);
6168 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitWorld
, &state
);
6169 expect(InvalidParameter
, status
);
6171 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitDisplay
, &state
);
6172 expect(InvalidParameter
, status
);
6174 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitMillimeter
+1, &state
);
6175 expect(InvalidParameter
, status
);
6177 status
= GdipBeginContainer(NULL
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6178 expect(InvalidParameter
, status
);
6180 status
= GdipBeginContainer(graphics
, NULL
, &srcrect
, UnitPixel
, &state
);
6181 expect(InvalidParameter
, status
);
6183 status
= GdipBeginContainer(graphics
, &dstrect
, NULL
, UnitPixel
, &state
);
6184 expect(InvalidParameter
, status
);
6186 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, -1, &state
);
6187 expect(InvalidParameter
, status
);
6189 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, NULL
);
6190 expect(InvalidParameter
, status
);
6192 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6195 memcpy(points
, test_points
, sizeof(points
));
6196 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6198 expectf(0.0, points
[0].X
);
6199 expectf(0.0, points
[0].Y
);
6200 expectf(1.0, points
[1].X
);
6201 expectf(0.0, points
[1].Y
);
6202 expectf(0.0, points
[2].X
);
6203 expectf(1.0, points
[2].Y
);
6205 status
= GdipEndContainer(graphics
, state
);
6208 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6211 memcpy(points
, test_points
, sizeof(points
));
6212 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6214 expectf(0.0, points
[0].X
);
6215 expectf(0.0, points
[0].Y
);
6216 expectf(1.0/dpix
, points
[1].X
);
6217 expectf(0.0, points
[1].Y
);
6218 expectf(0.0, points
[2].X
);
6219 expectf(1.0/dpiy
, points
[2].Y
);
6221 status
= GdipEndContainer(graphics
, state
);
6224 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
6228 dstrect
.Height
= 3.0;
6229 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6232 memcpy(points
, test_points
, sizeof(points
));
6233 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6235 expectf(2.0, points
[0].X
);
6236 expectf(0.0, points
[0].Y
);
6237 expectf(4.0, points
[1].X
);
6238 expectf(0.0, points
[1].Y
);
6239 expectf(2.0, points
[2].X
);
6240 expectf(6.0, points
[2].Y
);
6242 status
= GdipEndContainer(graphics
, state
);
6245 memcpy(points
, test_points
, sizeof(points
));
6246 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6248 expectf(0.0, points
[0].X
);
6249 expectf(0.0, points
[0].Y
);
6250 expectf(2.0, points
[1].X
);
6251 expectf(0.0, points
[1].Y
);
6252 expectf(0.0, points
[2].X
);
6253 expectf(2.0, points
[2].Y
);
6255 status
= GdipResetWorldTransform(graphics
);
6258 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6261 memcpy(points
, test_points
, sizeof(points
));
6262 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6264 expectf(1.0, points
[0].X
);
6265 expectf(0.0, points
[0].Y
);
6266 expectf((dpix
+1.0)/dpix
, points
[1].X
);
6267 expectf(0.0, points
[1].Y
);
6268 expectf(1.0, points
[2].X
);
6269 expectf(3.0/dpiy
, points
[2].Y
);
6271 status
= GdipEndContainer(graphics
, state
);
6274 status
= GdipSetPageUnit(graphics
, UnitInch
);
6277 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6280 memcpy(points
, test_points
, sizeof(points
));
6281 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6283 expectf(dpix
, points
[0].X
);
6284 expectf(0.0, points
[0].Y
);
6285 expectf(dpix
*2, points
[1].X
);
6286 expectf(0.0, points
[1].Y
);
6287 expectf(dpix
, points
[2].X
);
6288 expectf(dpiy
*3, points
[2].Y
);
6290 status
= GdipEndContainer(graphics
, state
);
6293 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6296 memcpy(points
, test_points
, sizeof(points
));
6297 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6299 expectf(dpix
, points
[0].X
);
6300 expectf(0.0, points
[0].Y
);
6301 expectf(dpix
+1.0, points
[1].X
);
6302 expectf(0.0, points
[1].Y
);
6303 expectf(dpix
, points
[2].X
);
6304 expectf(3.0, points
[2].Y
);
6306 status
= GdipEndContainer(graphics
, state
);
6309 GdipDeleteGraphics(graphics
);
6311 ReleaseDC(hwnd
, hdc
);
6314 static void test_GdipGraphicsSetAbort(void)
6318 GpGraphics
*graphics
;
6320 if (!pGdipGraphicsSetAbort
)
6322 win_skip("GdipGraphicsSetAbort() is not supported.\n");
6328 status
= GdipCreateFromHDC(hdc
, &graphics
);
6331 status
= pGdipGraphicsSetAbort(NULL
, NULL
);
6332 expect(InvalidParameter
, status
);
6334 status
= pGdipGraphicsSetAbort(graphics
, NULL
);
6337 GdipDeleteGraphics(graphics
);
6339 ReleaseDC(hwnd
, hdc
);
6342 #define BLUE_COLOR (0xff0000ff)
6343 #define is_blue_color(color) ( ((color) & 0x00ffffff) == 0xff )
6344 #define get_bitmap_pixel(x,y) pixel[(y)*(width) + (x)]
6345 static DWORD
* GetBitmapPixelBuffer(HDC hdc
, HBITMAP hbmp
, int width
, int height
)
6347 BITMAPINFOHEADER bi
;
6349 DWORD
*buffer
= (DWORD
*)GdipAlloc(width
*height
*4);
6351 bi
.biSize
= sizeof(BITMAPINFOHEADER
);
6353 bi
.biHeight
= -height
; /*very Important, set negative, indicating a top-down DIB*/
6356 bi
.biCompression
= BI_RGB
;
6358 bi
.biXPelsPerMeter
= 0;
6359 bi
.biYPelsPerMeter
= 0;
6361 bi
.biClrImportant
= 0;
6363 lines
= GetDIBits(hdc
, hbmp
, 0, height
, buffer
, (BITMAPINFO
*)&bi
, DIB_RGB_COLORS
);
6364 ok(lines
== height
, "Expected GetDIBits:%p,%d->%d,%d\n", buffer
, height
, lines
, GetLastError());
6369 static void test_GdipFillRectanglesOnMemoryDCSolidBrush(void)
6371 ARGB color
[6] = {0,0,0,0,0,0};
6373 RECT rect
= {100, 100, 180, 180};
6374 UINT width
= rect
.right
- rect
.left
;
6375 UINT height
= rect
.bottom
- rect
.top
;
6376 GpStatus status
= 0;
6377 GpSolidFill
*brush
= NULL
;
6378 GpGraphics
*graphics
= NULL
;
6379 HDC dc
= GetDC( hwnd
);
6380 HDC hdc
= CreateCompatibleDC(dc
);
6381 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6382 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6383 DWORD
* pixel
= NULL
;
6385 /*Change the window origin is the key test point*/
6386 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6388 status
= GdipCreateSolidFill(BLUE_COLOR
, &brush
);
6391 status
= GdipCreateFromHDC(hdc
, &graphics
);
6394 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6395 width
, height
, CombineModeReplace
);
6398 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6401 GdipDeleteBrush((GpBrush
*)brush
);
6402 GdipDeleteGraphics(graphics
);
6404 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6407 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6408 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6409 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6410 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6411 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6412 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6415 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6416 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6417 "Expected GdipFillRectangleI take effect!\n" );
6420 SelectObject(hdc
, old
);
6423 ReleaseDC(hwnd
, dc
);
6426 static void test_GdipFillRectanglesOnMemoryDCTextureBrush(void)
6428 ARGB color
[6] = {0,0,0,0,0,0};
6430 RECT rect
= {100, 100, 180, 180};
6431 UINT width
= rect
.right
- rect
.left
;
6432 UINT height
= rect
.bottom
- rect
.top
;
6433 GpStatus status
= 0;
6439 GpTexture
*brush
= NULL
;
6440 GpGraphics
*graphics
= NULL
;
6441 HDC dc
= GetDC( hwnd
);
6442 HDC hdc
= CreateCompatibleDC(dc
);
6443 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6444 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6448 UINT src_img_width
= width
/2;
6449 UINT src_img_height
= height
/2;
6450 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6451 DWORD
*pixel
= (DWORD
*)src_img_data
;
6452 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6454 /*Change the window origin is the key test point*/
6455 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6457 /*build a blue solid image!*/
6458 for(y
= 0; y
< src_img_height
; ++y
)
6460 for(x
= 0; x
< src_img_width
; ++x
)
6462 pixel
[x
] = BLUE_COLOR
;
6465 pixel
+= src_img_width
;
6468 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6469 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6472 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6475 status
= GdipCreateFromHDC(hdc
, &graphics
);
6478 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6479 width
, height
, CombineModeReplace
);
6482 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6485 GdipDisposeImage(src_img
.image
);
6486 GdipDeleteBrush((GpBrush
*)brush
);
6487 GdipDeleteGraphics(graphics
);
6488 GdipFree(src_img_data
);
6490 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6493 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6494 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6495 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6496 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6497 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6498 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6500 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6501 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6502 "Expected GdipFillRectangleI take effect!\n" );
6505 SelectObject(hdc
, old
);
6508 ReleaseDC(hwnd
, dc
);
6511 static void test_GdipFillRectanglesOnBitmapTextureBrush(void)
6513 ARGB color
[6] = {0,0,0,0,0,0};
6516 RECT rect
= {100, 100, 180, 180};
6517 UINT width
= rect
.right
- rect
.left
;
6518 UINT height
= rect
.bottom
- rect
.top
;
6519 UINT src_img_width
= width
/2;
6520 UINT src_img_height
= height
/2;
6522 GpStatus status
= 0;
6534 GpTexture
*brush
= NULL
;
6535 GpGraphics
*graphics
= NULL
;
6536 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6537 DWORD
*pixel
= (DWORD
*)src_img_data
;
6538 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6540 status
= GdipCreateBitmapFromScan0(width
, height
, width
*4,
6541 PixelFormat32bppARGB
, NULL
, &dst_img
.bitmap
);
6544 /*build a blue solid image!*/
6545 for(y
= 0; y
< src_img_height
; ++y
)
6547 for(x
= 0; x
< src_img_width
; ++x
)
6549 pixel
[x
] = BLUE_COLOR
;
6552 pixel
+= src_img_width
;
6555 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6556 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6559 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6562 status
= GdipGetImageGraphicsContext(dst_img
.image
, &graphics
);
6565 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6568 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, width
/2, height
/2);
6571 GdipDeleteBrush((GpBrush
*)brush
);
6572 GdipDeleteGraphics(graphics
);
6574 GdipBitmapGetPixel(dst_img
.bitmap
, 0, 0, &color
[0]);
6575 GdipBitmapGetPixel(dst_img
.bitmap
, 0, 1, &color
[1]);
6576 GdipBitmapGetPixel(dst_img
.bitmap
, 1, 0, &color
[2]);
6577 GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, 0, &color
[3]);
6578 GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, height
/2, &color
[4]);
6579 GdipBitmapGetPixel(dst_img
.bitmap
, 0, height
/2, &color
[5]);
6581 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6582 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6583 "Expected GdipFillRectangleI take effect!\n" );
6585 GdipDisposeImage(src_img
.image
);
6586 GdipDisposeImage(dst_img
.image
);
6587 GdipFree(src_img_data
);
6590 static void test_GdipDrawImagePointsRectOnMemoryDC(void)
6592 ARGB color
[6] = {0,0,0,0,0,0};
6594 RECT rect
= {100, 100, 180, 180};
6595 UINT width
= rect
.right
- rect
.left
;
6596 UINT height
= rect
.bottom
- rect
.top
;
6597 GpStatus status
= 0;
6603 GpGraphics
*graphics
= NULL
;
6604 HDC dc
= GetDC( hwnd
);
6605 HDC hdc
= CreateCompatibleDC(dc
);
6606 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6607 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6611 UINT src_img_width
= width
/2;
6612 UINT src_img_height
= height
/2;
6613 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6614 DWORD
*pixel
= (DWORD
*)src_img_data
;
6615 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6617 /*Change the window origin is the key test point*/
6618 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6620 /*build a blue solid image!*/
6621 for(y
= 0; y
< src_img_height
; ++y
)
6623 for(x
= 0; x
< src_img_width
; ++x
)
6625 pixel
[x
] = BLUE_COLOR
;
6628 pixel
+= src_img_width
;
6631 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6632 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6635 status
= GdipCreateFromHDC(hdc
, &graphics
);
6638 status
= GdipDrawImageRectRectI(graphics
, src_img
.image
,
6639 rect
.left
+width
/2, rect
.top
+height
/2, width
/2, height
/2,
6640 0, 0, src_img_width
, src_img_height
, UnitPixel
, NULL
, NULL
, NULL
);
6643 GdipDisposeImage(src_img
.image
);
6644 GdipDeleteGraphics(graphics
);
6645 GdipFree(src_img_data
);
6647 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6650 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6651 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6652 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6653 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6654 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6655 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6657 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6658 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6659 "Expected GdipDrawImageRectRectI take effect!\n" );
6662 SelectObject(hdc
, old
);
6665 ReleaseDC(hwnd
, dc
);
6668 static void test_cliphrgn_transform(void)
6672 GpGraphics
*graphics
;
6679 SetViewportOrgEx(hdc
, 10, 10, NULL
);
6681 status
= GdipCreateFromHDC(hdc
, &graphics
);
6684 rgn
= CreateRectRgn(0, 0, 100, 100);
6686 status
= GdipSetClipHrgn(graphics
, rgn
, CombineModeReplace
);
6689 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
6691 expectf(-10.0, rectf
.X
);
6692 expectf(-10.0, rectf
.Y
);
6693 expectf(100.0, rectf
.Width
);
6694 expectf(100.0, rectf
.Height
);
6696 status
= GdipIsVisiblePoint(graphics
, 95, 95, &res
);
6700 status
= GdipIsVisiblePoint(graphics
, -5, -5, &res
);
6706 GdipDeleteGraphics(graphics
);
6708 SetViewportOrgEx(hdc
, 0, 0, NULL
);
6710 ReleaseDC(hwnd
, hdc
);
6713 static void test_hdc_caching(void)
6718 GpGraphics
*graphics
;
6724 hdc
= CreateCompatibleDC(0);
6725 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
6726 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
6727 bmi
.bmiHeader
.biHeight
= -5;
6728 bmi
.bmiHeader
.biWidth
= 5;
6729 bmi
.bmiHeader
.biBitCount
= 32;
6730 bmi
.bmiHeader
.biPlanes
= 1;
6731 bmi
.bmiHeader
.biCompression
= BI_RGB
;
6732 bmi
.bmiHeader
.biClrUsed
= 0;
6734 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
6735 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
6737 SelectObject(hdc
, hbm
);
6739 SetViewportOrgEx(hdc
, 1, 1, NULL
);
6741 hrgn
= CreateRectRgn(0, 0, 3, 3);
6742 SelectClipRgn(hdc
, hrgn
);
6745 status
= GdipCreateSolidFill((ARGB
)0xffaaaaaa, (GpSolidFill
**)&brush
);
6748 status
= GdipCreateFromHDC(hdc
, &graphics
);
6751 memset(bits
, 0, sizeof(*bits
) * 25);
6752 status
= GdipFillRectangleI(graphics
, brush
, 0, 0, 4, 4);
6756 expect(0xffaaaaaa, bits
[6]);
6757 expect(0xffaaaaaa, bits
[12]);
6758 expect(0, bits
[18]);
6759 expect(0, bits
[24]);
6761 SetViewportOrgEx(hdc
, 0, 0, NULL
);
6762 OffsetClipRgn(hdc
, 2, 2);
6764 memset(bits
, 0, sizeof(*bits
) * 25);
6765 status
= GdipFillRectangleI(graphics
, brush
, 0, 0, 4, 4);
6769 expect(0xffaaaaaa, bits
[6]);
6770 expect(0xffaaaaaa, bits
[12]);
6771 expect(0, bits
[18]);
6772 expect(0, bits
[24]);
6774 GdipDeleteGraphics(graphics
);
6776 GdipDeleteBrush(brush
);
6782 START_TEST(graphics
)
6784 struct GdiplusStartupInput gdiplusStartupInput
;
6785 ULONG_PTR gdiplusToken
;
6787 HMODULE gdiplus_mod
= GetModuleHandleA("gdiplus.dll");
6789 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
6791 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
6792 hmsvcrt
= LoadLibraryA("msvcrt");
6793 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
6794 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
6796 pGdipGraphicsSetAbort
= (void*)GetProcAddress(gdiplus_mod
, "GdipGraphicsSetAbort");
6798 memset( &class, 0, sizeof(class) );
6799 class.lpszClassName
= "gdiplus_test";
6800 class.style
= CS_HREDRAW
| CS_VREDRAW
;
6801 class.lpfnWndProc
= DefWindowProcA
;
6802 class.hInstance
= GetModuleHandleA(0);
6803 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
6804 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6805 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
6806 RegisterClassA( &class );
6807 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6808 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
6809 ok(hwnd
!= NULL
, "Expected window to be created\n");
6811 gdiplusStartupInput
.GdiplusVersion
= 1;
6812 gdiplusStartupInput
.DebugEventCallback
= NULL
;
6813 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
6814 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
6816 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
6820 test_measured_extra_space();
6821 test_measure_string();
6822 test_font_height_scaling();
6824 test_pen_thickness();
6825 test_GdipMeasureString();
6826 test_constructor_destructor();
6827 test_save_restore();
6828 test_GdipFillClosedCurve2();
6829 test_GdipFillClosedCurve2I();
6830 test_GdipDrawBezierI();
6832 test_GdipDrawArcI();
6833 test_GdipDrawCurve();
6834 test_GdipDrawCurveI();
6835 test_GdipDrawCurve2();
6836 test_GdipDrawCurve2I();
6837 test_GdipDrawCurve3();
6838 test_GdipDrawCurve3I();
6839 test_GdipDrawLineI();
6840 test_GdipDrawLinesI();
6841 test_GdipDrawImagePointsRect();
6842 test_GdipFillClosedCurve();
6843 test_GdipFillClosedCurveI();
6844 test_GdipFillPath();
6845 test_GdipDrawString();
6846 test_GdipGetNearestColor();
6847 test_GdipGetVisibleClipBounds();
6848 test_GdipIsVisiblePoint();
6849 test_GdipIsVisibleRect();
6850 test_Get_Release_DC();
6851 test_BeginContainer2();
6852 test_transformpoints();
6853 test_get_set_clip();
6857 test_textcontrast();
6858 test_fromMemoryBitmap();
6859 test_string_functions();
6860 test_get_set_interpolation();
6861 test_get_set_textrenderinghint();
6862 test_getdc_scaled();
6864 test_bitmapfromgraphics();
6865 test_GdipFillRectangles();
6866 test_GdipGetVisibleClipBounds_memoryDC();
6867 test_GdipFillRectanglesOnMemoryDCSolidBrush();
6868 test_GdipFillRectanglesOnMemoryDCTextureBrush();
6869 test_GdipFillRectanglesOnBitmapTextureBrush();
6870 test_GdipDrawImagePointsRectOnMemoryDC();
6871 test_container_rects();
6872 test_GdipGraphicsSetAbort();
6873 test_cliphrgn_transform();
6876 GdiplusShutdown(gdiplusToken
);
6877 DestroyWindow( hwnd
);