Ignore:
Timestamp:
Feb 3, 2000, 11:23:25 AM (26 years ago)
Author:
dengert
Message:

speedup conversion RGB555 -> RGB565

File:
1 edited

Legend:

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

    r2600 r2602  
    1 /* $Id: blit.cpp,v 1.2 2000-02-02 23:45:06 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.3 2000-02-03 10:23:24 dengert Exp $ */
    22
    33/*
     
    3838    if(dsect)
    3939    {
    40         dprintf((" Do stretched DIB Blt\n"));
    41         rc  = dsect->BitBlt( hdcDest,
     40        dprintf((" Do stretched DIB Blt\n"));
     41        rc  = dsect->BitBlt( hdcDest,
    4242                             nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
    4343                             nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
    4444                             dwRop);
    45         return rc;
     45        return rc;
    4646    }
    4747  }
     
    5858        if(dsect) {
    5959                rc = dsect->BitBlt(hdcDest, arg2, arg3, arg4, arg5, arg7, arg8, arg4, arg5, arg9);
    60                 if(rc) {
    61                         BITMAPINFO bmpinfo = {0};
    62                         DIBSection *dest = DIBSection::findHDC(hdcDest);
    63                         if(dest) {
    64                                 dprintf(("Sync dest DIB section"));
    65                                 bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    66                                 GetDIBits(hdcDest, dest->GetBitmapHandle(), 0, 300, 0, &bmpinfo, dest->GetRGBUsage());
    67                                 dprintf(("height        %d", bmpinfo.bmiHeader.biHeight));
    68                                 dprintf(("width         %d", bmpinfo.bmiHeader.biWidth));
    69                                 dprintf(("biBitCount    %d", bmpinfo.bmiHeader.biBitCount));
    70                                 GetDIBits(hdcDest, dest->GetBitmapHandle(), 0, 300, dest->GetDIBObject(), &bmpinfo, dest->GetRGBUsage());
    71                         }
    72                 }
    73                 return rc;
     60                if(rc) {
     61                        BITMAPINFO bmpinfo = {0};
     62                        DIBSection *dest = DIBSection::findHDC(hdcDest);
     63                        if(dest) {
     64                                dprintf(("Sync dest DIB section"));
     65                                bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
     66                                GetDIBits(hdcDest, dest->GetBitmapHandle(), 0, 300, 0, &bmpinfo, dest->GetRGBUsage());
     67                                dprintf(("height        %d", bmpinfo.bmiHeader.biHeight));
     68                                dprintf(("width         %d", bmpinfo.bmiHeader.biWidth));
     69                                dprintf(("biBitCount    %d", bmpinfo.bmiHeader.biBitCount));
     70                                GetDIBits(hdcDest, dest->GetBitmapHandle(), 0, 300, dest->GetDIBObject(), &bmpinfo, dest->GetRGBUsage());
     71                        }
     72                }
     73                return rc;
    7474        }
    7575    }
     
    7979//******************************************************************************
    8080//******************************************************************************
    81 INT WIN32API SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx, 
    82                                DWORD cy, INT xSrc, INT ySrc, 
    83                                UINT startscan, UINT lines, LPCVOID bits, 
     81INT WIN32API SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
     82                               DWORD cy, INT xSrc, INT ySrc,
     83                               UINT startscan, UINT lines, LPCVOID bits,
    8484                               const BITMAPINFO *info, UINT coloruse)
    8585{
     
    9191    SetLastError(0);
    9292    if(info == NULL) {
    93         goto invalid_parameter;
     93        goto invalid_parameter;
    9494    }
    9595    height = info->bmiHeader.biHeight;
     
    9898    if (height < 0) height = -height;
    9999    if (!lines || (startscan >= height)) {
    100         goto invalid_parameter;
     100        goto invalid_parameter;
    101101    }
    102102    if (startscan + lines > height) lines = height - startscan;
     
    130130    //SvL: Ignore BI_BITFIELDS type (SetDIBitsToDevice fails otherwise)
    131131    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)));
    135         ((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         }
     132        DWORD *bitfields = (DWORD *)info->bmiColors;
     133
     134        dprintf(("BI_BITFIELDS compression %x %x %x", *bitfields, *(bitfields+1), *(bitfields+2)));
     135        ((BITMAPINFO *)info)->bmiHeader.biCompression = 0;
     136        compression = BI_BITFIELDS;
     137        if(*(bitfields+1) == 0x3E0) {//RGB 555?
     138            extern void _Optlink RGB555to565 (WORD *dest, WORD *src, ULONG num);
     139
     140                newbits = (WORD *)malloc(imgsize);
     141                RGB555to565 (newbits, (WORD *)bits, imgsize/sizeof(WORD));
     142                bits = newbits;
     143        }
    153144    }
    154145
    155146    if(info->bmiHeader.biHeight < 0)
    156         ((BITMAPINFO *)info)->bmiHeader.biHeight = -info->bmiHeader.biHeight;
     147        ((BITMAPINFO *)info)->bmiHeader.biHeight = -info->bmiHeader.biHeight;
    157148
    158149    result = O32_SetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (PBITMAPINFO)info, coloruse);
     
    165156
    166157    if(compression == BI_BITFIELDS) {
    167         ((BITMAPINFO *)info)->bmiHeader.biCompression = BI_BITFIELDS;
    168         if(newbits) free(newbits);
     158        ((BITMAPINFO *)info)->bmiHeader.biCompression = BI_BITFIELDS;
     159        if(newbits) free(newbits);
    169160    }
    170161    return result;
Note: See TracChangeset for help on using the changeset viewer.