gdi/dib.c GetDIBits

Walt Ogburn reuben at ugcs.caltech.edu
Wed Nov 3 23:24:08 CST 2004


This patch avoids calling CreateCompatibleDC or DeleteDC within GetDIBits
because GetDIBits is used by some brush methods that lock GDI.  This
problem causes SelectObject to error out when called on a pattern brush.

I think we can safely take the color info from the existing hdc, instead
of making a new memory hdc for use within GetDIBits; but Huw Davies may
have something to say about this (see his patch at
http://www.winehq.org/hypermail/wine-patches/2004/03/0434.html).

- Walter


Changelog:
Take color info from existing hdc instead of creating a new memory HDC.


Index: dlls/gdi/dib.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/dib.c,v
retrieving revision 1.7
diff -u -r1.7 dib.c
--- dlls/gdi/dib.c      2 Nov 2004 05:23:49 -0000       1.7
+++ dlls/gdi/dib.c      4 Nov 2004 05:08:24 -0000
@@ -516,7 +516,6 @@
     DC * dc;
     BITMAPOBJ * bmp;
     int i;
-    HDC memdc;
     int bitmap_type;
     BOOL core_header;
     LONG width;
@@ -536,16 +535,13 @@
         return 0;
     }
     core_header = (bitmap_type == 0);
-    memdc = CreateCompatibleDC(hdc);
     if (!(dc = DC_GetDCUpdate( hdc )))
     {
-        DeleteDC(memdc);
         return 0;
     }
     if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
     {
         GDI_ReleaseObj( hdc );
-        DeleteDC(memdc);
        return 0;
     }

@@ -563,7 +559,7 @@
           same color depth then get the color map from it */
        if (bmp->dib && bmp->dib->dsBm.bmBitsPixel == bpp) {
             if(coloruse == DIB_RGB_COLORS) {
-                HBITMAP oldbm = SelectObject(memdc, hbitmap);
+                HBITMAP oldbm = SelectObject(hdc, hbitmap);
                 unsigned int colors = 1 << bpp;

                 if (core_header)
@@ -574,7 +570,7 @@
                     if (buffer)
                     {
                         RGBTRIPLE* index = rgbTriples;
-                        GetDIBColorTable(memdc, 0, colors, buffer);
+                        GetDIBColorTable(hdc, 0, colors, buffer);

                         for (i=0; i < colors; i++, index++)
                         {
@@ -588,9 +584,9 @@
                 }
                 else
                 {
-                    GetDIBColorTable(memdc, 0, colors, colorPtr);
+                    GetDIBColorTable(hdc, 0, colors, colorPtr);
                 }
-                SelectObject(memdc, oldbm);
+                SelectObject(hdc, oldbm);
             }
             else {
                 WORD *index = colorPtr;
@@ -606,7 +602,6 @@
                 if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->hPalette,
PALETTE_MAGIC ))) {
                     GDI_ReleaseObj( hdc );
                     GDI_ReleaseObj( hbitmap );
-                    DeleteDC(memdc);
                     return 0;
                 }
                 palEntry = palette->logpalette.palPalEntry;
@@ -962,7 +957,6 @@

     GDI_ReleaseObj( hdc );
     GDI_ReleaseObj( hbitmap );
-    DeleteDC(memdc);
     return lines;
 }



More information about the wine-patches mailing list