Ignore:
Timestamp:
May 22, 2000, 9:11:28 PM (25 years ago)
Author:
sandervl
Message:

StretchDIBits bugfix (dib sections)

File:
1 edited

Legend:

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

    r3527 r3589  
    1 /* $Id: blit.cpp,v 1.11 2000-05-12 19:14:55 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.12 2000-05-22 19:11:27 sandervl Exp $ */
    22
    33/*
     
    220220//******************************************************************************
    221221//******************************************************************************
     222INT WIN32API StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
     223                           INT heightDst, INT xSrc, INT ySrc, INT widthSrc,
     224                           INT heightSrc, const void *bits,
     225                           const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
     226{
     227#if 1
     228 INT rc;
     229
     230    dprintf(("GDI32: StretchDIBits %x to (%d,%d) (%d,%d) from (%d,%d) (%d,%d), %x %x %x %x", hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, bits, info, wUsage, dwRop));
     231
     232    if(wUsage == DIB_PAL_COLORS && info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
     233    {
     234        // workaround for open32 bug.
     235        // If syscolors > 256 and wUsage == DIB_PAL_COLORS.
     236
     237        int i;
     238        USHORT *pColorIndex = (USHORT *)info->bmiColors;
     239        RGBQUAD *pColors = (RGBQUAD *) alloca(info->bmiHeader.biClrUsed *
     240                         sizeof(RGBQUAD));
     241        BITMAPINFO *infoLoc = (BITMAPINFO *) alloca(sizeof(BITMAPINFO) +
     242                             info->bmiHeader.biClrUsed * sizeof(RGBQUAD));
     243
     244        memcpy(infoLoc, info, sizeof(BITMAPINFO));
     245
     246        if(GetDIBColorTable(hdc, 0, info->bmiHeader.biClrUsed, pColors) == 0)
     247                return FALSE;
     248
     249        for(i=0;i<info->bmiHeader.biClrUsed;i++, pColorIndex++)
     250        {
     251                infoLoc->bmiColors[i] = pColors[*pColorIndex];
     252        }
     253
     254        rc = O32_StretchDIBits(hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc,
     255                               widthSrc, heightSrc, (void *)bits,
     256                               (PBITMAPINFO)infoLoc, DIB_RGB_COLORS, dwRop);
     257
     258        if(rc != heightDst) {
     259                dprintf(("StretchDIBits failed with rc %x", rc));
     260        }
     261        else {
     262                DIBSection *destdib = DIBSection::findHDC(hdc);
     263                if(destdib) {
     264                        destdib->sync(hdc, yDst, heightDst);
     265                }
     266        }
     267
     268        return rc;
     269    }
     270
     271    rc = O32_StretchDIBits(hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc,
     272                             widthSrc, heightSrc, (void *)bits,
     273                             (PBITMAPINFO)info, wUsage, dwRop);
     274    if(rc != heightDst) {
     275        dprintf(("StretchDIBits failed with rc %x", rc));
     276    }
     277    else {
     278        DIBSection *destdib = DIBSection::findHDC(hdc);
     279        if(destdib) {
     280                destdib->sync(hdc, yDst, heightDst);
     281        }
     282    }
     283
     284    return rc;
     285#else
     286    dprintf(("GDI32: StretchDIBits\n"));
     287    return O32_StretchDIBits(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, (void *)arg10, (PBITMAPINFO)arg11, arg12, arg13);
     288#endif
     289}
     290//******************************************************************************
     291//******************************************************************************
    222292int WIN32API SetStretchBltMode( HDC arg1, int  arg2)
    223293{
Note: See TracChangeset for help on using the changeset viewer.