Results 1 to 2 of 2

Thread: QPixmap rendering: QTransform adds random shifts

  1. #1
    Join Date
    Jun 2012
    Location
    Austria
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QPixmap rendering: QTransform adds random shifts

    I am rendering a QPixmap and several QPainterPath's through a QPainter object like this:

    Qt Code:
    1. QPainter painter;
    2. painter.begin(this);
    3. painter.setWorldTransform(transf);
    4. painter.drawPixmap(pix->corners, *(pix->pixmap), pix->pixmap->rect());
    5. painter.drawPath(aPaiterPath1);
    6. painter.drawPath(aPaiterPath2);
    7. // more QPaiterPath objects are rendered
    8. painter.setWorldTransform(QTransform());
    9. // paint other stuff
    10. painter.end();
    To copy to clipboard, switch view to plain text mode 

    Between repaints the transformation transf is changed but all other data - especiall the pixmap and the paths - remains untouched.
    I would expect, that the paths keep their relative alignment to the pixmap, no matter what transf is.

    Problem: In certain zoom levels (usually quit large zoom levels, e.g. displaying one pixmap-pixel as about 300x300 screen pixels) the pixmap starts to shift erratically beneath the paths. Maxumin shifts are about plus minus one half of a pixmap-pixel (which translates to 150+ screen pixels !) with no obvioos ralation to the expected position. See the screenshots for reference. The blue and cyan squares are the highly magnified pixels of my pixmap and the thin black line is the path. Actually the diamond shaped path should be perfectly centered within the cyan colored pixel.

    expected: http://image-upload.de/image/SmbrpD/17401b0ea9.png
    faulty: http://image-upload.de/image/pPlNTK/2af9a87d87.png

    I experimented with QPainter::.setRenderHint with no visible change whatsoever.

    Any ideas highly appreciated!
    Last edited by stryga42; 26th June 2012 at 10:23.

  2. #2
    Join Date
    Jun 2012
    Location
    Austria
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap rendering: QTransform adds random shifts

    solved:
    QPainter::setRenderHint(QPainter::SmoothPixmapTran sform, true);
    does solve the issue; my problem was that I called it before QPainter::begin(). If you do it right, it suddenly works :-)

Similar Threads

  1. [ANN] ODB C++ ORM adds support for Qt
    By borisk in forum Qt Programming
    Replies: 0
    Last Post: 28th April 2011, 12:08
  2. Replies: 1
    Last Post: 29th June 2010, 15:59
  3. Replies: 1
    Last Post: 7th April 2010, 16:26
  4. Rendering QGraphicsScene to QPixmap to save
    By Rooster in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2009, 05:24
  5. Text shifts when control appears...
    By MrGarbage in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2008, 03:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.