Module: wine Branch: master Commit: 49ae7360228348bbe6f188daa1a2b388ea327258 URL: http://source.winehq.org/git/wine.git/?a=commit;h=49ae7360228348bbe6f188daa1...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Dec 12 20:20:06 2011 +0100
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 deletions(-)
diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index 66c9234..571a070 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 cd96e3e..6c63c3d 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 439a10f..67f1c99 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -392,6 +392,20 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, }
/*********************************************************************** + * 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 */ COLORREF dibdrv_GetPixel( PHYSDEV dev, INT x, INT y ) diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index accfc91..6e8e1d4 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 )