Ignore:
Timestamp:
Feb 3, 2000, 12:45:07 AM (26 years ago)
Author:
sandervl
Message:

RGB 555 conversion in SetDIBitsToDevice + quake 2 BitBlt fix

File:
1 edited

Legend:

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

    r2592 r2600  
    1 /* $Id: blit.cpp,v 1.1 2000-02-01 12:53:29 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.2 2000-02-02 23:45:06 sandervl Exp $ */
    22
    33/*
     
    7171                        }
    7272                }
     73                return rc;
    7374        }
    7475    }
     
    8586    INT result, imgsize, palsize, height, width;
    8687    char *ptr;
     88    ULONG compression = 0;
     89    WORD *newbits = 0;
    8790
    8891    SetLastError(0);
     
    126129
    127130    //SvL: Ignore BI_BITFIELDS type (SetDIBitsToDevice fails otherwise)
    128     if(info->bmiHeader.biCompression == BI_BITFIELDS)
     131    if(info->bmiHeader.biCompression == BI_BITFIELDS) {
     132        DWORD *bitfields = (DWORD *)info->bmiColors;
     133
     134        dprintf(("BI_BITFIELDS compression %x %x %x", *bitfields, *(bitfields+1), *(bitfields+2)));
    129135        ((BITMAPINFO *)info)->bmiHeader.biCompression = 0;
     136        compression = BI_BITFIELDS;
     137        if(*(bitfields+1) == 0x3E0) {//RGB 555?
     138          WORD *dstbits, *srcbits;
     139          WORD  pixel;
     140
     141                newbits = dstbits = (WORD *)malloc(imgsize);
     142                srcbits = (WORD *)bits;
     143                for(int i=0;i<imgsize/sizeof(WORD);i++) {
     144                        pixel     = *dstbits = *srcbits++;
     145                        *dstbits &= 0x1F;
     146                        pixel    &= 0x7FE0;
     147                        pixel   <<= 1;
     148                        *dstbits  = *dstbits | pixel;
     149                        dstbits++;
     150                }
     151                bits = newbits;
     152        }
     153    }
     154
    130155    if(info->bmiHeader.biHeight < 0)
    131156        ((BITMAPINFO *)info)->bmiHeader.biHeight = -info->bmiHeader.biHeight;
    132157
    133 //    result = OSLibSetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (WINBITMAPINFOHEADER *)info, coloruse);
    134 //    result = 1;
    135158    result = O32_SetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (PBITMAPINFO)info, coloruse);
    136159    //SvL: Wrong Open32 return value
     
    141164    dprintf(("GDI32: SetDIBitsToDevice %d %d %d %d %x %d", info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biPlanes, info->bmiHeader.biBitCount, info->bmiHeader.biCompression, info->bmiHeader.biSizeImage));
    142165
     166    if(compression == BI_BITFIELDS) {
     167        ((BITMAPINFO *)info)->bmiHeader.biCompression = BI_BITFIELDS;
     168        if(newbits) free(newbits);
     169    }
    143170    return result;
    144171
Note: See TracChangeset for help on using the changeset viewer.