Huw Davies : gdi32: Implement GetPixel.

Alexandre Julliard julliard at winehq.org
Wed Oct 19 14:05:26 CDT 2011


Module: wine
Branch: master
Commit: f6c7e96a61bf6755f005bb7d1883154ffacc65c3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f6c7e96a61bf6755f005bb7d1883154ffacc65c3

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Oct 19 12:41:58 2011 +0100

gdi32: Implement GetPixel.

---

 dlls/gdi32/dibdrv/dc.c       |    2 +-
 dlls/gdi32/dibdrv/dibdrv.h   |    1 +
 dlls/gdi32/dibdrv/graphics.c |   23 +++++++++++++++++++
 dlls/gdi32/tests/bitmap.c    |   50 +++++++++++++++++++++---------------------
 dlls/gdi32/tests/palette.c   |    1 -
 5 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c
index 877c132..335baae 100644
--- a/dlls/gdi32/dibdrv/dc.c
+++ b/dlls/gdi32/dibdrv/dc.c
@@ -554,7 +554,7 @@ const struct gdi_dc_funcs dib_driver =
     NULL,                               /* pGetICMProfile */
     dibdrv_GetImage,                    /* pGetImage */
     NULL,                               /* pGetNearestColor */
-    NULL,                               /* pGetPixel */
+    dibdrv_GetPixel,                    /* pGetPixel */
     NULL,                               /* pGetPixelFormat */
     NULL,                               /* pGetSystemPaletteEntries */
     NULL,                               /* pGetTextExtentExPoint */
diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index e5f4645..74a786d 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -106,6 +106,7 @@ extern DWORD    dibdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const struct g
                                    struct bitblt_coords *src, struct bitblt_coords *dst, BLENDFUNCTION func ) 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_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;
 extern BOOL     dibdrv_PaintRgn( PHYSDEV dev, HRGN hrgn ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index b68b17e..65f5b9a 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -57,6 +57,29 @@ static RECT get_device_rect( HDC hdc, int left, int top, int right, int bottom,
 }
 
 /***********************************************************************
+ *           dibdrv_GetPixel
+ */
+COLORREF dibdrv_GetPixel( PHYSDEV dev, INT x, INT y )
+{
+    dibdrv_physdev *pdev = get_dibdrv_pdev( dev );
+    POINT pt;
+    DWORD pixel;
+
+    TRACE( "(%p, %d, %d)\n", dev, x, y );
+
+    pt.x = x;
+    pt.y = y;
+    LPtoDP( dev->hdc, &pt, 1 );
+
+    if (pt.x < 0 || pt.x >= pdev->dib.width ||
+        pt.y < 0 || pt.y >= pdev->dib.height)
+        return CLR_INVALID;
+
+    pixel = pdev->dib.funcs->get_pixel( &pdev->dib, &pt );
+    return pdev->dib.funcs->pixel_to_colorref( &pdev->dib, pixel );
+}
+
+/***********************************************************************
  *           dibdrv_LineTo
  */
 BOOL dibdrv_LineTo( PHYSDEV dev, INT x, INT y )
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index bf18b9b..f5fd5fd 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -580,19 +580,19 @@ static void test_dibsections(void)
     c0 = RGB(pbmi->bmiColors[0].rgbRed, pbmi->bmiColors[0].rgbGreen, pbmi->bmiColors[0].rgbBlue);
     c1 = RGB(pbmi->bmiColors[1].rgbRed, pbmi->bmiColors[1].rgbGreen, pbmi->bmiColors[1].rgbBlue);
 
-    test_color(hdcmem, DIBINDEX(0), c0, 0, 1);
-    test_color(hdcmem, DIBINDEX(1), c1, 0, 1);
-    test_color(hdcmem, DIBINDEX(2), c0, 0, 1);
-    test_color(hdcmem, PALETTEINDEX(0), c0, 0, 1);
-    test_color(hdcmem, PALETTEINDEX(1), c0, 0, 1);
-    test_color(hdcmem, PALETTEINDEX(2), c0, 0, 1);
+    test_color(hdcmem, DIBINDEX(0), c0, 0, 0);
+    test_color(hdcmem, DIBINDEX(1), c1, 0, 0);
+    test_color(hdcmem, DIBINDEX(2), c0, 0, 0);
+    test_color(hdcmem, PALETTEINDEX(0), c0, 0, 0);
+    test_color(hdcmem, PALETTEINDEX(1), c0, 0, 0);
+    test_color(hdcmem, PALETTEINDEX(2), c0, 0, 0);
     test_color(hdcmem, PALETTERGB(pbmi->bmiColors[0].rgbRed, pbmi->bmiColors[0].rgbGreen,
-        pbmi->bmiColors[0].rgbBlue), c0, 0, 1);
+        pbmi->bmiColors[0].rgbBlue), c0, 0, 0);
     test_color(hdcmem, PALETTERGB(pbmi->bmiColors[1].rgbRed, pbmi->bmiColors[1].rgbGreen,
-        pbmi->bmiColors[1].rgbBlue), c1, 0, 1);
-    test_color(hdcmem, PALETTERGB(0, 0, 0), c0, 0, 1);
-    test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 0, 1);
-    test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1, 0, 1);
+        pbmi->bmiColors[1].rgbBlue), c1, 0, 0);
+    test_color(hdcmem, PALETTERGB(0, 0, 0), c0, 0, 0);
+    test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 0, 0);
+    test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1, 0, 0);
 
     SelectObject(hdcmem, oldbm);
     DeleteObject(hdib);
@@ -704,22 +704,22 @@ static void test_dibsections(void)
     c0 = RGB(plogpal->palPalEntry[0].peRed, plogpal->palPalEntry[0].peGreen, plogpal->palPalEntry[0].peBlue);
     c1 = RGB(plogpal->palPalEntry[1].peRed, plogpal->palPalEntry[1].peGreen, plogpal->palPalEntry[1].peBlue);
 
-    test_color(hdcmem, DIBINDEX(0), c0, 0, 1);
-    test_color(hdcmem, DIBINDEX(1), c1, 0, 1);
-    test_color(hdcmem, DIBINDEX(2), c0, 0, 1);
-    test_color(hdcmem, PALETTEINDEX(0), c0, 0, 1);
-    test_color(hdcmem, PALETTEINDEX(1), c1, 0, 1);
-    test_color(hdcmem, PALETTEINDEX(2), c0, 0, 1);
+    test_color(hdcmem, DIBINDEX(0), c0, 0, 0);
+    test_color(hdcmem, DIBINDEX(1), c1, 0, 0);
+    test_color(hdcmem, DIBINDEX(2), c0, 0, 0);
+    test_color(hdcmem, PALETTEINDEX(0), c0, 0, 0);
+    test_color(hdcmem, PALETTEINDEX(1), c1, 0, 0);
+    test_color(hdcmem, PALETTEINDEX(2), c0, 0, 0);
     test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[0].peRed, plogpal->palPalEntry[0].peGreen,
-        plogpal->palPalEntry[0].peBlue), c0, 0, 1);
+        plogpal->palPalEntry[0].peBlue), c0, 0, 0);
     test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[1].peRed, plogpal->palPalEntry[1].peGreen,
-        plogpal->palPalEntry[1].peBlue), c1, 0, 1);
-    test_color(hdcmem, PALETTERGB(0, 0, 0), c1, 0, 1);
-    test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 0, 1);
-    test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0, 0, 1);
-    test_color(hdcmem, PALETTERGB(0, 1, 0), c1, 0, 1);
-    test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1, 0, 1);
-    test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0, 0, 1);
+        plogpal->palPalEntry[1].peBlue), c1, 0, 0);
+    test_color(hdcmem, PALETTERGB(0, 0, 0), c1, 0, 0);
+    test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 0, 0);
+    test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0, 0, 0);
+    test_color(hdcmem, PALETTERGB(0, 1, 0), c1, 0, 0);
+    test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1, 0, 0);
+    test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0, 0, 0);
 
     /* Bottom and 2nd row from top green, everything else magenta */
     bits[0] = bits[1] = 0xff;
diff --git a/dlls/gdi32/tests/palette.c b/dlls/gdi32/tests/palette.c
index 0a5822a..039be59 100644
--- a/dlls/gdi32/tests/palette.c
+++ b/dlls/gdi32/tests/palette.c
@@ -109,7 +109,6 @@ static void test_DIB_PAL_COLORS(void) {
     SetPixel( memhdc, 0, 0, setColor );
     chkColor = RGB( logpalettedata[3].peRed, logpalettedata[3].peGreen, logpalettedata[3].peBlue );
     getColor = GetPixel( memhdc, 0, 0 );
-todo_wine /* this will be removed with the GetPixel patch */
     ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
 
     SelectPalette( memhdc, hpalOld, FALSE );




More information about the wine-cvs mailing list