[PATCH v2 0/3] MR10714: Various fixes of GdipMeasureString GdipWarpPath and GdipGetNearestColor in graphics.c module
From: Bartosz Kosiorek <gang65@poczta.onet.pl> --- dlls/gdiplus/graphics.c | 17 +++++++++++++++-- dlls/gdiplus/tests/graphics.c | 6 +++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index b278bfd1d94..24705b7fe9b 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5258,8 +5258,21 @@ GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB* argb) { static int once; GpBitmap *bitmap = (GpBitmap *)graphics->image; - if (IsIndexedPixelFormat(bitmap->format) && !once++) - FIXME("(%p, %p): Passing color unmodified\n", graphics, argb); + if (IsIndexedPixelFormat(bitmap->format)) + { + if (!once++) + FIXME("(%p, %p): Passing indexed color unmodified\n", graphics, argb); + } + else if (bitmap->format == PixelFormat16bppRGB565) + { + /* 16bpp RGB565: Keep top 5 bits for R and B channels, top 6 bits for G channel */ + *argb = (*argb & 0x00F8FCF8) | 0xFF000000; + } + else if (bitmap->format == PixelFormat16bppRGB555) + { + /* 16bpp RGB555: Keep top 5 bits for R, G, B channels */ + *argb = (*argb & 0x00F8F8F8) | 0xFF000000; + } } return Ok; diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 96ef52ce935..4210b5886c1 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -3252,7 +3252,8 @@ static void test_GdipGetNearestColor(void) expect(Ok, status); status = GdipGetNearestColor(graphics, &color); expect(Ok, status); - todo_wine expect(0xffa8bce8, color); + ok(color == 0xffa8bce8, + "Expected 0xffa8bce8, got %.8lx\n", color); GdipDeleteGraphics(graphics); GdipDisposeImage((GpImage*)bitmap); @@ -3262,10 +3263,9 @@ static void test_GdipGetNearestColor(void) expect(Ok, status); status = GdipGetNearestColor(graphics, &color); expect(Ok, status); - todo_wine ok(color == 0xffa8b8e8 || broken(color == 0xffa0b8e0), /* Win98/WinMe */ - "Expected ffa8b8e8, got %.8lx\n", color); + "Expected 0xffa8b8e8, got %.8lx\n", color); GdipDeleteGraphics(graphics); GdipDisposeImage((GpImage*)bitmap); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10714
From: Bartosz Kosiorek <gang65@poczta.onet.pl> --- dlls/gdiplus/graphicspath.c | 4 ++++ dlls/gdiplus/tests/graphicspath.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index a18f37395d2..24759132c1d 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -1929,6 +1929,10 @@ GpStatus WINGDIPAPI GdipWarpPath(GpPath *path, GpMatrix* matrix, FIXME("(%p,%s,%p,%i,%0.2f,%0.2f,%0.2f,%0.2f,%i,%0.2f)\n", path, debugstr_matrix(matrix), points, count, x, y, width, height, warpmode, flatness); + if (!path || !points || count < 1) { + return InvalidParameter; + } + return NotImplemented; } diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 2a92f842101..baa216c2254 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1503,15 +1503,15 @@ static void test_warp_path(void) /* NULL path */ status = GdipWarpPath(NULL, NULL, dest_points, count, 0.0, 0.0, 128.0, 128.0, WarpModePerspective, FlatnessDefault); - todo_wine expect(InvalidParameter, status); + expect(InvalidParameter, status); /* NULL destination points */ status = GdipWarpPath(path, NULL, NULL, count, 0.0, 0.0, 128.0, 128.0, WarpModePerspective, FlatnessDefault); - todo_wine expect(InvalidParameter, status); + expect(InvalidParameter, status); /* Zero number of point in destination points */ status = GdipWarpPath(path, NULL, dest_points, 0, 0.0, 0.0, 128.0, 128.0, WarpModePerspective, FlatnessDefault); - todo_wine expect(InvalidParameter, status); + expect(InvalidParameter, status); /* Valid warp with one destination point */ status = GdipWarpPath(path, NULL, dest_points, 1, 0.0, 0.0, 128.0, 128.0, WarpModePerspective, FlatnessDefault); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10714
From: Bartosz Kosiorek <gang65@poczta.onet.pl> --- dlls/gdiplus/graphics.c | 15 +++++++++++++-- dlls/gdiplus/tests/graphics.c | 4 ---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 24705b7fe9b..b6b4ac729e2 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -6091,15 +6091,26 @@ static GpStatus measure_string_callback(struct gdip_format_string_info *info) switch (info->format ? info->format->align : StringAlignmentNear) { case StringAlignmentCenter: - bounds->X = bounds->X + (info->rect->Width/2) - (bounds->Width/2); + bounds->X += (info->rect->Width - bounds->Width) / 2; break; case StringAlignmentFar: - bounds->X = bounds->X + info->rect->Width - bounds->Width; + bounds->X += info->rect->Width - bounds->Width; break; default: break; } + switch (info->format ? info->format->line_align : StringAlignmentNear) + { + case StringAlignmentCenter: + bounds->Y += (info->rect->Height - bounds->Height) / 2; + break; + case StringAlignmentFar: + bounds->Y += info->rect->Height - bounds->Height; + break; + default: + break; + } return Ok; } diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 4210b5886c1..a25e84b8be8 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4921,7 +4921,6 @@ static void test_measure_string(void) expect(3, glyphs); expect(1, lines); expectf_(5.0 + width/2.0, bounds.X, 0.01); - todo_wine expectf(5.0 + height/2.0, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); @@ -4937,7 +4936,6 @@ static void test_measure_string(void) expect(1, lines); todo_wine expectf_(5.0 - width/2.0, bounds.X, 0.01); - todo_wine expectf(5.0 - height/2.0, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); @@ -4988,7 +4986,6 @@ static void test_measure_string(void) expect(3, glyphs); expect(1, lines); expectf_(5.0 + width, bounds.X, 0.01); - todo_wine expectf(5.0 + height, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); @@ -5004,7 +5001,6 @@ static void test_measure_string(void) expect(1, lines); todo_wine expectf_(5.0 - width, bounds.X, 0.01); - todo_wine expectf(5.0 - height, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10714
participants (2)
-
Bartosz Kosiorek -
Bartosz Kosiorek (@gang65)