[Qt-interest] Best way to zoom an image

Cole, Derek dcole at integrity-apps.com
Thu Jan 20 19:29:44 CET 2011


I also wanted to point out, that I used a label to display my image based on something I read online as being the most common way. 

My end goal is to create sort of a canvas where I can zoom in on any part of the image (under the mouse preferrably), track the location I am zoomed into relative to the real image (in other words maybe now (0,0) of my label matches up to (451,619) of my original image). I would also like to be able to draw a rectangle over a portion of the scaled image, and then zoom in to that portion, again, tracking where I am in the zoomed image relative to the original.

If all that isnt possible using my current configuration, please advise

Thanks

Derek

-----Original Message-----
From: qt-interest-bounces+dcole=integrity-apps.com at qt.nokia.com on behalf of Cole, Derek
Sent: Thu 1/20/2011 1:22 PM
To: qt-interest at qt.nokia.com
Subject: [Qt-interest] Best way to zoom an image
 

Hello,

I have created a label that is containing a Pixmap of an image that is much larger than the label, so I did some work to try to scale the image:

    QPixmap p(QPixmap::fromImage(*qi,Qt::AutoColor));
    QPixmap p1(p.scaled(ui->viewLabel->width(),ui->viewLabel->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation ));
    ui->viewLabel->setPixmap(p1);
    ui->viewLabel->setFixedHeight(p1.height());
    ui->viewLabel->setFixedWidth(p1.width());

I guess my question is, if I wanted to get that pixmap p1 from the label, with something like "viewLabel->pixmap()", can I now scale that image back to its original size, or have I lost something with the compression to make the smaller image when I first scaled p1?

In other words, if I was to zoom "all the way in" on viewLabel's pixmap, would I then be able to zoom all the way back out and see my full, unaltered image?

If not, what is the best way to do this? I basically want to load my image, and then use the mouse wheel to zoom in and out on the image, always keeping the same level of image quality

Thanks

Derek

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110120/5c8759ad/attachment.html 


More information about the Qt-interest-old mailing list