Changeset 5677 for trunk/src


Ignore:
Timestamp:
May 10, 2001, 7:03:18 PM (24 years ago)
Author:
sandervl
Message:

bugfixes

Location:
trunk/src/gdi32
Files:
3 edited

Legend:

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

    r5252 r5677  
    1 /* $Id: blit.cpp,v 1.24 2001-02-23 10:37:42 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.25 2001-05-10 17:03:17 sandervl Exp $ */
    22
    33/*
     
    9191//******************************************************************************
    9292//******************************************************************************
    93 INT WIN32API SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
     93static INT SetDIBitsToDevice_(HDC hdc, INT xDest, INT yDest, DWORD cx,
    9494                               DWORD cy, INT xSrc, INT ySrc,
    9595                               UINT startscan, UINT lines, LPCVOID bits,
     
    198198    SetLastError(ERROR_INVALID_PARAMETER);
    199199    return 0;
     200}
     201//******************************************************************************
     202//******************************************************************************
     203INT WIN32API SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
     204                               DWORD cy, INT xSrc, INT ySrc,
     205                               UINT startscan, UINT lines, LPCVOID bits,
     206                               const BITMAPINFO *info, UINT coloruse)
     207{
     208    if(info->bmiHeader.biHeight < 0 && info->bmiHeader.biBitCount != 8 && info->bmiHeader.biCompression == 0) {
     209        // upside down
     210        INT rc = 0;
     211        BITMAPINFO newInfo;
     212        newInfo.bmiHeader = info->bmiHeader;
     213        long lLineByte = ((newInfo.bmiHeader.biWidth * (info->bmiHeader.biBitCount == 15 ? 16 : info->bmiHeader.biBitCount) + 31) / 32) * 4;
     214        long lHeight   = -newInfo.bmiHeader.biHeight;
     215        newInfo.bmiHeader.biHeight = -info->bmiHeader.biHeight;
     216
     217        char *newBits = (char *)malloc( lLineByte * lHeight );
     218        if(newBits) {
     219            unsigned char *pbSrc = (unsigned char *)bits + lLineByte * (lHeight - 1);
     220            unsigned char *pbDst = (unsigned char *)newBits;
     221            for(int y = 0; y < lHeight; y++) {
     222                memcpy( pbDst, pbSrc, lLineByte );
     223                pbDst += lLineByte;
     224                pbSrc -= lLineByte;
     225            }
     226            rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, DIB_RGB_COLORS );
     227            free( newBits );
     228        }
     229        return rc;
     230    }
     231    else
     232    if(info->bmiHeader.biBitCount == 8 && info->bmiHeader.biCompression == 0 && !(GetDeviceCaps( hdc, RASTERCAPS ) & RC_PALETTE)) {
     233        INT rc = 0;
     234        // convert 8bit to 24bit
     235
     236        BITMAPINFO newInfo;
     237        newInfo.bmiHeader = info->bmiHeader;
     238        newInfo.bmiHeader.biBitCount = 24;
     239        long lLineByte24 = ((newInfo.bmiHeader.biWidth * 24 + 31) / 32) * 4;
     240        long lLineByte8  = ((newInfo.bmiHeader.biWidth *  8 + 31) / 32) * 4;
     241        long lHeight   = newInfo.bmiHeader.biHeight;
     242        if(lHeight < 0) lHeight = -lHeight;
     243
     244        char *newBits = (char *)malloc( lLineByte24 * lHeight );
     245        if(newBits) {
     246            //
     247            // Get Palette Entries
     248            //
     249            PALETTEENTRY aEntries[256];
     250            LOGPALETTE *pLog = (LOGPALETTE *)malloc( sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * 256 );
     251            pLog->palVersion = 0x300;
     252            pLog->palNumEntries = 256;
     253
     254            HPALETTE hPaletteDummy = CreatePalette( pLog );
     255            free( pLog );
     256            HPALETTE hPalette = SelectPalette( hdc, hPaletteDummy, FALSE );
     257            GetPaletteEntries( hPalette, 0, 255, aEntries  );
     258            SelectPalette( hdc, hPalette, FALSE );
     259            DeleteObject( hPaletteDummy );
     260
     261            //
     262            // convert 8bit to 24bit
     263            //
     264            if(newInfo.bmiHeader.biHeight > 0) {
     265                unsigned char *pbSrc = (unsigned char *)bits;
     266                unsigned char *pbDst = (unsigned char *)newBits;
     267                for(int y = 0; y < lHeight; y++) {
     268                    for(int x = 0; x < newInfo.bmiHeader.biWidth; x++) {
     269                        PALETTEENTRY src = aEntries[pbSrc[x]];
     270                        pbDst[x * 3 + 0] = src.peBlue;
     271                        pbDst[x * 3 + 1] = src.peGreen;
     272                        pbDst[x * 3 + 2] = src.peRed;
     273                    }
     274                    pbDst += lLineByte24;
     275                    pbSrc += lLineByte8;
     276                }
     277            } else {
     278                // upside down
     279                newInfo.bmiHeader.biHeight = -info->bmiHeader.biHeight;
     280                unsigned char *pbSrc = (unsigned char *)bits + lLineByte8 * (lHeight - 1);
     281                unsigned char *pbDst = (unsigned char *)newBits;
     282                for(int y = 0; y < lHeight; y++) {
     283                    for(int x = 0; x < newInfo.bmiHeader.biWidth; x++) {
     284                        PALETTEENTRY src = aEntries[pbSrc[x]];
     285                        pbDst[x * 3 + 0] = src.peBlue;
     286                        pbDst[x * 3 + 1] = src.peGreen;
     287                        pbDst[x * 3 + 2] = src.peRed;
     288                    }
     289                    pbDst += lLineByte24;
     290                    pbSrc -= lLineByte8;
     291                }
     292            }
     293            rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, DIB_RGB_COLORS );
     294            free( newBits );
     295        }
     296        return rc;
     297    } else {
     298        return SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse );
     299    }
    200300}
    201301//******************************************************************************
  • trunk/src/gdi32/dibsect.cpp

    r5399 r5677  
    1 /* $Id: dibsect.cpp,v 1.49 2001-03-29 18:52:53 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.50 2001-05-10 17:03:18 sandervl Exp $ */
    22
    33/*
     
    559559  else  bitmapBits = bmpBits;
    560560
     561  switch(Rop) {
     562      case 0xcc0020: /* SRCCOPY */
     563          Rop = ROP_SRCCOPY;
     564          break;
     565      case 0xee0086: /* SRCPAINT */
     566          Rop = ROP_SRCPAINT;
     567          break;
     568      case 0x8800c6: /* SRCAND */
     569          Rop = ROP_SRCAND;
     570          break;
     571      case 0x660046: /* SRCINVERT */
     572          Rop = ROP_SRCINVERT;
     573          break;
     574      case 0x440328: /* SRCERASE */
     575          Rop = ROP_SRCERASE;
     576          break;
     577      case 0x330008: /* NOTSRCCOPY */
     578          Rop = ROP_NOTSRCCOPY;
     579          break;
     580      case 0x1100a6: /* NOTSRCERASE */
     581          Rop = ROP_NOTSRCERASE;
     582          break;
     583      case 0xc000ca: /* MERGECOPY */
     584          Rop = ROP_MERGECOPY;
     585          break;
     586      case 0xbb0226: /* MERGEPAINT */
     587          Rop = ROP_MERGEPAINT;
     588          break;
     589      case 0xf00021: /* PATCOPY */
     590          Rop = ROP_PATCOPY;
     591          break;
     592      case 0xfb0a09: /* PATPAINT */
     593          Rop = ROP_PATPAINT;
     594          break;
     595      case 0x5a0049: /* PATINVERT */
     596          Rop = ROP_PATINVERT;
     597          break;
     598      case 0x550009: /* DSTINVERT */
     599          Rop = ROP_DSTINVERT;
     600          break;
     601      case 0x000042: /* BLACKNESS */
     602          Rop = ROP_ZERO;
     603          break;
     604      case 0xff0062: /* WHITENESS */
     605          Rop = ROP_ONE;
     606          break;
     607      default:
     608          Rop = ROP_SRCCOPY;
     609          break;
     610  }
     611
    561612  //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc)
    562613  if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
     
    585636
    586637
    587         rc = GpiDrawBits(hps, bmpBitsDblBuffer, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);
     638        rc = GpiDrawBits(hps, bmpBitsDblBuffer, pOS2bmp, 4, &point[0], Rop, os2mode);
    588639  }
    589640  else {
    590         rc = GpiDrawBits(hps, bitmapBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);
     641        rc = GpiDrawBits(hps, bitmapBits, pOS2bmp, 4, &point[0], Rop, os2mode);
    591642  }
    592643  if(rc == GPI_OK) {
  • trunk/src/gdi32/oslibgpi.cpp

    r5165 r5677  
    1 /* $Id: oslibgpi.cpp,v 1.10 2001-02-18 14:19:08 sandervl Exp $ */
     1/* $Id: oslibgpi.cpp,v 1.11 2001-05-10 17:03:18 sandervl Exp $ */
    22
    33/*
     
    143143    }
    144144
    145     if(pptl[0].x == pptl[1].x || pptl[0].y == pptl[1].y)
    146     {
    147         return FALSE; // empty rectangle
    148     }
    149 
    150145    if(GetDCData(pHps)->isLeftLeft)
    151146    {
Note: See TracChangeset for help on using the changeset viewer.