What I did is a big project and which handled image is like this
MLGraphicsView
( MLGraphicsScene
* scene,
QWidget * parent
= 0, Qt
::WindowFlags f
= 0 ) ,m_scale(1.0)
{
}
~MLGraphicsView()
{}
protected:
//Take over the interaction
{
// Scale the view / do the zoom
double scaleFactor = 1.5;
if(event->delta() > 0) {
// Zoom in
scale(scaleFactor, scaleFactor);
m_scale *= scaleFactor;
} else {
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
m_scale /= scaleFactor;
}
// some other part
gScene->clear();
QPixmap pixmap
= m_visDocument
->getImag
( camId
);
if( !pixmap )
{
ART_LOG_ERROR( logger, "Camera " << camId << " is empty. " );
continue;
}
gScene->addItem(line);
MLGraphicsView( MLGraphicsScene * scene, QWidget * parent = 0, Qt::WindowFlags f = 0 )
:QGraphicsView( scene )
,m_scale(1.0)
{
setDragMode( QGraphicsView::ScrollHandDrag );
}
~MLGraphicsView()
{}
protected:
//Take over the interaction
virtual void wheelEvent(QWheelEvent* event)
{
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
double scaleFactor = 1.5;
if(event->delta() > 0) {
// Zoom in
scale(scaleFactor, scaleFactor);
m_scale *= scaleFactor;
} else {
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
m_scale /= scaleFactor;
}
// some other part
QGraphicsScene* gScene = this->getView()->scene();
gScene->clear();
QPixmap pixmap = m_visDocument->getImag( camId );
if( !pixmap )
{
ART_LOG_ERROR( logger, "Camera " << camId << " is empty. " );
continue;
}
QGraphicsPixmapItem * qpixmap = gScene->addPixmap( pixmap );
QGraphicsLineItem* line = new QGraphicsLineItem( -size, 0, size, 0 );
gScene->addItem(line);
To copy to clipboard, switch view to plain text mode
what you did is just a 2*2 pixmap and with the same color, you can try load a bigger windows picture, and then zoom it in in bigger levels, maybe you will see what I get.
Like the 1.5^9 = 38.4434 times, that if qt is doing right, 1-38 pixel should be same color, but 39 is random. But in my img you saw, it lookes like 1-25 is sampled correct, 25-38is not. It is obviously wrong!
Bookmarks