Hi,
First of all, I have seen similar questions in this forum, but I didn't find the answers I was looking for (or maybe I didn't understand the solution).
Ok, now to the question -
I have a QLabel, whose size and location (coordinates) are fixed, and I need to display a image in it. This image can be zoomed/width fitted/page fitted/original view, and if the image is larger than the QLabel, I need to give options to move the image on press of some up/down/left/right QButtons. (exact scenario is that after a Scan, preview image is displayed on our panel, and that needs to be zoomed/panned)
I have been able to do the zoom stuff by using scaled/scaledToWidth/scaledToHeight, but I am having problems in moving/panning the image (QPixmap).
This is my code for down button
mut->lock(); //mutex, just for some test
const QPixmap *p1
=label
->pixmap
();
//label is the QLabel object. This is more of a hit and trial code, and this part was giving some compilation issue with constructor, so the code is written like this p->scroll(0,-10,label->rect(),&exposed);
label->setPixmap(*p);
mut->unlock();
mut->lock(); //mutex, just for some test
QRegion exposed;
const QPixmap *p1=label->pixmap(); //label is the QLabel object. This is more of a hit and trial code, and this part was giving some compilation issue with constructor, so the code is written like this
QPixmap *p=new QPixmap(*p1);
p->scroll(0,-10,label->rect(),&exposed);
label->setPixmap(*p);
mut->unlock();
To copy to clipboard, switch view to plain text mode
But the problems I am getting are that
1) when I press buttons fast, there is some sort of banding (part of image repeating on one end).
2) I cannot specify any offset using the scroll function, as the image is scrolled only in the QPixmap rect area (not the QLabel area). So the image is not actually moved to the offset. I have attached screenshot for the same
qpixmap.jpg
Can someone let me know a better way to do this image panning? (My base QLabel cannot be moved or resized, as that is the preview area)
Thanks in advance
Ash
Bookmarks