Changeset 9614 for trunk/src


Ignore:
Timestamp:
Jan 4, 2003, 7:18:05 PM (23 years ago)
Author:
sandervl
Message:

GetDIBits fixes (flip bitmap and only return bitfields data when requested by the app)

File:
1 edited

Legend:

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

    r9604 r9614  
    1 /* $Id: dibitmap.cpp,v 1.37 2003-01-03 21:42:55 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.38 2003-01-04 18:18:05 sandervl Exp $ */
    22
    33/*
     
    366366    pDCData pHps; 
    367367    HDC hdcMem;
     368    DWORD biCompression;
    368369
    369370    dprintf(("GDI32: GetDIBits %x %x %d %d %x %x (biBitCount %d) %d", hdc, hBitmap, uStartScan, cScanLines, lpvBits, lpbi, lpbi->bmiHeader.biBitCount, uUsage));
     
    382383    else  hdcMem = hdc;
    383384
    384     if(lpbi->bmiHeader.biHeight < 0) {
    385         //NOTE: workaround for WGSS bug; remove when fixed
     385    if(lpvBits) {
     386        biCompression = lpbi->bmiHeader.biCompression;
     387    }
     388
     389    //If the app wants bitmap data and upside down, then flip image
     390    if(lpvBits && lpbi->bmiHeader.biHeight < 0 && (lpbi->bmiHeader.biCompression == BI_RGB ||
     391       lpbi->bmiHeader.biCompression == BI_BITFIELDS))
     392    {
     393        INT rc = -1;
     394        long lLineByte;
    386395        LONG height = lpbi->bmiHeader.biHeight;
    387396
    388         nrlines = O32_GetDIBits(hdcMem, hBitmap, uStartScan, cScanLines, lpvBits, lpbi, uUsage);
    389 
    390         //NOTE: workaround for WGSS bug; remove when fixed
     397        lpbi->bmiHeader.biHeight = -lpbi->bmiHeader.biHeight;
     398
     399        lLineByte = DIB_GetDIBWidthBytes(lpbi->bmiHeader.biWidth, lpbi->bmiHeader.biBitCount);
     400
     401        dprintf(("flip bitmap (negative height)"));
     402        char *pNewBits = (char *)malloc( lLineByte * cScanLines );
     403        if(pNewBits) {
     404            nrlines = O32_GetDIBits(hdcMem, hBitmap, uStartScan, cScanLines, pNewBits, lpbi, uUsage);
     405
     406            unsigned char *pbSrc = (unsigned char *)pNewBits + lLineByte * (cScanLines - 1);
     407            unsigned char *pbDst = (unsigned char *)lpvBits;
     408            for(int y = 0; y < cScanLines; y++) {
     409                memcpy( pbDst, pbSrc, lLineByte );
     410                pbDst += lLineByte;
     411                pbSrc -= lLineByte;
     412            }
     413            free(pNewBits);
     414        }
     415        else DebugInt3();
     416 
     417        //restore height
    391418        lpbi->bmiHeader.biHeight = height;
    392419    }
     
    395422    }
    396423
     424    if(lpvBits) {
     425        //WGSS always sets it to BI_RGB
     426        lpbi->bmiHeader.biCompression = biCompression;
     427    }
     428
    397429    if(pHps->isMemoryPS)
    398430        DeleteDC(hdcMem);
    399431
    400     if(lpvBits) {
     432    //Only return bitfields info if the app wants it
     433    if(lpvBits && lpbi->bmiHeader.biCompression == BI_BITFIELDS) {
    401434        // set proper color masks (only if lpvBits not NULL)
    402435        switch(lpbi->bmiHeader.biBitCount) {
     
    426459            break;
    427460        }
    428         if(lpbi->bmiHeader.biCompression == BI_RGB && lpbi->bmiHeader.biBitCount > 8) {
    429             lpbi->bmiHeader.biCompression = BI_BITFIELDS;
    430             dprintf(("BI_BITFIELDS: %x %x %x", ((DWORD*)(lpbi->bmiColors))[0], ((DWORD*)(lpbi->bmiColors))[1], ((DWORD*)(lpbi->bmiColors))[2]));
    431         }
     461        dprintf(("BI_BITFIELDS: %x %x %x", ((DWORD*)(lpbi->bmiColors))[0], ((DWORD*)(lpbi->bmiColors))[1], ((DWORD*)(lpbi->bmiColors))[2]));
    432462    }
    433463    if(nrlines && lpvBits && lpbi->bmiHeader.biBitCount == 16 && ((DWORD*)(lpbi->bmiColors))[1] == RGB555_GREEN_MASK)
Note: See TracChangeset for help on using the changeset viewer.