Changeset 5870 for trunk/src


Ignore:
Timestamp:
Jun 2, 2001, 9:24:38 AM (24 years ago)
Author:
sandervl
Message:

StretchDIBits fix for RGB555

File:
1 edited

Legend:

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

    r5825 r5870  
    1 /* $Id: blit.cpp,v 1.29 2001-05-29 09:45:20 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.30 2001-06-02 07:24:38 sandervl Exp $ */
    22
    33/*
     
    376376{
    377377 INT rc;
     378 DWORD bitfields[3];
     379 WORD *newbits = NULL;
    378380
    379381    dprintf(("GDI32: StretchDIBits %x to (%d,%d) (%d,%d) from (%d,%d) (%d,%d), %x %x %x %x", hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, bits, info, wUsage, dwRop));
     
    431433        return rc;
    432434    }
     435
     436    switch(info->bmiHeader.biBitCount) {
     437    case 15:
     438    case 16:
     439        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0x7c00;
     440        bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 1) : 0x03e0;
     441        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
     442        break;
     443    case 32:
     444        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
     445        bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 1) : 0xff00;
     446        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0xff;
     447        break;
     448    default:
     449        bitfields[0] = 0;
     450        bitfields[1] = 0;
     451        bitfields[2] = 0;
     452        break;
     453    }
     454
     455    if(bitfields[1] == 0x3E0)
     456    {//RGB 555?
     457        dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2]));
     458
     459        int imgsize = CalcBitmapSize(info->bmiHeader.biBitCount,
     460                                     info->bmiHeader.biWidth, info->bmiHeader.biHeight);
     461
     462        newbits = (WORD *)malloc(imgsize);
     463        if(CPUFeatures & CPUID_MMX) {
     464             RGB555to565MMX(newbits, (WORD *)bits, imgsize/sizeof(WORD));
     465        }
     466        else RGB555to565(newbits, (WORD *)bits, imgsize/sizeof(WORD));
     467        bits = newbits;
     468    }
     469
    433470    rc = O32_StretchDIBits(hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc,
    434471                             widthSrc, heightSrc, (void *)bits,
    435472                             (PBITMAPINFO)info, wUsage, dwRop);
     473
     474    if(newbits) free(newbits);
     475
    436476    //Open32 always returns height of bitmap (regardless of how many scanlines were copied)
    437477    if(rc != heightSrc && rc != info->bmiHeader.biHeight) {
Note: See TracChangeset for help on using the changeset viewer.