[PATCH v4 0/2] MR10714: Various fixes for 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
On Wed Apr 22 21:03:00 2026 +0000, Esme Povirk wrote:
I think the GdipMeasureString change runs into the same problem as !9775, which is that we can't calculate Y position without knowing the full height of the string. I have removed GdipMeasureString fixes from this PR. I will make such fixes in separate PR.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10714#note_137373
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10714
participants (3)
-
Bartosz Kosiorek -
Bartosz Kosiorek (@gang65) -
Esme Povirk (@madewokherd)