Ignore:
Timestamp:
Aug 28, 2001, 8:58:57 PM (24 years ago)
Author:
sandervl
Message:

CreateDIBitmap fix for negative height

File:
1 edited

Legend:

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

    r6594 r6603  
    1 /* $Id: dibitmap.cpp,v 1.26 2001-08-26 14:22:44 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.27 2001-08-28 18:58:57 sandervl Exp $ */
    22
    33/*
     
    4848    {
    4949        dprintf(("GDI32: CreateDIBitmap negative height! (%d,%d)", lpbmih->biWidth, lpbmih->biHeight));
     50        //TODO: doesn't work if memory is readonly!!
    5051        ((BITMAPINFOHEADER *)lpbmih)->biHeight = -lpbmih->biHeight;
     52
     53        if(lpbInit && fdwInit == CBM_INIT) {
     54            // upside down
     55            HBITMAP rc = 0;
     56            long lLineByte = DIB_GetDIBWidthBytes(lpbmih->biWidth, lpbmih->biBitCount);
     57            long lHeight   = lpbmih->biHeight;
     58   
     59            newbits = (WORD *)malloc( lLineByte * lHeight );
     60            if(newbits) {
     61                unsigned char *pbSrc = (unsigned char *)lpbInit + lLineByte * (lHeight - 1);
     62                unsigned char *pbDst = (unsigned char *)newbits;
     63                for(int y = 0; y < lHeight; y++) {
     64                    memcpy( pbDst, pbSrc, lLineByte );
     65                    pbDst += lLineByte;
     66                    pbSrc -= lLineByte;
     67                }
     68                rc = CreateDIBitmap(hdc, lpbmih, fdwInit, newbits, lpbmi, fuUsage);
     69                free( newbits );
     70            }
     71
     72            ((BITMAPINFOHEADER *)lpbmih)->biHeight = iHeight;
     73            return rc;
     74        }
    5175    }
    5276
Note: See TracChangeset for help on using the changeset viewer.