Changeset 7327 for trunk/src


Ignore:
Timestamp:
Nov 13, 2001, 2:18:22 PM (24 years ago)
Author:
sandervl
Message:

workaround added for 32 bpp blitting with matrox display driver

Location:
trunk/src/gdi32
Files:
3 edited

Legend:

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

    r6692 r7327  
    1 /* $Id: blit.cpp,v 1.34 2001-09-10 11:02:40 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.35 2001-11-13 13:18:22 sandervl Exp $ */
    22
    33/*
     
    147147        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
    148148        break;
     149
     150    case 24:
    149151    case 32:
    150152        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
     
    226228                               const BITMAPINFO *info, UINT coloruse)
    227229{
     230    static BOOL fMatrox32BppBug = FALSE;
     231    INT rc = 0;
     232    char *newBits = NULL;
     233
     234    //If upside down, reverse scanlines and call SetDIBitsToDevice again
    228235    if(info->bmiHeader.biHeight < 0 && info->bmiHeader.biBitCount != 8 && info->bmiHeader.biCompression == 0) {
    229236        // upside down
    230         INT rc = 0;
     237        INT rc = -1;
    231238        BITMAPINFO newInfo;
    232239        newInfo.bmiHeader = info->bmiHeader;
     
    244251                pbSrc -= lLineByte;
    245252            }
    246             rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, DIB_RGB_COLORS );
     253            rc = SetDIBitsToDevice( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, coloruse );
    247254            free( newBits );
    248255        }
     256        else DebugInt3();
     257
    249258        return rc;
    250259    }
     260
     261    //We must convert 32 bpp bitmap data to 24 bpp on systems with the Matrox
     262    //display driver. (GpiDrawBits for 32 bpp fails with insufficient memory error)
     263    if(info->bmiHeader.biBitCount == 32 && fMatrox32BppBug)
     264    {
     265        BITMAPINFO newInfo;
     266        newInfo.bmiHeader = info->bmiHeader;
     267
     268        long lLineWidth;
     269        long lHeight    = (newInfo.bmiHeader.biHeight > 0) ? newInfo.bmiHeader.biHeight : -newInfo.bmiHeader.biHeight;
     270        long lWidth     = newInfo.bmiHeader.biWidth;
     271
     272        newInfo.bmiHeader.biBitCount  = 24;
     273        newInfo.bmiHeader.biSizeImage = CalcBitmapSize(24, newInfo.bmiHeader.biWidth,
     274                                                       newInfo.bmiHeader.biHeight);
     275
     276        lLineWidth = newInfo.bmiHeader.biSizeImage / lHeight;
     277
     278        //convert 32 bits bitmap data to 24 bits
     279        newBits = (char *)malloc(newInfo.bmiHeader.biSizeImage+16); //extra room needed for copying (too much)
     280        if(!newBits) {
     281            DebugInt3();
     282            return -1;
     283        }
     284        unsigned char *pbSrc = (unsigned char *)bits;
     285        unsigned char *pbDst = (unsigned char *)newBits;
     286        //not very efficient
     287        for(int i = 0; i < lHeight; i++) {
     288            for(int j=0;j<lWidth;j++) {
     289                *(DWORD *)pbDst = *(DWORD *)pbSrc;
     290                pbSrc += 4;
     291                pbDst += 3;
     292            }
     293            //24 bpp scanline must be aligned at 4 byte boundary
     294            pbDst += (lLineWidth - 3*lWidth);
     295        }
     296        rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, newBits, &newInfo, coloruse );
     297        free(newBits);
     298        return rc;
     299    }
     300    rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse );
     301
     302    if(rc == -1 && info->bmiHeader.biBitCount == 32 && !fMatrox32BppBug)
     303    {
     304        //The Matrox driver seems to have some difficulty blitting 32bpp
     305        //data. (out of memory error) The same operation works fine with SDD.
     306        fMatrox32BppBug = TRUE;
     307        return SetDIBitsToDevice(hdc, xDest, yDest, cx,
     308                                 cy, xSrc, ySrc,
     309                                 startscan, lines, bits,
     310                                 info, coloruse);
     311    }
     312    return rc;
     313
    251314//SvL: Breaks startup bitmap of Acrobat Reader 4.05
    252315#if 0
     
    319382    }
    320383#endif
    321     else {
    322         return SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse );
    323     }
    324384}
    325385//******************************************************************************
     
    441501        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
    442502        break;
     503    case 24:
    443504    case 32:
    444505        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
     
    470531        ((BITMAPINFO *)info)->bmiHeader.biCompression = 0;
    471532        compression = BI_BITFIELDS;
    472 
    473533    }
    474534
     
    629689
    630690                case 32:
    631                         return cx*cy;
     691                        return cx*cy*4;
    632692
    633693                default:
  • trunk/src/gdi32/dibitmap.cpp

    r6603 r7327  
    1 /* $Id: dibitmap.cpp,v 1.27 2001-08-28 18:58:57 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.28 2001-11-13 13:18:22 sandervl Exp $ */
    22
    33/*
     
    9696        bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ?  *((DWORD *)lpbmi->bmiColors + 2) : 0x001f;
    9797        break;
     98    case 24:
    9899    case 32:
    99         bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : 0xff0000;
     100        bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors        : 0xff0000;
    100101        bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ?  *((DWORD *)lpbmi->bmiColors + 1) : 0xff00;
    101102        bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ?  *((DWORD *)lpbmi->bmiColors + 2) : 0xff;
     
    361362        case 24:
    362363        case 32:
    363            ((DWORD*)(lpbi->bmiColors))[0] = 0x0000FF;
     364           ((DWORD*)(lpbi->bmiColors))[0] = 0xFF0000;
    364365           ((DWORD*)(lpbi->bmiColors))[1] = 0x00FF00;
    365            ((DWORD*)(lpbi->bmiColors))[2] = 0xFF0000;
     366           ((DWORD*)(lpbi->bmiColors))[2] = 0x0000FF;
    366367           break;
    367368        }
     
    448449        bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)pBitmapInfo->bmiColors + 2) : 0x001f;
    449450        break;
     451
     452    case 24:
    450453    case 32:
    451454        bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : 0xff0000;
  • trunk/src/gdi32/dibsect.cpp

    r7113 r7327  
    1 /* $Id: dibsect.cpp,v 1.58 2001-10-18 17:01:34 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.59 2001-11-13 13:18:22 sandervl Exp $ */
    22
    33/*
     
    157157
    158158           case 24:
    159                 dibinfo.dsBitfields[0] = 0xff;
    160                 dibinfo.dsBitfields[1] = 0xff00;
    161                 dibinfo.dsBitfields[2] = 0xff0000;
    162                 break;
    163 
    164159           case 32:
    165                 dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0xff;
    166                 dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0xff00;
    167                 dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0xff0000;
    168                 if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
     160                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors       : 0xff0000;
     161                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x00ff00;
     162                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x0000ff;
     163                if(dibinfo.dsBitfields[0] != 0xff0000 && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff) {
    169164                    dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
    170165                }
     
    336331
    337332           case 24:
    338                 dibinfo.dsBitfields[0] = 0xff;
    339                 dibinfo.dsBitfields[1] = 0xff00;
    340                 dibinfo.dsBitfields[2] = 0xff0000;
    341                 break;
    342 
    343333           case 32:
    344                 dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors : 0xff;
    345                 dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0xff00;
    346                 dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0xff0000;
    347                 if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
     334                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS_W) ? *(DWORD *)pColors       : 0xff0000;
     335                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 1) : 0x00ff00;
     336                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS_W) ? *((DWORD *)pColors + 2) : 0x0000ff;
     337                if(dibinfo.dsBitfields[0] != 0xff0000 && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff) {
    348338                    dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
    349339                }
Note: See TracChangeset for help on using the changeset viewer.