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
24 #define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
25 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
26 #define expectf(expected, got) expectf_((expected), (got), 0.001)
28 static GpStatus (WINAPI
*pGdipGraphicsSetAbort
)(GpGraphics
*,GdiplusAbort
*);
30 static const REAL mm_per_inch
= 25.4;
31 static const REAL point_per_inch
= 72.0;
34 static void set_rect_empty(RectF
*rc
)
42 /* converts a given unit to its value in pixels */
43 static REAL
units_to_pixels(REAL units
, GpUnit unit
, REAL dpi
)
51 return units
* dpi
/ point_per_inch
;
55 return units
* dpi
/ 300.0; /* Per MSDN */
57 return units
* dpi
/ mm_per_inch
;
59 ok(0, "Unsupported unit: %d\n", unit
);
64 /* converts value in pixels to a given unit */
65 static REAL
pixels_to_units(REAL pixels
, GpUnit unit
, REAL dpi
)
73 return pixels
* point_per_inch
/ dpi
;
77 return pixels
* 300.0 / dpi
;
79 return pixels
* mm_per_inch
/ dpi
;
81 ok(0, "Unsupported unit: %d\n", unit
);
86 static REAL
units_scale(GpUnit from
, GpUnit to
, REAL dpi
)
88 REAL pixels
= units_to_pixels(1.0, from
, dpi
);
89 return pixels_to_units(pixels
, to
, dpi
);
92 static GpGraphics
*create_graphics(REAL res_x
, REAL res_y
, GpUnit unit
, REAL scale
, GpImage
**image
)
100 GpGraphics
*graphics
= NULL
;
103 status
= GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
106 status
= GdipBitmapSetResolution(u
.bitmap
, res_x
, res_y
);
108 status
= GdipGetImageHorizontalResolution(u
.image
, &res
);
111 status
= GdipGetImageVerticalResolution(u
.image
, &res
);
115 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
120 status
= GdipGetDpiX(graphics
, &res
);
123 status
= GdipGetDpiY(graphics
, &res
);
127 status
= GdipSetPageUnit(graphics
, unit
);
129 status
= GdipSetPageScale(graphics
, scale
);
135 static void test_constructor_destructor(void)
138 GpGraphics
*graphics
= NULL
;
139 HDC hdc
= GetDC( hwnd
);
141 stat
= GdipCreateFromHDC(NULL
, &graphics
);
142 expect(OutOfMemory
, stat
);
143 stat
= GdipDeleteGraphics(graphics
);
144 expect(InvalidParameter
, stat
);
146 stat
= GdipCreateFromHDC(hdc
, &graphics
);
148 stat
= GdipDeleteGraphics(graphics
);
151 stat
= GdipCreateFromHWND(NULL
, &graphics
);
153 stat
= GdipDeleteGraphics(graphics
);
156 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
158 stat
= GdipDeleteGraphics(graphics
);
161 stat
= GdipDeleteGraphics(NULL
);
162 expect(InvalidParameter
, stat
);
163 ReleaseDC(hwnd
, hdc
);
171 /* Linked list prepend function. */
172 static void log_state(GraphicsState data
, node
** log
)
174 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
176 new_entry
->data
= data
;
177 new_entry
->next
= *log
;
181 /* Checks if there are duplicates in the list, and frees it. */
182 static void check_no_duplicates(node
* log
)
194 while((temp
= temp
->next
)){
195 if(log
->data
== temp
->data
){
202 }while((log
= log
->next
));
207 HeapFree(GetProcessHeap(), 0, temp
);
215 static void test_save_restore(void)
218 GraphicsState state_a
, state_b
, state_c
;
219 InterpolationMode mode
;
220 GpGraphics
*graphics1
, *graphics2
;
221 node
* state_log
= NULL
;
222 HDC hdc
= GetDC( hwnd
);
223 state_a
= state_b
= state_c
= 0xdeadbeef;
225 /* Invalid saving. */
226 GdipCreateFromHDC(hdc
, &graphics1
);
227 stat
= GdipSaveGraphics(graphics1
, NULL
);
228 expect(InvalidParameter
, stat
);
229 stat
= GdipSaveGraphics(NULL
, &state_a
);
230 expect(InvalidParameter
, stat
);
231 GdipDeleteGraphics(graphics1
);
233 log_state(state_a
, &state_log
);
235 /* Basic save/restore. */
236 GdipCreateFromHDC(hdc
, &graphics1
);
237 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
238 stat
= GdipSaveGraphics(graphics1
, &state_a
);
240 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
241 stat
= GdipRestoreGraphics(graphics1
, state_a
);
243 GdipGetInterpolationMode(graphics1
, &mode
);
244 expect(InterpolationModeBilinear
, mode
);
245 GdipDeleteGraphics(graphics1
);
247 log_state(state_a
, &state_log
);
249 /* Restoring garbage doesn't affect saves. */
250 GdipCreateFromHDC(hdc
, &graphics1
);
251 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
252 GdipSaveGraphics(graphics1
, &state_a
);
253 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
254 GdipSaveGraphics(graphics1
, &state_b
);
255 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
256 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
258 GdipRestoreGraphics(graphics1
, state_b
);
259 GdipGetInterpolationMode(graphics1
, &mode
);
260 expect(InterpolationModeBicubic
, mode
);
261 GdipRestoreGraphics(graphics1
, state_a
);
262 GdipGetInterpolationMode(graphics1
, &mode
);
263 expect(InterpolationModeBilinear
, mode
);
264 GdipDeleteGraphics(graphics1
);
266 log_state(state_a
, &state_log
);
267 log_state(state_b
, &state_log
);
269 /* Restoring older state invalidates newer saves (but not older saves). */
270 GdipCreateFromHDC(hdc
, &graphics1
);
271 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
272 GdipSaveGraphics(graphics1
, &state_a
);
273 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
274 GdipSaveGraphics(graphics1
, &state_b
);
275 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
276 GdipSaveGraphics(graphics1
, &state_c
);
277 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
278 GdipRestoreGraphics(graphics1
, state_b
);
279 GdipGetInterpolationMode(graphics1
, &mode
);
280 expect(InterpolationModeBicubic
, mode
);
281 GdipRestoreGraphics(graphics1
, state_c
);
282 GdipGetInterpolationMode(graphics1
, &mode
);
283 expect(InterpolationModeBicubic
, mode
);
284 GdipRestoreGraphics(graphics1
, state_a
);
285 GdipGetInterpolationMode(graphics1
, &mode
);
286 expect(InterpolationModeBilinear
, mode
);
287 GdipDeleteGraphics(graphics1
);
289 log_state(state_a
, &state_log
);
290 log_state(state_b
, &state_log
);
291 log_state(state_c
, &state_log
);
293 /* Restoring older save from one graphics object does not invalidate
294 * newer save from other graphics object. */
295 GdipCreateFromHDC(hdc
, &graphics1
);
296 GdipCreateFromHDC(hdc
, &graphics2
);
297 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
298 GdipSaveGraphics(graphics1
, &state_a
);
299 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
300 GdipSaveGraphics(graphics2
, &state_b
);
301 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
302 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
303 GdipRestoreGraphics(graphics1
, state_a
);
304 GdipGetInterpolationMode(graphics1
, &mode
);
305 expect(InterpolationModeBilinear
, mode
);
306 GdipRestoreGraphics(graphics2
, state_b
);
307 GdipGetInterpolationMode(graphics2
, &mode
);
308 expect(InterpolationModeBicubic
, mode
);
309 GdipDeleteGraphics(graphics1
);
310 GdipDeleteGraphics(graphics2
);
312 /* You can't restore a state to a graphics object that didn't save it. */
313 GdipCreateFromHDC(hdc
, &graphics1
);
314 GdipCreateFromHDC(hdc
, &graphics2
);
315 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
316 GdipSaveGraphics(graphics1
, &state_a
);
317 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
318 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
319 GdipRestoreGraphics(graphics2
, state_a
);
320 GdipGetInterpolationMode(graphics2
, &mode
);
321 expect(InterpolationModeNearestNeighbor
, mode
);
322 GdipDeleteGraphics(graphics1
);
323 GdipDeleteGraphics(graphics2
);
325 log_state(state_a
, &state_log
);
327 /* A state created by SaveGraphics cannot be restored with EndContainer. */
328 GdipCreateFromHDC(hdc
, &graphics1
);
329 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
330 stat
= GdipSaveGraphics(graphics1
, &state_a
);
332 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
333 stat
= GdipEndContainer(graphics1
, state_a
);
335 GdipGetInterpolationMode(graphics1
, &mode
);
336 expect(InterpolationModeBicubic
, mode
);
337 stat
= GdipRestoreGraphics(graphics1
, state_a
);
339 GdipGetInterpolationMode(graphics1
, &mode
);
340 expect(InterpolationModeBilinear
, mode
);
341 GdipDeleteGraphics(graphics1
);
343 log_state(state_a
, &state_log
);
345 /* A state created by BeginContainer cannot be restored with RestoreGraphics. */
346 GdipCreateFromHDC(hdc
, &graphics1
);
347 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
348 stat
= GdipBeginContainer2(graphics1
, &state_a
);
350 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
351 stat
= GdipRestoreGraphics(graphics1
, state_a
);
353 GdipGetInterpolationMode(graphics1
, &mode
);
354 expect(InterpolationModeBicubic
, mode
);
355 stat
= GdipEndContainer(graphics1
, state_a
);
357 GdipGetInterpolationMode(graphics1
, &mode
);
358 expect(InterpolationModeBilinear
, mode
);
359 GdipDeleteGraphics(graphics1
);
361 log_state(state_a
, &state_log
);
363 /* BeginContainer and SaveGraphics use the same stack. */
364 GdipCreateFromHDC(hdc
, &graphics1
);
365 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
366 stat
= GdipBeginContainer2(graphics1
, &state_a
);
368 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
369 stat
= GdipSaveGraphics(graphics1
, &state_b
);
371 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
372 stat
= GdipEndContainer(graphics1
, state_a
);
374 GdipGetInterpolationMode(graphics1
, &mode
);
375 expect(InterpolationModeBilinear
, mode
);
376 stat
= GdipRestoreGraphics(graphics1
, state_b
);
378 GdipGetInterpolationMode(graphics1
, &mode
);
379 expect(InterpolationModeBilinear
, mode
);
380 GdipDeleteGraphics(graphics1
);
382 log_state(state_a
, &state_log
);
383 log_state(state_b
, &state_log
);
385 /* The same state value should never be returned twice. */
387 check_no_duplicates(state_log
);
389 ReleaseDC(hwnd
, hdc
);
392 static void test_GdipFillClosedCurve2(void)
395 GpGraphics
*graphics
= NULL
;
396 GpSolidFill
*brush
= NULL
;
397 HDC hdc
= GetDC( hwnd
);
409 /* make a graphics object and brush object */
410 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
412 status
= GdipCreateFromHDC(hdc
, &graphics
);
414 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
416 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
418 /* InvalidParameter cases: null graphics, null brush, null points */
419 status
= GdipFillClosedCurve2(NULL
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
420 expect(InvalidParameter
, status
);
422 status
= GdipFillClosedCurve2(graphics
, NULL
, NULL
, 3, 0.5, FillModeAlternate
);
423 expect(InvalidParameter
, status
);
425 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
426 expect(InvalidParameter
, status
);
428 status
= GdipFillClosedCurve2(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
429 expect(InvalidParameter
, status
);
431 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, NULL
, 3, 0.5, FillModeAlternate
);
432 expect(InvalidParameter
, status
);
434 status
= GdipFillClosedCurve2(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
435 expect(InvalidParameter
, status
);
437 status
= GdipFillClosedCurve2(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
438 expect(InvalidParameter
, status
);
440 /* InvalidParameter cases: invalid count */
441 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
442 expect(InvalidParameter
, status
);
444 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
445 expect(InvalidParameter
, status
);
447 /* Valid test cases */
448 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
451 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
454 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
457 GdipDeleteGraphics(graphics
);
458 GdipDeleteBrush((GpBrush
*)brush
);
460 ReleaseDC(hwnd
, hdc
);
463 static void test_GdipFillClosedCurve2I(void)
466 GpGraphics
*graphics
= NULL
;
467 GpSolidFill
*brush
= NULL
;
468 HDC hdc
= GetDC( hwnd
);
480 /* make a graphics object and brush object */
481 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
483 status
= GdipCreateFromHDC(hdc
, &graphics
);
485 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
487 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
489 /* InvalidParameter cases: null graphics, null brush */
490 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
491 when points == NULL, so don't test this condition */
492 status
= GdipFillClosedCurve2I(NULL
, NULL
, points
, 3, 0.5, FillModeAlternate
);
493 expect(InvalidParameter
, status
);
495 status
= GdipFillClosedCurve2I(graphics
, NULL
, points
, 3, 0.5, FillModeAlternate
);
496 expect(InvalidParameter
, status
);
498 status
= GdipFillClosedCurve2I(NULL
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
499 expect(InvalidParameter
, status
);
501 /* InvalidParameter cases: invalid count */
502 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 0, 0.5, FillModeAlternate
);
503 expect(InvalidParameter
, status
);
505 /* OutOfMemory cases: large (unsigned) int */
506 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, -1, 0.5, FillModeAlternate
);
507 expect(OutOfMemory
, status
);
509 /* Valid test cases */
510 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 1, 0.5, FillModeAlternate
);
513 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 2, 0.5, FillModeAlternate
);
516 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, points
, 3, 0.5, FillModeAlternate
);
519 GdipDeleteGraphics(graphics
);
520 GdipDeleteBrush((GpBrush
*)brush
);
522 ReleaseDC(hwnd
, hdc
);
525 static void test_GdipDrawArc(void)
528 GpGraphics
*graphics
= NULL
;
530 HDC hdc
= GetDC( hwnd
);
532 /* make a graphics object and pen object */
533 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
535 status
= GdipCreateFromHDC(hdc
, &graphics
);
537 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
539 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
541 ok(pen
!= NULL
, "Expected pen to be initialized\n");
543 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
544 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
545 expect(InvalidParameter
, status
);
547 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
548 expect(InvalidParameter
, status
);
550 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
551 expect(InvalidParameter
, status
);
553 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
554 expect(InvalidParameter
, status
);
556 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
557 expect(InvalidParameter
, status
);
559 /* successful case */
560 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
564 GdipDeleteGraphics(graphics
);
566 ReleaseDC(hwnd
, hdc
);
569 static void test_GdipDrawArcI(void)
572 GpGraphics
*graphics
= NULL
;
574 HDC hdc
= GetDC( hwnd
);
576 /* make a graphics object and pen object */
577 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
579 status
= GdipCreateFromHDC(hdc
, &graphics
);
581 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
583 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
585 ok(pen
!= NULL
, "Expected pen to be initialized\n");
587 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
588 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
589 expect(InvalidParameter
, status
);
591 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
592 expect(InvalidParameter
, status
);
594 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
595 expect(InvalidParameter
, status
);
597 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
598 expect(InvalidParameter
, status
);
600 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
601 expect(InvalidParameter
, status
);
603 /* successful case */
604 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
608 GdipDeleteGraphics(graphics
);
610 ReleaseDC(hwnd
, hdc
);
613 static void test_BeginContainer2(void)
617 REAL defClip
[] = {5, 10, 15, 20};
618 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
619 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
620 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
621 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
622 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
623 REAL scale
, defScale
= 17;
624 GpUnit unit
, defUnit
= UnitPixel
;
625 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
626 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
627 UINT contrast
, defContrast
= 5;
628 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
631 GpGraphics
*graphics
= NULL
;
632 HDC hdc
= GetDC( hwnd
);
634 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
636 status
= GdipCreateFromHDC(hdc
, &graphics
);
638 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
640 /* null graphics, null container */
641 status
= GdipBeginContainer2(NULL
, &cont1
);
642 expect(InvalidParameter
, status
);
644 status
= GdipBeginContainer2(graphics
, NULL
);
645 expect(InvalidParameter
, status
);
647 status
= GdipEndContainer(NULL
, cont1
);
648 expect(InvalidParameter
, status
);
650 /* test all quality-related values */
651 GdipSetCompositingMode(graphics
, defCompmode
);
652 GdipSetCompositingQuality(graphics
, defCompqual
);
653 GdipSetInterpolationMode(graphics
, defInterp
);
654 GdipSetPageScale(graphics
, defScale
);
655 GdipSetPageUnit(graphics
, defUnit
);
656 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
657 GdipSetSmoothingMode(graphics
, defSmoothmode
);
658 GdipSetTextContrast(graphics
, defContrast
);
659 GdipSetTextRenderingHint(graphics
, defTexthint
);
661 status
= GdipBeginContainer2(graphics
, &cont1
);
664 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
665 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
666 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
667 GdipSetPageScale(graphics
, 10);
668 GdipSetPageUnit(graphics
, UnitDocument
);
669 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
670 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
671 GdipSetTextContrast(graphics
, 7);
672 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
674 status
= GdipEndContainer(graphics
, cont1
);
677 GdipGetCompositingMode(graphics
, &compmode
);
678 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
680 GdipGetCompositingQuality(graphics
, &compqual
);
681 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
683 GdipGetInterpolationMode(graphics
, &interp
);
684 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
686 GdipGetPageScale(graphics
, &scale
);
687 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
689 GdipGetPageUnit(graphics
, &unit
);
690 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
692 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
693 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
695 GdipGetSmoothingMode(graphics
, &smoothmode
);
696 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
698 GdipGetTextContrast(graphics
, &contrast
);
699 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
701 GdipGetTextRenderingHint(graphics
, &texthint
);
702 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
704 /* test world transform */
705 status
= GdipBeginContainer2(graphics
, &cont1
);
708 status
= GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
709 defTrans
[4], defTrans
[5], &transform
);
711 GdipSetWorldTransform(graphics
, transform
);
712 GdipDeleteMatrix(transform
);
715 status
= GdipBeginContainer2(graphics
, &cont2
);
718 status
= GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
720 GdipSetWorldTransform(graphics
, transform
);
721 GdipDeleteMatrix(transform
);
724 status
= GdipEndContainer(graphics
, cont2
);
727 status
= GdipCreateMatrix(&transform
);
729 GdipGetWorldTransform(graphics
, transform
);
730 GdipGetMatrixElements(transform
, elems
);
731 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
732 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
733 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
734 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
735 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
736 fabs(defTrans
[5] - elems
[5]) < 0.0001,
737 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
738 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
739 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
740 GdipDeleteMatrix(transform
);
743 status
= GdipEndContainer(graphics
, cont1
);
747 status
= GdipBeginContainer2(graphics
, &cont1
);
750 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
752 status
= GdipBeginContainer2(graphics
, &cont2
);
755 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
757 status
= GdipEndContainer(graphics
, cont2
);
760 status
= GdipGetClipBounds(graphics
, &clip
);
763 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
764 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
765 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
766 fabs(defClip
[3] - clip
.Height
) < 0.0001,
767 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
768 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
769 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
771 status
= GdipEndContainer(graphics
, cont1
);
775 status
= GdipBeginContainer2(graphics
, &cont1
);
778 status
= GdipBeginContainer2(graphics
, &cont2
);
781 status
= GdipBeginContainer2(graphics
, &cont3
);
784 status
= GdipEndContainer(graphics
, cont3
);
787 status
= GdipBeginContainer2(graphics
, &cont4
);
790 status
= GdipEndContainer(graphics
, cont4
);
794 status
= GdipEndContainer(graphics
, cont1
);
797 /* end an already-ended container */
798 status
= GdipEndContainer(graphics
, cont1
);
801 GdipDeleteGraphics(graphics
);
802 ReleaseDC(hwnd
, hdc
);
805 static void test_GdipDrawBezierI(void)
808 GpGraphics
*graphics
= NULL
;
810 HDC hdc
= GetDC( hwnd
);
812 /* make a graphics object and pen object */
813 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
815 status
= GdipCreateFromHDC(hdc
, &graphics
);
817 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
819 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
821 ok(pen
!= NULL
, "Expected pen to be initialized\n");
823 /* InvalidParameter cases: null graphics, null pen */
824 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
825 expect(InvalidParameter
, status
);
827 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
828 expect(InvalidParameter
, status
);
830 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
831 expect(InvalidParameter
, status
);
833 /* successful case */
834 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
838 GdipDeleteGraphics(graphics
);
840 ReleaseDC(hwnd
, hdc
);
843 static void test_GdipDrawCurve3(void)
846 GpGraphics
*graphics
= NULL
;
848 HDC hdc
= GetDC( hwnd
);
860 /* make a graphics object and pen object */
861 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
863 status
= GdipCreateFromHDC(hdc
, &graphics
);
865 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
867 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
869 ok(pen
!= NULL
, "Expected pen to be initialized\n");
871 /* InvalidParameter cases: null graphics, null pen */
872 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
873 expect(InvalidParameter
, status
);
875 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
876 expect(InvalidParameter
, status
);
878 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
879 expect(InvalidParameter
, status
);
881 /* InvalidParameter cases: invalid count */
882 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
883 expect(InvalidParameter
, status
);
885 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
886 expect(InvalidParameter
, status
);
888 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
889 expect(InvalidParameter
, status
);
891 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
892 expect(InvalidParameter
, status
);
894 /* InvalidParameter cases: invalid number of segments */
895 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
896 expect(InvalidParameter
, status
);
898 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
899 expect(InvalidParameter
, status
);
901 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
902 expect(InvalidParameter
, status
);
904 /* Valid test cases */
905 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
908 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
911 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
914 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
918 GdipDeleteGraphics(graphics
);
920 ReleaseDC(hwnd
, hdc
);
923 static void test_GdipDrawCurve3I(void)
926 GpGraphics
*graphics
= NULL
;
928 HDC hdc
= GetDC( hwnd
);
940 /* make a graphics object and pen object */
941 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
943 status
= GdipCreateFromHDC(hdc
, &graphics
);
945 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
947 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
949 ok(pen
!= NULL
, "Expected pen to be initialized\n");
951 /* InvalidParameter cases: null graphics, null pen */
952 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
953 expect(InvalidParameter
, status
);
955 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
956 expect(InvalidParameter
, status
);
958 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
959 expect(InvalidParameter
, status
);
961 /* InvalidParameter cases: invalid count */
962 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
963 expect(OutOfMemory
, status
);
965 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
966 expect(InvalidParameter
, status
);
968 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
969 expect(InvalidParameter
, status
);
971 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
972 expect(InvalidParameter
, status
);
974 /* InvalidParameter cases: invalid number of segments */
975 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
976 expect(InvalidParameter
, status
);
978 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
979 expect(InvalidParameter
, status
);
981 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
982 expect(InvalidParameter
, status
);
984 /* Valid test cases */
985 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
988 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
991 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
994 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
998 GdipDeleteGraphics(graphics
);
1000 ReleaseDC(hwnd
, hdc
);
1003 static void test_GdipDrawCurve2(void)
1006 GpGraphics
*graphics
= NULL
;
1008 HDC hdc
= GetDC( hwnd
);
1020 /* make a graphics object and pen object */
1021 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1023 status
= GdipCreateFromHDC(hdc
, &graphics
);
1025 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1027 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1029 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1031 /* InvalidParameter cases: null graphics, null pen */
1032 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
1033 expect(InvalidParameter
, status
);
1035 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
1036 expect(InvalidParameter
, status
);
1038 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
1039 expect(InvalidParameter
, status
);
1041 /* InvalidParameter cases: invalid count */
1042 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
1043 expect(InvalidParameter
, status
);
1045 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
1046 expect(InvalidParameter
, status
);
1048 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
1049 expect(InvalidParameter
, status
);
1051 /* Valid test cases */
1052 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
1055 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
1058 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
1061 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
1065 GdipDeleteGraphics(graphics
);
1067 ReleaseDC(hwnd
, hdc
);
1070 static void test_GdipDrawCurve2I(void)
1073 GpGraphics
*graphics
= NULL
;
1075 HDC hdc
= GetDC( hwnd
);
1087 /* make a graphics object and pen object */
1088 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1090 status
= GdipCreateFromHDC(hdc
, &graphics
);
1092 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1094 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1096 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1098 /* InvalidParameter cases: null graphics, null pen */
1099 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
1100 expect(InvalidParameter
, status
);
1102 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
1103 expect(InvalidParameter
, status
);
1105 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
1106 expect(InvalidParameter
, status
);
1108 /* InvalidParameter cases: invalid count */
1109 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
1110 expect(OutOfMemory
, status
);
1112 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
1113 expect(InvalidParameter
, status
);
1115 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
1116 expect(InvalidParameter
, status
);
1118 /* Valid test cases */
1119 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
1122 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
1125 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
1128 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
1132 GdipDeleteGraphics(graphics
);
1134 ReleaseDC(hwnd
, hdc
);
1137 static void test_GdipDrawCurve(void)
1140 GpGraphics
*graphics
= NULL
;
1142 HDC hdc
= GetDC( hwnd
);
1154 /* make a graphics object and pen object */
1155 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1157 status
= GdipCreateFromHDC(hdc
, &graphics
);
1159 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1161 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1163 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1165 /* InvalidParameter cases: null graphics, null pen */
1166 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
1167 expect(InvalidParameter
, status
);
1169 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
1170 expect(InvalidParameter
, status
);
1172 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
1173 expect(InvalidParameter
, status
);
1175 /* InvalidParameter cases: invalid count */
1176 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
1177 expect(InvalidParameter
, status
);
1179 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
1180 expect(InvalidParameter
, status
);
1182 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
1183 expect(InvalidParameter
, status
);
1185 /* Valid test cases */
1186 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
1189 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
1193 GdipDeleteGraphics(graphics
);
1195 ReleaseDC(hwnd
, hdc
);
1198 static void test_GdipDrawCurveI(void)
1201 GpGraphics
*graphics
= NULL
;
1203 HDC hdc
= GetDC( hwnd
);
1215 /* make a graphics object and pen object */
1216 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1218 status
= GdipCreateFromHDC(hdc
, &graphics
);
1220 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1222 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1224 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1226 /* InvalidParameter cases: null graphics, null pen */
1227 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
1228 expect(InvalidParameter
, status
);
1230 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
1231 expect(InvalidParameter
, status
);
1233 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
1234 expect(InvalidParameter
, status
);
1236 /* InvalidParameter cases: invalid count */
1237 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
1238 expect(OutOfMemory
, status
);
1240 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
1241 expect(InvalidParameter
, status
);
1243 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
1244 expect(InvalidParameter
, status
);
1246 /* Valid test cases */
1247 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
1250 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
1254 GdipDeleteGraphics(graphics
);
1256 ReleaseDC(hwnd
, hdc
);
1259 static void test_GdipDrawLineI(void)
1262 GpGraphics
*graphics
= NULL
;
1264 HDC hdc
= GetDC( hwnd
);
1266 /* make a graphics object and pen object */
1267 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1269 status
= GdipCreateFromHDC(hdc
, &graphics
);
1271 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1273 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1275 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1277 /* InvalidParameter cases: null graphics, null pen */
1278 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
1279 expect(InvalidParameter
, status
);
1281 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
1282 expect(InvalidParameter
, status
);
1284 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
1285 expect(InvalidParameter
, status
);
1287 /* successful case */
1288 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
1292 GdipDeleteGraphics(graphics
);
1294 ReleaseDC(hwnd
, hdc
);
1297 static void test_GdipDrawImagePointsRect(void)
1300 GpGraphics
*graphics
= NULL
;
1302 GpBitmap
*bm
= NULL
;
1303 BYTE rbmi
[sizeof(BITMAPINFOHEADER
)];
1305 BITMAPINFO
*bmi
= (BITMAPINFO
*)rbmi
;
1306 HDC hdc
= GetDC( hwnd
);
1310 memset(rbmi
, 0, sizeof(rbmi
));
1311 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1312 bmi
->bmiHeader
.biWidth
= 10;
1313 bmi
->bmiHeader
.biHeight
= 10;
1314 bmi
->bmiHeader
.biPlanes
= 1;
1315 bmi
->bmiHeader
.biBitCount
= 32;
1316 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1317 status
= GdipCreateBitmapFromGdiDib(bmi
, buff
, &bm
);
1319 ok(NULL
!= bm
, "Expected bitmap to be initialized\n");
1320 status
= GdipCreateFromHDC(hdc
, &graphics
);
1330 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 4, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1331 expect(NotImplemented
, status
);
1332 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 2, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1333 expect(InvalidParameter
, status
);
1334 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1336 status
= GdipDrawImagePointsRect(graphics
, NULL
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1337 expect(InvalidParameter
, status
);
1338 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, NULL
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1339 expect(InvalidParameter
, status
);
1340 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 0, 0, UnitPixel
, NULL
, NULL
, NULL
);
1342 memset(ptf
, 0, sizeof(ptf
));
1343 status
= GdipDrawImagePointsRect(graphics
, (GpImage
*)bm
, ptf
, 3, 0, 0, 10, 10, UnitPixel
, NULL
, NULL
, NULL
);
1346 GdipDisposeImage((GpImage
*)bm
);
1347 GdipDeleteGraphics(graphics
);
1348 ReleaseDC(hwnd
, hdc
);
1351 static void test_GdipDrawLinesI(void)
1354 GpGraphics
*graphics
= NULL
;
1356 GpPoint
*ptf
= NULL
;
1357 HDC hdc
= GetDC( hwnd
);
1359 /* make a graphics object and pen object */
1360 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1362 status
= GdipCreateFromHDC(hdc
, &graphics
);
1364 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1366 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1368 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1370 /* make some arbitrary valid points*/
1371 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1379 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1380 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1381 expect(InvalidParameter
, status
);
1383 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1384 expect(InvalidParameter
, status
);
1386 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1387 expect(InvalidParameter
, status
);
1389 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1390 expect(InvalidParameter
, status
);
1392 /* successful case */
1393 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1398 GdipDeleteGraphics(graphics
);
1400 ReleaseDC(hwnd
, hdc
);
1403 static void test_GdipFillClosedCurve(void)
1406 GpGraphics
*graphics
= NULL
;
1407 GpSolidFill
*brush
= NULL
;
1408 HDC hdc
= GetDC( hwnd
);
1420 /* make a graphics object and brush object */
1421 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1423 status
= GdipCreateFromHDC(hdc
, &graphics
);
1425 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1427 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1429 /* InvalidParameter cases: null graphics, null brush, null points */
1430 status
= GdipFillClosedCurve(NULL
, NULL
, NULL
, 3);
1431 expect(InvalidParameter
, status
);
1433 status
= GdipFillClosedCurve(graphics
, NULL
, NULL
, 3);
1434 expect(InvalidParameter
, status
);
1436 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, NULL
, 3);
1437 expect(InvalidParameter
, status
);
1439 status
= GdipFillClosedCurve(NULL
, NULL
, points
, 3);
1440 expect(InvalidParameter
, status
);
1442 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, NULL
, 3);
1443 expect(InvalidParameter
, status
);
1445 status
= GdipFillClosedCurve(graphics
, NULL
, points
, 3);
1446 expect(InvalidParameter
, status
);
1448 status
= GdipFillClosedCurve(NULL
, (GpBrush
*)brush
, points
, 3);
1449 expect(InvalidParameter
, status
);
1451 /* InvalidParameter cases: invalid count */
1452 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, -1);
1453 expect(InvalidParameter
, status
);
1455 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 0);
1456 expect(InvalidParameter
, status
);
1458 /* Valid test cases */
1459 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 1);
1462 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 2);
1465 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, points
, 3);
1468 GdipDeleteGraphics(graphics
);
1469 GdipDeleteBrush((GpBrush
*)brush
);
1471 ReleaseDC(hwnd
, hdc
);
1474 static void test_GdipFillClosedCurveI(void)
1477 GpGraphics
*graphics
= NULL
;
1478 GpSolidFill
*brush
= NULL
;
1479 HDC hdc
= GetDC( hwnd
);
1491 /* make a graphics object and brush object */
1492 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1494 status
= GdipCreateFromHDC(hdc
, &graphics
);
1496 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1498 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1500 /* InvalidParameter cases: null graphics, null brush */
1501 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1502 when points == NULL, so don't test this condition */
1503 status
= GdipFillClosedCurveI(NULL
, NULL
, points
, 3);
1504 expect(InvalidParameter
, status
);
1506 status
= GdipFillClosedCurveI(graphics
, NULL
, points
, 3);
1507 expect(InvalidParameter
, status
);
1509 status
= GdipFillClosedCurveI(NULL
, (GpBrush
*)brush
, points
, 3);
1510 expect(InvalidParameter
, status
);
1512 /* InvalidParameter cases: invalid count */
1513 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 0);
1514 expect(InvalidParameter
, status
);
1516 /* OutOfMemory cases: large (unsigned) int */
1517 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, -1);
1518 expect(OutOfMemory
, status
);
1520 /* Valid test cases */
1521 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 1);
1524 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 2);
1527 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, points
, 3);
1530 GdipDeleteGraphics(graphics
);
1531 GdipDeleteBrush((GpBrush
*)brush
);
1533 ReleaseDC(hwnd
, hdc
);
1536 static void test_Get_Release_DC(void)
1539 GpGraphics
*graphics
= NULL
;
1543 HDC hdc
= GetDC( hwnd
);
1546 CompositingQuality quality
;
1547 CompositingMode compmode
;
1548 InterpolationMode intmode
;
1552 PixelOffsetMode offsetmode
;
1553 SmoothingMode smoothmode
;
1554 TextRenderingHint texthint
;
1562 ARGB color
= 0x00000000;
1563 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1576 for(i
= 0; i
< 5;i
++){
1577 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1578 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1584 rect
[0].Height
= 70;
1588 rect
[1].Height
= 20;
1590 for(i
= 0; i
< 2;i
++){
1591 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1592 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1593 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1594 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1597 status
= GdipCreateMatrix(&m
);
1599 GdipCreateRegion(®ion
);
1600 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1601 GdipCreatePath(FillModeAlternate
, &path
);
1602 GdipCreateRegion(&clip
);
1604 status
= GdipCreateFromHDC(hdc
, &graphics
);
1606 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1607 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1610 /* NULL arguments */
1611 status
= GdipGetDC(NULL
, NULL
);
1612 expect(InvalidParameter
, status
);
1613 status
= GdipGetDC(graphics
, NULL
);
1614 expect(InvalidParameter
, status
);
1615 status
= GdipGetDC(NULL
, &retdc
);
1616 expect(InvalidParameter
, status
);
1618 status
= GdipReleaseDC(NULL
, NULL
);
1619 expect(InvalidParameter
, status
);
1620 status
= GdipReleaseDC(graphics
, NULL
);
1621 expect(InvalidParameter
, status
);
1622 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1623 expect(InvalidParameter
, status
);
1625 /* Release without Get */
1626 status
= GdipReleaseDC(graphics
, hdc
);
1627 expect(InvalidParameter
, status
);
1630 status
= GdipGetDC(graphics
, &retdc
);
1632 ok(retdc
== hdc
, "Invalid HDC returned\n");
1633 /* call it once more */
1634 status
= GdipGetDC(graphics
, &retdc
);
1635 expect(ObjectBusy
, status
);
1637 /* try all Graphics calls here */
1638 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1639 expect(ObjectBusy
, status
);
1640 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1641 expect(ObjectBusy
, status
);
1642 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1643 expect(ObjectBusy
, status
);
1644 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1645 expect(ObjectBusy
, status
);
1646 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1647 expect(ObjectBusy
, status
);
1648 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1649 expect(ObjectBusy
, status
);
1650 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1651 expect(ObjectBusy
, status
);
1652 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1653 expect(ObjectBusy
, status
);
1654 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1655 expect(ObjectBusy
, status
);
1656 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1657 expect(ObjectBusy
, status
);
1658 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1659 expect(ObjectBusy
, status
);
1660 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1661 expect(ObjectBusy
, status
);
1662 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1663 expect(ObjectBusy
, status
);
1664 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1665 expect(ObjectBusy
, status
);
1666 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1667 expect(ObjectBusy
, status
);
1668 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1669 expect(ObjectBusy
, status
);
1670 /* GdipDrawImage/GdipDrawImageI */
1671 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1672 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1673 /* GdipDrawImageRect/GdipDrawImageRectI */
1674 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1675 expect(ObjectBusy
, status
);
1676 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1677 expect(ObjectBusy
, status
);
1678 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1679 expect(ObjectBusy
, status
);
1680 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1681 expect(ObjectBusy
, status
);
1682 status
= GdipDrawPath(graphics
, pen
, path
);
1683 expect(ObjectBusy
, status
);
1684 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1685 expect(ObjectBusy
, status
);
1686 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1687 expect(ObjectBusy
, status
);
1688 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1689 expect(ObjectBusy
, status
);
1690 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1691 expect(ObjectBusy
, status
);
1692 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1693 expect(ObjectBusy
, status
);
1694 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1695 expect(ObjectBusy
, status
);
1696 /* GdipDrawString */
1697 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1698 expect(ObjectBusy
, status
);
1699 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1700 expect(ObjectBusy
, status
);
1701 status
= GdipFillClosedCurve(graphics
, (GpBrush
*)brush
, ptf
, 5);
1702 expect(ObjectBusy
, status
);
1703 status
= GdipFillClosedCurveI(graphics
, (GpBrush
*)brush
, pt
, 5);
1704 expect(ObjectBusy
, status
);
1705 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1706 expect(ObjectBusy
, status
);
1707 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1708 expect(ObjectBusy
, status
);
1709 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1710 expect(ObjectBusy
, status
);
1711 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1712 expect(ObjectBusy
, status
);
1713 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1714 expect(ObjectBusy
, status
);
1715 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1716 expect(ObjectBusy
, status
);
1717 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1718 expect(ObjectBusy
, status
);
1719 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1720 expect(ObjectBusy
, status
);
1721 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1722 expect(ObjectBusy
, status
);
1723 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1724 expect(ObjectBusy
, status
);
1725 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1726 expect(ObjectBusy
, status
);
1727 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1728 expect(ObjectBusy
, status
);
1729 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1730 expect(ObjectBusy
, status
);
1731 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1732 expect(ObjectBusy
, status
);
1733 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1734 expect(ObjectBusy
, status
);
1735 status
= GdipGetClipBounds(graphics
, rectf
);
1736 expect(ObjectBusy
, status
);
1737 status
= GdipGetClipBoundsI(graphics
, rect
);
1738 expect(ObjectBusy
, status
);
1739 status
= GdipGetCompositingMode(graphics
, &compmode
);
1740 expect(ObjectBusy
, status
);
1741 status
= GdipGetCompositingQuality(graphics
, &quality
);
1742 expect(ObjectBusy
, status
);
1743 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1744 expect(ObjectBusy
, status
);
1745 status
= GdipGetNearestColor(graphics
, &color
);
1746 expect(ObjectBusy
, status
);
1747 status
= GdipGetPageScale(graphics
, &r
);
1748 expect(ObjectBusy
, status
);
1749 status
= GdipGetPageUnit(graphics
, &unit
);
1750 expect(ObjectBusy
, status
);
1751 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1752 expect(ObjectBusy
, status
);
1753 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1754 expect(ObjectBusy
, status
);
1755 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1756 expect(ObjectBusy
, status
);
1757 status
= GdipGetWorldTransform(graphics
, m
);
1758 expect(ObjectBusy
, status
);
1759 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1760 expect(ObjectBusy
, status
);
1761 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1762 expect(ObjectBusy
, status
);
1763 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1764 expect(ObjectBusy
, status
);
1765 /* GdipMeasureCharacterRanges */
1766 /* GdipMeasureString */
1767 status
= GdipResetClip(graphics
);
1768 expect(ObjectBusy
, status
);
1769 status
= GdipResetWorldTransform(graphics
);
1770 expect(ObjectBusy
, status
);
1771 /* GdipRestoreGraphics */
1772 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1773 expect(ObjectBusy
, status
);
1774 /* GdipSaveGraphics */
1775 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1776 expect(ObjectBusy
, status
);
1777 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1778 expect(ObjectBusy
, status
);
1779 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1780 expect(ObjectBusy
, status
);
1781 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1782 expect(ObjectBusy
, status
);
1783 status
= GdipSetPageScale(graphics
, 1.0);
1784 expect(ObjectBusy
, status
);
1785 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1786 expect(ObjectBusy
, status
);
1787 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1788 expect(ObjectBusy
, status
);
1789 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1790 expect(ObjectBusy
, status
);
1791 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1792 expect(ObjectBusy
, status
);
1793 status
= GdipSetWorldTransform(graphics
, m
);
1794 expect(ObjectBusy
, status
);
1795 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1796 expect(ObjectBusy
, status
);
1797 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1798 expect(ObjectBusy
, status
);
1799 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1800 expect(ObjectBusy
, status
);
1801 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1802 expect(ObjectBusy
, status
);
1803 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1804 expect(ObjectBusy
, status
);
1805 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1806 expect(ObjectBusy
, status
);
1807 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1808 expect(ObjectBusy
, status
);
1809 status
= GdipTranslateClipI(graphics
, 0, 0);
1810 expect(ObjectBusy
, status
);
1811 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1812 expect(ObjectBusy
, status
);
1813 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1814 expect(ObjectBusy
, status
);
1815 status
= GdipGetDpiX(graphics
, &r
);
1816 expect(ObjectBusy
, status
);
1817 status
= GdipGetDpiY(graphics
, &r
);
1818 expect(ObjectBusy
, status
);
1819 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1820 expect(ObjectBusy
, status
);
1821 status
= GdipGetClip(graphics
, region
);
1822 expect(ObjectBusy
, status
);
1823 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1824 expect(ObjectBusy
, status
);
1826 /* try to delete before release */
1827 status
= GdipDeleteGraphics(graphics
);
1828 expect(ObjectBusy
, status
);
1830 status
= GdipReleaseDC(graphics
, retdc
);
1834 GdipDeleteGraphics(graphics
);
1836 GdipDeleteRegion(clip
);
1837 GdipDeletePath(path
);
1838 GdipDeleteBrush((GpBrush
*)brush
);
1839 GdipDeleteRegion(region
);
1840 GdipDeleteMatrix(m
);
1843 ReleaseDC(hwnd
, hdc
);
1846 static void test_transformpoints(void)
1849 GpGraphics
*graphics
= NULL
;
1850 HDC hdc
= GetDC( hwnd
);
1854 status
= GdipCreateFromHDC(hdc
, &graphics
);
1857 /* NULL arguments */
1858 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1859 expect(InvalidParameter
, status
);
1860 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1861 expect(InvalidParameter
, status
);
1862 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1863 expect(InvalidParameter
, status
);
1864 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1865 expect(InvalidParameter
, status
);
1867 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
+1, CoordinateSpaceWorld
, ptf
, 2);
1868 expect(InvalidParameter
, status
);
1869 status
= GdipTransformPoints(graphics
, -1, CoordinateSpaceWorld
, ptf
, 2);
1870 expect(InvalidParameter
, status
);
1871 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceDevice
+1, ptf
, 2);
1872 expect(InvalidParameter
, status
);
1873 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, -1, ptf
, 2);
1874 expect(InvalidParameter
, status
);
1880 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1882 expectf(1.0, ptf
[0].X
);
1883 expectf(0.0, ptf
[0].Y
);
1884 expectf(0.0, ptf
[1].X
);
1885 expectf(1.0, ptf
[1].Y
);
1887 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1889 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1891 status
= GdipSetPageScale(graphics
, 3.0);
1898 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1900 expectf(18.0, ptf
[0].X
);
1901 expectf(15.0, ptf
[0].Y
);
1902 expectf(15.0, ptf
[1].X
);
1903 expectf(18.0, ptf
[1].Y
);
1909 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1911 expectf(6.0, ptf
[0].X
);
1912 expectf(5.0, ptf
[0].Y
);
1913 expectf(5.0, ptf
[1].X
);
1914 expectf(6.0, ptf
[1].Y
);
1920 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1922 expectf(3.0, ptf
[0].X
);
1923 expectf(0.0, ptf
[0].Y
);
1924 expectf(0.0, ptf
[1].X
);
1925 expectf(3.0, ptf
[1].Y
);
1931 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1933 expectf(1.0, ptf
[0].X
);
1934 expectf(0.0, ptf
[0].Y
);
1935 expectf(0.0, ptf
[1].X
);
1936 expectf(1.0, ptf
[1].Y
);
1942 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1944 expectf(1.0, ptf
[0].X
);
1945 expectf(0.0, ptf
[0].Y
);
1946 expectf(0.0, ptf
[1].X
);
1947 expectf(1.0, ptf
[1].Y
);
1953 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1955 expectf(1.0, ptf
[0].X
);
1956 expectf(0.0, ptf
[0].Y
);
1957 expectf(0.0, ptf
[1].X
);
1958 expectf(1.0, ptf
[1].Y
);
1964 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1966 expect(18, pt
[0].X
);
1967 expect(15, pt
[0].Y
);
1968 expect(15, pt
[1].X
);
1969 expect(18, pt
[1].Y
);
1971 GdipDeleteGraphics(graphics
);
1972 ReleaseDC(hwnd
, hdc
);
1975 static void test_get_set_clip(void)
1978 GpGraphics
*graphics
= NULL
;
1979 HDC hdc
= GetDC( hwnd
);
1984 status
= GdipCreateFromHDC(hdc
, &graphics
);
1987 rect
.X
= rect
.Y
= 0.0;
1988 rect
.Height
= rect
.Width
= 100.0;
1990 status
= GdipCreateRegionRect(&rect
, &clip
);
1993 /* NULL arguments */
1994 status
= GdipGetClip(NULL
, NULL
);
1995 expect(InvalidParameter
, status
);
1996 status
= GdipGetClip(graphics
, NULL
);
1997 expect(InvalidParameter
, status
);
1998 status
= GdipGetClip(NULL
, clip
);
1999 expect(InvalidParameter
, status
);
2001 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
2002 expect(InvalidParameter
, status
);
2003 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
2004 expect(InvalidParameter
, status
);
2006 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
2007 expect(InvalidParameter
, status
);
2008 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
2009 expect(InvalidParameter
, status
);
2012 status
= GdipGetClip(graphics
, clip
);
2014 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2018 /* remains infinite after reset */
2020 status
= GdipResetClip(graphics
);
2022 status
= GdipGetClip(graphics
, clip
);
2024 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2028 /* set to empty and then reset to infinite */
2029 status
= GdipSetEmpty(clip
);
2031 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
2034 status
= GdipGetClip(graphics
, clip
);
2037 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
2040 status
= GdipResetClip(graphics
);
2042 status
= GdipGetClip(graphics
, clip
);
2045 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
2049 GdipDeleteRegion(clip
);
2051 GdipDeleteGraphics(graphics
);
2052 ReleaseDC(hwnd
, hdc
);
2055 static void test_isempty(void)
2058 GpGraphics
*graphics
= NULL
;
2059 HDC hdc
= GetDC( hwnd
);
2063 status
= GdipCreateFromHDC(hdc
, &graphics
);
2066 status
= GdipCreateRegion(&clip
);
2070 status
= GdipIsClipEmpty(NULL
, NULL
);
2071 expect(InvalidParameter
, status
);
2072 status
= GdipIsClipEmpty(graphics
, NULL
);
2073 expect(InvalidParameter
, status
);
2074 status
= GdipIsClipEmpty(NULL
, &res
);
2075 expect(InvalidParameter
, status
);
2077 /* default is infinite */
2079 status
= GdipIsClipEmpty(graphics
, &res
);
2083 GdipDeleteRegion(clip
);
2085 GdipDeleteGraphics(graphics
);
2086 ReleaseDC(hwnd
, hdc
);
2089 static void test_clear(void)
2093 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
2094 expect(InvalidParameter
, status
);
2097 static void test_textcontrast(void)
2100 HDC hdc
= GetDC( hwnd
);
2101 GpGraphics
*graphics
;
2104 status
= GdipGetTextContrast(NULL
, NULL
);
2105 expect(InvalidParameter
, status
);
2107 status
= GdipCreateFromHDC(hdc
, &graphics
);
2110 status
= GdipGetTextContrast(graphics
, NULL
);
2111 expect(InvalidParameter
, status
);
2112 status
= GdipGetTextContrast(graphics
, &contrast
);
2114 expect(4, contrast
);
2116 GdipDeleteGraphics(graphics
);
2117 ReleaseDC(hwnd
, hdc
);
2120 static void test_GdipDrawString(void)
2123 GpGraphics
*graphics
= NULL
;
2126 GpStringFormat
*format
;
2129 HDC hdc
= GetDC( hwnd
);
2130 static const WCHAR string
[] = {'T','e','s','t',0};
2131 static const PointF positions
[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
2134 memset(&logfont
,0,sizeof(logfont
));
2135 strcpy(logfont
.lfFaceName
,"Arial");
2136 logfont
.lfHeight
= 12;
2137 logfont
.lfCharSet
= DEFAULT_CHARSET
;
2139 status
= GdipCreateFromHDC(hdc
, &graphics
);
2142 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
2143 if (status
== NotTrueTypeFont
|| status
== FileNotFound
)
2145 skip("Arial not installed.\n");
2150 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
2153 status
= GdipCreateStringFormat(0,0,&format
);
2161 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
2164 status
= GdipCreateMatrix(&matrix
);
2167 status
= GdipDrawDriverString(NULL
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2168 expect(InvalidParameter
, status
);
2170 status
= GdipDrawDriverString(graphics
, NULL
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2171 expect(InvalidParameter
, status
);
2173 status
= GdipDrawDriverString(graphics
, string
, 4, NULL
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2174 expect(InvalidParameter
, status
);
2176 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, NULL
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2177 expect(InvalidParameter
, status
);
2179 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, NULL
, DriverStringOptionsCmapLookup
, matrix
);
2180 expect(InvalidParameter
, status
);
2182 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
|0x10, matrix
);
2185 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, NULL
);
2188 status
= GdipDrawDriverString(graphics
, string
, 4, fnt
, brush
, positions
, DriverStringOptionsCmapLookup
, matrix
);
2191 GdipDeleteMatrix(matrix
);
2192 GdipDeleteGraphics(graphics
);
2193 GdipDeleteBrush(brush
);
2194 GdipDeleteFont(fnt
);
2195 GdipDeleteStringFormat(format
);
2197 ReleaseDC(hwnd
, hdc
);
2200 static void test_GdipGetVisibleClipBounds_screen(void)
2203 GpGraphics
*graphics
= NULL
;
2205 GpRectF rectf
, exp
, clipr
;
2208 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2210 status
= GdipCreateFromHDC(hdc
, &graphics
);
2212 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2214 /* no clipping rect */
2217 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
2218 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
2220 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2222 ok(rectf
.X
== exp
.X
&&
2224 rectf
.Width
== exp
.Width
&&
2225 rectf
.Height
== exp
.Height
,
2226 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2227 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
2228 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2229 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2231 /* clipping rect entirely within window */
2232 exp
.X
= clipr
.X
= 10;
2233 exp
.Y
= clipr
.Y
= 12;
2234 exp
.Width
= clipr
.Width
= 14;
2235 exp
.Height
= clipr
.Height
= 16;
2237 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2240 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2242 ok(rectf
.X
== exp
.X
&&
2244 rectf
.Width
== exp
.Width
&&
2245 rectf
.Height
== exp
.Height
,
2246 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2247 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2248 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2249 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2251 /* clipping rect partially outside of screen */
2257 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2265 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2267 ok(rectf
.X
== exp
.X
&&
2269 rectf
.Width
== exp
.Width
&&
2270 rectf
.Height
== exp
.Height
,
2271 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2272 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2273 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2274 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2276 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2278 ok(recti
.X
== exp
.X
&&
2280 recti
.Width
== exp
.Width
&&
2281 recti
.Height
== exp
.Height
,
2282 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2283 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2284 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2285 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2287 GdipDeleteGraphics(graphics
);
2291 static void test_GdipGetVisibleClipBounds_window(void)
2294 GpGraphics
*graphics
= NULL
;
2295 GpRectF rectf
, window
, exp
, clipr
;
2301 /* get client area size */
2302 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
2303 window
.X
= wnd_rect
.left
;
2304 window
.Y
= wnd_rect
.top
;
2305 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
2306 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
2308 hdc
= BeginPaint(hwnd
, &ps
);
2310 status
= GdipCreateFromHDC(hdc
, &graphics
);
2312 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2314 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2316 ok(rectf
.X
== window
.X
&&
2317 rectf
.Y
== window
.Y
&&
2318 rectf
.Width
== window
.Width
&&
2319 rectf
.Height
== window
.Height
,
2320 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2321 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2322 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2323 window
.X
, window
.Y
, window
.Width
, window
.Height
);
2325 /* clipping rect entirely within window */
2326 exp
.X
= clipr
.X
= 20;
2327 exp
.Y
= clipr
.Y
= 8;
2328 exp
.Width
= clipr
.Width
= 30;
2329 exp
.Height
= clipr
.Height
= 20;
2331 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2334 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2336 ok(rectf
.X
== exp
.X
&&
2338 rectf
.Width
== exp
.Width
&&
2339 rectf
.Height
== exp
.Height
,
2340 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2341 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2342 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2343 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2345 /* clipping rect partially outside of window */
2346 clipr
.X
= window
.Width
- 10;
2347 clipr
.Y
= window
.Height
- 15;
2351 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
2354 exp
.X
= window
.Width
- 10;
2355 exp
.Y
= window
.Height
- 15;
2359 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2361 ok(rectf
.X
== exp
.X
&&
2363 rectf
.Width
== exp
.Width
&&
2364 rectf
.Height
== exp
.Height
,
2365 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2366 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2367 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2368 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2370 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
2372 ok(recti
.X
== exp
.X
&&
2374 recti
.Width
== exp
.Width
&&
2375 recti
.Height
== exp
.Height
,
2376 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2377 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2378 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
2379 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2381 /* window bounds with transform applied */
2382 status
= GdipResetClip(graphics
);
2385 status
= GdipScaleWorldTransform(graphics
, 0.5, 0.5, MatrixOrderPrepend
);
2388 exp
.X
= window
.X
* 2.0;
2389 exp
.Y
= window
.Y
* 2.0;
2390 exp
.Width
= window
.Width
* 2.0;
2391 exp
.Height
= window
.Height
* 2.0;
2393 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
2395 ok(rectf
.X
== exp
.X
&&
2397 rectf
.Width
== exp
.Width
&&
2398 rectf
.Height
== exp
.Height
,
2399 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be "
2400 "twice the window size (%0.f, %0.f, %0.f, %0.f)\n",
2401 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
2402 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
2404 GdipDeleteGraphics(graphics
);
2405 EndPaint(hwnd
, &ps
);
2408 static void test_GdipGetVisibleClipBounds(void)
2410 GpGraphics
* graphics
= NULL
;
2413 HDC hdc
= GetDC( hwnd
);
2416 status
= GdipCreateFromHDC(hdc
, &graphics
);
2418 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2420 /* test null parameters */
2421 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
2422 expect(InvalidParameter
, status
);
2424 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
2425 expect(InvalidParameter
, status
);
2427 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
2428 expect(InvalidParameter
, status
);
2430 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
2431 expect(InvalidParameter
, status
);
2433 GdipDeleteGraphics(graphics
);
2434 ReleaseDC(hwnd
, hdc
);
2436 test_GdipGetVisibleClipBounds_screen();
2437 test_GdipGetVisibleClipBounds_window();
2440 static void test_fromMemoryBitmap(void)
2443 GpGraphics
*graphics
= NULL
;
2444 GpBitmap
*bitmap
= NULL
;
2445 BYTE bits
[48] = {0};
2449 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
2452 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2455 status
= GdipGraphicsClear(graphics
, 0xff686868);
2458 GdipDeleteGraphics(graphics
);
2460 /* drawing writes to the memory provided */
2461 expect(0x68, bits
[10]);
2463 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2466 status
= GdipGetDC(graphics
, &hdc
);
2468 ok(hdc
!= NULL
, "got NULL hdc\n");
2470 color
= GetPixel(hdc
, 0, 0);
2471 /* The HDC is write-only, and native fills with a solid color to figure out
2472 * which pixels have changed. */
2473 todo_wine
expect(0x0c0b0d, color
);
2475 SetPixel(hdc
, 0, 0, 0x797979);
2476 SetPixel(hdc
, 1, 0, 0x0c0b0d);
2478 status
= GdipReleaseDC(graphics
, hdc
);
2481 GdipDeleteGraphics(graphics
);
2483 expect(0x79, bits
[0]);
2484 todo_wine
expect(0x68, bits
[3]);
2486 GdipDisposeImage((GpImage
*)bitmap
);
2488 /* We get the same kind of write-only HDC for a "normal" bitmap */
2489 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
2492 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2495 status
= GdipGetDC(graphics
, &hdc
);
2497 ok(hdc
!= NULL
, "got NULL hdc\n");
2499 color
= GetPixel(hdc
, 0, 0);
2500 todo_wine
expect(0x0c0b0d, color
);
2502 status
= GdipReleaseDC(graphics
, hdc
);
2505 GdipDeleteGraphics(graphics
);
2507 GdipDisposeImage((GpImage
*)bitmap
);
2509 /* If we don't draw to the HDC, the bits are never accessed */
2510 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, (BYTE
*)1, &bitmap
);
2513 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2516 status
= GdipGetDC(graphics
, &hdc
);
2518 ok(hdc
!= NULL
, "got NULL hdc\n");
2520 color
= GetPixel(hdc
, 0, 0);
2521 todo_wine
expect(0x0c0b0d, color
);
2523 status
= GdipReleaseDC(graphics
, hdc
);
2526 GdipDeleteGraphics(graphics
);
2528 GdipDisposeImage((GpImage
*)bitmap
);
2531 static void test_GdipIsVisiblePoint(void)
2534 GpGraphics
*graphics
= NULL
;
2535 HDC hdc
= GetDC( hwnd
);
2539 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2541 status
= GdipCreateFromHDC(hdc
, &graphics
);
2543 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2545 /* null parameters */
2546 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
2547 expect(InvalidParameter
, status
);
2549 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
2550 expect(InvalidParameter
, status
);
2552 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
2553 expect(InvalidParameter
, status
);
2555 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
2556 expect(InvalidParameter
, status
);
2560 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2562 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2566 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2568 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2572 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2574 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2578 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2580 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2582 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2587 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2589 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2593 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2595 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2597 /* translate into the center of the rect */
2598 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2602 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2604 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2608 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2610 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2612 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2617 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2619 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2623 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2625 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2629 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2631 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2635 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2637 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2641 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2643 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2647 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2649 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2653 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2655 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2659 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2661 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2665 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2667 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2671 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2673 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2677 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2679 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2683 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2685 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2689 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2691 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2693 /* integer version */
2696 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2698 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2702 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2704 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2706 GdipDeleteGraphics(graphics
);
2707 ReleaseDC(hwnd
, hdc
);
2710 static void test_GdipIsVisibleRect(void)
2713 GpGraphics
*graphics
= NULL
;
2714 HDC hdc
= GetDC( hwnd
);
2715 REAL x
, y
, width
, height
;
2718 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2720 status
= GdipCreateFromHDC(hdc
, &graphics
);
2722 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2724 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2725 expect(InvalidParameter
, status
);
2727 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2728 expect(InvalidParameter
, status
);
2730 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2731 expect(InvalidParameter
, status
);
2733 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2734 expect(InvalidParameter
, status
);
2736 /* entirely within the visible region */
2739 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2741 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2743 /* partially outside */
2744 x
= -10; width
= 20;
2745 y
= -10; height
= 20;
2746 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2748 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2750 /* entirely outside */
2752 y
= -10; height
= 5;
2753 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2755 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2757 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2760 /* entirely within the visible region */
2762 y
= 22; height
= 10;
2763 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2765 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2767 /* partially outside */
2769 y
= 55; height
= 10;
2770 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2772 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2774 /* entirely outside */
2777 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2779 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2781 /* translate into center of clipping rect */
2782 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2786 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2788 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2792 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2794 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2796 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2798 /* corners entirely outside, but some intersections */
2801 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2803 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2807 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2809 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2813 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2815 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2819 y
= 20; height
= 40;
2820 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2822 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2826 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2828 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2831 y
= 20; height
= 40;
2832 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2834 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2837 y
= 60; height
= 10;
2838 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2840 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2842 /* rounding tests */
2843 x
= 0.4; width
= 10.4;
2844 y
= 20; height
= 40;
2845 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2847 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2850 y
= 0.4; height
= 20.4;
2851 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2853 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2855 /* integer version */
2858 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2860 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2863 y
= 22; height
= 10;
2864 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2866 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2868 GdipDeleteGraphics(graphics
);
2869 ReleaseDC(hwnd
, hdc
);
2872 static void test_GdipGetNearestColor(void)
2875 GpGraphics
*graphics
;
2877 ARGB color
= 0xdeadbeef;
2878 HDC hdc
= GetDC( hwnd
);
2880 /* create a graphics object */
2881 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2883 status
= GdipCreateFromHDC(hdc
, &graphics
);
2885 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2887 status
= GdipGetNearestColor(graphics
, NULL
);
2888 expect(InvalidParameter
, status
);
2890 status
= GdipGetNearestColor(NULL
, &color
);
2891 expect(InvalidParameter
, status
);
2892 GdipDeleteGraphics(graphics
);
2894 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed
, NULL
, &bitmap
);
2896 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2897 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2900 status
= GdipGetNearestColor(graphics
, &color
);
2902 expect(0xdeadbeef, color
);
2903 GdipDeleteGraphics(graphics
);
2905 GdipDisposeImage((GpImage
*)bitmap
);
2907 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed
, NULL
, &bitmap
);
2909 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2910 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2913 status
= GdipGetNearestColor(graphics
, &color
);
2915 expect(0xdeadbeef, color
);
2916 GdipDeleteGraphics(graphics
);
2918 GdipDisposeImage((GpImage
*)bitmap
);
2920 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed
, NULL
, &bitmap
);
2922 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2923 ok(broken(status
== OutOfMemory
) /* winver < Win7 */ || status
== Ok
, "status=%u\n", status
);
2926 status
= GdipGetNearestColor(graphics
, &color
);
2928 expect(0xdeadbeef, color
);
2929 GdipDeleteGraphics(graphics
);
2931 GdipDisposeImage((GpImage
*)bitmap
);
2933 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale
, NULL
, &bitmap
);
2935 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2936 todo_wine
expect(OutOfMemory
, status
);
2938 GdipDeleteGraphics(graphics
);
2939 GdipDisposeImage((GpImage
*)bitmap
);
2941 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB
, NULL
, &bitmap
);
2943 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2945 status
= GdipGetNearestColor(graphics
, &color
);
2947 expect(0xdeadbeef, color
);
2948 GdipDeleteGraphics(graphics
);
2949 GdipDisposeImage((GpImage
*)bitmap
);
2951 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB
, NULL
, &bitmap
);
2953 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2955 status
= GdipGetNearestColor(graphics
, &color
);
2957 expect(0xdeadbeef, color
);
2958 GdipDeleteGraphics(graphics
);
2959 GdipDisposeImage((GpImage
*)bitmap
);
2961 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB
, NULL
, &bitmap
);
2963 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2965 status
= GdipGetNearestColor(graphics
, &color
);
2967 expect(0xdeadbeef, color
);
2968 GdipDeleteGraphics(graphics
);
2969 GdipDisposeImage((GpImage
*)bitmap
);
2971 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB
, NULL
, &bitmap
);
2975 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2977 status
= GdipGetNearestColor(graphics
, &color
);
2979 expect(0xdeadbeef, color
);
2980 GdipDeleteGraphics(graphics
);
2981 GdipDisposeImage((GpImage
*)bitmap
);
2984 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB
, NULL
, &bitmap
);
2988 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
2990 status
= GdipGetNearestColor(graphics
, &color
);
2992 expect(0xdeadbeef, color
);
2993 GdipDeleteGraphics(graphics
);
2994 GdipDisposeImage((GpImage
*)bitmap
);
2997 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB
, NULL
, &bitmap
);
3001 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3003 status
= GdipGetNearestColor(graphics
, &color
);
3005 expect(0xdeadbeef, color
);
3006 GdipDeleteGraphics(graphics
);
3007 GdipDisposeImage((GpImage
*)bitmap
);
3010 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565
, NULL
, &bitmap
);
3012 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3014 status
= GdipGetNearestColor(graphics
, &color
);
3016 todo_wine
expect(0xffa8bce8, color
);
3017 GdipDeleteGraphics(graphics
);
3018 GdipDisposeImage((GpImage
*)bitmap
);
3020 status
= GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555
, NULL
, &bitmap
);
3022 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3024 status
= GdipGetNearestColor(graphics
, &color
);
3027 ok(color
== 0xffa8b8e8 ||
3028 broken(color
== 0xffa0b8e0), /* Win98/WinMe */
3029 "Expected ffa8b8e8, got %.8x\n", color
);
3030 GdipDeleteGraphics(graphics
);
3031 GdipDisposeImage((GpImage
*)bitmap
);
3033 ReleaseDC(hwnd
, hdc
);
3036 static void test_string_functions(void)
3039 GpGraphics
*graphics
;
3040 GpFontFamily
*family
;
3042 RectF rc
, char_bounds
, bounds
;
3044 ARGB color
= 0xff000000;
3045 HDC hdc
= GetDC( hwnd
);
3046 const WCHAR fontname
[] = {'T','a','h','o','m','a',0};
3047 const WCHAR teststring
[] = {'M','M',' ','M','\n','M',0};
3048 const WCHAR teststring2
[] = {'j',0};
3049 REAL char_width
, char_height
;
3050 INT codepointsfitted
, linesfilled
;
3051 GpStringFormat
*format
;
3052 CharacterRange ranges
[3] = {{0, 1}, {1, 3}, {5, 1}};
3053 GpRegion
*regions
[4];
3054 BOOL region_isempty
[4];
3056 PointF positions
[8];
3059 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3060 status
= GdipCreateFromHDC(hdc
, &graphics
);
3062 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3064 status
= GdipCreateFontFamilyFromName(fontname
, NULL
, &family
);
3067 status
= GdipCreateFont(family
, 10.0, FontStyleRegular
, UnitPixel
, &font
);
3070 status
= GdipCreateSolidFill(color
, (GpSolidFill
**)&brush
);
3073 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3081 status
= GdipDrawString(NULL
, teststring
, 6, font
, &rc
, NULL
, brush
);
3082 expect(InvalidParameter
, status
);
3084 status
= GdipDrawString(graphics
, NULL
, 6, font
, &rc
, NULL
, brush
);
3085 expect(InvalidParameter
, status
);
3087 status
= GdipDrawString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, brush
);
3088 expect(InvalidParameter
, status
);
3090 status
= GdipDrawString(graphics
, teststring
, 6, font
, NULL
, NULL
, brush
);
3091 expect(InvalidParameter
, status
);
3093 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
);
3094 expect(InvalidParameter
, status
);
3096 status
= GdipDrawString(graphics
, teststring
, 6, font
, &rc
, NULL
, brush
);
3099 status
= GdipMeasureString(NULL
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3100 expect(InvalidParameter
, status
);
3102 status
= GdipMeasureString(graphics
, NULL
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3103 expect(InvalidParameter
, status
);
3105 status
= GdipMeasureString(graphics
, teststring
, 6, NULL
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3106 expect(InvalidParameter
, status
);
3108 status
= GdipMeasureString(graphics
, teststring
, 6, font
, NULL
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3109 expect(InvalidParameter
, status
);
3111 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, NULL
, &codepointsfitted
, &linesfilled
);
3112 expect(InvalidParameter
, status
);
3114 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, NULL
, &linesfilled
);
3117 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, NULL
);
3120 status
= GdipMeasureString(graphics
, teststring
, 1, font
, &rc
, NULL
, &char_bounds
, &codepointsfitted
, &linesfilled
);
3122 expectf(0.0, char_bounds
.X
);
3123 expectf(0.0, char_bounds
.Y
);
3124 ok(char_bounds
.Width
> 0, "got %0.2f\n", bounds
.Width
);
3125 ok(char_bounds
.Height
> 0, "got %0.2f\n", bounds
.Height
);
3126 expect(1, codepointsfitted
);
3127 expect(1, linesfilled
);
3129 status
= GdipMeasureString(graphics
, teststring
, 2, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3131 expectf(0.0, bounds
.X
);
3132 expectf(0.0, bounds
.Y
);
3133 ok(bounds
.Width
> char_bounds
.Width
, "got %0.2f, expected at least %0.2f\n", bounds
.Width
, char_bounds
.Width
);
3134 expectf(char_bounds
.Height
, bounds
.Height
);
3135 expect(2, codepointsfitted
);
3136 expect(1, linesfilled
);
3137 char_width
= bounds
.Width
- char_bounds
.Width
;
3139 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3141 expectf(0.0, bounds
.X
);
3142 expectf(0.0, bounds
.Y
);
3143 ok(bounds
.Width
> char_bounds
.Width
+ char_width
* 2, "got %0.2f, expected at least %0.2f\n",
3144 bounds
.Width
, char_bounds
.Width
+ char_width
* 2);
3145 ok(bounds
.Height
> char_bounds
.Height
, "got %0.2f, expected at least %0.2f\n", bounds
.Height
, char_bounds
.Height
);
3146 expect(6, codepointsfitted
);
3147 expect(2, linesfilled
);
3148 char_height
= bounds
.Height
- char_bounds
.Height
;
3150 /* Measure the first line. */
3151 status
= GdipMeasureString(graphics
, teststring
, 4, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3153 expectf(0.0, bounds
.X
);
3154 expectf(0.0, bounds
.Y
);
3155 expect(4, codepointsfitted
);
3156 expect(1, linesfilled
);
3158 /* Give just enough space to fit the first line. */
3159 rc
.Width
= bounds
.Width
;
3160 status
= GdipMeasureString(graphics
, teststring
, 5, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3162 expectf(0.0, bounds
.X
);
3163 expectf(0.0, bounds
.Y
);
3164 todo_wine
expect(5, codepointsfitted
);
3165 todo_wine
expect(1, linesfilled
);
3167 /* Cut off everything after the first space. */
3168 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3170 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3172 expectf(0.0, bounds
.X
);
3173 expectf(0.0, bounds
.Y
);
3174 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3175 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3176 expect(6, codepointsfitted
);
3177 expect(3, linesfilled
);
3179 /* Cut off everything including the first space. */
3180 rc
.Width
= char_bounds
.Width
+ char_width
* 1.7;
3182 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3184 expectf(0.0, bounds
.X
);
3185 expectf(0.0, bounds
.Y
);
3186 expectf_(char_bounds
.Width
+ char_width
, bounds
.Width
, 0.01);
3187 expectf_(char_bounds
.Height
+ char_height
* 2, bounds
.Height
, 0.01);
3188 expect(6, codepointsfitted
);
3189 expect(3, linesfilled
);
3191 /* Cut off everything after the first character. */
3192 rc
.Width
= char_bounds
.Width
+ char_width
* 0.8;
3194 status
= GdipMeasureString(graphics
, teststring
, 6, font
, &rc
, NULL
, &bounds
, &codepointsfitted
, &linesfilled
);
3196 expectf(0.0, bounds
.X
);
3197 expectf(0.0, bounds
.Y
);
3198 expectf_(char_bounds
.Width
, bounds
.Width
, 0.01);
3199 expectf_(char_bounds
.Height
+ char_height
* 3, bounds
.Height
, 0.05);
3200 expect(6, codepointsfitted
);
3201 todo_wine
expect(4, linesfilled
);
3203 for (i
= 0; i
< 4; i
++)
3204 regions
[i
] = (GpRegion
*)0xdeadbeef;
3206 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 0, regions
);
3209 for (i
= 0; i
< 4; i
++)
3210 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3212 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3215 for (i
= 0; i
< 4; i
++)
3216 ok(regions
[i
] == (GpRegion
*)0xdeadbeef, "expected 0xdeadbeef, got %p\n", regions
[i
]);
3218 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 3, ranges
);
3221 set_rect_empty(&rc
);
3225 status
= GdipCreateRegion(®ions
[i
]);
3227 status
= GdipSetEmpty(regions
[i
]);
3231 status
= GdipMeasureCharacterRanges(NULL
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3232 expect(InvalidParameter
, status
);
3234 status
= GdipMeasureCharacterRanges(graphics
, NULL
, 6, font
, &rc
, format
, 3, regions
);
3235 expect(InvalidParameter
, status
);
3237 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, NULL
, &rc
, format
, 3, regions
);
3238 expect(InvalidParameter
, status
);
3240 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, NULL
, format
, 3, regions
);
3241 expect(InvalidParameter
, status
);
3245 /* Crashes on Windows XP */
3246 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, NULL
, 3, regions
);
3247 expect(InvalidParameter
, status
);
3250 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, NULL
);
3251 expect(InvalidParameter
, status
);
3253 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 2, regions
);
3254 expect(InvalidParameter
, status
);
3256 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3259 for (i
= 0; i
< 4; i
++)
3261 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3265 ok(region_isempty
[0], "region should be empty\n");
3266 ok(region_isempty
[1], "region should be empty\n");
3267 ok(region_isempty
[2], "region should be empty\n");
3268 ok(region_isempty
[3], "region should be empty\n");
3273 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 4, regions
);
3278 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3282 ok(!region_isempty
[0], "region shouldn't be empty\n");
3283 ok(!region_isempty
[1], "region shouldn't be empty\n");
3284 ok(!region_isempty
[2], "region shouldn't be empty\n");
3285 ok(region_isempty
[3], "region should be empty\n");
3287 /* Cut off everything after the first space, and the second line. */
3288 rc
.Width
= char_bounds
.Width
+ char_width
* 2.1;
3289 rc
.Height
= char_bounds
.Height
+ char_height
* 0.5;
3291 status
= GdipMeasureCharacterRanges(graphics
, teststring
, 6, font
, &rc
, format
, 3, regions
);
3296 status
= GdipIsEmptyRegion(regions
[i
], graphics
, ®ion_isempty
[i
]);
3300 ok(!region_isempty
[0], "region shouldn't be empty\n");
3301 ok(!region_isempty
[1], "region shouldn't be empty\n");
3302 ok(region_isempty
[2], "region should be empty\n");
3303 ok(region_isempty
[3], "region should be empty\n");
3306 GdipDeleteRegion(regions
[i
]);
3308 status
= GdipCreateMatrix(&identity
);
3315 memset(positions
, 0, sizeof(positions
));
3316 status
= GdipMeasureDriverString(NULL
, teststring
, 6, font
, positions
,
3317 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3319 expect(InvalidParameter
, status
);
3321 status
= GdipMeasureDriverString(graphics
, NULL
, 6, font
, positions
,
3322 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3324 expect(InvalidParameter
, status
);
3326 status
= GdipMeasureDriverString(graphics
, teststring
, 6, NULL
, positions
,
3327 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3329 expect(InvalidParameter
, status
);
3331 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, NULL
,
3332 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3334 expect(InvalidParameter
, status
);
3336 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3337 0x100, identity
, &rc
);
3340 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3341 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3345 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3346 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3348 expect(InvalidParameter
, status
);
3354 status
= GdipMeasureDriverString(graphics
, teststring
, 6, font
, positions
,
3355 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3360 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3361 ok(rc
.Width
> 0.0, "unexpected Width %0.2f\n", rc
.Width
);
3362 ok(rc
.Height
> 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3364 char_width
= rc
.Width
;
3365 char_height
= rc
.Height
;
3371 status
= GdipMeasureDriverString(graphics
, teststring
, 4, font
, positions
,
3372 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3377 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3378 ok(rc
.Width
< char_width
, "got Width %0.2f, expecting less than %0.2f\n", rc
.Width
, char_width
);
3379 expectf(char_height
, rc
.Height
);
3385 status
= GdipMeasureDriverString(graphics
, teststring2
, 1, font
, positions
,
3386 DriverStringOptionsCmapLookup
|DriverStringOptionsRealizedAdvance
,
3391 ok(rc
.Y
< 0.0, "unexpected Y %0.2f\n", rc
.Y
);
3392 ok(rc
.Width
> 0, "unexpected Width %0.2f\n", rc
.Width
);
3393 expectf(rc
.Height
, char_height
);
3395 GdipDeleteMatrix(identity
);
3396 GdipDeleteStringFormat(format
);
3397 GdipDeleteBrush(brush
);
3398 GdipDeleteFont(font
);
3399 GdipDeleteFontFamily(family
);
3400 GdipDeleteGraphics(graphics
);
3402 ReleaseDC(hwnd
, hdc
);
3405 static void test_get_set_interpolation(void)
3407 GpGraphics
*graphics
;
3408 HDC hdc
= GetDC( hwnd
);
3410 InterpolationMode mode
;
3412 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3413 status
= GdipCreateFromHDC(hdc
, &graphics
);
3415 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3417 status
= GdipGetInterpolationMode(NULL
, &mode
);
3418 expect(InvalidParameter
, status
);
3422 /* Crashes on Windows XP */
3423 status
= GdipGetInterpolationMode(graphics
, NULL
);
3424 expect(InvalidParameter
, status
);
3427 status
= GdipSetInterpolationMode(NULL
, InterpolationModeNearestNeighbor
);
3428 expect(InvalidParameter
, status
);
3431 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQualityBicubic
+1);
3432 expect(InvalidParameter
, status
);
3434 status
= GdipSetInterpolationMode(graphics
, InterpolationModeInvalid
);
3435 expect(InvalidParameter
, status
);
3437 status
= GdipGetInterpolationMode(graphics
, &mode
);
3439 expect(InterpolationModeBilinear
, mode
);
3441 status
= GdipSetInterpolationMode(graphics
, InterpolationModeNearestNeighbor
);
3444 status
= GdipGetInterpolationMode(graphics
, &mode
);
3446 expect(InterpolationModeNearestNeighbor
, mode
);
3448 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
3451 status
= GdipGetInterpolationMode(graphics
, &mode
);
3453 expect(InterpolationModeBilinear
, mode
);
3455 status
= GdipSetInterpolationMode(graphics
, InterpolationModeLowQuality
);
3458 status
= GdipGetInterpolationMode(graphics
, &mode
);
3460 expect(InterpolationModeBilinear
, mode
);
3462 status
= GdipSetInterpolationMode(graphics
, InterpolationModeHighQuality
);
3465 status
= GdipGetInterpolationMode(graphics
, &mode
);
3467 expect(InterpolationModeHighQualityBicubic
, mode
);
3469 GdipDeleteGraphics(graphics
);
3471 ReleaseDC(hwnd
, hdc
);
3474 static void test_get_set_textrenderinghint(void)
3476 GpGraphics
*graphics
;
3477 HDC hdc
= GetDC( hwnd
);
3479 TextRenderingHint hint
;
3481 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
3482 status
= GdipCreateFromHDC(hdc
, &graphics
);
3484 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
3486 status
= GdipGetTextRenderingHint(NULL
, &hint
);
3487 expect(InvalidParameter
, status
);
3489 status
= GdipGetTextRenderingHint(graphics
, NULL
);
3490 expect(InvalidParameter
, status
);
3492 status
= GdipSetTextRenderingHint(NULL
, TextRenderingHintAntiAlias
);
3493 expect(InvalidParameter
, status
);
3496 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
+1);
3497 expect(InvalidParameter
, status
);
3499 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3501 expect(TextRenderingHintSystemDefault
, hint
);
3503 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
3506 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3508 expect(TextRenderingHintSystemDefault
, hint
);
3510 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintAntiAliasGridFit
);
3513 status
= GdipGetTextRenderingHint(graphics
, &hint
);
3515 expect(TextRenderingHintAntiAliasGridFit
, hint
);
3517 GdipDeleteGraphics(graphics
);
3519 ReleaseDC(hwnd
, hdc
);
3522 static void test_getdc_scaled(void)
3525 GpGraphics
*graphics
= NULL
;
3526 GpBitmap
*bitmap
= NULL
;
3528 HBRUSH hbrush
, holdbrush
;
3531 status
= GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB
, NULL
, &bitmap
);
3534 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
3537 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
3540 status
= GdipGetDC(graphics
, &hdc
);
3542 ok(hdc
!= NULL
, "got NULL hdc\n");
3544 hbrush
= CreateSolidBrush(RGB(255, 0, 0));
3546 holdbrush
= SelectObject(hdc
, hbrush
);
3548 Rectangle(hdc
, 2, 2, 6, 6);
3550 SelectObject(hdc
, holdbrush
);
3552 DeleteObject(hbrush
);
3554 status
= GdipReleaseDC(graphics
, hdc
);
3557 GdipDeleteGraphics(graphics
);
3559 status
= GdipBitmapGetPixel(bitmap
, 3, 3, &color
);
3561 expect(0xffff0000, color
);
3563 status
= GdipBitmapGetPixel(bitmap
, 8, 8, &color
);
3565 expect(0xff000000, color
);
3567 GdipDisposeImage((GpImage
*)bitmap
);
3570 static void test_GdipMeasureString(void)
3572 static const struct test_data
3574 REAL res_x
, res_y
, page_scale
;
3578 { 200.0, 200.0, 1.0, UnitPixel
}, /* base */
3579 { 200.0, 200.0, 2.0, UnitPixel
},
3580 { 200.0, 200.0, 1.0, UnitDisplay
},
3581 { 200.0, 200.0, 2.0, UnitDisplay
},
3582 { 200.0, 200.0, 1.0, UnitInch
},
3583 { 200.0, 200.0, 2.0, UnitInch
},
3584 { 200.0, 600.0, 1.0, UnitPoint
},
3585 { 200.0, 600.0, 2.0, UnitPoint
},
3586 { 200.0, 600.0, 1.0, UnitDocument
},
3587 { 200.0, 600.0, 2.0, UnitDocument
},
3588 { 200.0, 600.0, 1.0, UnitMillimeter
},
3589 { 200.0, 600.0, 2.0, UnitMillimeter
},
3590 { 200.0, 600.0, 1.0, UnitDisplay
},
3591 { 200.0, 600.0, 2.0, UnitDisplay
},
3592 { 200.0, 600.0, 1.0, UnitPixel
},
3593 { 200.0, 600.0, 2.0, UnitPixel
},
3595 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
3596 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
3598 GpGraphics
*graphics
;
3599 GpFontFamily
*family
;
3601 GpStringFormat
*format
;
3603 REAL base_cx
= 0, base_cy
= 0, height
;
3608 GpUnit font_unit
, unit
;
3610 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
3612 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
3615 /* font size in pixels */
3616 status
= GdipCreateFont(family
, 100.0, FontStyleRegular
, UnitPixel
, &font
);
3618 status
= GdipGetFontSize(font
, &font_size
);
3620 expectf(100.0, font_size
);
3621 status
= GdipGetFontUnit(font
, &font_unit
);
3623 expect(UnitPixel
, font_unit
);
3625 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3629 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3631 lf
.lfHeight
= 0xdeadbeef;
3632 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3634 height
= units_to_pixels(font_size
, td
[i
].unit
, td
[i
].res_y
);
3635 if (td
[i
].unit
!= UnitDisplay
)
3636 height
*= td
[i
].page_scale
;
3637 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3638 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3640 height
= font_size
+ 2.0 * font_size
/ 6.0;
3642 set_rect_empty(&rc
);
3643 set_rect_empty(&bounds
);
3644 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3649 base_cx
= bounds
.Width
;
3650 base_cy
= bounds
.Height
;
3653 expectf(0.0, bounds
.X
);
3654 expectf(0.0, bounds
.Y
);
3656 expectf_(height
, bounds
.Height
, height
/ 100.0);
3657 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3661 /* make sure it really fits */
3662 bounds
.Width
+= 1.0;
3663 bounds
.Height
+= 1.0;
3667 set_rect_empty(&bounds
);
3668 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3670 expectf(50.0, bounds
.X
);
3671 expectf(50.0, bounds
.Y
);
3673 expectf_(height
, bounds
.Height
, height
/ 100.0);
3674 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3678 status
= GdipDeleteGraphics(graphics
);
3681 status
= GdipDisposeImage(image
);
3685 GdipDeleteFont(font
);
3687 /* font size in logical units */
3688 /* UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
3689 for (unit
= 3; unit
<= 6; unit
++)
3691 /* create a font which final height is 100.0 pixels with 200 dpi device */
3692 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
3693 height
= pixels_to_units(75.0, unit
, 200.0);
3694 status
= GdipCreateFont(family
, height
, FontStyleRegular
, unit
, &font
);
3696 status
= GdipGetFontSize(font
, &font_size
);
3698 expectf(height
, font_size
);
3699 status
= GdipGetFontUnit(font
, &font_unit
);
3701 expect(unit
, font_unit
);
3703 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3708 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3710 lf
.lfHeight
= 0xdeadbeef;
3711 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3713 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3714 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_x
);
3716 height
= units_to_pixels(font_size
, font_unit
, td
[i
].res_y
);
3717 /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
3718 ok(-lf
.lfHeight
== (LONG
)(height
+ 0.5), "%u: expected %d (%f), got %d\n",
3719 i
, (LONG
)(height
+ 0.5), height
, lf
.lfHeight
);
3721 if (td
[i
].unit
== UnitDisplay
|| td
[i
].unit
== UnitPixel
)
3722 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_x
);
3724 unit_scale
= units_scale(font_unit
, td
[i
].unit
, td
[i
].res_y
);
3725 /*trace("%u: %d to %d, %.1f dpi => unit_scale %f\n", i, font_unit, td[i].unit, td[i].res_y, unit_scale);*/
3726 height
= (font_size
+ 2.0 * font_size
/ 6.0) * unit_scale
;
3727 if (td
[i
].unit
!= UnitDisplay
)
3728 height
/= td
[i
].page_scale
;
3729 /*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);*/
3731 set_rect_empty(&rc
);
3732 set_rect_empty(&bounds
);
3733 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3738 base_cx
= bounds
.Width
;
3739 base_cy
= bounds
.Height
;
3742 expectf(0.0, bounds
.X
);
3743 expectf(0.0, bounds
.Y
);
3745 expectf_(height
, bounds
.Height
, height
/ 85.0);
3746 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3750 /* make sure it really fits */
3751 bounds
.Width
+= 1.0;
3752 bounds
.Height
+= 1.0;
3756 set_rect_empty(&bounds
);
3757 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3759 expectf(50.0, bounds
.X
);
3760 expectf(50.0, bounds
.Y
);
3762 expectf_(height
, bounds
.Height
, height
/ 85.0);
3763 expectf_(bounds
.Height
/ base_cy
, bounds
.Width
/ base_cx
, 0.1);
3767 /* verify the result */
3768 height
= units_to_pixels(bounds
.Height
, td
[i
].unit
, td
[i
].res_x
);
3769 if (td
[i
].unit
!= UnitDisplay
)
3770 height
*= td
[i
].page_scale
;
3771 /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
3772 i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
3774 expectf_(100.0, height
, 1.1);
3776 status
= GdipDeleteGraphics(graphics
);
3779 status
= GdipDisposeImage(image
);
3783 GdipDeleteFont(font
);
3786 /* Font with units = UnitWorld */
3787 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3789 GpPointF pt
= {0.0, 100.0};
3791 REAL expected_width
, expected_height
;
3793 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].page_scale
, &image
);
3795 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3798 status
= GdipCreateFont(family
, pt
.Y
, FontStyleRegular
, UnitWorld
, &font
);
3801 status
= GdipGetFontUnit(font
, &font_unit
);
3803 expect(UnitWorld
, font_unit
);
3805 lf
.lfHeight
= 0xdeadbeef;
3806 status
= GdipGetLogFontW(font
, graphics
, &lf
);
3808 ok(lf
.lfHeight
== -100, "%u: expected -100, got %d\n", i
, lf
.lfHeight
);
3810 set_rect_empty(&rc
);
3811 set_rect_empty(&bounds
);
3812 status
= GdipMeasureString(graphics
, string
, -1, font
, &rc
, format
, &bounds
, &chars
, &lines
);
3817 base_cx
= bounds
.Width
;
3818 base_cy
= bounds
.Height
;
3824 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &pt
, 1);
3827 /* height is constant in device space, width is proportional to height in world space */
3828 expected_width
= base_cx
* pt
.Y
;
3829 expected_height
= base_cy
* pt
.Y
;
3831 todo_wine_if(td
[i
].unit
!= UnitDisplay
&& td
[i
].unit
!= UnitPixel
)
3832 ok(fabs(expected_width
- bounds
.Width
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_width
, bounds
.Width
);
3833 ok(fabs(expected_height
- bounds
.Height
) <= 0.001, "%u: expected %f, got %f\n", i
, expected_height
, bounds
.Height
);
3835 GdipDeleteGraphics(graphics
);
3836 GdipDisposeImage(image
);
3837 GdipDeleteFont(font
);
3840 GdipDeleteFontFamily(family
);
3841 GdipDeleteStringFormat(format
);
3844 static void test_transform(void)
3846 static const struct test_data
3848 REAL res_x
, res_y
, scale
;
3850 GpPointF in
[2], out
[2];
3853 { 96.0, 96.0, 1.0, UnitPixel
,
3854 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3855 { 96.0, 96.0, 1.0, UnitDisplay
,
3856 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3857 { 96.0, 96.0, 1.0, UnitInch
,
3858 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
3859 { 123.0, 456.0, 1.0, UnitPoint
,
3860 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
3861 { 123.0, 456.0, 1.0, UnitDocument
,
3862 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
3863 { 123.0, 456.0, 2.0, UnitMillimeter
,
3864 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
3865 { 196.0, 296.0, 1.0, UnitDisplay
,
3866 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3867 { 196.0, 296.0, 1.0, UnitPixel
,
3868 { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
3871 GpGraphics
*graphics
;
3876 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3878 graphics
= create_graphics(td
[i
].res_x
, td
[i
].res_y
, td
[i
].unit
, td
[i
].scale
, &image
);
3879 ptf
[0].X
= td
[i
].in
[0].X
;
3880 ptf
[0].Y
= td
[i
].in
[0].Y
;
3881 ptf
[1].X
= td
[i
].in
[1].X
;
3882 ptf
[1].Y
= td
[i
].in
[1].Y
;
3883 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
3885 expectf(td
[i
].out
[0].X
, ptf
[0].X
);
3886 expectf(td
[i
].out
[0].Y
, ptf
[0].Y
);
3887 expectf(td
[i
].out
[1].X
, ptf
[1].X
);
3888 expectf(td
[i
].out
[1].Y
, ptf
[1].Y
);
3889 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
3891 expectf(td
[i
].in
[0].X
, ptf
[0].X
);
3892 expectf(td
[i
].in
[0].Y
, ptf
[0].Y
);
3893 expectf(td
[i
].in
[1].X
, ptf
[1].X
);
3894 expectf(td
[i
].in
[1].Y
, ptf
[1].Y
);
3895 status
= GdipDeleteGraphics(graphics
);
3897 status
= GdipDisposeImage(image
);
3902 static void test_pen_thickness(void)
3904 static const struct test_data
3906 REAL res_x
, res_y
, scale
;
3907 GpUnit pen_unit
, page_unit
;
3909 INT cx
, cy
, path_cx
, path_cy
;
3912 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 1.0, 1, 1, 1, 1 },
3913 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.0, 0, 0, 1, 1 },
3914 { 10.0, 10.0, 1.0, UnitPixel
, UnitPixel
, 0.1, 1, 1, 1, 1 },
3915 { 10.0, 10.0, 3.0, UnitPixel
, UnitPixel
, 2.0, 2, 2, 2, 2 },
3916 { 10.0, 10.0, 30.0, UnitPixel
, UnitInch
, 1.0, 1, 1, 1, 1 },
3917 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 1.0, 1, 1, 1, 1 },
3918 { 10.0, 10.0, 1.0, UnitWorld
, UnitPixel
, 0.0, 1, 1, 1, 1 },
3919 { 10.0, 10.0, 3.0, UnitWorld
, UnitPixel
, 2.0, 6, 6, 6, 6 },
3920 { 10.0, 10.0, 2.0, UnitWorld
, UnitInch
, 1.0, 20, 20, 20, 20 },
3924 GpGraphics
*graphics
;
3936 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
3938 status
= GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB
, NULL
, &u
.bitmap
);
3941 status
= GdipBitmapSetResolution(u
.bitmap
, td
[i
].res_x
, td
[i
].res_y
);
3944 status
= GdipGetImageGraphicsContext(u
.image
, &graphics
);
3947 status
= GdipSetPageUnit(graphics
, td
[i
].page_unit
);
3950 status
= GdipSetPageScale(graphics
, td
[i
].scale
);
3953 status
= GdipCreatePen1(0xffffffff, td
[i
].pen_width
, td
[i
].pen_unit
, &pen
);
3956 corner
.X
= corner
.Y
= 100.0;
3957 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &corner
, 1);
3960 status
= GdipDrawLine(graphics
, pen
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
3963 status
= GdipDrawLine(graphics
, pen
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
3966 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
3972 for (j
=0; j
<100; j
++)
3974 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3981 for (j
=99; j
>=0; j
--)
3983 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
3992 ok(size
== td
[i
].cx
, "%u: expected %d, got %d\n", i
, td
[i
].cx
, size
);
3997 for (j
=0; j
<100; j
++)
3999 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4006 for (j
=99; j
>=0; j
--)
4008 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4017 ok(size
== td
[i
].cy
, "%u: expected %d, got %d\n", i
, td
[i
].cy
, size
);
4019 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4022 status
= GdipGraphicsClear(graphics
, 0xff000000);
4025 status
= GdipCreatePath(FillModeAlternate
, &path
);
4028 status
= GdipAddPathLine(path
, corner
.X
/2, 0, corner
.X
/2, corner
.Y
);
4031 status
= GdipClosePathFigure(path
);
4034 status
= GdipAddPathLine(path
, 0, corner
.Y
/2, corner
.X
, corner
.Y
/2);
4037 status
= GdipDrawPath(graphics
, pen
, path
);
4040 GdipDeletePath(path
);
4042 status
= GdipBitmapLockBits(u
.bitmap
, NULL
, ImageLockModeRead
, PixelFormat24bppRGB
, &bd
);
4048 for (j
=0; j
<100; j
++)
4050 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4057 for (j
=99; j
>=0; j
--)
4059 if (((BYTE
*)bd
.Scan0
)[j
*3] == 0xff)
4068 ok(size
== td
[i
].path_cx
, "%u: expected %d, got %d\n", i
, td
[i
].path_cx
, size
);
4073 for (j
=0; j
<100; j
++)
4075 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4082 for (j
=99; j
>=0; j
--)
4084 if (((BYTE
*)bd
.Scan0
)[bd
.Stride
*j
] == 0xff)
4093 ok(size
== td
[i
].path_cy
, "%u: expected %d, got %d\n", i
, td
[i
].path_cy
, size
);
4095 status
= GdipBitmapUnlockBits(u
.bitmap
, &bd
);
4099 GdipDeleteGraphics(graphics
);
4100 GdipDisposeImage(u
.image
);
4104 /* Many people on the net ask why there is so much difference in rendered
4105 * text height between gdiplus and gdi32, this test suggests an answer to
4106 * that question. Important: this test assumes that font dpi == device dpi.
4108 static void test_font_height_scaling(void)
4110 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4111 static const WCHAR string
[] = { '1','2','3','4','5','6','7',0 };
4113 GpStringFormat
*format
;
4114 CharacterRange range
= { 0, 7 };
4116 GpGraphics
*graphics
;
4117 GpFontFamily
*family
;
4121 REAL height
, dpi
, scale
;
4123 GpUnit gfx_unit
, font_unit
;
4125 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4127 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4129 status
= GdipCreateRegion(®ion
);
4132 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4135 hdc
= CreateCompatibleDC(0);
4136 status
= GdipCreateFromHDC(hdc
, &graphics
);
4139 status
= GdipGetDpiY(graphics
, &dpi
);
4142 /* First check if tested functionality works:
4143 * under XP if font and graphics units differ then GdipTransformPoints
4144 * followed by GdipSetPageUnit to change the graphics units breaks region
4145 * scaling in GdipMeasureCharacterRanges called later.
4147 status
= GdipSetPageUnit(graphics
, UnitDocument
);
4152 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4155 status
= GdipSetPageUnit(graphics
, UnitInch
);
4158 status
= GdipCreateFont(family
, 720.0, FontStyleRegular
, UnitPoint
, &font
);
4161 set_rect_empty(&rect
);
4162 set_rect_empty(&bounds
);
4163 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4165 trace("test bounds: %f,%f,%f,%f\n", bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4167 set_rect_empty(&rect
);
4168 rect
.Width
= 32000.0;
4169 rect
.Height
= 32000.0;
4170 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4173 set_rect_empty(&rect
);
4174 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4176 trace("test region: %f,%f,%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4178 GdipDeleteFont(font
);
4180 scale
= rect
.Height
/ bounds
.Height
;
4181 if (fabs(scale
- 1.0) > 0.1)
4183 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale
);
4187 status
= GdipScaleWorldTransform(graphics
, 0.01, 0.01, MatrixOrderAppend
);
4190 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4191 /* UnitPixel as a font base unit is not tested because it drastically
4192 differs in behaviour */
4193 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4195 /* create a font for the final text height of 100 pixels */
4196 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4197 status
= GdipSetPageUnit(graphics
, font_unit
);
4201 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, &ptf
, 1);
4204 /*trace("height %f units\n", height);*/
4205 status
= GdipCreateFont(family
, height
, FontStyleRegular
, font_unit
, &font
);
4208 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4209 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4211 static const WCHAR doubleW
[2] = { 'W','W' };
4212 RectF bounds_1
, bounds_2
;
4213 REAL margin
, margin_y
, font_height
;
4216 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4219 margin_y
= units_to_pixels(height
/ 8.0, font_unit
, dpi
);
4220 margin_y
= pixels_to_units(margin_y
, gfx_unit
, dpi
);
4222 status
= GdipGetFontHeight(font
, graphics
, &font_height
);
4225 set_rect_empty(&rect
);
4226 set_rect_empty(&bounds
);
4227 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, NULL
, NULL
);
4229 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4231 expectf_(font_height
+ margin_y
, bounds
.Height
, 0.005);
4234 ptf
.Y
= bounds
.Height
;
4235 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, &ptf
, 1);
4237 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4239 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4241 /* verify the result */
4242 ptf
.Y
= units_to_pixels(bounds
.Height
, gfx_unit
, dpi
);
4244 match
= fabs(100.0 - ptf
.Y
) <= 1.0;
4246 ok(match
, "Expected 100.0, got %f\n", ptf
.Y
);
4248 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4249 set_rect_empty(&rect
);
4250 set_rect_empty(&bounds_1
);
4251 status
= GdipMeasureString(graphics
, doubleW
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4253 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4254 set_rect_empty(&rect
);
4255 set_rect_empty(&bounds_2
);
4256 status
= GdipMeasureString(graphics
, doubleW
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4259 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4260 margin
= bounds_1
.Width
- bounds_2
.Width
/ 2.0;
4261 /*trace("margin %f\n", margin);*/
4262 ok(margin
> 0.0, "wrong margin %f\n", margin
);
4264 set_rect_empty(&rect
);
4265 rect
.Width
= 320000.0;
4266 rect
.Height
= 320000.0;
4267 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4269 set_rect_empty(&rect
);
4270 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4272 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4273 ok(rect
.X
> 0.0, "wrong rect.X %f\n", rect
.X
);
4274 expectf(0.0, rect
.Y
);
4275 match
= fabs(1.0 - margin
/ rect
.X
) <= 0.05;
4276 ok(match
, "Expected %f, got %f\n", margin
, rect
.X
);
4277 match
= fabs(1.0 - font_height
/ rect
.Height
) <= 0.1;
4278 ok(match
, "Expected %f, got %f\n", font_height
, rect
.Height
);
4279 match
= fabs(1.0 - bounds
.Width
/ (rect
.Width
+ margin
* 2.0)) <= 0.05;
4280 ok(match
, "Expected %f, got %f\n", bounds
.Width
, rect
.Width
+ margin
* 2.0);
4283 GdipDeleteFont(font
);
4287 status
= GdipDeleteGraphics(graphics
);
4291 GdipDeleteFontFamily(family
);
4292 GdipDeleteRegion(region
);
4293 GdipDeleteStringFormat(format
);
4296 static void test_measure_string(void)
4298 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4299 static const WCHAR string
[] = { 'A','0','1',0 };
4301 GpStringFormat
*format
;
4302 CharacterRange range
;
4304 GpGraphics
*graphics
;
4305 GpFontFamily
*family
;
4309 REAL width
, height
, width_1
, width_2
;
4310 REAL margin_x
, margin_y
, width_rgn
, height_rgn
;
4313 status
= GdipCreateStringFormat(StringFormatFlagsNoWrap
, LANG_NEUTRAL
, &format
);
4317 status
= GdipCreateRegion(®ion
);
4320 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4323 hdc
= CreateCompatibleDC(0);
4324 status
= GdipCreateFromHDC(hdc
, &graphics
);
4326 status
= GdipCreateFont(family
, 20, FontStyleRegular
, UnitPixel
, &font
);
4329 margin_x
= 20.0 / 6.0;
4330 margin_y
= 20.0 / 8.0;
4332 set_rect_empty(&rect
);
4333 set_rect_empty(&bounds
);
4334 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4338 expectf(0.0, bounds
.X
);
4339 expectf(0.0, bounds
.Y
);
4340 width
= bounds
.Width
;
4341 height
= bounds
.Height
;
4343 set_rect_empty(&rect
);
4344 rect
.Height
= height
/ 2.0;
4345 set_rect_empty(&bounds
);
4346 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4350 expectf(0.0, bounds
.X
);
4351 expectf(0.0, bounds
.Y
);
4352 expectf(width
, bounds
.Width
);
4354 expectf(height
/ 2.0, bounds
.Height
);
4357 range
.Length
= lstrlenW(string
);
4358 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4363 rect
.Width
= 32000.0;
4364 rect
.Height
= 32000.0;
4365 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4367 set_rect_empty(&bounds
);
4368 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4370 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4371 expectf(5.0, bounds
.Y
);
4372 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4374 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4376 width_rgn
= bounds
.Width
;
4377 height_rgn
= bounds
.Height
;
4381 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4384 set_rect_empty(&rect
);
4385 rect
.Width
= 32000.0;
4386 rect
.Height
= 32000.0;
4387 status
= GdipMeasureCharacterRanges(graphics
, string
, 1, font
, &rect
, format
, 1, ®ion
);
4389 set_rect_empty(&bounds
);
4390 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4392 expectf_(margin_x
, bounds
.X
, 1.0);
4393 expectf(0.0, bounds
.Y
);
4394 ok(bounds
.Width
< width_rgn
/ 2.0, "width of 1 glyph is wrong\n");
4395 expectf(height_rgn
, bounds
.Height
);
4396 width_1
= bounds
.Width
;
4399 range
.Length
= lstrlenW(string
);
4400 status
= GdipSetStringFormatMeasurableCharacterRanges(format
, 1, &range
);
4407 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4409 set_rect_empty(&bounds
);
4410 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4412 expectf(0.0, bounds
.X
);
4413 expectf(0.0, bounds
.Y
);
4414 expectf(0.0, bounds
.Width
);
4415 expectf(0.0, bounds
.Height
);
4419 rect
.Width
= width_rgn
/ 2.0;
4420 rect
.Height
= 32000.0;
4421 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4423 set_rect_empty(&bounds
);
4424 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4426 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4427 expectf(5.0, bounds
.Y
);
4428 expectf_(width_1
, bounds
.Width
, 1.0);
4430 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4432 status
= GdipSetStringFormatFlags(format
, StringFormatFlagsNoWrap
| StringFormatFlagsNoClip
);
4438 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4440 set_rect_empty(&bounds
);
4441 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4443 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4444 expectf(5.0, bounds
.Y
);
4445 expectf(width_rgn
, bounds
.Width
);
4446 expectf(height_rgn
, bounds
.Height
);
4450 rect
.Width
= width_rgn
/ 2.0;
4451 rect
.Height
= 32000.0;
4452 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4454 set_rect_empty(&bounds
);
4455 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4457 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4458 expectf(5.0, bounds
.Y
);
4459 expectf_(width_1
, bounds
.Width
, 1.0);
4460 expectf(height_rgn
, bounds
.Height
);
4462 set_rect_empty(&rect
);
4463 rect
.Height
= height
/ 2.0;
4464 set_rect_empty(&bounds
);
4465 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4469 expectf(0.0, bounds
.X
);
4470 expectf(0.0, bounds
.Y
);
4471 expectf_(width
, bounds
.Width
, 0.01);
4473 expectf(height
, bounds
.Height
);
4475 set_rect_empty(&rect
);
4476 set_rect_empty(&bounds
);
4477 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4481 expectf(0.0, bounds
.X
);
4482 expectf(0.0, bounds
.Y
);
4483 ok(bounds
.Width
< width
/ 2.0, "width of 1 glyph is wrong\n");
4484 expectf(height
, bounds
.Height
);
4485 width_1
= bounds
.Width
;
4487 set_rect_empty(&rect
);
4488 set_rect_empty(&bounds
);
4489 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4493 expectf(0.0, bounds
.X
);
4494 expectf(0.0, bounds
.Y
);
4495 ok(bounds
.Width
< width
, "width of 2 glyphs is wrong\n");
4496 ok(bounds
.Width
> width_1
, "width of 2 glyphs is wrong\n");
4497 expectf(height
, bounds
.Height
);
4498 width_2
= bounds
.Width
;
4500 set_rect_empty(&rect
);
4501 rect
.Width
= width
/ 2.0;
4502 set_rect_empty(&bounds
);
4503 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4507 expectf(0.0, bounds
.X
);
4508 expectf(0.0, bounds
.Y
);
4509 expectf_(width_1
, bounds
.Width
, 0.01);
4510 expectf(height
, bounds
.Height
);
4512 set_rect_empty(&rect
);
4513 rect
.Height
= height
;
4514 rect
.Width
= width
- 0.05;
4515 set_rect_empty(&bounds
);
4516 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4520 expectf(0.0, bounds
.X
);
4521 expectf(0.0, bounds
.Y
);
4522 expectf_(width_2
, bounds
.Width
, 0.01);
4523 expectf(height
, bounds
.Height
);
4525 set_rect_empty(&rect
);
4526 rect
.Height
= height
;
4527 rect
.Width
= width_2
- 0.05;
4528 set_rect_empty(&bounds
);
4529 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4533 expectf(0.0, bounds
.X
);
4534 expectf(0.0, bounds
.Y
);
4535 expectf_(width_1
, bounds
.Width
, 0.01);
4536 expectf(height
, bounds
.Height
);
4538 /* Default (Near) alignment */
4541 rect
.Width
= width
* 2.0;
4542 rect
.Height
= height
* 2.0;
4543 set_rect_empty(&bounds
);
4544 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4548 expectf(5.0, bounds
.X
);
4549 expectf(5.0, bounds
.Y
);
4550 expectf_(width
, bounds
.Width
, 0.01);
4551 expectf(height
, bounds
.Height
);
4555 rect
.Width
= 32000.0;
4556 rect
.Height
= 32000.0;
4557 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4559 set_rect_empty(&bounds
);
4560 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4562 expectf_(5.0 + margin_x
, bounds
.X
, 1.0);
4563 expectf(5.0, bounds
.Y
);
4564 expectf_(width
- margin_x
*2.0, bounds
.Width
, 1.0);
4566 expectf_(height
- margin_y
, bounds
.Height
, 1.0);
4568 width_rgn
= bounds
.Width
;
4569 height_rgn
= bounds
.Height
;
4571 /* Center alignment */
4572 GdipSetStringFormatAlign(format
, StringAlignmentCenter
);
4573 GdipSetStringFormatLineAlign(format
, StringAlignmentCenter
);
4577 rect
.Width
= width
* 2.0;
4578 rect
.Height
= height
* 2.0;
4579 set_rect_empty(&bounds
);
4580 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4585 expectf_(5.0 + width
/2.0, bounds
.X
, 0.01);
4587 expectf(5.0 + height
/2.0, bounds
.Y
);
4588 expectf_(width
, bounds
.Width
, 0.01);
4589 expectf(height
, bounds
.Height
);
4595 set_rect_empty(&bounds
);
4596 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4601 expectf_(5.0 - width
/2.0, bounds
.X
, 0.01);
4603 expectf(5.0 - height
/2.0, bounds
.Y
);
4604 expectf_(width
, bounds
.Width
, 0.01);
4605 expectf(height
, bounds
.Height
);
4609 rect
.Width
= width_rgn
* 2.0;
4610 rect
.Height
= height_rgn
* 2.0;
4611 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4613 set_rect_empty(&bounds
);
4614 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4617 expectf_(5.0 + width_rgn
/2.0, bounds
.X
, 1.0);
4619 expectf_(5.0 + height_rgn
/2.0, bounds
.Y
, 1.0);
4620 expectf_(width_rgn
, bounds
.Width
, 1.0);
4621 expectf_(height_rgn
, bounds
.Height
, 1.0);
4627 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4629 set_rect_empty(&bounds
);
4630 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4633 expectf_(5.0 - width_rgn
/2.0, bounds
.X
, 1.0);
4635 expectf_(5.0 - height_rgn
/2.0, bounds
.Y
, 1.0);
4636 expectf_(width_rgn
, bounds
.Width
, 1.0);
4637 expectf_(height_rgn
, bounds
.Height
, 1.0);
4640 GdipSetStringFormatAlign(format
, StringAlignmentFar
);
4641 GdipSetStringFormatLineAlign(format
, StringAlignmentFar
);
4645 rect
.Width
= width
* 2.0;
4646 rect
.Height
= height
* 2.0;
4647 set_rect_empty(&bounds
);
4648 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4653 expectf_(5.0 + width
, bounds
.X
, 0.01);
4655 expectf(5.0 + height
, bounds
.Y
);
4656 expectf_(width
, bounds
.Width
, 0.01);
4657 expectf(height
, bounds
.Height
);
4663 set_rect_empty(&bounds
);
4664 status
= GdipMeasureString(graphics
, string
, -1, font
, &rect
, format
, &bounds
, &glyphs
, &lines
);
4669 expectf_(5.0 - width
, bounds
.X
, 0.01);
4671 expectf(5.0 - height
, bounds
.Y
);
4672 expectf_(width
, bounds
.Width
, 0.01);
4673 expectf(height
, bounds
.Height
);
4677 rect
.Width
= width_rgn
* 2.0;
4678 rect
.Height
= height_rgn
* 2.0;
4679 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4681 set_rect_empty(&bounds
);
4682 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4685 expectf_(5.0 + width_rgn
, bounds
.X
, 2.0);
4687 expectf_(5.0 + height_rgn
, bounds
.Y
, 1.0);
4688 expectf_(width_rgn
, bounds
.Width
, 1.0);
4689 expectf_(height_rgn
, bounds
.Height
, 1.0);
4695 status
= GdipMeasureCharacterRanges(graphics
, string
, -1, font
, &rect
, format
, 1, ®ion
);
4697 set_rect_empty(&bounds
);
4698 status
= GdipGetRegionBounds(region
, graphics
, &bounds
);
4701 expectf_(5.0 - width_rgn
, bounds
.X
, 2.0);
4703 expectf_(5.0 - height_rgn
, bounds
.Y
, 1.0);
4704 expectf_(width_rgn
, bounds
.Width
, 1.0);
4705 expectf_(height_rgn
, bounds
.Height
, 1.0);
4707 status
= GdipDeleteFont(font
);
4710 status
= GdipDeleteGraphics(graphics
);
4714 GdipDeleteFontFamily(family
);
4715 GdipDeleteRegion(region
);
4716 GdipDeleteStringFormat(format
);
4719 static void test_measured_extra_space(void)
4721 static const WCHAR tahomaW
[] = { 'T','a','h','o','m','a',0 };
4722 static const WCHAR string
[2] = { 'W','W' };
4723 GpStringFormat
*format
;
4725 GpGraphics
*graphics
;
4726 GpFontFamily
*family
;
4729 GpUnit gfx_unit
, font_unit
;
4730 RectF bounds_1
, bounds_2
, rect
;
4731 REAL margin
, font_size
, dpi
;
4733 status
= GdipCreateStringFormat(0, LANG_NEUTRAL
, &format
);
4736 status
= GdipCreateFontFamilyFromName(tahomaW
, NULL
, &family
);
4738 hdc
= CreateCompatibleDC(0);
4739 status
= GdipCreateFromHDC(hdc
, &graphics
);
4742 status
= GdipGetDpiX(graphics
, &dpi
);
4745 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4746 /* UnitPixel as a font base unit is not tested because it differs in behaviour */
4747 for (font_unit
= 3; font_unit
<= 6; font_unit
++)
4749 status
= GdipCreateFont(family
, 1234.0, FontStyleRegular
, font_unit
, &font
);
4752 status
= GdipGetFontSize(font
, &font_size
);
4754 font_size
= units_to_pixels(font_size
, font_unit
, dpi
);
4755 /*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
4757 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4758 for (gfx_unit
= 2; gfx_unit
<= 6; gfx_unit
++)
4760 status
= GdipSetPageUnit(graphics
, gfx_unit
);
4763 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4764 set_rect_empty(&rect
);
4765 set_rect_empty(&bounds_1
);
4766 status
= GdipMeasureString(graphics
, string
, 1, font
, &rect
, format
, &bounds_1
, NULL
, NULL
);
4768 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4769 set_rect_empty(&rect
);
4770 set_rect_empty(&bounds_2
);
4771 status
= GdipMeasureString(graphics
, string
, 2, font
, &rect
, format
, &bounds_2
, NULL
, NULL
);
4774 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4775 margin
= units_to_pixels(bounds_1
.Width
- bounds_2
.Width
/ 2.0, gfx_unit
, dpi
);
4776 /*trace("margin %f pixels\n", margin);*/
4777 expectf_(font_size
/ 6.0, margin
, font_size
/ 100.0);
4780 GdipDeleteFont(font
);
4783 GdipDeleteGraphics(graphics
);
4785 GdipDeleteFontFamily(family
);
4786 GdipDeleteStringFormat(format
);
4789 static void test_alpha_hdc(void)
4793 HBITMAP hbm
, old_hbm
;
4794 GpGraphics
*graphics
;
4800 hdc
= CreateCompatibleDC(0);
4801 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
4802 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
4803 bmi
.bmiHeader
.biHeight
= 5;
4804 bmi
.bmiHeader
.biWidth
= 5;
4805 bmi
.bmiHeader
.biBitCount
= 32;
4806 bmi
.bmiHeader
.biPlanes
= 1;
4807 bmi
.bmiHeader
.biCompression
= BI_RGB
;
4808 bmi
.bmiHeader
.biClrUsed
= 0;
4810 hbm
= CreateDIBSection(hdc
, &bmi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
4811 ok(hbm
!= NULL
, "CreateDIBSection failed\n");
4813 old_hbm
= SelectObject(hdc
, hbm
);
4815 status
= GdipCreateFromHDC(hdc
, &graphics
);
4818 status
= GdipGetVisibleClipBounds(graphics
, &bounds
);
4820 expectf(0.0, bounds
.X
);
4821 expectf(0.0, bounds
.Y
);
4822 expectf(5.0, bounds
.Width
);
4823 expectf(5.0, bounds
.Height
);
4825 bits
[0] = 0xdeadbeef;
4827 status
= GdipGraphicsClear(graphics
, 0xffaaaaaa);
4830 expect(0xffaaaaaa, bits
[0]);
4832 bits
[0] = 0xdeadbeef;
4834 status
= GdipGetDC(graphics
, &gp_hdc
);
4837 colorref
= GetPixel(gp_hdc
, 0, 4);
4838 expect(0xefbead, colorref
);
4840 SetPixel(gp_hdc
, 0, 4, 0xffffff);
4842 expect(0xffffff, bits
[0]);
4844 status
= GdipReleaseDC(graphics
, gp_hdc
);
4847 SelectObject(hdc
, old_hbm
);
4849 bits
[0] = 0xdeadbeef;
4851 status
= GdipGraphicsClear(graphics
, 0xffbbbbbb);
4854 todo_wine
expect(0xffbbbbbb, bits
[0]);
4856 GdipDeleteGraphics(graphics
);
4862 static void test_bitmapfromgraphics(void)
4865 GpGraphics
*graphics
= NULL
;
4866 HDC hdc
= GetDC( hwnd
);
4867 GpBitmap
*bitmap
= NULL
;
4869 REAL imageres
, graphicsres
;
4872 stat
= GdipCreateFromHDC(hdc
, &graphics
);
4875 stat
= GdipCreateBitmapFromGraphics(12, 13, NULL
, &bitmap
);
4876 expect(InvalidParameter
, stat
);
4878 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, NULL
);
4879 expect(InvalidParameter
, stat
);
4881 stat
= GdipCreateBitmapFromGraphics(12, 13, graphics
, &bitmap
);
4884 stat
= GdipGetImagePixelFormat((GpImage
*)bitmap
, &format
);
4886 expect(PixelFormat32bppPARGB
, format
);
4888 stat
= GdipGetDpiX(graphics
, &graphicsres
);
4891 stat
= GdipGetImageHorizontalResolution((GpImage
*)bitmap
, &imageres
);
4893 expectf(graphicsres
, imageres
);
4895 stat
= GdipGetDpiY(graphics
, &graphicsres
);
4898 stat
= GdipGetImageVerticalResolution((GpImage
*)bitmap
, &imageres
);
4900 expectf(graphicsres
, imageres
);
4902 stat
= GdipGetImageWidth((GpImage
*)bitmap
, &width
);
4906 stat
= GdipGetImageHeight((GpImage
*)bitmap
, &height
);
4910 GdipDeleteGraphics(graphics
);
4911 GdipDisposeImage((GpImage
*)bitmap
);
4914 static void test_clipping(void)
4918 GpGraphics
*graphics
;
4919 GpRegion
*region
, *region100x100
;
4928 hdc
= CreateCompatibleDC(0);
4929 status
= GdipCreateFromHDC(hdc
, &graphics
);
4932 status
= GdipGetPageUnit(graphics
, &unit
);
4934 expect(UnitDisplay
, unit
);
4936 status
= GdipCreateRegion(®ion
);
4938 status
= GdipSetEmpty(region
);
4941 status
= GdipCreateRegion(®ion100x100
);
4943 status
= GdipSetEmpty(region100x100
);
4946 rect
.X
= rect
.Y
= 100.0;
4947 rect
.Width
= rect
.Height
= 100.0;
4948 status
= GdipCombineRegionRect(region100x100
, &rect
, CombineModeUnion
);
4950 status
= GdipSetClipRegion(graphics
, region100x100
, CombineModeReplace
);
4953 status
= GdipGetClipBounds(graphics
, &rect
);
4955 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4956 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4958 /* Clip region does not account for changes to gdi32 transform */
4959 SetViewportOrgEx(hdc
, 10, 10, NULL
);
4961 status
= GdipGetClipBounds(graphics
, &rect
);
4963 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4964 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4966 SetViewportOrgEx(hdc
, 0, 0, NULL
);
4968 status
= GdipSetEmpty(region
);
4970 status
= GdipGetClip(graphics
, region
);
4972 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
4974 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
4975 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
4981 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
4983 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
4984 "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
);
4986 status
= GdipCreateMatrix(&matrix
);
4988 status
= GdipScaleMatrix(matrix
, 2.0, 4.0, MatrixOrderAppend
);
4990 status
= GdipTranslateMatrix(matrix
, 10.0, 20.0, MatrixOrderAppend
);
4992 status
= GdipSetWorldTransform(graphics
, matrix
);
4995 status
= GdipGetClipBounds(graphics
, &rect
);
4997 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
4998 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5000 status
= GdipSetEmpty(region
);
5002 status
= GdipGetClip(graphics
, region
);
5004 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5006 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5007 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5009 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5011 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5012 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5014 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5016 ret
= GetRgnBox(hrgn
, &rc
);
5017 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5018 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5019 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5022 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5024 ret
= GetRgnBox(hrgn
, &rc
);
5025 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5026 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5027 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5034 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5036 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5037 "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
);
5039 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5041 ret
= GetRgnBox(hrgn
, &rc
);
5042 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5043 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5044 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5047 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5049 ret
= GetRgnBox(hrgn
, &rc
);
5050 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5051 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5052 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5059 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5061 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5062 "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
);
5064 status
= GdipSetPageScale(graphics
, 2.0);
5067 status
= GdipGetClipBounds(graphics
, &rect
);
5069 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5070 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5072 status
= GdipSetEmpty(region
);
5074 status
= GdipGetClip(graphics
, region
);
5076 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5078 ok(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0,
5079 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5081 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5083 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5084 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5086 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5088 ret
= GetRgnBox(hrgn
, &rc
);
5089 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5090 ok(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45,
5091 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc
));
5094 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5096 ret
= GetRgnBox(hrgn
, &rc
);
5097 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5098 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5099 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5106 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5108 ok(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0,
5109 "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
);
5111 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5113 ret
= GetRgnBox(hrgn
, &rc
);
5114 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5115 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5116 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5119 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5121 ret
= GetRgnBox(hrgn
, &rc
);
5122 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5123 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5124 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5131 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5133 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5134 "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
);
5136 GdipSetPageUnit(graphics
, UnitPoint
);
5139 status
= GdipGetClipBounds(graphics
, &rect
);
5141 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5142 /* rounding under Wine is slightly different */
5143 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5144 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5145 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5147 status
= GdipSetEmpty(region
);
5149 status
= GdipGetClip(graphics
, region
);
5151 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5153 ok((rect
.X
== 13.75 && rect
.Y
== 4.375 && rect
.Width
== 18.75 && rect
.Height
== 9.375) ||
5154 /* rounding under Wine is slightly different */
5155 (rect
.X
== 14.0 && rect
.Y
== 4.0 && rect
.Width
== 19.0 && rect
.Height
== 10.0) /* Wine */ ||
5156 broken(rect
.X
== 45.0 && rect
.Y
== 20.0 && rect
.Width
== 50.0 && rect
.Height
== 25.0) /* before Win7 */,
5157 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5159 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5161 ok(rect
.X
== 100.0 && rect
.Y
== 100.0 && rect
.Width
== 100.0 && rect
.Height
== 100.0,
5162 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5164 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5166 ret
= GetRgnBox(hrgn
, &rc
);
5167 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5168 ok((rc
.left
== 14 && rc
.top
== 5 && rc
.right
== 33 && rc
.bottom
== 14) ||
5169 /* rounding under Wine is slightly different */
5170 (rc
.left
== 14 && rc
.top
== 4 && rc
.right
== 33 && rc
.bottom
== 14) /* Wine */ ||
5171 broken(rc
.left
== 45 && rc
.top
== 20 && rc
.right
== 95 && rc
.bottom
== 45) /* before Win7 */,
5172 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc
));
5175 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5177 ret
= GetRgnBox(hrgn
, &rc
);
5178 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5179 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5180 broken(rc
.left
== 267 && rc
.top
== 267 && rc
.right
== 534 && rc
.bottom
== 534) /* before Win7 */,
5181 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5188 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5190 ok((ptf
[0].X
== 13.75 && ptf
[0].Y
== 4.375 && ptf
[1].X
== 32.5 && ptf
[1].Y
== 13.75) ||
5191 broken(ptf
[0].X
== 45.0 && ptf
[0].Y
== 20.0 && ptf
[1].X
== 95.0 && ptf
[1].Y
== 45.0) /* before Win7 */,
5192 "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
);
5194 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5196 ret
= GetRgnBox(hrgn
, &rc
);
5197 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5198 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5199 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5202 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5204 ret
= GetRgnBox(hrgn
, &rc
);
5205 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5206 ok((rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1094 && rc
.bottom
== 2187) ||
5207 /* rounding under Wine is slightly different */
5208 (rc
.left
== 560 && rc
.top
== 1120 && rc
.right
== 1093 && rc
.bottom
== 2187) /* Wine */,
5209 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc
));
5216 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5218 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5220 expectf(100.0, ptf
[0].X
);
5221 expectf(100.0, ptf
[0].Y
);
5222 expectf(200.125, ptf
[1].X
);
5223 expectf(200.03125, ptf
[1].Y
);
5225 else /* before Win7 */
5227 ok(broken(fabs(ptf
[0].X
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].X
);
5228 ok(broken(fabs(ptf
[0].Y
- 275.0) < 0.001), "expected 275.0, got %f\n", ptf
[0].Y
);
5229 ok(broken(fabs(ptf
[1].X
- 542.0) < 0.001), "expected 542.0, got %f\n", ptf
[1].X
);
5230 ok(broken(fabs(ptf
[1].Y
- 541.75) < 0.001), "expected 541.75, got %f\n", ptf
[1].Y
);
5233 status
= GdipTransformRegion(region100x100
, matrix
);
5236 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5238 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5239 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5241 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5243 ret
= GetRgnBox(hrgn
, &rc
);
5244 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5245 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5246 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5249 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5251 ret
= GetRgnBox(hrgn
, &rc
);
5252 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5253 ok((rc
.left
== 1147 && rc
.top
== 4534 && rc
.right
== 2214 && rc
.bottom
== 8800) ||
5254 /* rounding under Wine is slightly different */
5255 (rc
.left
== 1147 && rc
.top
== 4533 && rc
.right
== 2213 && rc
.bottom
== 8800) /* Wine */,
5256 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc
));
5263 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5265 if (fabs(ptf
[0].X
- 210.0625) < 0.001)
5267 expectf(210.0625, ptf
[0].X
);
5268 expectf(420.0625, ptf
[0].Y
);
5269 expectf(410.125, ptf
[1].X
);
5270 expectf(820.0, ptf
[1].Y
);
5272 else /* before Win7 */
5274 ok(broken(fabs(ptf
[0].X
- 568.5) < 0.001), "expected 568.5, got %f\n", ptf
[0].X
);
5275 ok(broken(fabs(ptf
[0].Y
- 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf
[0].Y
);
5276 ok(broken(fabs(ptf
[1].X
- 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf
[1].X
);
5277 ok(broken(fabs(ptf
[1].Y
- 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf
[1].Y
);
5280 status
= GdipRotateMatrix(matrix
, 30.0, MatrixOrderAppend
);
5282 status
= GdipSetWorldTransform(graphics
, matrix
);
5285 status
= GdipGetClipBounds(graphics
, &rect
);
5287 expectf_(20.612978, rect
.X
, 1.0);
5288 expectf_(-6.256012, rect
.Y
, 1.5);
5289 expectf_(25.612978, rect
.Width
, 1.0);
5290 expectf_(12.806489, rect
.Height
, 1.0);
5292 status
= GdipSetEmpty(region
);
5294 status
= GdipGetClip(graphics
, region
);
5296 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5298 /* rounding under Wine is slightly different */
5299 expectf_(20.612978, rect
.X
, 1.0);
5300 expectf_(-6.256012, rect
.Y
, 1.5);
5301 expectf_(25.612978, rect
.Width
, 1.0);
5302 expectf_(12.806489, rect
.Height
, 1.0);
5304 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5306 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5307 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5309 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5311 ret
= GetRgnBox(hrgn
, &rc
);
5312 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5313 ok((rc
.left
== 22 && rc
.top
== -6 && rc
.right
== 46 && rc
.bottom
== 7) ||
5314 /* rounding under Wine is slightly different */
5315 (rc
.left
== 21 && rc
.top
== -5 && rc
.right
== 46 && rc
.bottom
== 7) /* Wine */,
5316 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc
));
5319 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5321 ret
= GetRgnBox(hrgn
, &rc
);
5322 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5323 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5324 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5335 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5337 expectf(20.612978, ptf
[0].X
);
5338 expectf(-1.568512, ptf
[0].Y
);
5339 expectf(46.225956, ptf
[1].X
);
5340 expectf(1.862977, ptf
[1].Y
);
5341 expectf(36.850956, ptf
[2].X
);
5342 expectf(-6.256012, ptf
[2].Y
);
5343 expectf(29.987980, ptf
[3].X
);
5344 expectf(6.550478, ptf
[3].Y
);
5346 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5348 ret
= GetRgnBox(hrgn
, &rc
);
5349 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5350 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5351 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5354 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5356 ret
= GetRgnBox(hrgn
, &rc
);
5357 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5358 ok((rc
.left
== -3406 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) ||
5359 /* rounding under Wine is slightly different */
5360 (rc
.left
== -3407 && rc
.top
== 4500 && rc
.right
== -350 && rc
.bottom
== 8728) /* Wine */,
5361 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc
));
5372 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5374 expectf(-136.190491, ptf
[0].X
);
5375 expectf(520.010742, ptf
[0].Y
);
5376 expectf(756.417175, ptf
[1].X
);
5377 expectf(720.031616, ptf
[1].Y
);
5378 expectf(360.042114, ptf
[2].X
);
5379 expectf(376.760742, ptf
[2].Y
);
5380 expectf(260.184570, ptf
[3].X
);
5381 expectf(863.281616, ptf
[3].Y
);
5383 status
= GdipRotateMatrix(matrix
, -90.0, MatrixOrderAppend
);
5385 status
= GdipSetWorldTransform(graphics
, matrix
);
5388 status
= GdipGetClipBounds(graphics
, &rect
);
5390 expectf_(-28.100956, rect
.X
, 1.0);
5391 expectf_(7.806488, rect
.Y
, 1.5);
5392 expectf_(25.612978, rect
.Width
, 1.0);
5393 expectf_(12.806489, rect
.Height
, 1.0);
5395 status
= GdipSetEmpty(region
);
5397 status
= GdipGetClip(graphics
, region
);
5399 status
= GdipGetRegionBounds(region
, graphics
, &rect
);
5401 /* rounding under Wine is slightly different */
5402 expectf_(-28.100956, rect
.X
, 1.0);
5403 expectf_(7.806488, rect
.Y
, 1.5);
5404 expectf_(25.612978, rect
.Width
, 1.0);
5405 expectf_(12.806489, rect
.Height
, 1.0);
5407 status
= GdipGetRegionBounds(region100x100
, graphics
, &rect
);
5409 ok(rect
.X
== 210.0 && rect
.Y
== 420.0 && rect
.Width
== 200.0 && rect
.Height
== 400.0,
5410 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
5412 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5414 ret
= GetRgnBox(hrgn
, &rc
);
5415 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5416 ok((rc
.left
== -27 && rc
.top
== 8 && rc
.right
== -2 && rc
.bottom
== 21) ||
5417 /* rounding under Wine is slightly different */
5418 (rc
.left
== -28 && rc
.top
== 9 && rc
.right
== -2 && rc
.bottom
== 21) /* Wine */,
5419 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc
));
5422 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5424 ret
= GetRgnBox(hrgn
, &rc
);
5425 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5426 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5427 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5438 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5440 expectf(-11.862979, ptf
[0].X
);
5441 expectf(7.806488, ptf
[0].Y
);
5442 expectf(-18.725958, ptf
[1].X
);
5443 expectf(20.612976, ptf
[1].Y
);
5444 expectf(-2.487981, ptf
[2].X
);
5445 expectf(15.925477, ptf
[2].Y
);
5446 expectf(-28.100956, ptf
[3].X
);
5447 expectf(12.493987, ptf
[3].Y
);
5449 status
= GdipGetRegionHRgn(region100x100
, NULL
, &hrgn
);
5451 ret
= GetRgnBox(hrgn
, &rc
);
5452 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5453 ok(rc
.left
== 210 && rc
.top
== 420 && rc
.right
== 410 && rc
.bottom
== 820,
5454 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc
));
5457 status
= GdipGetRegionHRgn(region100x100
, graphics
, &hrgn
);
5459 ret
= GetRgnBox(hrgn
, &rc
);
5460 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5461 ok((rc
.left
== 4500 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) ||
5462 /* rounding under Wine is slightly different */
5463 (rc
.left
== 4499 && rc
.top
== 351 && rc
.right
== 8728 && rc
.bottom
== 3407) /* Wine */,
5464 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc
));
5475 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5477 expectf(-1055.021484, ptf
[0].X
);
5478 expectf(-70.595329, ptf
[0].Y
);
5479 expectf(-1455.063232, ptf
[1].X
);
5480 expectf(375.708435, ptf
[1].Y
);
5481 expectf(-768.521484, ptf
[2].X
);
5482 expectf(177.520981, ptf
[2].Y
);
5483 expectf(-1741.563110, ptf
[3].X
);
5484 expectf(127.592125, ptf
[3].Y
);
5486 GdipDeleteMatrix(matrix
);
5487 GdipDeleteRegion(region
);
5488 GdipDeleteRegion(region100x100
);
5489 GdipDeleteGraphics(graphics
);
5493 static void test_clipping_2(void)
5498 GpGraphics
*graphics
;
5508 hdc
= CreateCompatibleDC(0);
5509 status
= GdipCreateFromHDC(hdc
, &graphics
);
5512 status
= GdipGetPageUnit(graphics
, &unit
);
5514 expect(UnitDisplay
, unit
);
5516 GdipSetPageUnit(graphics
, UnitInch
);
5518 status
= GdipCreateRegion(®ion
);
5520 status
= GdipSetEmpty(region
);
5522 rect
.X
= rect
.Y
= 100.0;
5523 rect
.Width
= rect
.Height
= 100.0;
5524 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5526 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5529 status
= GdipGetClip(graphics
, region
);
5531 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5533 ret
= GetRgnBox(hrgn
, &rc
);
5534 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5535 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5536 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5538 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5540 ret
= GetRgnBox(hrgn
, &rc
);
5541 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5542 ok(rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200,
5543 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5550 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5552 expectf(100.0, ptf
[0].X
);
5553 expectf(100.0, ptf
[0].Y
);
5554 expectf(200.0, ptf
[1].X
);
5555 expectf(200.0, ptf
[1].X
);
5557 GdipSetPageUnit(graphics
, UnitPoint
);
5559 status
= GdipGetClip(graphics
, region
);
5561 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5563 ret
= GetRgnBox(hrgn
, &rc
);
5564 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5565 ok((rc
.left
== 7200 && rc
.top
== 7200 && rc
.right
== 14400 && rc
.bottom
== 14400) ||
5566 broken(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) /* before Win7 */,
5567 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc
));
5569 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5571 ret
= GetRgnBox(hrgn
, &rc
);
5572 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5573 ok((rc
.left
== 9600 && rc
.top
== 9600 && rc
.right
== 19200 && rc
.bottom
== 19200) ||
5574 broken(rc
.left
== 134 && rc
.top
== 134 && rc
.right
== 267 && rc
.bottom
== 267) /* before Win7 */,
5575 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc
));
5582 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5584 if (fabs(ptf
[0].X
- 7200.0) < 0.001)
5585 ok(ptf
[0].X
== 7200.0 && ptf
[0].Y
== 7200.0 && ptf
[1].X
== 14400.0 && ptf
[1].Y
== 14400.0,
5586 "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
);
5587 else /* before Win7 */
5589 ok(broken(fabs(ptf
[0].X
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].X
);
5590 ok(broken(fabs(ptf
[0].Y
- 100.0) < 0.001), "expected 100.0, got %f\n", ptf
[0].Y
);
5591 ok(broken(fabs(ptf
[1].X
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].X
);
5592 ok(broken(fabs(ptf
[1].Y
- 200.0) < 0.001), "expected 200.0, got %f\n", ptf
[1].Y
);
5595 GdipDeleteRegion(region
);
5597 GdipSetPageUnit(graphics
, UnitPixel
);
5599 status
= GdipCreateRegion(®ion
);
5601 status
= GdipSetEmpty(region
);
5603 rect
.X
= rect
.Y
= 100.0;
5604 rect
.Width
= rect
.Height
= 100.0;
5605 status
= GdipCombineRegionRect(region
, &rect
, CombineModeUnion
);
5607 status
= GdipSetClipRegion(graphics
, region
, CombineModeReplace
);
5610 status
= GdipGetClip(graphics
, region
);
5612 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5614 ret
= GetRgnBox(hrgn
, &rc
);
5615 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5616 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5617 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5618 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5620 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5622 ret
= GetRgnBox(hrgn
, &rc
);
5623 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5624 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5625 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5626 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5633 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5635 if (fabs(ptf
[0].X
- 100.0) < 0.001)
5636 ok(ptf
[0].X
== 100.0 && ptf
[0].Y
== 100.0 && ptf
[1].X
== 200.0 && ptf
[1].Y
== 200.0,
5637 "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
);
5638 else /* before Win7 */
5640 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5641 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5642 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5643 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5646 GdipSetPageUnit(graphics
, UnitPoint
);
5648 status
= GdipGetClip(graphics
, region
);
5650 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5652 ret
= GetRgnBox(hrgn
, &rc
);
5653 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5654 ok((rc
.left
== 75 && rc
.top
== 75 && rc
.right
== 150 && rc
.bottom
== 150) ||
5655 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5656 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc
));
5658 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5660 ret
= GetRgnBox(hrgn
, &rc
);
5661 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5662 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5663 broken(rc
.left
== 2 && rc
.top
== 2 && rc
.right
== 3 && rc
.bottom
== 3) /* before Win7 */,
5664 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5671 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5673 if (fabs(ptf
[0].X
- 75.0) < 0.001)
5674 ok(ptf
[0].X
== 75.0 && ptf
[0].Y
== 75.0 && ptf
[1].X
== 150.0 && ptf
[1].Y
== 150.0,
5675 "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
);
5676 else /* before Win7 */
5678 ok(broken(fabs(ptf
[0].X
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].X
);
5679 ok(broken(fabs(ptf
[0].Y
- 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf
[0].Y
);
5680 ok(broken(fabs(ptf
[1].X
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].X
);
5681 ok(broken(fabs(ptf
[1].Y
- 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf
[1].Y
);
5684 status
= GdipCreateMatrix(&matrix
);
5686 status
= GdipTranslateMatrix(matrix
, 10.0, 10.0, MatrixOrderAppend
);
5688 status
= GdipSetWorldTransform(graphics
, matrix
);
5690 GdipDeleteMatrix(matrix
);
5692 status
= GdipGetClip(graphics
, region
);
5694 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5696 ret
= GetRgnBox(hrgn
, &rc
);
5697 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5698 ok(rc
.left
== 65 && rc
.top
== 65 && rc
.right
== 140 && rc
.bottom
== 140,
5699 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc
));
5701 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5703 ret
= GetRgnBox(hrgn
, &rc
);
5704 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5705 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5706 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5713 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5715 expectf(65.0, ptf
[0].X
);
5716 expectf(65.0, ptf
[0].Y
);
5717 expectf(140.0, ptf
[1].X
);
5718 expectf(140.0, ptf
[1].X
);
5720 status
= GdipCreateMatrix(&matrix
);
5722 status
= GdipScaleMatrix(matrix
, 0.25, 0.5, MatrixOrderAppend
);
5724 status
= GdipSetWorldTransform(graphics
, matrix
);
5726 GdipDeleteMatrix(matrix
);
5728 status
= GdipGetClip(graphics
, region
);
5730 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5732 ret
= GetRgnBox(hrgn
, &rc
);
5733 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5734 ok(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300,
5735 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc
));
5737 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5739 ret
= GetRgnBox(hrgn
, &rc
);
5740 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5741 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5742 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5749 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5751 expectf(300.0, ptf
[0].X
);
5752 expectf(150.0, ptf
[0].Y
);
5753 expectf(600.0, ptf
[1].X
);
5754 expectf(300.0, ptf
[1].Y
);
5756 status
= GdipSetPageScale(graphics
, 2.0);
5759 status
= GdipGetClip(graphics
, region
);
5761 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5763 ret
= GetRgnBox(hrgn
, &rc
);
5764 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5765 ok((rc
.left
== 150 && rc
.top
== 75 && rc
.right
== 300 && rc
.bottom
== 150) ||
5766 broken(rc
.left
== 300 && rc
.top
== 150 && rc
.right
== 600 && rc
.bottom
== 300) /* before Win7 */,
5767 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc
));
5769 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5771 ret
= GetRgnBox(hrgn
, &rc
);
5772 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5773 ok((rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200) ||
5774 broken(rc
.left
== 200 && rc
.top
== 200 && rc
.right
== 400 && rc
.bottom
== 400) /* before Win7 */,
5775 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5782 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
5784 if (fabs(ptf
[0].X
- 150.0) < 0.001)
5786 expectf(150.0, ptf
[0].X
);
5787 expectf(75.0, ptf
[0].Y
);
5788 expectf(300.0, ptf
[1].X
);
5789 expectf(150.0, ptf
[1].Y
);
5791 else /* before Win7 */
5793 ok(broken(fabs(ptf
[0].X
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[0].X
);
5794 ok(broken(fabs(ptf
[0].Y
- 150.0) < 0.001), "expected 150.0, got %f\n", ptf
[0].Y
);
5795 ok(broken(fabs(ptf
[1].X
- 600.0) < 0.001), "expected 600.0, got %f\n", ptf
[1].X
);
5796 ok(broken(fabs(ptf
[1].Y
- 300.0) < 0.001), "expected 300.0, got %f\n", ptf
[1].Y
);
5799 status
= GdipCreateMatrix(&matrix
);
5801 status
= GdipRotateMatrix(matrix
, 45.0, MatrixOrderAppend
);
5803 status
= GdipSetWorldTransform(graphics
, matrix
);
5805 GdipDeleteMatrix(matrix
);
5807 status
= GdipGetClip(graphics
, region
);
5809 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5811 ret
= GetRgnBox(hrgn
, &rc
);
5812 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5813 ok((rc
.left
== 54 && rc
.top
== -26 && rc
.right
== 107 && rc
.bottom
== 27) ||
5814 /* rounding under Wine is slightly different */
5815 (rc
.left
== 53 && rc
.top
== -26 && rc
.right
== 106 && rc
.bottom
== 27) /* Wine */,
5816 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc
));
5818 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5820 ret
= GetRgnBox(hrgn
, &rc
);
5821 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5822 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5823 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5834 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5836 expectf(53.033016, ptf
[0].X
);
5837 expectf(0.0, ptf
[0].Y
);
5838 expectf(106.066032, ptf
[1].X
);
5839 expectf(0.0, ptf
[1].Y
);
5840 expectf(79.549522, ptf
[2].X
);
5841 expectf(-26.516510, ptf
[2].Y
);
5842 expectf(79.549522, ptf
[3].X
);
5843 expectf(26.516508, ptf
[3].Y
);
5845 status
= GdipCreateMatrix(&matrix
);
5847 status
= GdipRotateMatrix(matrix
, -45.0, MatrixOrderAppend
);
5849 status
= GdipSetWorldTransform(graphics
, matrix
);
5851 GdipDeleteMatrix(matrix
);
5853 status
= GdipGetClip(graphics
, region
);
5855 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
5857 ret
= GetRgnBox(hrgn
, &rc
);
5858 ok(ret
== COMPLEXREGION
, "expected COMPLEXREGION, got %d\n", ret
);
5859 ok((rc
.left
== -26 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 107) ||
5860 /* rounding under Wine is slightly different */
5861 (rc
.left
== -27 && rc
.top
== 54 && rc
.right
== 27 && rc
.bottom
== 106) /* Wine */,
5862 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc
));
5864 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
5866 ret
= GetRgnBox(hrgn
, &rc
);
5867 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
5868 ok(rc
.left
== 100 && rc
.top
== 100 && rc
.right
== 200 && rc
.bottom
== 200,
5869 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc
));
5880 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 4);
5882 expectf(0.0, ptf
[0].X
);
5883 expectf(53.033005, ptf
[0].Y
);
5884 expectf(0.0, ptf
[1].X
);
5885 expectf(106.066010, ptf
[1].Y
);
5886 expectf(26.516491, ptf
[2].X
);
5887 expectf(79.549507, ptf
[2].Y
);
5888 expectf(-26.516520, ptf
[3].X
);
5889 expectf(79.549500, ptf
[3].Y
);
5891 GdipDeleteRegion(region
);
5892 GdipDeleteGraphics(graphics
);
5897 static void test_GdipFillRectangles(void)
5900 GpGraphics
*graphics
= NULL
;
5901 GpBrush
*brush
= NULL
;
5902 HDC hdc
= GetDC( hwnd
);
5903 GpRectF rects
[2] = {{0,0,10,10}, {10,10,10,10}};
5905 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
5907 status
= GdipCreateFromHDC(hdc
, &graphics
);
5909 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
5911 status
= GdipCreateSolidFill((ARGB
)0xffff00ff, (GpSolidFill
**)&brush
);
5913 ok(brush
!= NULL
, "Expected brush to be initialized\n");
5915 status
= GdipFillRectangles(NULL
, brush
, rects
, 2);
5916 expect(InvalidParameter
, status
);
5918 status
= GdipFillRectangles(graphics
, NULL
, rects
, 2);
5919 expect(InvalidParameter
, status
);
5921 status
= GdipFillRectangles(graphics
, brush
, NULL
, 2);
5922 expect(InvalidParameter
, status
);
5924 status
= GdipFillRectangles(graphics
, brush
, rects
, 0);
5925 expect(InvalidParameter
, status
);
5927 status
= GdipFillRectangles(graphics
, brush
, rects
, -1);
5928 expect(InvalidParameter
, status
);
5930 status
= GdipFillRectangles(graphics
, brush
, rects
, 1);
5933 status
= GdipFillRectangles(graphics
, brush
, rects
, 2);
5936 GdipDeleteBrush(brush
);
5937 GdipDeleteGraphics(graphics
);
5939 ReleaseDC(hwnd
, hdc
);
5942 static void test_GdipGetVisibleClipBounds_memoryDC(void)
5951 GpGraphics
* graphics
= NULL
;
5955 ok(GetClientRect(hwnd
, &rect
), "GetClientRect should have succeeded\n");
5956 width
= rect
.right
- rect
.left
;
5957 height
= rect
.bottom
- rect
.top
;
5960 hdc
= CreateCompatibleDC ( dc
);
5961 bmp
= CreateCompatibleBitmap ( dc
, width
, height
);
5962 old
= SelectObject (hdc
, bmp
);
5964 /*change the window origin is the key test point*/
5965 SetWindowOrgEx (hdc
, rect
.left
+10, rect
.top
+10, &pt
);
5967 status
= GdipCreateFromHDC(hdc
, &graphics
);
5970 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5973 ok(boundRect
.X
==rect
.left
+10 &&
5974 boundRect
.Y
==rect
.top
+10 &&
5975 boundRect
.Width
==width
&&
5976 boundRect
.Height
==height
, "Expected GdipGetVisibleClipBoundsI ok\n");
5978 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
5981 status
= GdipGetVisibleClipBoundsI(graphics
, &boundRect
);
5984 ok(boundRect
.X
==rect
.left
+10 &&
5985 boundRect
.Y
==rect
.top
+10 &&
5986 boundRect
.Width
==width
-10 &&
5987 boundRect
.Height
==height
-10, "Expected GdipGetVisibleClipBoundsI ok\n");
5989 GdipDeleteGraphics(graphics
);
5991 SelectObject (hdc
, old
);
5994 ReleaseDC(hwnd
, dc
);
5997 static void test_container_rects(void)
6000 GpGraphics
*graphics
;
6001 HDC hdc
= GetDC( hwnd
);
6002 GpRectF dstrect
, srcrect
;
6003 GraphicsContainer state
;
6004 static const GpPointF test_points
[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
6008 status
= GdipCreateFromHDC(hdc
, &graphics
);
6013 dstrect
.Width
= 1.0;
6014 dstrect
.Height
= 1.0;
6017 status
= GdipGetDpiX(graphics
, &dpix
);
6020 status
= GdipGetDpiY(graphics
, &dpiy
);
6023 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitWorld
, &state
);
6024 expect(InvalidParameter
, status
);
6026 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitDisplay
, &state
);
6027 expect(InvalidParameter
, status
);
6029 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitMillimeter
+1, &state
);
6030 expect(InvalidParameter
, status
);
6032 status
= GdipBeginContainer(NULL
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6033 expect(InvalidParameter
, status
);
6035 status
= GdipBeginContainer(graphics
, NULL
, &srcrect
, UnitPixel
, &state
);
6036 expect(InvalidParameter
, status
);
6038 status
= GdipBeginContainer(graphics
, &dstrect
, NULL
, UnitPixel
, &state
);
6039 expect(InvalidParameter
, status
);
6041 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, -1, &state
);
6042 expect(InvalidParameter
, status
);
6044 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, NULL
);
6045 expect(InvalidParameter
, status
);
6047 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6050 memcpy(points
, test_points
, sizeof(points
));
6051 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6053 expectf(0.0, points
[0].X
);
6054 expectf(0.0, points
[0].Y
);
6055 expectf(1.0, points
[1].X
);
6056 expectf(0.0, points
[1].Y
);
6057 expectf(0.0, points
[2].X
);
6058 expectf(1.0, points
[2].Y
);
6060 status
= GdipEndContainer(graphics
, state
);
6063 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6066 memcpy(points
, test_points
, sizeof(points
));
6067 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6069 expectf(0.0, points
[0].X
);
6070 expectf(0.0, points
[0].Y
);
6071 expectf(1.0/dpix
, points
[1].X
);
6072 expectf(0.0, points
[1].Y
);
6073 expectf(0.0, points
[2].X
);
6074 expectf(1.0/dpiy
, points
[2].Y
);
6076 status
= GdipEndContainer(graphics
, state
);
6079 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
6083 dstrect
.Height
= 3.0;
6084 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6087 memcpy(points
, test_points
, sizeof(points
));
6088 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6090 expectf(2.0, points
[0].X
);
6091 expectf(0.0, points
[0].Y
);
6092 expectf(4.0, points
[1].X
);
6093 expectf(0.0, points
[1].Y
);
6094 expectf(2.0, points
[2].X
);
6095 expectf(6.0, points
[2].Y
);
6097 status
= GdipEndContainer(graphics
, state
);
6100 memcpy(points
, test_points
, sizeof(points
));
6101 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6103 expectf(0.0, points
[0].X
);
6104 expectf(0.0, points
[0].Y
);
6105 expectf(2.0, points
[1].X
);
6106 expectf(0.0, points
[1].Y
);
6107 expectf(0.0, points
[2].X
);
6108 expectf(2.0, points
[2].Y
);
6110 status
= GdipResetWorldTransform(graphics
);
6113 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6116 memcpy(points
, test_points
, sizeof(points
));
6117 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6119 expectf(1.0, points
[0].X
);
6120 expectf(0.0, points
[0].Y
);
6121 expectf((dpix
+1.0)/dpix
, points
[1].X
);
6122 expectf(0.0, points
[1].Y
);
6123 expectf(1.0, points
[2].X
);
6124 expectf(3.0/dpiy
, points
[2].Y
);
6126 status
= GdipEndContainer(graphics
, state
);
6129 status
= GdipSetPageUnit(graphics
, UnitInch
);
6132 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitPixel
, &state
);
6135 memcpy(points
, test_points
, sizeof(points
));
6136 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6138 expectf(dpix
, points
[0].X
);
6139 expectf(0.0, points
[0].Y
);
6140 expectf(dpix
*2, points
[1].X
);
6141 expectf(0.0, points
[1].Y
);
6142 expectf(dpix
, points
[2].X
);
6143 expectf(dpiy
*3, points
[2].Y
);
6145 status
= GdipEndContainer(graphics
, state
);
6148 status
= GdipBeginContainer(graphics
, &dstrect
, &srcrect
, UnitInch
, &state
);
6151 memcpy(points
, test_points
, sizeof(points
));
6152 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, points
, 3);
6154 expectf(dpix
, points
[0].X
);
6155 expectf(0.0, points
[0].Y
);
6156 expectf(dpix
+1.0, points
[1].X
);
6157 expectf(0.0, points
[1].Y
);
6158 expectf(dpix
, points
[2].X
);
6159 expectf(3.0, points
[2].Y
);
6161 status
= GdipEndContainer(graphics
, state
);
6164 GdipDeleteGraphics(graphics
);
6166 ReleaseDC(hwnd
, hdc
);
6169 static void test_GdipGraphicsSetAbort(void)
6173 GpGraphics
*graphics
;
6175 if (!pGdipGraphicsSetAbort
)
6177 win_skip("GdipGraphicsSetAbort() is not supported.\n");
6183 status
= GdipCreateFromHDC(hdc
, &graphics
);
6186 status
= pGdipGraphicsSetAbort(NULL
, NULL
);
6187 expect(InvalidParameter
, status
);
6189 status
= pGdipGraphicsSetAbort(graphics
, NULL
);
6192 GdipDeleteGraphics(graphics
);
6194 ReleaseDC(hwnd
, hdc
);
6197 #define BLUE_COLOR (0xff0000ff)
6198 #define is_blue_color(color) ( ((color) & 0x00ffffff) == 0xff )
6199 #define get_bitmap_pixel(x,y) pixel[(y)*(width) + (x)]
6200 static DWORD
* GetBitmapPixelBuffer(HDC hdc
, HBITMAP hbmp
, int width
, int height
)
6202 BITMAPINFOHEADER bi
;
6204 DWORD
*buffer
= (DWORD
*)GdipAlloc(width
*height
*4);
6206 bi
.biSize
= sizeof(BITMAPINFOHEADER
);
6208 bi
.biHeight
= -height
; /*very Important, set negative, indicating a top-down DIB*/
6211 bi
.biCompression
= BI_RGB
;
6213 bi
.biXPelsPerMeter
= 0;
6214 bi
.biYPelsPerMeter
= 0;
6216 bi
.biClrImportant
= 0;
6218 lines
= GetDIBits(hdc
, hbmp
, 0, height
, buffer
, (BITMAPINFO
*)&bi
, DIB_RGB_COLORS
);
6219 ok(lines
== height
, "Expected GetDIBits:%p,%d->%d,%d\n", buffer
, height
, lines
, GetLastError());
6224 static void ReleaseBitmapPixelBuffer(DWORD
* buffer
)
6226 if (buffer
) GdipFree(buffer
);
6229 static void test_GdipFillRectanglesOnMemoryDCSolidBrush(void)
6231 ARGB color
[6] = {0,0,0,0,0,0};
6233 RECT rect
= {100, 100, 180, 180};
6234 UINT width
= rect
.right
- rect
.left
;
6235 UINT height
= rect
.bottom
- rect
.top
;
6236 GpStatus status
= 0;
6237 GpSolidFill
*brush
= NULL
;
6238 GpGraphics
*graphics
= NULL
;
6239 HDC dc
= GetDC( hwnd
);
6240 HDC hdc
= CreateCompatibleDC(dc
);
6241 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6242 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6243 DWORD
* pixel
= NULL
;
6245 /*Change the window origin is the key test point*/
6246 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6248 status
= GdipCreateSolidFill(BLUE_COLOR
, &brush
);
6251 status
= GdipCreateFromHDC(hdc
, &graphics
);
6254 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6255 width
, height
, CombineModeReplace
);
6258 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6261 GdipDeleteBrush((GpBrush
*)brush
);
6262 GdipDeleteGraphics(graphics
);
6264 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6267 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6268 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6269 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6270 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6271 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6272 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6275 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6276 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6277 "Expected GdipFillRectangleI take effect!\n" );
6278 ReleaseBitmapPixelBuffer(pixel
);
6280 SelectObject(hdc
, old
);
6283 ReleaseDC(hwnd
, dc
);
6286 static void test_GdipFillRectanglesOnMemoryDCTextureBrush(void)
6288 ARGB color
[6] = {0,0,0,0,0,0};
6290 RECT rect
= {100, 100, 180, 180};
6291 UINT width
= rect
.right
- rect
.left
;
6292 UINT height
= rect
.bottom
- rect
.top
;
6293 GpStatus status
= 0;
6299 GpTexture
*brush
= NULL
;
6300 GpGraphics
*graphics
= NULL
;
6301 HDC dc
= GetDC( hwnd
);
6302 HDC hdc
= CreateCompatibleDC(dc
);
6303 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6304 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6308 UINT src_img_width
= width
/2;
6309 UINT src_img_height
= height
/2;
6310 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6311 DWORD
*pixel
= (DWORD
*)src_img_data
;
6312 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6314 /*Change the window origin is the key test point*/
6315 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6317 /*build a blue solid image!*/
6318 for(y
= 0; y
< src_img_height
; ++y
)
6320 for(x
= 0; x
< src_img_width
; ++x
)
6322 pixel
[x
] = BLUE_COLOR
;
6325 pixel
+= src_img_width
;
6328 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6329 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6332 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6335 status
= GdipCreateFromHDC(hdc
, &graphics
);
6338 status
= GdipSetClipRectI(graphics
, rect
.left
+width
/2, rect
.top
+height
/2,
6339 width
, height
, CombineModeReplace
);
6342 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, rect
.right
, rect
.bottom
);
6345 GdipDisposeImage(src_img
.image
);
6346 GdipDeleteBrush((GpBrush
*)brush
);
6347 GdipDeleteGraphics(graphics
);
6348 GdipFree(src_img_data
);
6350 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6353 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6354 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6355 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6356 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6357 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6358 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6360 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6361 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6362 "Expected GdipFillRectangleI take effect!\n" );
6363 ReleaseBitmapPixelBuffer(pixel
);
6365 SelectObject(hdc
, old
);
6368 ReleaseDC(hwnd
, dc
);
6371 static void test_GdipFillRectanglesOnBitmapTextureBrush(void)
6373 ARGB color
[6] = {0,0,0,0,0,0};
6376 RECT rect
= {100, 100, 180, 180};
6377 UINT width
= rect
.right
- rect
.left
;
6378 UINT height
= rect
.bottom
- rect
.top
;
6379 UINT src_img_width
= width
/2;
6380 UINT src_img_height
= height
/2;
6382 GpStatus status
= 0;
6394 GpTexture
*brush
= NULL
;
6395 GpGraphics
*graphics
= NULL
;
6396 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6397 DWORD
*pixel
= (DWORD
*)src_img_data
;
6398 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6400 status
= GdipCreateBitmapFromScan0(width
, height
, width
*4,
6401 PixelFormat32bppARGB
, NULL
, &dst_img
.bitmap
);
6404 /*build a blue solid image!*/
6405 for(y
= 0; y
< src_img_height
; ++y
)
6407 for(x
= 0; x
< src_img_width
; ++x
)
6409 pixel
[x
] = BLUE_COLOR
;
6412 pixel
+= src_img_width
;
6415 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6416 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6419 status
= GdipCreateTexture(src_img
.image
, 0, &brush
);
6422 status
= GdipGetImageGraphicsContext(dst_img
.image
, &graphics
);
6425 status
= GdipSetClipRectI(graphics
, 0, 0, width
, height
, CombineModeReplace
);
6428 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, width
/2, height
/2);
6431 GdipDeleteBrush((GpBrush
*)brush
);
6432 GdipDeleteGraphics(graphics
);
6434 GdipBitmapGetPixel(dst_img
.bitmap
, 0, 0, &color
[0]);
6435 GdipBitmapGetPixel(dst_img
.bitmap
, 0, 1, &color
[1]);
6436 GdipBitmapGetPixel(dst_img
.bitmap
, 1, 0, &color
[2]);
6437 GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, 0, &color
[3]);
6438 GdipBitmapGetPixel(dst_img
.bitmap
, width
/2, height
/2, &color
[4]);
6439 GdipBitmapGetPixel(dst_img
.bitmap
, 0, height
/2, &color
[5]);
6441 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6442 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6443 "Expected GdipFillRectangleI take effect!\n" );
6445 GdipDisposeImage(src_img
.image
);
6446 GdipDisposeImage(dst_img
.image
);
6447 GdipFree(src_img_data
);
6450 static void test_GdipDrawImagePointsRectOnMemoryDC(void)
6452 ARGB color
[6] = {0,0,0,0,0,0};
6454 RECT rect
= {100, 100, 180, 180};
6455 UINT width
= rect
.right
- rect
.left
;
6456 UINT height
= rect
.bottom
- rect
.top
;
6457 GpStatus status
= 0;
6463 GpGraphics
*graphics
= NULL
;
6464 HDC dc
= GetDC( hwnd
);
6465 HDC hdc
= CreateCompatibleDC(dc
);
6466 HBITMAP bmp
= CreateCompatibleBitmap(dc
, width
, height
);
6467 HGDIOBJ old
= SelectObject(hdc
, bmp
);
6471 UINT src_img_width
= width
/2;
6472 UINT src_img_height
= height
/2;
6473 BYTE
*src_img_data
= GdipAlloc(src_img_width
*src_img_height
*4);
6474 DWORD
*pixel
= (DWORD
*)src_img_data
;
6475 ok(pixel
!= NULL
, "Expected src_img_data is valid\n");
6477 /*Change the window origin is the key test point*/
6478 SetWindowOrgEx(hdc
, rect
.left
, rect
.top
, &pt
);
6480 /*build a blue solid image!*/
6481 for(y
= 0; y
< src_img_height
; ++y
)
6483 for(x
= 0; x
< src_img_width
; ++x
)
6485 pixel
[x
] = BLUE_COLOR
;
6488 pixel
+= src_img_width
;
6491 status
= GdipCreateBitmapFromScan0(src_img_width
, src_img_height
, src_img_width
*4,
6492 PixelFormat32bppARGB
, src_img_data
, &src_img
.bitmap
);
6495 status
= GdipCreateFromHDC(hdc
, &graphics
);
6498 status
= GdipDrawImageRectRectI(graphics
, src_img
.image
,
6499 rect
.left
+width
/2, rect
.top
+height
/2, width
/2, height
/2,
6500 0, 0, src_img_width
, src_img_height
, UnitPixel
, NULL
, NULL
, NULL
);
6503 GdipDisposeImage(src_img
.image
);
6504 GdipDeleteGraphics(graphics
);
6505 GdipFree(src_img_data
);
6507 pixel
= GetBitmapPixelBuffer(hdc
, bmp
, width
, height
);
6510 color
[0] = get_bitmap_pixel(width
/2, height
/2);
6511 color
[1] = get_bitmap_pixel(width
/2+1, height
/2);
6512 color
[2] = get_bitmap_pixel(width
/2, height
/2+1);
6513 color
[3] = get_bitmap_pixel(width
/2-1, height
/2-1);
6514 color
[4] = get_bitmap_pixel(width
/2-1, height
-1);
6515 color
[5] = get_bitmap_pixel(width
-1, height
/2-1);
6517 ok(is_blue_color(color
[0]) && is_blue_color(color
[1]) && is_blue_color(color
[2]) &&
6518 color
[3] == 0 && color
[4] == 0 && color
[5] == 0,
6519 "Expected GdipDrawImageRectRectI take effect!\n" );
6520 ReleaseBitmapPixelBuffer(pixel
);
6522 SelectObject(hdc
, old
);
6525 ReleaseDC(hwnd
, dc
);
6528 START_TEST(graphics
)
6530 struct GdiplusStartupInput gdiplusStartupInput
;
6531 ULONG_PTR gdiplusToken
;
6533 HMODULE gdiplus_mod
= GetModuleHandleA("gdiplus.dll");
6535 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
6537 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
6538 hmsvcrt
= LoadLibraryA("msvcrt");
6539 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
6540 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
6542 pGdipGraphicsSetAbort
= (void*)GetProcAddress(gdiplus_mod
, "GdipGraphicsSetAbort");
6544 memset( &class, 0, sizeof(class) );
6545 class.lpszClassName
= "gdiplus_test";
6546 class.style
= CS_HREDRAW
| CS_VREDRAW
;
6547 class.lpfnWndProc
= DefWindowProcA
;
6548 class.hInstance
= GetModuleHandleA(0);
6549 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
6550 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6551 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
6552 RegisterClassA( &class );
6553 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6554 CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
6555 ok(hwnd
!= NULL
, "Expected window to be created\n");
6557 gdiplusStartupInput
.GdiplusVersion
= 1;
6558 gdiplusStartupInput
.DebugEventCallback
= NULL
;
6559 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
6560 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
6562 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
6566 test_measured_extra_space();
6567 test_measure_string();
6568 test_font_height_scaling();
6570 test_pen_thickness();
6571 test_GdipMeasureString();
6572 test_constructor_destructor();
6573 test_save_restore();
6574 test_GdipFillClosedCurve2();
6575 test_GdipFillClosedCurve2I();
6576 test_GdipDrawBezierI();
6578 test_GdipDrawArcI();
6579 test_GdipDrawCurve();
6580 test_GdipDrawCurveI();
6581 test_GdipDrawCurve2();
6582 test_GdipDrawCurve2I();
6583 test_GdipDrawCurve3();
6584 test_GdipDrawCurve3I();
6585 test_GdipDrawLineI();
6586 test_GdipDrawLinesI();
6587 test_GdipDrawImagePointsRect();
6588 test_GdipFillClosedCurve();
6589 test_GdipFillClosedCurveI();
6590 test_GdipDrawString();
6591 test_GdipGetNearestColor();
6592 test_GdipGetVisibleClipBounds();
6593 test_GdipIsVisiblePoint();
6594 test_GdipIsVisibleRect();
6595 test_Get_Release_DC();
6596 test_BeginContainer2();
6597 test_transformpoints();
6598 test_get_set_clip();
6601 test_textcontrast();
6602 test_fromMemoryBitmap();
6603 test_string_functions();
6604 test_get_set_interpolation();
6605 test_get_set_textrenderinghint();
6606 test_getdc_scaled();
6608 test_bitmapfromgraphics();
6609 test_GdipFillRectangles();
6610 test_GdipGetVisibleClipBounds_memoryDC();
6611 test_GdipFillRectanglesOnMemoryDCSolidBrush();
6612 test_GdipFillRectanglesOnMemoryDCTextureBrush();
6613 test_GdipFillRectanglesOnBitmapTextureBrush();
6614 test_GdipDrawImagePointsRectOnMemoryDC();
6615 test_container_rects();
6616 test_GdipGraphicsSetAbort();
6618 GdiplusShutdown(gdiplusToken
);
6619 DestroyWindow( hwnd
);