From 49ae7360228348bbe6f188daa1a2b388ea327258 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 12 Dec 2011 20:20:06 +0100 Subject: [PATCH] gdi32: Implement GetNearestColor in the DIB driver. --- dlls/gdi32/dibdrv/dc.c | 2 +- dlls/gdi32/dibdrv/dibdrv.h | 1 + dlls/gdi32/dibdrv/graphics.c | 14 ++++++++++++++ dlls/gdi32/tests/bitmap.c | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index 66c92344289..571a0705f13 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -530,7 +530,7 @@ const struct gdi_dc_funcs dib_driver = NULL, /* pGetICMProfile */ dibdrv_GetImage, /* pGetImage */ NULL, /* pGetKerningPairs */ - NULL, /* pGetNearestColor */ + dibdrv_GetNearestColor, /* pGetNearestColor */ NULL, /* pGetOutlineTextMetrics */ dibdrv_GetPixel, /* pGetPixel */ NULL, /* pGetPixelFormat */ diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h index cd96e3e2f91..6c63c3d9290 100644 --- a/dlls/gdi32/dibdrv/dibdrv.h +++ b/dlls/gdi32/dibdrv/dibdrv.h @@ -124,6 +124,7 @@ extern BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect, LPCWSTR str, UINT count, const INT *dx ) DECLSPEC_HIDDEN; extern DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info, struct gdi_image_bits *bits, struct bitblt_coords *src ) DECLSPEC_HIDDEN; +extern COLORREF dibdrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF dibdrv_GetPixel( PHYSDEV dev, INT x, INT y ) DECLSPEC_HIDDEN; extern BOOL dibdrv_LineTo( PHYSDEV dev, INT x, INT y ) DECLSPEC_HIDDEN; extern BOOL dibdrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index 439a10f275f..67f1c99731b 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -391,6 +391,20 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, return TRUE; } +/*********************************************************************** + * dibdrv_GetNearestColor + */ +COLORREF dibdrv_GetNearestColor( PHYSDEV dev, COLORREF color ) +{ + dibdrv_physdev *pdev = get_dibdrv_pdev( dev ); + DWORD pixel; + + TRACE( "(%p, %08x)\n", dev, color ); + + pixel = get_pixel_color( pdev, color, FALSE ); + return pdev->dib.funcs->pixel_to_colorref( &pdev->dib, pixel ); +} + /*********************************************************************** * dibdrv_GetPixel */ diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index accfc916bcd..6e8e1d4fa11 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -346,6 +346,8 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ok(c == exp, "SetPixel failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \ c = GetPixel(hdc, 0, 0); \ ok(c == exp, "GetPixel failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \ + c = GetNearestColor(hdc, color); \ + ok(c == exp, "GetNearestColor failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \ } static void test_dib_bits_access( HBITMAP hdib, void *bits )