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

Pixel shift in QGraphicsPixmapItem for several scale

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.13.0 Beta2
    • 5.8.0
    • None
    • Windows 7 32 bits

      QtCreator 4.2.1 with Qt 5.8.0, based on mingw 5.3.0
    • 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
          31 kB
          Mark Hoffmann
        2. graphicsviewNEW.png
          7 kB
          Celine Dalverny
        3. qtbug60782.png
          16 kB
          Allan Sandfeld Jensen
        4. QtBug-60782-pixmapshifted.zip
          536 kB
          Celine Dalverny
        5. QTBUG-60782 Qt4.7.2.png
          20 kB
          Mark Hoffmann
        6. QtSupport2.PNG
          29 kB
          Celine Dalverny
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            celined Celine Dalverny
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes