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