Huw Davies : gdi32: Don't use a dib-section' s bitfields unless its depth matches the requested depth.

Alexandre Julliard julliard at winehq.org
Tue Jul 12 13:47:11 CDT 2011


Module: wine
Branch: master
Commit: 74707e956e9c9a3060bbc31447d053820d385a36
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=74707e956e9c9a3060bbc31447d053820d385a36

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Jul 12 16:10:49 2011 +0100

gdi32: Don't use a dib-section's bitfields unless its depth matches the requested depth.

---

 dlls/gdi32/dib.c |   32 ++++++++++----------------------
 1 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 3268086..5103919 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -439,6 +439,10 @@ static const RGBQUAD DefLogPaletteQuads[20] = { /* Copy of Default Logical Palet
     { 0xff, 0xff, 0xff, 0x00 }
 };
 
+static const DWORD bit_fields_888[3] = {0xff0000, 0x00ff00, 0x0000ff};
+static const DWORD bit_fields_565[3] = {0xf800, 0x07e0, 0x001f};
+static const DWORD bit_fields_555[3] = {0x7c00, 0x03e0, 0x001f};
+
 /******************************************************************************
  * GetDIBits [GDI32.@]
  *
@@ -646,11 +650,7 @@ INT WINAPI GetDIBits(
 
     case 15:
         if (info->bmiHeader.biCompression == BI_BITFIELDS)
-        {
-            ((PDWORD)info->bmiColors)[0] = 0x7c00;
-            ((PDWORD)info->bmiColors)[1] = 0x03e0;
-            ((PDWORD)info->bmiColors)[2] = 0x001f;
-        }
+            memcpy( info->bmiColors, bit_fields_555, sizeof(bit_fields_555) );
         break;
 
     case 16:
@@ -658,21 +658,13 @@ INT WINAPI GetDIBits(
         {
             if (bmp->dib)
             {
-                if (bmp->dib->dsBmih.biCompression == BI_BITFIELDS)
+                if (bmp->dib->dsBmih.biCompression == BI_BITFIELDS && bmp->dib->dsBmih.biBitCount == bpp)
                     memcpy( info->bmiColors, bmp->dib->dsBitfields, 3 * sizeof(DWORD) );
                 else
-                {
-                    ((PDWORD)info->bmiColors)[0] = 0x7c00;
-                    ((PDWORD)info->bmiColors)[1] = 0x03e0;
-                    ((PDWORD)info->bmiColors)[2] = 0x001f;
-                }
+                    memcpy( info->bmiColors, bit_fields_555, sizeof(bit_fields_555) );
             }
             else
-            {
-                ((PDWORD)info->bmiColors)[0] = 0xf800;
-                ((PDWORD)info->bmiColors)[1] = 0x07e0;
-                ((PDWORD)info->bmiColors)[2] = 0x001f;
-            }
+                memcpy( info->bmiColors, bit_fields_565, sizeof(bit_fields_565) );
         }
         break;
 
@@ -680,14 +672,10 @@ INT WINAPI GetDIBits(
     case 32:
         if (info->bmiHeader.biCompression == BI_BITFIELDS)
         {
-            if (bmp->dib && bmp->dib->dsBmih.biCompression == BI_BITFIELDS)
+            if (bmp->dib && bmp->dib->dsBmih.biCompression == BI_BITFIELDS && bmp->dib->dsBmih.biBitCount == bpp)
                 memcpy( info->bmiColors, bmp->dib->dsBitfields, 3 * sizeof(DWORD) );
             else
-            {
-                ((PDWORD)info->bmiColors)[0] = 0xff0000;
-                ((PDWORD)info->bmiColors)[1] = 0x00ff00;
-                ((PDWORD)info->bmiColors)[2] = 0x0000ff;
-            }
+                memcpy( info->bmiColors, bit_fields_888, sizeof(bit_fields_888) );
         }
         break;
     }




More information about the wine-cvs mailing list