Ignore:
Timestamp:
May 11, 2001, 7:09:45 PM (24 years ago)
Author:
sandervl
Message:

StretchDIBits now supports negative heightblit.cpp

File:
1 edited

Legend:

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

    r5689 r5690  
    1 /* $Id: blit.cpp,v 1.26 2001-05-11 14:59:26 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.27 2001-05-11 17:09:45 sandervl Exp $ */
    22
    33/*
     
    160160    if(bitfields[1] == 0x3E0)
    161161    {//RGB 555?
    162         dprintf(("BI_BITFIELDS compression %x %x %x", *bitfields, *(bitfields+1), *(bitfields+2)));
     162        dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2]));
    163163
    164164        newbits = (WORD *)malloc(imgsize);
     
    364364//******************************************************************************
    365365//******************************************************************************
    366 INT WIN32API StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
     366static INT StretchDIBits_(HDC hdc, INT xDst, INT yDst, INT widthDst,
    367367                           INT heightDst, INT xSrc, INT ySrc, INT widthSrc,
    368368                           INT heightSrc, const void *bits,
     
    452452//******************************************************************************
    453453//******************************************************************************
     454INT WIN32API StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
     455                           INT heightDst, INT xSrc, INT ySrc, INT widthSrc,
     456                           INT heightSrc, const void *bits,
     457                           const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
     458{
     459
     460    if(info->bmiHeader.biHeight < 0) {
     461        // upside down
     462        INT rc = 0;
     463        BITMAPINFO newInfo;
     464        newInfo.bmiHeader = info->bmiHeader;
     465        long lLineByte = ((newInfo.bmiHeader.biWidth * (info->bmiHeader.biBitCount == 15 ? 16 : info->bmiHeader.biBitCount) + 31) / 32) * 4;
     466        long lHeight   = -newInfo.bmiHeader.biHeight;
     467        newInfo.bmiHeader.biHeight = -newInfo.bmiHeader.biHeight;
     468
     469        char *newBits = (char *)malloc( lLineByte * lHeight );
     470        if(newBits) {
     471            unsigned char *pbSrc = (unsigned char *)bits + lLineByte * (lHeight - 1);
     472            unsigned char *pbDst = (unsigned char *)newBits;
     473            for(int y = 0; y < lHeight; y++) {
     474                memcpy( pbDst, pbSrc, lLineByte );
     475                pbDst += lLineByte;
     476                pbSrc -= lLineByte;
     477            }
     478            rc = StretchDIBits_(hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, newBits, info, wUsage, dwRop);
     479            free( newBits );
     480        }
     481        return rc;
     482    } else {
     483        return StretchDIBits_(hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, bits, info, wUsage, dwRop);
     484    }
     485}
     486//******************************************************************************
     487//******************************************************************************
    454488int WIN32API SetStretchBltMode( HDC arg1, int  arg2)
    455489{
Note: See TracChangeset for help on using the changeset viewer.