Changeset 4677 for trunk/src


Ignore:
Timestamp:
Nov 22, 2000, 10:04:32 PM (25 years ago)
Author:
sandervl
Message:

Workaround for StretchDIBits added for icon mask stretching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/winicon.cpp

    r4665 r4677  
    1 /* $Id: winicon.cpp,v 1.16 2000-11-21 15:17:14 sandervl Exp $ */
     1/* $Id: winicon.cpp,v 1.17 2000-11-22 21:04:32 sandervl Exp $ */
    22/*
    33 * Win32 Icon Code for OS/2
     
    610610                        if (hMem) {
    611611                            hOld = SelectObject(hMem, hAndBits);
     612//SvL: This also doesn't work as StretchDIBits doesn't handle 1bpp bitmaps correctly
     613//--------->>> hack alert!
     614#if 1
     615                            HBITMAP hBmp, hOld1;
     616                            HDC hMem1;
     617
     618                            hMem1 = CreateCompatibleDC(hdc);
     619
     620                            int linewidth = BITMAP_GetWidthBytes(pInfo->bmiHeader.biWidth, 1);
     621
     622                            char *newpix = (char *)malloc(linewidth*pInfo->bmiHeader.biHeight);
     623
     624                            newpix += ((pInfo->bmiHeader.biHeight-1)*linewidth);
     625
     626                            if(cbSize - size - colorsize - bwsize == bwsize)
     627                            {//this means an AND and XOR mask is present (interleaved; and/xor)
     628                                for(int i=0;i<pInfo->bmiHeader.biHeight;i++) {
     629                                    memcpy(newpix, xbits, linewidth);
     630                                    newpix -= linewidth;
     631                                    xbits  += linewidth*2;
     632                                }
     633                            }
     634                            else {
     635                                for(int i=0;i<pInfo->bmiHeader.biHeight;i++) {
     636                                    memcpy(newpix, xbits, linewidth);
     637                                    newpix -= linewidth;
     638                                    xbits  += linewidth;
     639                                }
     640                            }
     641                            newpix += linewidth;
     642                            hBmp = CreateBitmap(pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight, 1, 1, newpix);
     643                            free(newpix);
     644
     645                            hOld1 = SelectObject(hMem1, hBmp);
     646
     647                            res = StretchBlt(hMem, 0, 0, width, height, hMem1,  0, 0, pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight, SRCCOPY);
     648
     649                            SelectObject(hMem1, hOld1);
     650                            DeleteObject(hBmp);
     651                            DeleteDC(hMem1);
     652
     653
     654#else
    612655                            res = StretchDIBits(hMem, 0, 0, width, height, 0, 0,
    613656                                                pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight,
    614657                                                xbits, pInfo, DIB_RGB_COLORS, SRCCOPY);
     658#endif
    615659                            SelectObject(hMem, hOld);
    616660                            DeleteDC(hMem);
     
    618662                        else res = FALSE;
    619663                        if (!res) {
    620                             DeleteObject(hAndBits); hAndBits = 0;
     664                            DeleteObject(hAndBits);
     665                            hAndBits = 0;
    621666                        }
    622667                    }
Note: See TracChangeset for help on using the changeset viewer.