Changeset 3235 for trunk/src


Ignore:
Timestamp:
Mar 25, 2000, 1:19:08 PM (25 years ago)
Author:
sandervl
Message:

dibsection blit + setdibits fixes

Location:
trunk/src/gdi32
Files:
3 edited

Legend:

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

    r3227 r3235  
    1 /* $Id: dibitmap.cpp,v 1.6 2000-03-24 19:24:47 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.7 2000-03-25 12:19:07 sandervl Exp $ */
    22
    33/*
     
    5050HBITMAP WIN32API CreateCompatibleBitmap( HDC hdc, int nWidth, int nHeight)
    5151{
    52     dprintf(("GDI32: CreateCompatibleBitmap %x (%d,%d)", hdc, nWidth, nHeight));
    53     return O32_CreateCompatibleBitmap(hdc, nWidth, nHeight);
     52 HBITMAP hBitmap;
     53
     54    hBitmap = O32_CreateCompatibleBitmap(hdc, nWidth, nHeight);
     55    dprintf(("GDI32: CreateCompatibleBitmap %x (%d,%d) returned %x", hdc, nWidth, nHeight, hBitmap));
     56    return hBitmap;
    5457}
    5558//******************************************************************************
     
    6669                                 UINT cBitsPerPel, const void *lpvBits)
    6770{
    68  HBITMAP rc;
    69 
    70     rc = O32_CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits);
    71     dprintf(("GDI32: CreateBitmap (%d,%d) bps %d returned %x", nWidth, nHeight, cBitsPerPel, rc));
    72     return(rc);
     71 HBITMAP hBitmap;
     72
     73    hBitmap = O32_CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits);
     74    dprintf(("GDI32: CreateBitmap (%d,%d) bps %d returned %x", nWidth, nHeight, cBitsPerPel, hBitmap));
     75    return(hBitmap);
    7376}
    7477//******************************************************************************
  • trunk/src/gdi32/dibsect.cpp

    r3227 r3235  
    1 /* $Id: dibsect.cpp,v 1.22 2000-03-24 19:24:47 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.23 2000-03-25 12:19:07 sandervl Exp $ */
    22
    33/*
     
    3838//******************************************************************************
    3939DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip)
    40                 : bmpBits(NULL), pOS2bmp(NULL), next(NULL)
     40                : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsRGB565(NULL)
    4141{
    4242  int  os2bmpsize;
     
    145145                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0x03e0;
    146146                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0x001f;
     147
     148                //double buffer for rgb 555 dib sections (for conversion)
     149                if(dibinfo.dsBitfields[1] == 0x03e0) {
     150                        DosAllocMem((PPVOID)&bmpBitsRGB565, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
     151                }
    147152                break;
    148153
     
    202207   if(bmpBits)
    203208        DosFreeMem(bmpBits);
     209
     210   if(bmpBitsRGB565)
     211        DosFreeMem(bmpBitsRGB565);
    204212
    205213   if(pOS2bmp)
     
    302310   dibinfo.dsOffset         = 0; // TODO: put the correct value here (if createdibsection with file handle)
    303311
    304    if(pbmi->biCompression == BI_BITFIELDS)
    305    {
     312   if(coloruse == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
     313   {
     314        dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
     315   }
     316   else {
    306317        char *pColors = (char *)pbmi + 1;
    307318
    308         dibinfo.dsBitfields[0] = *((DWORD *)pColors);
    309         dibinfo.dsBitfields[1] = *((DWORD *)pColors+1);
    310         dibinfo.dsBitfields[2] = *((DWORD *)pColors+2);
     319        switch(pbmi->biBitCount)
     320        {
     321           case 16:
     322                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS) ? *(DWORD *)pColors : 0x7c00;
     323                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0x03e0;
     324                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0x001f;
     325                break;
     326
     327           case 24:
     328                dibinfo.dsBitfields[0] = 0xff;
     329                dibinfo.dsBitfields[1] = 0xff00;
     330                dibinfo.dsBitfields[2] = 0xff0000;
     331                break;
     332
     333           case 32:
     334                dibinfo.dsBitfields[0] = (pbmi->biCompression == BI_BITFIELDS) ? *(DWORD *)pColors : 0xff;
     335                dibinfo.dsBitfields[1] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 1) : 0xff00;
     336                dibinfo.dsBitfields[2] = (pbmi->biCompression == BI_BITFIELDS) ? *((DWORD *)pColors + 2) : 0xff0000;
     337                if(dibinfo.dsBitfields[0] != 0xff && dibinfo.dsBitfields[1] != 0xff00 && dibinfo.dsBitfields[2] != 0xff0000) {
     338                        dprintf(("DIBSection: unsupported bitfields for 32 bits bitmap!!"));
     339                }
     340                break;
     341        }
    311342        dprintf(("BI_BITFIELDS %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2]));
    312343   }
     
    411442        dprintf(("DIBSection::BitBlt; convert rgb 555 to 565"));
    412443
    413         bitmapBits = (WORD *)malloc(pOS2bmp->cbImage);
     444        if(bmpBitsRGB565 == NULL)
     445                DebugInt3();
     446
    414447        if(CPUFeatures & CPUID_MMX) {
    415                 RGB555to565MMX((WORD *)bitmapBits, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
     448                RGB555to565MMX((WORD *)bmpBitsRGB565, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
    416449        }
    417         else    RGB555to565((WORD *)bitmapBits, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
    418         rc = GpiDrawBits(hps, bitmapBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR);
    419         free(bitmapBits);
     450        else    RGB555to565((WORD *)bmpBitsRGB565, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
     451        rc = GpiDrawBits(hps, bmpBitsRGB565, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR);
    420452  }
    421453  else  rc = GpiDrawBits(hps, bmpBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR);
  • trunk/src/gdi32/dibsect.h

    r3227 r3235  
    1 /* $Id: dibsect.h,v 1.13 2000-03-24 19:24:48 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.14 2000-03-25 12:19:08 sandervl Exp $ */
    22
    33/*
     
    102102          HWND  hwndParent;
    103103          HDC   hdc;
    104           char *bmpBits;
     104          char *bmpBits, *bmpBitsRGB565;
    105105          BOOL  fFlip;
    106106          int   bmpsize;
Note: See TracChangeset for help on using the changeset viewer.