Changeset 9638 for trunk/src


Ignore:
Timestamp:
Jan 7, 2003, 11:26:01 AM (23 years ago)
Author:
sandervl
Message:

Convert color masks to b&w in CreateIconIndirect

File:
1 edited

Legend:

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

    r9624 r9638  
    1 /* $Id: winicon.cpp,v 1.39 2003-01-05 16:34:58 sandervl Exp $ */
     1/* $Id: winicon.cpp,v 1.40 2003-01-07 10:26:01 sandervl Exp $ */
    22/*
    33 * Win32 Icon Code for OS/2
     
    200200
    201201        /* Transfer the bitmap bits to the CURSORICONINFO structure */
    202         GetBitmapBits( iconinfo->hbmMask ,sizeAnd,(char*)(info + 1) );
     202        if(bmpAnd.bmBitsPixel > 1)
     203        {//Our code expects b&w masks, so convert it first
     204         //We could also use GetDIBits to do the conversion for us, but it returns
     205         //scanlines aligned differently from what we want.
     206            HBITMAP oldbmpSrc, oldbmpDest, hbmMask;
     207            HDC     hdcSrc, hdcDest;
     208
     209            hdcSrc  = CreateCompatibleDC(0);
     210            oldbmpSrc = SelectObject(hdcSrc, iconinfo->hbmMask);
     211
     212            hdcDest = CreateCompatibleDC(0);
     213            hbmMask = CreateBitmap(bmpAnd.bmWidth, bmpAnd.bmHeight, 1,
     214                                   1, NULL);
     215            oldbmpDest = SelectObject(hdcDest, hbmMask);
     216
     217            //blit to the destination HDC & convert to 1bpp
     218            BitBlt(hdcDest, 0, 0, bmpAnd.bmWidth, bmpAnd.bmHeight,
     219                   hdcSrc, 0, 0, SRCCOPY);
     220
     221            //recalculate the mask bitmap size
     222            GetObjectA( hbmMask, sizeof(bmpAnd), &bmpAnd );
     223            sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
     224
     225            //query the 1bpp bitmap data
     226            GetBitmapBits( hbmMask ,sizeAnd,(char*)(info + 1) );
     227
     228            SelectObject(hdcSrc, oldbmpSrc);
     229            SelectObject(hdcDest, oldbmpDest);
     230            DeleteObject(hbmMask);
     231            DeleteDC(hdcSrc);
     232            DeleteDC(hdcDest);
     233        }
     234        else {
     235            GetBitmapBits( iconinfo->hbmMask ,sizeAnd,(char*)(info + 1) );
     236        }
    203237        if(bmpXor.bmBitsPixel > 1)
    204238        {
Note: See TracChangeset for help on using the changeset viewer.