From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/graphics.c | 28 +++++++++++++++++++++++----- dlls/gdiplus/tests/image.c | 12 +++++------- 2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index bbbf598f0e1..94fc4d640d2 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -324,6 +324,23 @@ static void restore_dc(GpGraphics *graphics, INT state) RestoreDC(graphics->hdc, state); }
+static void round_half_down_points(POINT *pti, GpPointF *ptf, INT count) +{ + int i; + + for(i = 0; i < count; i++){ + if(isnan(ptf[i].X)) + pti[i].x = 0; + else + pti[i].x = ceilf(ptf[i].X - 0.5); + + if(isnan(ptf[i].Y)) + pti[i].y = 0; + else + pti[i].y = ceilf(ptf[i].Y - 0.5); + } +} + static void round_points(POINT *pti, GpPointF *ptf, INT count) { int i; @@ -3042,7 +3059,6 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image DrawImageAbort callback, VOID * callbackData) { GpPointF ptf[4]; - POINT pti[4]; GpStatus stat;
TRACE("(%p, %p, %p, %d, %f, %f, %f, %f, %d, %p, %p, %p)\n", graphics, image, points, @@ -3095,10 +3111,6 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image if (!srcwidth || !srcheight || (ptf[3].X == ptf[0].X && ptf[3].Y == ptf[0].Y)) return Ok; gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 4); - round_points(pti, ptf, 4); - - TRACE("%s %s %s %s\n", wine_dbgstr_point(&pti[0]), wine_dbgstr_point(&pti[1]), - wine_dbgstr_point(&pti[2]), wine_dbgstr_point(&pti[3]));
srcx = units_to_pixels(srcx, srcUnit, image->xres, graphics->printer_display); srcy = units_to_pixels(srcy, srcUnit, image->yres, graphics->printer_display); @@ -3111,6 +3123,12 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image GpBitmap* bitmap = (GpBitmap*)image; BOOL do_resampling = FALSE; BOOL use_software = FALSE; + POINT pti[4]; + + round_half_down_points(pti, ptf, 4); + + TRACE("%s %s %s %s\n", wine_dbgstr_point(&pti[0]), wine_dbgstr_point(&pti[1]), + wine_dbgstr_point(&pti[2]), wine_dbgstr_point(&pti[3]));
TRACE("graphics: %.2fx%.2f dpi, fmt %#x, scale %f, image: %.2fx%.2f dpi, fmt %#x, color %08lx\n", graphics->xres, graphics->yres, diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index b9b3466ea4f..84beee49cd2 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -4837,7 +4837,6 @@ static void test_DrawImage_scale(void) REAL scale_x; PixelOffsetMode pixel_offset_mode; const BYTE *image; - BOOL todo; } td[] = { { 0.8, PixelOffsetModeNone, image_080 }, /* 0 */ @@ -4859,18 +4858,18 @@ static void test_DrawImage_scale(void) { 0.8, PixelOffsetModeHalf, image_080 }, /* 14 */ { 1.0, PixelOffsetModeHalf, image_100 }, { 1.2, PixelOffsetModeHalf, image_120_half }, - { 1.5, PixelOffsetModeHalf, image_150_half, TRUE }, + { 1.5, PixelOffsetModeHalf, image_150_half }, { 1.8, PixelOffsetModeHalf, image_180_half }, { 2.0, PixelOffsetModeHalf, image_200_half }, - { 2.5, PixelOffsetModeHalf, image_250_half, TRUE }, + { 2.5, PixelOffsetModeHalf, image_250_half },
{ 0.8, PixelOffsetModeHighQuality, image_080 }, /* 21 */ { 1.0, PixelOffsetModeHighQuality, image_100 }, { 1.2, PixelOffsetModeHighQuality, image_120_half }, - { 1.5, PixelOffsetModeHighQuality, image_150_half, TRUE }, + { 1.5, PixelOffsetModeHighQuality, image_150_half }, { 1.8, PixelOffsetModeHighQuality, image_180_half }, { 2.0, PixelOffsetModeHighQuality, image_200_half }, - { 2.5, PixelOffsetModeHighQuality, image_250_half, TRUE }, + { 2.5, PixelOffsetModeHighQuality, image_250_half }, { 2.51, PixelOffsetModeHighQuality, image_251_half }, }; BYTE src_2x1[6] = { 0x80,0x80,0x80, 0xcc,0xcc,0xcc }; @@ -4915,8 +4914,7 @@ static void test_DrawImage_scale(void) expect(Ok, status);
match = memcmp(dst_8x1, td[i].image, sizeof(dst_8x1)) == 0; - todo_wine_if (!match && td[i].todo) - ok(match, "%d: data should match\n", i); + ok(match, "%d: data should match\n", i); if (!match) { trace("Expected: %s\n", dbgstr_hexdata(td[i].image, sizeof(dst_8x1)));