Changeset 20624


Ignore:
Timestamp:
May 14, 2003, 1:39:59 PM (22 years ago)
Author:
sandervl
Message:

DIB section: do not fetch more colors from a bitmap header than biClrUsed (if ..= 0); GetDIBits: save and restore negative height & log failure

Location:
tags/trunk/src/gdi32
Files:
2 edited

Legend:

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

    r20306 r20624  
    1 /* $Id: dibitmap.cpp,v 1.39 2003-02-06 20:28:09 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.40 2003-05-14 11:39:59 sandervl Exp $ */
    22
    33/*
     
    366366    dprintf(("GDI32: GetDIBits %x %x %d %d %x %x (biBitCount %d) %d", hdc, hBitmap, uStartScan, cScanLines, lpvBits, lpbi, lpbi->bmiHeader.biBitCount, uUsage));
    367367
     368#if 0
     369    if(lpvBits && DIBSection::getSection() != NULL)
     370    {
     371        DIBSection *dsect;
     372
     373        dsect = DIBSection::findObj(hBitmap);
     374        if(dsect) {
     375             char *bmpBits = dsect->GetDIBObject();
     376
     377             if(lpbi->bmiHeader.biBitCount == dsect->GetBitCount() &&
     378                lpbi->bmiHeader.biWidth > 0)
     379             {
     380                 LONG lLineByte;
     381
     382                 dprintf(("Quick copy from DIB section memory"));
     383                 lLineByte = DIB_GetDIBWidthBytes(lpbi->bmiHeader.biWidth, lpbi->bmiHeader.biBitCount);
     384                 
     385                 memcpy(lpvBits, bmpBits+(uStartScan*lLineByte), cScanLines*lLineByte);
     386                 return cScanLines;
     387             }
     388        }
     389    }
     390#endif
     391
    368392    //SvL: WGSS screws up the DC if it's a memory DC
    369393    //     TODO: Fix in WGSS (tries to select another bitmap in the DC which fails)
     
    415439    }
    416440    else {
     441        LONG height = lpbi->bmiHeader.biHeight;
     442
     443        if(lpbi->bmiHeader.biHeight < 0) {
     444            lpbi->bmiHeader.biHeight = -lpbi->bmiHeader.biHeight;
     445        }
    417446        nrlines = O32_GetDIBits(hdcMem, hBitmap, uStartScan, cScanLines, lpvBits, lpbi, uUsage);
     447
     448        //restore height
     449        lpbi->bmiHeader.biHeight = height;
    418450    }
    419451
     
    470502    }
    471503
    472     //WGSS/Open32 returns 0 when querying the bitmap info; must return nr of scanlines
    473     //as 0 signals failure
     504    //WGSS/Open32 returns 1 when querying the bitmap info; must return nr of scanlines
     505    //(0 signals failure)
    474506    if(lpvBits == NULL) {
    475        nrlines = cScanLines;
     507       if(nrlines != 0)
     508            nrlines = cScanLines;
     509       else dprintf(("GetDIBits failed!!"));
    476510    }
    477511    return nrlines;
  • TabularUnified tags/trunk/src/gdi32/dibsect.cpp

    r20502 r20624  
    1 /* $Id: dibsect.cpp,v 1.65 2003-04-01 15:57:05 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.66 2003-05-14 11:39:59 sandervl Exp $ */
    22
    33/*
     
    141141        dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
    142142        if(palsize) {
    143             SetDIBColorTable(0, (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1));
     143            SetDIBColorTable(0, (pbmi->biClrUsed) ? pbmi->biClrUsed : (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1));
    144144        }
    145145   }
     
    350350   dprintf(("DIBSection::SetDIBits (%d,%d), %d %d", pbmi->biWidth, pbmi->biHeight, pbmi->biBitCount, pbmi->biCompression));
    351351   if(palsize) {
    352         SetDIBColorTable(0, 1 << pbmi->biBitCount, (RGBQUAD *)(pbmi+1));
     352        SetDIBColorTable(0, (pbmi->biClrUsed) ? pbmi->biClrUsed : (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1));
    353353   }
    354354
     
    393393  {
    394394    pOS2bmp->argbColor[i].fcOptions = 0;
    395 #ifdef DEBUG
    396395    dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) ));
    397 #endif
    398396  }
    399397  return(cEntries);
     
    420418    pOS2bmp->argbColor[i].bGreen = palentry[i].peGreen;
    421419    pOS2bmp->argbColor[i].bRed   = palentry[i].peRed;
    422 #ifdef DEBUG
    423420    dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) ));
    424 #endif
    425421  }
    426422
Note: See TracChangeset for help on using the changeset viewer.