Changeset 6595 for trunk/src


Ignore:
Timestamp:
Aug 26, 2001, 4:23:35 PM (24 years ago)
Author:
sandervl
Message:

several icon/cursor fixes

Location:
trunk/src/user32
Files:
2 edited

Legend:

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

    r6586 r6595  
    1 /* $Id: oslibres.cpp,v 1.19 2001-08-25 10:54:19 sandervl Exp $ */
     1/* $Id: oslibres.cpp,v 1.20 2001-08-26 14:23:33 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    2525#include "oslibres.h"
    2626#include "pmwindow.h"
     27#include <wingdi32.h>
    2728
    2829#define DBG_LOCALLOG    DBG_oslibres
     
    307308        pBmpColor->ulColorEncoding  = BCE_RGB;
    308309
    309             os2rgb                      = &pBmpColor->argbColor[0];
    310             rgb                         = (RGBQUAD *)(pXorBits);
    311 
    312             if(pXorBmp->bmBitsPixel <= 8) {
    313                 for(i=0;i<(1<<pXorBmp->bmBitsPixel);i++) {
    314                         os2rgb->bRed   = rgb->rgbRed;
    315                         os2rgb->bBlue  = rgb->rgbBlue;
    316                         os2rgb->bGreen = rgb->rgbGreen;
    317                         os2rgb++;
    318                         rgb++;
    319                 }
     310        os2rgb                      = &pBmpColor->argbColor[0];
     311        rgb                         = (RGBQUAD *)(pXorBits);
     312
     313        if(pXorBmp->bmBitsPixel <= 8) {
     314            for(i=0;i<(1<<pXorBmp->bmBitsPixel);i++) {
     315                    os2rgb->bRed   = rgb->rgbRed;
     316                    os2rgb->bBlue  = rgb->rgbBlue;
     317                    os2rgb->bGreen = rgb->rgbGreen;
     318                    os2rgb++;
     319                    rgb++;
     320            }
    320321        }
    321322
     
    329330                    src  += pXorBmp->bmWidthBytes;
    330331                }
     332        }
     333        else   
     334        if(pXorBmp->bmBitsPixel == 16) {
     335                ConvertRGB555to565(os2rgb, rgb, pXorBmp->bmHeight * pXorBmp->bmWidthBytes);
    331336        }
    332337        else    memcpy(os2rgb, rgb, pXorBmp->bmHeight * pXorBmp->bmWidthBytes);
  • trunk/src/user32/winicon.cpp

    r6487 r6595  
    1 /* $Id: winicon.cpp,v 1.28 2001-08-08 10:07:19 sandervl Exp $ */
     1/* $Id: winicon.cpp,v 1.29 2001-08-26 14:23:35 sandervl Exp $ */
    22/*
    33 * Win32 Icon Code for OS/2
     
    101101static ICONCACHE* CURSORICON_FindCache(HANDLE handle);
    102102
     103static HGLOBAL CreateCursorIconIndirect( HINSTANCE hInstance,
     104                                         CURSORICONINFO *info,
     105                                         LPCVOID lpANDbits,
     106                                         LPCVOID lpXORbits, BOOL fIcon);
     107
    103108/***********************************************************************
    104109 *           CreateIcon    (USER32.75)
     
    122127    info.dwResGroupId = -1;
    123128    info.hColorBmp = 0;
    124     return CreateCursorIconIndirect(0, &info, lpANDbits, lpXORbits);
     129    return CreateCursorIconIndirect(0, &info, lpANDbits, lpXORbits, TRUE);
    125130}
    126131/**********************************************************************
     
    149154    BITMAP bmpXor,bmpAnd;
    150155    HICON hObj;
    151     int sizeXor,sizeAnd;
     156    int sizeXor,sizeAnd,colortablesize;
    152157
    153158    dprintf(("USER32: CreateIconIndirect %x", iconinfo));
     
    156161    GetObjectA( iconinfo->hbmMask, sizeof(bmpAnd), &bmpAnd );
    157162
    158     sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
     163    colortablesize = 0;
     164
     165    if(bmpXor.bmBitsPixel <= 8) {
     166         colortablesize = sizeof(RGBQUAD)*(1<<bmpXor.bmBitsPixel);
     167         sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes + colortablesize;
     168    }
     169    else sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
     170
    159171    sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
    160172
     
    189201        /* Transfer the bitmap bits to the CURSORICONINFO structure */
    190202        GetBitmapBits( iconinfo->hbmMask ,sizeAnd,(char*)(info + 1) );
    191         GetBitmapBits( iconinfo->hbmColor,sizeXor,(char*)(info + 1) +sizeAnd);
     203        if(bmpXor.bmBitsPixel > 1)
     204        {
     205            BITMAPINFO* pInfo = (BITMAPINFO *)malloc(sizeof(BITMAPINFO)+colortablesize+3*sizeof(DWORD)); //+ extra space for > 8bpp images
     206            HBITMAP oldbmp;
     207            HDC     hdc;
     208
     209            hdc = CreateCompatibleDC(0);
     210
     211            memset(pInfo, 0, sizeof(BITMAPINFO)+colortablesize+3*sizeof(DWORD));
     212            pInfo->bmiHeader.biSize     = sizeof(BITMAPINFOHEADER);
     213            pInfo->bmiHeader.biPlanes   = info->bPlanes;
     214            pInfo->bmiHeader.biBitCount = info->bBitsPerPixel;
     215
     216            GetDIBits(hdc, iconinfo->hbmColor, 0, bmpXor.bmHeight, (char *)(info + 1) + sizeAnd + colortablesize, pInfo, DIB_RGB_COLORS);
     217            if(colortablesize) {
     218                memcpy((char *)(info + 1) + sizeAnd, (char *)&pInfo->bmiHeader + pInfo->bmiHeader.biSize, colortablesize);
     219            }
     220
     221            DeleteDC(hdc);
     222            free(pInfo);
     223        }
     224        else {
     225            GetBitmapBits( iconinfo->hbmColor,sizeXor,(char*)(info + 1) +sizeAnd);
     226        }
     227
     228#ifdef __WIN32OS2__
     229        info->hColorBmp = OSLibWinCreatePointer(info, (char*)(info + 1), (LPBITMAP_W)&bmpAnd, (char*)(info + 1) + sizeAnd, (LPBITMAP_W)&bmpXor, FALSE);
     230#endif
    192231        GlobalUnlock(hObj);
    193232
     
    200239        }
    201240#endif
     241        dprintf(("USER32: CreateIconIndirect %x returned %x", iconinfo, hIcon));
    202242        return hIcon;
    203243    }
     
    352392    info.hColorBmp     = 0;
    353393
    354     return CreateCursorIconIndirect( 0, &info, lpANDbits, lpXORbits );
     394    return CreateCursorIconIndirect( 0, &info, lpANDbits, lpXORbits, FALSE);
    355395}
    356396//******************************************************************************
     
    520560 *           CreateCursorIconIndirect
    521561 */
    522 HGLOBAL WIN32API CreateCursorIconIndirect( HINSTANCE hInstance,
    523                                            CURSORICONINFO *info,
    524                                            LPCVOID lpANDbits,
    525                                            LPCVOID lpXORbits )
     562static HGLOBAL CreateCursorIconIndirect( HINSTANCE hInstance,
     563                                         CURSORICONINFO *info,
     564                                         LPCVOID lpANDbits,
     565                                         LPCVOID lpXORbits, BOOL fIcon)
    526566{
    527567    HGLOBAL handle;
    528568    char *ptr;
    529569    int sizeAnd, sizeXor;
     570#ifdef __WIN32OS2__
     571    BITMAP bmpXor, bmpAnd;
     572#endif
    530573
    531574    if (!lpXORbits || !lpANDbits || info->bPlanes != 1) return 0;
     
    540583    memcpy( ptr + sizeof(CURSORICONINFO), lpANDbits, sizeAnd );
    541584    memcpy( ptr + sizeof(CURSORICONINFO) + sizeAnd, lpXORbits, sizeXor );
     585#ifdef __WIN32OS2__
     586    bmpAnd.bmType       = 0;
     587    bmpAnd.bmWidth      = info->nWidth;
     588    bmpAnd.bmHeight     = info->nHeight;
     589    bmpAnd.bmWidthBytes = BITMAP_GetWidthBytes(info->nWidth, 1);
     590    bmpAnd.bmPlanes     = info->bPlanes;
     591    bmpAnd.bmBitsPixel  = 1;
     592    bmpAnd.bmBits       = NULL;
     593
     594    bmpXor.bmType       = 0;
     595    bmpXor.bmWidth      = info->nWidth;
     596    bmpXor.bmHeight     = info->nHeight;
     597    bmpXor.bmWidthBytes = info->nWidthBytes;
     598    bmpXor.bmPlanes     = info->bPlanes;
     599    bmpXor.bmBitsPixel  = info->bBitsPerPixel;
     600    bmpXor.bmBits       = NULL;
     601    ((CURSORICONINFO *)ptr)->hColorBmp =
     602          OSLibWinCreatePointer(info, (char *)lpANDbits, (LPBITMAP_W)&bmpAnd, (char *)lpXORbits, (LPBITMAP_W)&bmpXor, fIcon == FALSE);
     603#endif
    542604    GlobalUnlock( handle );
    543605
     
    549611        return 0;
    550612    }
     613    dprintf(("USER32: CreateCursorIconIndirect returned %x", hIcon));
    551614    return hIcon;
    552615#else
Note: See TracChangeset for help on using the changeset viewer.