Results 1 to 3 of 3

Thread: QGraphicsPixmapItem zoom out loses percision

  1. #1
    Join Date
    Jul 2009
    Location
    Jordan, and UAE
    Posts
    55
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsPixmapItem zoom out loses percision

    Hello everyone,

    I've created an application that uses QGraphicsView & QGraphicsScene, and I've subclassed a QGraphicsPixmapItem,

    The application loads an image, around 5 mb of size, it is very fast when it comes to zooming in/out or rotating, but the problem with zooming out is that the image seems to loose precision, and I cant read the lines written anymore


    I do the scaling using the following code
    Qt Code:
    1. qreal imageCenterX = m_imageItem->x()+ m_imageItem->boundingRect().width()/2;
    2. qreal imageCenterY = m_imageItem->y()+ m_imageItem->boundingRect().height()/2;
    3.  
    4.  
    5. m_imageItem->setTransform(QTransform().translate(imageCenterX, imageCenterY).rotate(angle).scale(zoomFactor, zoomFactor).translate(-imageCenterX, -imageCenterY));
    To copy to clipboard, switch view to plain text mode 

    I've looked at the image viewer application example from Qt 4.5 examples, their code does a very good zooming in/out, and it keep the precision excellent, they use QLabel to load the QPixmap object, but its very very slow in zooming

    Qt Code:
    1. scaleFactor *= factor;
    2. imageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
    To copy to clipboard, switch view to plain text mode 

    I've attached a sample pmb to show the difference between my app, and the image viewer app

    mine is the one on the left (least precision), and image viewer is the right one

    any comment is more than welcome

    Best regards
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsPixmapItem zoom out loses percision

    did you use QGraphicsPixmapItem::setTransformationMode() with Qt::SmoothTransformation and/or QGraphicsView::setRenderHints() with QPainter::Antialiasing | QPainter::SmoothPixmapTransform?

  3. #3
    Join Date
    Apr 2008
    Posts
    45
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsPixmapItem zoom out loses percision

    Quote Originally Posted by Lykurg View Post
    did you use QGraphicsPixmapItem::setTransformationMode() with Qt::SmoothTransformation and/or QGraphicsView::setRenderHints() with QPainter::Antialiasing | QPainter::SmoothPixmapTransform?
    These should do it. IIRC, SmoothPixmapTransform is not default.

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.