Fixes for DIBs to show with correct vertical orientation
authorJason Filby <jason.filby@gmail.com>
Tue, 17 Sep 2002 23:20:44 +0000 (23:20 +0000)
committerJason Filby <jason.filby@gmail.com>
Tue, 17 Sep 2002 23:20:44 +0000 (23:20 +0000)
svn path=/trunk/; revision=3514

reactos/subsys/win32k/dib/dib.h
reactos/subsys/win32k/dib/dib1bpp.c
reactos/subsys/win32k/dib/dib24bpp.c
reactos/subsys/win32k/dib/dib4bpp.c
reactos/subsys/win32k/eng/copybits.c
reactos/subsys/win32k/objects/dib.c

index cdc0323..4d00fed 100644 (file)
@@ -14,7 +14,7 @@ PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
 BOOLEAN DIB_To_1BPP_Bitblt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
         PRECTL  DestRect,  POINTL  *SourcePoint,
-                            ULONG   Delta,     XLATEOBJ *ColorTranslation);
+                            LONG   Delta,     XLATEOBJ *ColorTranslation);
 
 PFN_DIB_PutPixel DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
 PFN_DIB_GetPixel DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
@@ -23,7 +23,7 @@ PFN_DIB_VLine DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
 BOOLEAN DIB_To_4BPP_Bitblt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
         PRECTL  DestRect,  POINTL  *SourcePoint,
-                            ULONG   Delta,     XLATEOBJ *ColorTranslation);
+                            LONG   Delta,     XLATEOBJ *ColorTranslation);
 
 PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
 PFN_DIB_GetPixel DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
@@ -32,4 +32,4 @@ PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG
 BOOLEAN DIB_To_24BPP_Bitblt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
         PRECTL  DestRect,  POINTL  *SourcePoint,
-                             ULONG   Delta,     XLATEOBJ *ColorTranslation);
+                            LONG   Delta,     XLATEOBJ *ColorTranslation);
index eafc4e5..e2d36ef 100644 (file)
@@ -53,9 +53,9 @@ PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
 BOOLEAN DIB_To_1BPP_Bitblt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
         PRECTL  DestRect,  POINTL  *SourcePoint,
-        ULONG   Delta,     XLATEOBJ *ColorTranslation)
+        LONG    Delta,     XLATEOBJ *ColorTranslation)
 {
-  ULONG    i, j, sx, sy = SourcePoint->y;
+  LONG    i, j, sx, sy = SourcePoint->y;
 
   switch(SourceGDI->BitsPerPixel)
   {
index f5bab13..1e27752 100644 (file)
@@ -41,7 +41,7 @@ PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG
 {
   PBYTE byteaddr = SurfObj->pvBits + y1 * SurfObj->lDelta;
   PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
-  ULONG  lDelta = SurfObj->lDelta;
+  LONG lDelta = SurfObj->lDelta;
 
   byteaddr = (PBYTE)addr;
   while(y1++ <= y2) {
@@ -86,9 +86,9 @@ VOID DIB_24BPP_BltTo_24BPP(PSURFOBJ dstpsd, LONG dstx, LONG dsty, LONG w, LONG h
 BOOLEAN DIB_To_24BPP_Bitblt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
         PRECTL  DestRect,  POINTL  *SourcePoint,
-        ULONG   Delta,     XLATEOBJ *ColorTranslation)
+        LONG    Delta,     XLATEOBJ *ColorTranslation)
 {
-  ULONG    i, j, sx, sy, xColor, f1;
+  LONG     i, j, sx, sy, xColor, f1;
   PBYTE    DestBits, SourceBits_24BPP, DestLine, SourceLine_24BPP;
   PRGBTRIPLE  SPDestBits, SPSourceBits_24BPP, SPDestLine, SPSourceLine_24BPP; // specially for 24-to-24 blit
   PBYTE    SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;
index dc38a2f..e9a7d94 100644 (file)
@@ -53,9 +53,9 @@ PFN_DIB_VLine DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
 BOOLEAN DIB_To_4BPP_Bitblt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
         PRECTL  DestRect,  POINTL  *SourcePoint,
-        ULONG   Delta,     XLATEOBJ *ColorTranslation)
+        LONG   Delta,      XLATEOBJ *ColorTranslation)
 {
-  ULONG    i, j, sx, sy, f1, f2, xColor;
+  LONG     i, j, sx, sy, f1, f2, xColor;
   PBYTE    SourceBits_24BPP, SourceLine_24BPP;
   PBYTE    DestBits, DestLine, SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;
   PWORD    SourceBits_16BPP, SourceLine_16BPP;
index 95359f2..bacaeb9 100644 (file)
@@ -19,9 +19,9 @@
 BOOLEAN CopyBitsCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
                      SURFGDI *DestGDI,  SURFGDI *SourceGDI,
                      PRECTL  DestRect,  POINTL  *SourcePoint,
-                     ULONG   Delta,     XLATEOBJ *ColorTranslation)
+                     LONG    Delta,     XLATEOBJ *ColorTranslation)
 {
-  ULONG DestWidth, DestHeight, CurrentDestLine, CurrentSourceLine, CurrentDestCol, CurrentSourceCol, i, TranslationPixel;
+  LONG DestWidth, DestHeight, CurrentDestLine, CurrentSourceLine, CurrentDestCol, CurrentSourceCol, i, TranslationPixel;
 
   PFN_DIB_GetPixel Source_DIB_GetPixel;
   PFN_DIB_PutPixel Dest_DIB_PutPixel;
index 494db31..8c9070d 100644 (file)
@@ -65,7 +65,7 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
   DC *dc;
   BITMAPOBJ *bitmap;
   HBITMAP SourceBitmap, DestBitmap;
-  INT result;
+  INT result = 0;
   BOOL copyBitsResult;
   PSURFOBJ DestSurf, SourceSurf;
   PSURFGDI DestGDI;
@@ -77,7 +77,8 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
   RGBQUAD *lpRGB;
   HPALETTE DDB_Palette, DIB_Palette;
   ULONG DDB_Palette_Type, DIB_Palette_Type;
-
+  PBYTE vBits = Bits;
+  INT scanDirection = 1, DIBWidth;
 
   // Check parameters
   if (!(dc = DC_HandleToPtr(hDC)))
@@ -105,10 +106,23 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
 
   // Create source surface
   SourceSize.cx = bmi->bmiHeader.biWidth;
-  SourceSize.cy = bmi->bmiHeader.biHeight;
-  SourceBitmap = EngCreateBitmap(SourceSize, DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount),
+  SourceSize.cy = abs(bmi->bmiHeader.biHeight);
+
+  // Determine width of DIB
+  DIBWidth = DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount);
+
+  // Determine DIB Vertical Orientation
+  if(bmi->bmiHeader.biHeight > 0)
+  {
+    scanDirection = -1;
+    vBits += DIBWidth * bmi->bmiHeader.biHeight - DIBWidth;
+  }
+
+  SourceBitmap = EngCreateBitmap(SourceSize,
+                                 DIBWidth * scanDirection,
                                  BitmapFormat(bmi->bmiHeader.biBitCount, bmi->bmiHeader.biCompression),
-                                 0, Bits);
+                                 0,
+                                 vBits);
   SourceSurf = (PSURFOBJ)AccessUserObject(SourceBitmap);
 
   // Destination palette obtained from the hDC
@@ -122,9 +136,11 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
   // Determine XLATEOBJ for color translation
   XlateObj = EngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette);
 
-  // Determine destination rectangle and source point
+  // Zero point
   ZeroPoint.x = 0;
   ZeroPoint.y = 0;
+
+  // Determine destination rectangle
   DestRect.top = 0;
   DestRect.left        = 0;
   DestRect.right       = SourceSize.cx;
@@ -132,6 +148,12 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
 
   copyBitsResult = EngCopyBits(DestSurf, SourceSurf, NULL, XlateObj, &DestRect, &ZeroPoint);
 
+  // If it succeeded, return number of scanlines copies
+  if(copyBitsResult == TRUE)
+  {
+    result = SourceSize.cy - 1;
+  }
+
   // Clean up
   EngDeleteSurface(SourceBitmap);
   EngDeleteSurface(DestBitmap);