VirtualBox

Ignore:
Timestamp:
Sep 1, 2008 4:56:03 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
35824
Message:

FE/Qt4-OSX: First fix for cursors without alpha channel but an bit mask.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp

    r11926 r11942  
    35073507
    35083508        /* Create a ARGB image out of the shape data. */
     3509        /* @todo: The following isn't nice but is working. Will fix this tomorrow. */
    35093510        QImage image  (me->width(), me->height(), QImage::Format_ARGB32);
    35103511        unsigned char alpha;
     3512        const uint8_t *pbSrcMask = (const uint8_t *)srcAndMaskPtr;
     3513        unsigned cbSrcMaskLine = RT_ALIGN(me->width(), 8) / 8;
    35113514        for (unsigned int y = 0; y < me->height(); ++y)
     3515        {
    35123516            for (unsigned int x = 0; x < me->width(); ++x)
    35133517            {
    3514                unsigned int color = ((unsigned int*)srcShapePtr)[y*me->width()+x];
     3518               int i = y*me->width()+x;
     3519               unsigned int color = ((unsigned int*)srcShapePtr)[i];
    35153520               if (me->hasAlpha())
    35163521                   alpha = qAlpha (color);
    35173522               else
    3518                    alpha = 0xff;
     3523               {
     3524//                   alpha = !srcAndMaskPtr[i] ? 0xff : 0x00;
     3525                   if (!(pbSrcMask[x / 8] & (1 << (7 - (x % 8)))))
     3526                       alpha  = 0xff;
     3527                   else
     3528                   {
     3529                       if (qRed (color) == 0xff &&
     3530                           qGreen (color) == 0xff &&
     3531                           qBlue (color) == 0xff)
     3532                       {
     3533                           color = 0;
     3534                           alpha = 0xff;
     3535                       }else
     3536                       {
     3537                           color = 0;
     3538                           alpha  = 0;
     3539                       }
     3540                   }
     3541               }
    35193542               image.setPixel (x, y, qRgba (qRed (color), qGreen (color), qBlue (color), alpha));
    35203543            }
     3544            pbSrcMask += cbSrcMaskLine;
     3545        }
    35213546        /* Invert the mask channel if there is one */
    35223547        QPixmap pixmap (QPixmap::fromImage (image));
    3523         if (!me->hasAlpha())
    3524         {
    3525             uchar* pu8DstData = (uchar*)alloca(me->width() * me->height());
    3526             unsigned int i = 0;
    3527             while (i < me->width() * me->height())
    3528             {
    3529                 pu8DstData[i] = 0xff-srcAndMaskPtr[i];
    3530                 ++i;
    3531             }
    3532             QBitmap bitmap = QBitmap::fromData (QSize (me->width(), me->height()),
    3533                                                 pu8DstData, QImage::Format_Mono);
    3534             /* Set the mask to the pixmap */
    3535             pixmap.setMask (bitmap);
    3536         }
     3548//        if (!me->hasAlpha())
     3549//        {
     3550//            uchar* pu8DstData = (uchar*)alloca(me->width() * me->height());
     3551//            unsigned int i = 0;
     3552//            while (i < me->width() * me->height())
     3553//            {
     3554//                pu8DstData[i] =  !srcAndMaskPtr[i] ? 0xff : 0x00;
     3555//                ++i;
     3556//            }
     3557//            QBitmap bitmap = QBitmap::fromData (QSize (me->width(), me->height()),
     3558//                                                pu8DstData, QImage::Format_Mono);
     3559//            /* Set the mask to the pixmap */
     3560//            pixmap.setMask (bitmap);
     3561//        }
    35373562//        printf ("has alpha %d- %d %d\n", me->hasAlpha(), me->width(), me->height());
    35383563        /* Set the new cursor */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette