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

Pixel shift in QGraphicsPixmapItem for several scale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.8.0
    • Fix Version/s: 5.13.0 Beta2
    • Labels:
      None
    • Environment:
      Windows 7 32 bits

      QtCreator 4.2.1 with Qt 5.8.0, based on mingw 5.3.0
    • Commits:
      8374b4016e730992ce72e69f81f183c518fdfe2c (qt/qtbase/wip/qt6)

      Description

      Hi,

      I am contacting you about a problem in the QGraphicsView class.

      I display a picture with a QGraphicsScene in QGraphicsView. The picture is added by QGraphicsPixmapItem in ARGB32 format. In this project, I use many various sizes of pictures. With some sizes and some scale values, I note a shift of the pixels. For each pixel from top to bottom ad from left to right, the shift increases, and last pixel in truncated.

      Then , the coordinates of the others objects (Items,Mouse,etc...) in the QGraphicsView are no more aligned with the picture.

      It does not appear all the time, but for some sizes of image, and some scales only. I don't understand why...

      For example:
      Picture size 1000x1000 :
      Scale values with egde problem : 50x50 , 40x40, 30x30, 20x20

      Picture size 50x50:
      Scale values with egde problem : 100x100, 200x200,400x400

      Picture size 1024x1024:
      Scale values with egde problem : 50x50, 30x30

      Picture size 2880x2880
      Scale values with egde problem : 20x20

      I need to know if it's a Qt Bug and if it will be fixed in further version, or if there is any problem in my code. Thank you in advance for your answer I hope as soon as possible .

      Extract of my code:

       

      class Lib_GraphicsView : public QGraphicsView
      {
         QGraphicsScene* m_qgsScene;
         QGraphicsPixmapItem* m_qgpiTotalPixmap;
      }

       

       

      Lib_GraphicsView::Lib_GraphicsView(QWidget *parent) : QGraphicsView(parent)
      {
      m_qgsScene = new QGraphicsScene(this);m_qgpiTotalPixmap = new  QGraphicsPixmapItem;         
      m_qgpiTotalPixmap->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);    setMouseTracking(true);    setTransformationAnchor(QGraphicsView::NoAnchor);     setAlignment(Qt::AlignAbsolute);
      }
      
      void Lib_GraphicsView::LoadFirstPixmap(int ImgIndex)
      {
             m_qgpiTotalPixmap = m_qgsScene->addPixmap(QPixmap::fromImage(QImage(m_pImageRGB,m_dwDataWidth+m_nbLignes,m_dwDataHeight+m_nbLignes,QImage::Format_ARGB32)));
      
          setSceneRect(-250000,-250000,500000,500000);
          setScene(m_qgsScene);
      ...
      }
      
      void Lib_GraphicsView::Zoom(int Value)
      {
      ...
         resetTransform();
         scale(Value, Value);
      ...
      }

       

       

       

        Attachments

        1. 16x32_Scaled_by_24.0.png
          16x32_Scaled_by_24.0.png
          31 kB
        2. graphicsviewNEW.png
          graphicsviewNEW.png
          7 kB
        3. qtbug60782.png
          qtbug60782.png
          16 kB
        4. QtBug-60782-pixmapshifted.zip
          536 kB
        5. QTBUG-60782 Qt4.7.2.png
          QTBUG-60782 Qt4.7.2.png
          20 kB
        6. QtSupport2.PNG
          QtSupport2.PNG
          29 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              allan.jensen Allan Sandfeld Jensen
              Reporter:
              celined Celine Dalverny
            • Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes