[ros-diffs] [fireball] 45599: - Implement usermode part of SetDIBitsToDevice.

fireball at svn.reactos.org fireball at svn.reactos.org
Tue Feb 16 19:43:21 CET 2010


Author: fireball
Date: Tue Feb 16 19:43:21 2010
New Revision: 45599

URL: http://svn.reactos.org/svn/reactos?rev=45599&view=rev
Log:
- Implement usermode part of SetDIBitsToDevice.

Modified:
    branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c
    branches/arwinss/reactos/dll/win32/winent.drv/winent.h

Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c?rev=45599&r1=45598&r2=45599&view=diff
==============================================================================
--- branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] Tue Feb 16 19:43:21 2010
@@ -732,8 +732,59 @@
                                     UINT startscan, UINT lines, LPCVOID bits,
                                     const BITMAPINFO *info, UINT coloruse )
 {
-    UNIMPLEMENTED;
-    return 0;
+    BOOL top_down;
+    LONG height, width;
+    WORD infoBpp, compression;
+    POINT pt;
+
+    pt.x = xDest; pt.y = yDest;
+    LPtoDP(physDev->hUserDC, &pt, 1);
+
+    /* Perform extensive parameter checking */
+    if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height,
+        &infoBpp, &compression ) == -1)
+        return 0;
+
+    top_down = (height < 0);
+    if (top_down) height = -height;
+
+    if (!lines || (startscan >= height)) return 0;
+    if (!top_down && startscan + lines > height) lines = height - startscan;
+
+    /* make xSrc,ySrc point to the upper-left corner, not the lower-left one,
+     * and clamp all values to fit inside [startscan,startscan+lines]
+     */
+    if (ySrc + cy <= startscan + lines)
+    {
+        UINT y = startscan + lines - (ySrc + cy);
+        if (ySrc < startscan) cy -= (startscan - ySrc);
+        if (!top_down)
+        {
+            /* avoid getting unnecessary lines */
+            ySrc = 0;
+            if (y >= lines) return 0;
+            lines -= y;
+        }
+        else
+        {
+            if (y >= lines) return lines;
+            ySrc = y;  /* need to get all lines in top down mode */
+        }
+    }
+    else
+    {
+        if (ySrc >= startscan + lines) return lines;
+        pt.y += ySrc + cy - (startscan + lines);
+        cy = startscan + lines - ySrc;
+        ySrc = 0;
+        if (cy > lines) cy = lines;
+    }
+    if (xSrc >= width) return lines;
+    if (xSrc + cx >= width) cx = width - xSrc;
+    if (!cx || !cy) return lines;
+
+    return RosGdiSetDIBitsToDevice(physDev->hKernelDC, pt.x, pt.y, cx, cy,
+        xSrc, ySrc, startscan, lines, bits, info, coloruse);
 }
 
 void CDECL RosDrv_SetDeviceClipping( NTDRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn )
@@ -850,4 +901,54 @@
     return FALSE;
 }
 
+/***********************************************************************
+ *           DIB_GetBitmapInfoEx
+ *
+ * Get the info from a bitmap header.
+ * Return 1 for INFOHEADER, 0 for COREHEADER, -1 for error.
+ */
+int DIB_GetBitmapInfoEx( const BITMAPINFOHEADER *header, LONG *width,
+                                LONG *height, WORD *planes, WORD *bpp,
+                                WORD *compr, DWORD *size )
+{
+    if (header->biSize == sizeof(BITMAPCOREHEADER))
+    {
+        const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header;
+        *width  = core->bcWidth;
+        *height = core->bcHeight;
+        *planes = core->bcPlanes;
+        *bpp    = core->bcBitCount;
+        *compr  = 0;
+        *size   = 0;
+        return 0;
+    }
+    if (header->biSize >= sizeof(BITMAPINFOHEADER))
+    {
+        *width  = header->biWidth;
+        *height = header->biHeight;
+        *planes = header->biPlanes;
+        *bpp    = header->biBitCount;
+        *compr  = header->biCompression;
+        *size   = header->biSizeImage;
+        return 1;
+    }
+    ERR("(%d): unknown/wrong size for header\n", header->biSize );
+    return -1;
+}
+
+/***********************************************************************
+ *           DIB_GetBitmapInfo
+ *
+ * Get the info from a bitmap header.
+ * Return 1 for INFOHEADER, 0 for COREHEADER, -1 for error.
+ */
+int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
+                              LONG *height, WORD *bpp, WORD *compr )
+{
+    WORD planes;
+    DWORD size;
+
+    return DIB_GetBitmapInfoEx( header, width, height, &planes, bpp, compr, &size);    
+}
+
 /* EOF */

Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.h
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent.drv/winent.h?rev=45599&r1=45598&r2=45599&view=diff
==============================================================================
--- branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] Tue Feb 16 19:43:21 2010
@@ -37,6 +37,15 @@
     RECT        client_rect;    /* client area relative to parent */
 };
 
+/* gdidrv.c */
+int DIB_GetBitmapInfoEx( const BITMAPINFOHEADER *header, LONG *width,
+                                LONG *height, WORD *planes, WORD *bpp,
+                                WORD *compr, DWORD *size );
+
+int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
+                              LONG *height, WORD *bpp, WORD *compr );
+
+
 /* font.c */
 VOID
 FeSelectFont(NTDRV_PDEVICE *physDev, HFONT hFont);




More information about the Ros-diffs mailing list