yazwas
17th September 2009, 16:26
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
qreal imageCenterX = m_imageItem->x()+ m_imageItem->boundingRect().width()/2;
qreal imageCenterY = m_imageItem->y()+ m_imageItem->boundingRect().height()/2;
m_imageItem->setTransform(QTransform().translate(imageCenterX, imageCenterY).rotate(angle).scale(zoomFactor, zoomFactor).translate(-imageCenterX, -imageCenterY));
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
scaleFactor *= factor;
imageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
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
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
qreal imageCenterX = m_imageItem->x()+ m_imageItem->boundingRect().width()/2;
qreal imageCenterY = m_imageItem->y()+ m_imageItem->boundingRect().height()/2;
m_imageItem->setTransform(QTransform().translate(imageCenterX, imageCenterY).rotate(angle).scale(zoomFactor, zoomFactor).translate(-imageCenterX, -imageCenterY));
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
scaleFactor *= factor;
imageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
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