Ignore:
Timestamp:
Mar 24, 2004, 5:55:35 PM (21 years ago)
Author:
sandervl
Message:

CreateDIBitmap: added workaround for DIB_PAL_COLORS mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/dibitmap.cpp

    r10373 r10558  
    1 /* $Id: dibitmap.cpp,v 1.42 2004-01-11 11:42:10 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.43 2004-03-24 16:55:35 sandervl Exp $ */
    22
    33/*
     
    7373    }
    7474
     75    //  For some reason, GPI messes up the colors in DIB_PAL_COLORS mode.
     76    //  Work around it by converting palette indexes to RGB values
     77    //  (SetDIBitsToDevice works under the same circumstances though)
     78    if(fuUsage == DIB_PAL_COLORS && lpbmi->bmiHeader.biSize == sizeof(BITMAPINFOHEADER) &&
     79       lpbmi->bmiHeader.biBitCount <= 8)
     80    {
     81        // workaround for open32 bug.
     82        // If syscolors > 256 and wUsage == DIB_PAL_COLORS.
     83
     84        int i;
     85        UINT biClrUsed;
     86        USHORT *pColorIndex = (USHORT *)lpbmi->bmiColors;
     87        RGBQUAD *pColors;
     88        BITMAPINFO *infoLoc;
     89
     90        biClrUsed = (lpbmi->bmiHeader.biClrUsed) ? lpbmi->bmiHeader.biClrUsed : (1<<lpbmi->bmiHeader.biBitCount);
     91
     92        pColors = (RGBQUAD *) alloca(biClrUsed * sizeof(RGBQUAD));
     93        infoLoc = (BITMAPINFO *) alloca(sizeof(BITMAPINFO) + biClrUsed * sizeof(RGBQUAD));
     94
     95        memcpy(infoLoc, lpbmi, sizeof(BITMAPINFO));
     96
     97        if(GetDIBColorTable(hdc, 0, biClrUsed, pColors) == 0)
     98        {
     99            dprintf(("ERROR: StretchDIBits: GetDIBColorTable failed!!"));
     100            return FALSE;
     101        }
     102        for(i=0;i<biClrUsed;i++, pColorIndex++)
     103        {
     104            infoLoc->bmiColors[i] = pColors[*pColorIndex];
     105        }
     106
     107        rc = CreateDIBitmap(hdc, lpbmih, fdwInit, lpbInit, (PBITMAPINFO)infoLoc,
     108                            DIB_RGB_COLORS);
     109   
     110        return rc;
     111    }
     112
    75113    // 2000/09/01 PH Netscape 4.7
    76114    // If color depth of lpbhmi is 16 bit and lpbmi is 8 bit,
Note: See TracChangeset for help on using the changeset viewer.