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

TexturePattern Bitmaps Background color problem

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0 Beta 1
    • 4.7.2
    • GUI: Painting
    • None
    • Windows 7 64bit, Qt 4.7.2, intel core i5 - 6gb ram,
    • b0a6c521ab85ef13ffd39e6502d6ab45dda25d7f

    Description

      When I use a bitmap as a texture pattern, the background is not correctly displayed. When you use a build-in pattern, this is done correctly.

      Here is some code to reproduce the problem:

      Example
      QBitmap bitmap("debug/test.png");
      QBrush brushBitmap(bitmap);
      QRect rect(80,0,160,100);
      QRect rect1(0,10,150,510);
      QRect rect2(160,10,150,510);
       
      painter.setBackgroundMode(  Qt::OpaqueMode );  // Qt::OpaqueMode / Qt::TransparentMode
      painter.setBackground(QColor(0,255,0)); // Background set to green
      painter.setPen(QPen(Qt::black, 1, Qt::SolidLine));
       
      painter.fillRect(rect,QBrush(Qt::red));
       
      painter.setBrush( brushBitmap );
      painter.drawRect(rect1);
       
      painter.setBrush(QBrush(Qt::black, Qt::BDiagPattern));
      painter.drawRect(rect2);
      

      I think the bug is located in the $QTDIR\src\gui\painting\qemulationpaintengine.cpp: 83

      Bug
      void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
      {
          QPainterState *s = state();
      
          if (s->bgMode == Qt::OpaqueMode) {
              Qt::BrushStyle style = brush.style();
              if (style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern)
                  real_engine->fill(path, s->bgBrush);
          }
      ....
      }

      should be

      BugFIX
      void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
      {
          QPainterState *s = state();
      
          if (s->bgMode == Qt::OpaqueMode) {
              Qt::BrushStyle style = brush.style();
              if ((style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern) ||  (style == Qt::TexturePattern ))
                  real_engine->fill(path, s->bgBrush);
          }
      ....
      }
      

      I'm Not experienced enough to know if this is the only change needed to solve the problem. But it solved my case.

      Attachments

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

        Activity

          People

            rodal Samuel Rødal
            fpbosman Frank Bosmans
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes