Index: trunk/src/gdi32/blit.cpp
===================================================================
--- trunk/src/gdi32/blit.cpp	(revision 7326)
+++ trunk/src/gdi32/blit.cpp	(revision 7327)
@@ -1,3 +1,3 @@
-/* $Id: blit.cpp,v 1.34 2001-09-10 11:02:40 sandervl Exp $ */
+/* $Id: blit.cpp,v 1.35 2001-11-13 13:18:22 sandervl Exp $ */
 
 /*
@@ -147,4 +147,6 @@
         bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
         break;
+
+    case 24:
     case 32:
         bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
@@ -226,7 +228,12 @@
                                const BITMAPINFO *info, UINT coloruse)
 {
+    static BOOL fMatrox32BppBug = FALSE;
+    INT rc = 0;
+    char *newBits = NULL;
+
+    //If upside down, reverse scanlines and call SetDIBitsToDevice again
     if(info->bmiHeader.biHeight < 0 && info->bmiHeader.biBitCount != 8 && info->bmiHeader.biCompression == 0) {
         // upside down
-        INT rc = 0;
+        INT rc = -1;
         BITMAPINFO newInfo;
         newInfo.bmiHeader = info->bmiHeader;
@@ -244,9 +251,65 @@
                 pbSrc -= lLineByte;
             }
-            rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, DIB_RGB_COLORS );
+            rc = SetDIBitsToDevice( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, coloruse );
             free( newBits );
         }
+        else DebugInt3();
+
         return rc;
     }
+
+    //We must convert 32 bpp bitmap data to 24 bpp on systems with the Matrox 
+    //display driver. (GpiDrawBits for 32 bpp fails with insufficient memory error)
+    if(info->bmiHeader.biBitCount == 32 && fMatrox32BppBug) 
+    {
+        BITMAPINFO newInfo;
+        newInfo.bmiHeader = info->bmiHeader;
+
+        long lLineWidth;
+        long lHeight    = (newInfo.bmiHeader.biHeight > 0) ? newInfo.bmiHeader.biHeight : -newInfo.bmiHeader.biHeight;
+        long lWidth     = newInfo.bmiHeader.biWidth;
+
+        newInfo.bmiHeader.biBitCount  = 24;
+        newInfo.bmiHeader.biSizeImage = CalcBitmapSize(24, newInfo.bmiHeader.biWidth, 
+                                                       newInfo.bmiHeader.biHeight);
+
+        lLineWidth = newInfo.bmiHeader.biSizeImage / lHeight;
+
+        //convert 32 bits bitmap data to 24 bits
+        newBits = (char *)malloc(newInfo.bmiHeader.biSizeImage+16); //extra room needed for copying (too much)
+        if(!newBits) {
+            DebugInt3();
+            return -1;
+        }
+        unsigned char *pbSrc = (unsigned char *)bits;
+        unsigned char *pbDst = (unsigned char *)newBits;
+        //not very efficient
+        for(int i = 0; i < lHeight; i++) {
+            for(int j=0;j<lWidth;j++) {
+                *(DWORD *)pbDst = *(DWORD *)pbSrc;
+                pbSrc += 4;
+                pbDst += 3;
+            }
+            //24 bpp scanline must be aligned at 4 byte boundary
+            pbDst += (lLineWidth - 3*lWidth);
+        }
+        rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, newBits, &newInfo, coloruse );
+        free(newBits);
+        return rc;
+    }
+    rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse );
+
+    if(rc == -1 && info->bmiHeader.biBitCount == 32 && !fMatrox32BppBug) 
+    {
+        //The Matrox driver seems to have some difficulty blitting 32bpp
+        //data. (out of memory error) The same operation works fine with SDD.
+        fMatrox32BppBug = TRUE;
+        return SetDIBitsToDevice(hdc, xDest, yDest, cx,
+                                 cy, xSrc, ySrc,
+                                 startscan, lines, bits,
+                                 info, coloruse);
+    }
+    return rc;
+
 //SvL: Breaks startup bitmap of Acrobat Reader 4.05
 #if 0
@@ -319,7 +382,4 @@
     } 
 #endif
-    else {
-        return SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse );
-    }
 }
 //******************************************************************************
@@ -441,4 +501,5 @@
         bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
         break;
+    case 24:
     case 32:
         bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
@@ -470,5 +531,4 @@
         ((BITMAPINFO *)info)->bmiHeader.biCompression = 0;
         compression = BI_BITFIELDS;
-
     }
 
@@ -629,5 +689,5 @@
 
                 case 32:
-                        return cx*cy;
+                        return cx*cy*4;
 
                 default:
Index: trunk/src/gdi32/dibitmap.cpp
===================================================================
--- trunk/src/gdi32/dibitmap.cpp	(revision 7326)
+++ trunk/src/gdi32/dibitmap.cpp	(revision 7327)
@@ -1,3 +1,3 @@
-/* $Id: dibitmap.cpp,v 1.27 2001-08-28 18:58:57 sandervl Exp $ */
+/* $Id: dibitmap.cpp,v 1.28 2001-11-13 13:18:22 sandervl Exp $ */
 
 /*
@@ -96,6 +96,7 @@
         bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ?  *((DWORD *)lpbmi->bmiColors + 2) : 0x001f;
         break;
+    case 24:
     case 32:
-        bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : 0xff0000;
+        bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors        : 0xff0000;
         bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ?  *((DWORD *)lpbmi->bmiColors + 1) : 0xff00;
         bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ?  *((DWORD *)lpbmi->bmiColors + 2) : 0xff;
@@ -361,7 +362,7 @@
         case 24:
         case 32:
-           ((DWORD*)(lpbi->bmiColors))[0] = 0x0000FF;
+           ((DWORD*)(lpbi->bmiColors))[0] = 0xFF0000;
            ((DWORD*)(lpbi->bmiColors))[1] = 0x00FF00;
-           ((DWORD*)(lpbi->bmiColors))[2] = 0xFF0000;
+           ((DWORD*)(lpbi->bmiColors))[2] = 0x0000FF;
            break;
         }
@@ -448,4 +449,6 @@
         bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)pBitmapInfo->bmiColors + 2) : 0x001f;
         break;
+
+    case 24:
     case 32:
         bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : 0xff0000;
Index: trunk/src/gdi32/dibsect.cpp
===================================================================
--- trunk/src/gdi32/dibsect.cpp	(revision 7326)
+++ trunk/src/gdi32/dibsect.cpp	(revision 7327)
@@ -1,3 +1,3 @@
-/* $Id: dibsect.cpp,v 1.58 2001-10-18 17:01:34 sandervl Exp $ */
+/* $Id: dibsect.cpp,v 1.59 2001-11-13 13:18:22 sandervl Exp $ */
 
 /*
@@ -157,14 +157,9 @@
 
            case 24:
-                dibinfo.dsBitfields[0] = 0xff;
-                dibinfo.dsBitfields[1] = 0xff00;
-                dibinfo.dsBitfields[2] = 0xff0000;
-                break;
-
            case 32:
-                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0xff;
-                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0xff00;
-                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0xff0000;
-                if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
+                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors       : 0xff0000;
+                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x00ff00;
+                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x0000ff;
+                if(dibinfo.dsBitfields[0] != 0xff0000 && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff) {
                     dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
                 }
@@ -336,14 +331,9 @@
 
            case 24:
-                dibinfo.dsBitfields[0] = 0xff;
-                dibinfo.dsBitfields[1] = 0xff00;
-                dibinfo.dsBitfields[2] = 0xff0000;
-                break;
-
            case 32:
-                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0xff;
-                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0xff00;
-                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0xff0000;
-                if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
+                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors       : 0xff0000;
+                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x00ff00;
+                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x0000ff;
+                if(dibinfo.dsBitfields[0] != 0xff0000 && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff) {
                     dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
                 }
