[ros-diffs] [jgardou] 50950: [GDI32_APITESTS] - Test behaviour of SetDIBits for 1bpp bitmaps. - Add small test to GetPixel just to verify that SetDIBits doesn't say BS.

jgardou at svn.reactos.org jgardou at svn.reactos.org
Wed Mar 2 01:15:10 UTC 2011


Author: jgardou
Date: Wed Mar  2 01:15:10 2011
New Revision: 50950

URL: http://svn.reactos.org/svn/reactos?rev=50950&view=rev
Log:
[GDI32_APITESTS]
  - Test behaviour of SetDIBits for 1bpp bitmaps.
  - Add small test to GetPixel just to verify that SetDIBits doesn't say BS.

Added:
    trunk/rostests/apitests/gdi32/GetPixel.c   (with props)
Modified:
    trunk/rostests/apitests/gdi32/CMakeLists.txt
    trunk/rostests/apitests/gdi32/SetDIBits.c
    trunk/rostests/apitests/gdi32/gdi32_apitest.rbuild
    trunk/rostests/apitests/gdi32/testlist.c

Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CMakeLists.txt?rev=50950&r1=50949&r2=50950&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] Wed Mar  2 01:15:10 2011
@@ -34,6 +34,7 @@
     GetCurrentObject.c
     GetDIBits.c
     GetObject.c
+    GetPixel.c
     GetStockObject.c
     GetTextExtentExPoint.c
     GetTextFace.c

Added: trunk/rostests/apitests/gdi32/GetPixel.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/GetPixel.c?rev=50950&view=auto
==============================================================================
--- trunk/rostests/apitests/gdi32/GetPixel.c (added)
+++ trunk/rostests/apitests/gdi32/GetPixel.c [iso-8859-1] Wed Mar  2 01:15:10 2011
@@ -1,0 +1,39 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for SetDIBits
+ * PROGRAMMERS:     Jérôme Gardou
+ */
+
+#include <stdio.h>
+#include <wine/test.h>
+#include <windows.h>
+
+
+void Test_GetPixel_1bpp()
+{
+    HDC hdc;
+    HBITMAP hbmp;
+    char buffer[] = {0x80, 0x0};
+    COLORREF color;
+
+    hbmp = CreateBitmap(2,1,1,1,buffer);
+    ok(hbmp != NULL, "Failed to create a monochrom bitmap...\n");
+    hdc = CreateCompatibleDC(0);
+    hbmp = SelectObject(hdc, hbmp);
+    ok(hbmp != NULL, "Could not select the bitmap into the DC.\n");
+
+    color = GetPixel(hdc, 0, 0);
+    ok(color == 0xFFFFFF, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
+    color = GetPixel(hdc, 1, 0);
+    ok(color == 0, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
+
+    hbmp = SelectObject(hdc, hbmp);
+    DeleteObject(hbmp);
+    DeleteDC(hdc);
+}
+
+START_TEST(GetPixel)
+{
+    Test_GetPixel_1bpp();
+}

Propchange: trunk/rostests/apitests/gdi32/GetPixel.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/rostests/apitests/gdi32/SetDIBits.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/SetDIBits.c?rev=50950&r1=50949&r2=50950&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/SetDIBits.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/SetDIBits.c [iso-8859-1] Wed Mar  2 01:15:10 2011
@@ -50,7 +50,94 @@
     DeleteObject(hbmp);
 }
 
+void Test_SetDIBits_1bpp()
+{
+    char buffer[sizeof(BITMAPINFOHEADER)+2*sizeof(RGBQUAD)];
+    HDC hdc;
+    BITMAPINFO* pBMI = (BITMAPINFO*)buffer;
+    char bits1bpp[] = {0x80, 0, 0, 0};
+    HBITMAP hbmp;
+    int ret;
+    COLORREF color;
+
+    hdc = CreateCompatibleDC(0);
+    if(!hdc)
+    {
+        trace("No device contexr !?\n");
+        return;
+    }
+
+    ZeroMemory(buffer, sizeof(buffer));
+
+    pBMI->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
+    pBMI->bmiHeader.biWidth=2;
+    pBMI->bmiHeader.biHeight=1;
+    pBMI->bmiHeader.biPlanes=1;
+    pBMI->bmiHeader.biBitCount=1;
+    pBMI->bmiHeader.biCompression=BI_RGB;
+    pBMI->bmiHeader.biSizeImage=0;
+    pBMI->bmiHeader.biXPelsPerMeter=0;
+    pBMI->bmiHeader.biYPelsPerMeter=0;
+    pBMI->bmiHeader.biClrUsed=2;
+    pBMI->bmiHeader.biClrImportant=0;
+    pBMI->bmiColors[0].rgbBlue = 0xFF;
+    pBMI->bmiColors[0].rgbGreen = 0xFF;
+    pBMI->bmiColors[0].rgbRed = 0xFF;
+
+    hbmp = CreateBitmap(2, 1, 1, 1, NULL);
+    ok(hbmp!=NULL, "Failed to create a monochrome bitmap\n");
+
+    ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
+    ok(ret == 1, "Copied %i scanlines\n", ret);
+
+    hbmp = SelectObject(hdc, hbmp);
+    ok(hbmp != NULL, "Could not select the bitmap into the context.\n");
+    color = GetPixel(hdc, 0,0);
+    ok(color == 0, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
+    color = GetPixel(hdc, 1,0);
+    ok(color == 0xFFFFFF, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
+
+    hbmp = SelectObject(hdc, hbmp);
+
+    /* Try something else than 0xFFFFFF */
+    pBMI->bmiColors[0].rgbBlue = 0xFF;
+    pBMI->bmiColors[0].rgbGreen = 0;
+    pBMI->bmiColors[0].rgbRed = 0;
+
+    ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
+    ok(ret == 1, "Copied %i scanlines\n", ret);
+
+    hbmp = SelectObject(hdc, hbmp);
+    ok(hbmp != NULL, "Could not select the bitmap into the context.\n");
+    color = GetPixel(hdc, 0,0);
+    ok(color == 0, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
+    color = GetPixel(hdc, 1,0);
+    ok(color == 0xFFFFFF, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
+
+    hbmp = SelectObject(hdc, hbmp);
+
+    /* Special : try 0 */
+    pBMI->bmiColors[0].rgbBlue = 0;
+    pBMI->bmiColors[0].rgbGreen = 0;
+    pBMI->bmiColors[0].rgbRed = 0;
+
+    ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
+    ok(ret == 1, "Copied %i scanlines\n", ret);
+
+    hbmp = SelectObject(hdc, hbmp);
+    ok(hbmp != NULL, "Could not select the bitmap into the context.\n");
+    color = GetPixel(hdc, 0,0);
+    ok(color == 0, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
+    color = GetPixel(hdc, 1,0);
+    ok(color == 0xFFFFFF, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
+
+    hbmp = SelectObject(hdc, hbmp);
+    DeleteObject(hbmp);
+    DeleteDC(hdc);
+}
+
 START_TEST(SetDIBits)
 {
     Test_SetDIBits();
+    Test_SetDIBits_1bpp();
 }

Modified: trunk/rostests/apitests/gdi32/gdi32_apitest.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/gdi32_apitest.rbuild?rev=50950&r1=50949&r2=50950&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/gdi32_apitest.rbuild [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/gdi32_apitest.rbuild [iso-8859-1] Wed Mar  2 01:15:10 2011
@@ -41,6 +41,7 @@
 	<file>GetCurrentObject.c</file>
 	<file>GetDIBits.c</file>
 	<file>GetObject.c</file>
+	<file>GetPixel.c</file>
 	<file>GetStockObject.c</file>
 	<file>GetTextExtentExPoint.c</file>
 	<file>GetTextFace.c</file>

Modified: trunk/rostests/apitests/gdi32/testlist.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/testlist.c?rev=50950&r1=50949&r2=50950&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] Wed Mar  2 01:15:10 2011
@@ -36,6 +36,7 @@
 extern void func_GetClipRgn(void);
 extern void func_GetCurrentObject(void);
 extern void func_GetDIBits(void);
+extern void func_GetPixel(void);
 extern void func_GetObject(void);
 extern void func_GetStockObject(void);
 extern void func_GetTextExtentExPoint(void);
@@ -82,6 +83,7 @@
     { "GetClipRgn", func_GetClipRgn },
     { "GetCurrentObject", func_GetCurrentObject },
     { "GetDIBits", func_GetDIBits },
+    { "GetPixel", func_GetPixel },
     { "GetObject", func_GetObject },
     { "GetStockObject", func_GetStockObject },
     { "GetTextExtentExPoint", func_GetTextExtentExPoint },




More information about the Ros-diffs mailing list