Ignore:
Timestamp:
Feb 27, 2004, 8:51:56 PM (21 years ago)
Author:
sandervl
Message:

Fixed mono mouse cursors:

File:
1 edited

Legend:

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

    r9889 r10488  
    1 /* $Id: oslibres.cpp,v 1.37 2003-03-03 16:36:26 sandervl Exp $ */
     1/* $Id: oslibres.cpp,v 1.38 2004-02-27 19:51:56 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    388388    hps = WinGetScreenPS(HWND_DESKTOP);
    389389
    390     if(pXorBits)
     390    if(pXorBits && pXorBmp->bmBitsPixel > 1)
    391391    {//color bitmap present
    392392        RGBQUAD *rgb;
     
    398398
    399399        colorsize = sizeof(BITMAPINFO2) + (pXorBmp->bmHeight * pXorBmp->bmWidthBytes) + rgbsize;
    400         pBmpColor = (BITMAPINFO2 *)malloc(colorsize);
     400        pBmpColor = (BITMAPINFO2 *)calloc(colorsize, 1);
    401401        if(pBmpColor == NULL) {
    402402            DebugInt3();
    403403            return 0;
    404404        }
    405         memset(pBmpColor, 0, colorsize);
    406405        pBmpColor->cbFix            = sizeof(BITMAPINFOHEADER2);
    407406        pBmpColor->cx               = (USHORT)pXorBmp->bmWidth;
     
    415414        rgb                         = (RGBQUAD *)(pXorBits);
    416415
    417 #if 0
    418         if(pXorBmp->bmBitsPixel == 1) {
    419             os2rgb->bRed = os2rgb->bBlue = os2rgb->bGreen = 0;
    420             os2rgb++;
    421             os2rgb->bRed = os2rgb->bBlue = os2rgb->bGreen = 0xff;
    422             os2rgb++;
    423         }
    424         else
    425 #endif
    426416        if(pXorBmp->bmBitsPixel <= 8) {
    427417            for(i=0;i<(1<<pXorBmp->bmBitsPixel);i++) {
     
    434424        }
    435425
    436         if(pXorBmp->bmBitsPixel == 1) {
    437                 //copy Xor bits (must reverse scanlines because origin is top left instead of bottom left)
    438                 src  = (char *)rgb;
    439                 dest = ((char *)os2rgb) + (pXorBmp->bmHeight - 1) * pXorBmp->bmWidthBytes;
    440                 for(i=0;i<pXorBmp->bmHeight;i++) {
    441                     memcpy(dest, src, pXorBmp->bmWidthBytes);
    442                     dest -= pXorBmp->bmWidthBytes;
    443                     src  += pXorBmp->bmWidthBytes;
    444                 }
    445         }
    446         else
    447426        if(pXorBmp->bmBitsPixel == 16) {
    448427                ConvertRGB555to565(os2rgb, rgb, pXorBmp->bmHeight * pXorBmp->bmWidthBytes);
     
    480459    //      &pBmpMask->argbColor[2] which it assumes is 16 colors long. But no proofs.
    481460    masksize = sizeof(BITMAPINFO2) + (pAndBmp->bmHeight * 2 * pAndBmp->bmWidthBytes) + (16+2)*sizeof(RGB2);
    482     pBmpMask = (BITMAPINFO2 *)malloc(masksize);
     461    pBmpMask = (BITMAPINFO2 *)calloc(masksize, 1);
    483462    if(pBmpMask == NULL) {
    484463        DebugInt3();
    485464        return 0;
    486465    }
    487     memset(pBmpMask, 0, masksize);
    488466    pBmpMask->cbFix             = sizeof(BITMAPINFOHEADER2);
    489467    pBmpMask->cx                = (USHORT)pAndBmp->bmWidth;
     
    493471    pBmpMask->ulCompression     = BCA_UNCOMP;
    494472    pBmpMask->ulColorEncoding   = BCE_RGB;
    495     memset(&pBmpMask->argbColor[0], 0, sizeof(RGB2));
     473    memset(&pBmpMask->argbColor[0], 0x00, sizeof(RGB));    //not the reserved byte
    496474    memset(&pBmpMask->argbColor[1], 0xff, sizeof(RGB)); //not the reserved byte
    497     if(pOS2XorBits) {
    498          dest = ((char *)&pBmpMask->argbColor[2]);
    499          memcpy(dest, pOS2XorBits, pAndBmp->bmWidthBytes*pAndBmp->bmHeight);
    500          free(pOS2XorBits);
    501          pOS2XorBits = NULL;
     475
     476    // The mono XOR bitmap must be first in the pointer bitmap
     477    if(pOS2XorBits || pXorBmp->bmBitsPixel == 1)
     478    {
     479        if(pXorBmp->bmBitsPixel == 1)
     480        {
     481            pOS2XorBits = (char *)calloc(pXorBmp->bmHeight, pXorBmp->bmWidthBytes);
     482
     483            //copy Xor bits (must reverse scanlines because origin is top left instead of bottom left)
     484            src  = (char *)pXorBits;
     485            dest = ((char *)pOS2XorBits) + (pXorBmp->bmHeight - 1) * pXorBmp->bmWidthBytes;
     486            for(i=0;i<pXorBmp->bmHeight;i++) {
     487                memcpy(dest, src, pXorBmp->bmWidthBytes);
     488                dest -= pXorBmp->bmWidthBytes;
     489                src  += pXorBmp->bmWidthBytes;
     490            }
     491        }
     492        //else converted bitmap (created by colorToMonoBitmap)
     493
     494        dest = ((char *)&pBmpMask->argbColor[2]);
     495        memcpy(dest, pOS2XorBits, pAndBmp->bmWidthBytes*pAndBmp->bmHeight);
     496        free(pOS2XorBits);
     497        pOS2XorBits = NULL;
    502498    }
    503499    // else Xor bits are already 0
Note: See TracChangeset for help on using the changeset viewer.