Index: trunk/src/gdi32/blit.cpp
===================================================================
--- trunk/src/gdi32/blit.cpp	(revision 5899)
+++ trunk/src/gdi32/blit.cpp	(revision 5901)
@@ -1,3 +1,3 @@
-/* $Id: blit.cpp,v 1.30 2001-06-02 07:24:38 sandervl Exp $ */
+/* $Id: blit.cpp,v 1.31 2001-06-03 14:52:46 sandervl Exp $ */
 
 /*
@@ -23,5 +23,5 @@
 
 static ULONG QueryPaletteSize(BITMAPINFOHEADER *pBHdr);
-static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy);
+ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy);
 
 //******************************************************************************
@@ -452,5 +452,4 @@
         break;
     }
-
     if(bitfields[1] == 0x3E0) 
     {//RGB 555?
@@ -582,5 +581,5 @@
 //******************************************************************************
 //******************************************************************************
-static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)
+ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)
 {
         ULONG alignment;
Index: trunk/src/gdi32/dibitmap.cpp
===================================================================
--- trunk/src/gdi32/dibitmap.cpp	(revision 5899)
+++ trunk/src/gdi32/dibitmap.cpp	(revision 5901)
@@ -1,3 +1,3 @@
-/* $Id: dibitmap.cpp,v 1.19 2001-06-01 12:29:25 sandervl Exp $ */
+/* $Id: dibitmap.cpp,v 1.20 2001-06-03 14:52:47 sandervl Exp $ */
 
 /*
@@ -15,9 +15,13 @@
 #include <string.h>
 #include <misc.h>
+#include <cpuhlp.h>
 #include <winuser32.h>
 #include "dibsect.h"
+#include "rgbcvt.h"
 
 #define DBG_LOCALLOG    DBG_dibitmap
 #include "dbglocal.h"
+
+ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy);
 
 //******************************************************************************
@@ -296,9 +300,9 @@
 #endif
 
-    // set proper color masks!
+    // set proper color masks
     switch(lpbi->bmiHeader.biBitCount) {
     case 16: //RGB 565
        ((DWORD*)(lpbi->bmiColors))[0] = 0xF800;
-       ((DWORD*)(lpbi->bmiColors))[1] = 0x07E0;
+       ((DWORD*)(lpbi->bmiColors))[1] = 0x03E0;
        ((DWORD*)(lpbi->bmiColors))[2] = 0x001F;
        break;
@@ -310,4 +314,17 @@
        break;
     }
+    if(lpvBits && lpbi->bmiHeader.biBitCount == 16 && ((DWORD*)(lpbi->bmiColors))[1] == 0x3E0) 
+    {//RGB 555?
+        dprintf(("RGB 565->555 conversion required"));
+
+        int imgsize = CalcBitmapSize(lpbi->bmiHeader.biBitCount,
+                                     lpbi->bmiHeader.biWidth, lpbi->bmiHeader.biHeight);
+
+        if(CPUFeatures & CPUID_MMX) {
+             RGB565to555MMX((WORD *)lpvBits, (WORD *)lpvBits, imgsize/sizeof(WORD));
+        }
+        else RGB565to555((WORD *)lpvBits, (WORD *)lpvBits, imgsize/sizeof(WORD));
+    }
+
     //WGSS/Open32 returns 0 when querying the bitmap info; must return nr of scanlines
     //as 0 signals failure
Index: trunk/src/gdi32/dibsect.cpp
===================================================================
--- trunk/src/gdi32/dibsect.cpp	(revision 5899)
+++ trunk/src/gdi32/dibsect.cpp	(revision 5901)
@@ -1,3 +1,3 @@
-/* $Id: dibsect.cpp,v 1.52 2001-05-29 09:45:21 sandervl Exp $ */
+/* $Id: dibsect.cpp,v 1.53 2001-06-03 14:52:47 sandervl Exp $ */
 
 /*
@@ -746,5 +746,4 @@
   memcpy(pOS2bmp, tmphdr, os2bmphdrsize);
 
-#if 0
   if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
     dprintf(("DIBSection::sync: convert RGB 565 to RGB 555"));
@@ -757,5 +756,5 @@
     else    RGB565to555((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
   }
-#endif
+
   free(tmphdr);
   if(rc != nDestHeight) {
Index: trunk/src/gdi32/palette.cpp
===================================================================
--- trunk/src/gdi32/palette.cpp	(revision 5899)
+++ trunk/src/gdi32/palette.cpp	(revision 5901)
@@ -1,3 +1,3 @@
-/* $Id: palette.cpp,v 1.9 2001-05-29 09:45:21 sandervl Exp $ */
+/* $Id: palette.cpp,v 1.10 2001-06-03 14:52:47 sandervl Exp $ */
 
 /*
@@ -58,4 +58,12 @@
     rc = O32_RealizePalette(hdc);
     dprintf(("GDI32: RealizePalette %x returned %d", hdc, rc));
+    if(rc && DIBSection::getSection() != NULL)
+    {
+        DIBSection *dsect = DIBSection::findHDC(hdc);
+        if(dsect)
+        {
+            dsect->sync(hdc, 0, dsect->GetHeight());
+        }
+    }
     return rc;
 }
@@ -85,15 +93,4 @@
   dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)", hdc, hPalette, bForceBackground));
   hPal = O32_SelectPalette(hdc, hPalette, bForceBackground);
-
-  //hack for beyond compare buttons (+ other apps)
-  //seems to select old palette into dc before unselecting dib section
-  if(bForceBackground != -1 && DIBSection::getSection() != NULL)
-  {
-    DIBSection *dsect = DIBSection::findHDC(hdc);
-    if(dsect)
-    {
-        dsect->sync(hdc, 0, dsect->GetHeight());
-    }
-  }
   return hPal;
 }
