Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-14784

QPixmap loses mask on scaling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Not Evaluated Not Evaluated
    • 4.7.2
    • 4.7.0
    • GUI: Painting
    • None
    • X11, RHEL4.6,

      The following code:

               pixmap.setMask(pixmap.createMaskFromColor(QColor(255,0,255)));
               QPixmap scaled_pixmap = pixmap.scaled(scaled_width, scaled_height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
      

      worked correctly in Qt 4.6 to generate a scaled pixmap with the mask in tact. In 4.7, the resulting bitmap has no transparency when used.

      The problem also occurs when using QIcon with a QPixmap with a mask.

      The following work-around works OK to generate a scaled, transparent pixmap:

              QBitmap mask = pixmap.createMaskFromColor(QColor(255,0,255));
              pixmap.setMask(mask);
              QPixmap transparent_pixmap(pixmap.size());
              transparent_pixmap.fill(QColor(255, 255, 255, 0));
              QPainter painter(&transparent_pixmap);
              painter.drawPixmap(0, 0, pixmap);
              painter.end();
              QPixmap scaled_pixmap = transparent_pixmap.scaled(scaled_width, scaled_height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            rodal Samuel Rødal
            mturnidge Martin Turnidge
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes