Changeset 940


Ignore:
Timestamp:
Aug 5, 2011, 1:51:26 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: Fixed assertion in QPixmap::setMask().

The mask size could be different due to incorrect error
handling in QPixmap::fromPmHBITMAP(). It was also
possible that a valid mask HBITMAP were incorrectly
processed. That would result into a QPixmap without a
mask.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/gui/image/qpixmap_pm.cpp

    r690 r940  
    316316    QImage mask;
    317317
    318     if (hbmMask != NULLHANDLE) {
     318    if (hbmMask != NULLHANDLE && GpiQueryBitmapInfoHeader(hbmMask, bmh)) {
    319319        // get the AND+XOR mask
    320         GpiSetBitmap(hps, hbmMask);
    321         mask = QImage(bmh->cx, bmh->cy * 2, QImage::Format_Mono);
    322         bmh->cPlanes = 1;
    323         bmh->cBitCount = 1;
    324         if (GpiQueryBitmapBits(hps, 0, mask.height(), (PBYTE)mask.bits(),
    325                                (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
    326             // take the palette
    327             QVector<QRgb> colors(2);
    328             colors[0] = QRgb(pal[0]);
    329             colors[1] = QRgb(pal[1]);
    330             mask.setColorTable(colors);
    331             // flip the bitmap top to bottom to cancel PM inversion
    332             mask = mask.mirrored(false, true);
    333             // drop the XOR mask
    334             mask = mask.copy(0, 0, mask.width(), mask.height() / 2);
    335             // create a normal mask from the AND mask
    336             mask.invertPixels();
     320        if ((int)bmh->cx == img.width() &&
     321            (int)bmh->cy == img.height() * 2 &&
     322            bmh->cPlanes == 1 && bmh->cBitCount == 1) {
     323            GpiSetBitmap(hps, hbmMask);
     324            mask = QImage(bmh->cx, bmh->cy, QImage::Format_Mono);
     325            if (GpiQueryBitmapBits(hps, 0, mask.height(), (PBYTE)mask.bits(),
     326                                   (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
     327                // take the palette
     328                QVector<QRgb> colors(2);
     329                colors[0] = QRgb(pal[0]);
     330                colors[1] = QRgb(pal[1]);
     331                mask.setColorTable(colors);
     332                // flip the bitmap top to bottom to cancel PM inversion
     333                mask = mask.mirrored(false, true);
     334                // drop the XOR mask
     335                mask = mask.copy(0, 0, mask.width(), mask.height() / 2);
     336                // create a normal mask from the AND mask
     337                mask.invertPixels();
     338            } else {
     339                mask = QImage();
     340            }
     341            GpiSetBitmap(hps, NULLHANDLE);
     342        } else {
     343            Q_ASSERT(false);
    337344        }
    338345    }
Note: See TracChangeset for help on using the changeset viewer.