- Timestamp:
- Dec 30, 2002, 3:05:21 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/dibitmap.cpp
r9429 r9565 1 /* $Id: dibitmap.cpp,v 1.3 5 2002-11-26 10:53:07sandervl Exp $ */1 /* $Id: dibitmap.cpp,v 1.36 2002-12-30 14:05:21 sandervl Exp $ */ 2 2 3 3 /* … … 53 53 ((BITMAPINFOHEADER *)lpbmih)->biHeight = -lpbmih->biHeight; 54 54 55 if(lpbInit && fdwInit == CBM_INIT) { 55 if(lpbInit && fdwInit == CBM_INIT) 56 { 56 57 // upside down 57 58 HBITMAP rc = 0; … … 69 70 } 70 71 rc = CreateDIBitmap(hdc, lpbmih, fdwInit, newbits, lpbmi, fuUsage); 71 72 free( newbits ); 72 73 } 73 74 … … 544 545 } 545 546 546 if(pBitmapInfo->bmiHeader.biHeight < 0) { 547 dprintf(("!WARNING! Negative height!!")); 548 } 549 ret = O32_SetDIBits(hdc, hBitmap, startscan, numlines, pBits, pBitmapInfo, usage); 547 //If upside down, reverse scanlines and call SetDIBits again 548 if(pBitmapInfo->bmiHeader.biHeight < 0 && (pBitmapInfo->bmiHeader.biCompression == BI_RGB || 549 pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)) 550 { 551 // upside down 552 INT rc = -1; 553 long lLineByte; 554 555 //TODO: doesn't work if memory is readonly!! 556 ((BITMAPINFO *)pBitmapInfo)->bmiHeader.biHeight = -pBitmapInfo->bmiHeader.biHeight; 557 558 lLineByte = DIB_GetDIBWidthBytes(pBitmapInfo->bmiHeader.biWidth, pBitmapInfo->bmiHeader.biBitCount); 559 560 dprintf(("Reverse bitmap (negative height)")); 561 char *pNewBits = (char *)malloc( lLineByte * numlines ); 562 if(pNewBits) { 563 unsigned char *pbSrc = (unsigned char *)pBits + lLineByte * (numlines - 1); 564 unsigned char *pbDst = (unsigned char *)pNewBits; 565 for(int y = 0; y < numlines; y++) { 566 memcpy( pbDst, pbSrc, lLineByte ); 567 pbDst += lLineByte; 568 pbSrc -= lLineByte; 569 } 570 ret = O32_SetDIBits(hdc, hBitmap, startscan, numlines, pNewBits, pBitmapInfo, usage); 571 free(pNewBits); 572 } 573 else DebugInt3(); 574 575 //TODO: doesn't work if memory is readonly!! 576 ((BITMAPINFO *)pBitmapInfo)->bmiHeader.biHeight = -pBitmapInfo->bmiHeader.biHeight; 577 } 578 else { 579 ret = O32_SetDIBits(hdc, hBitmap, startscan, numlines, pBits, pBitmapInfo, usage); 580 } 550 581 if(newbits) free(newbits); 551 582
Note:
See TracChangeset
for help on using the changeset viewer.