[Qt-interest] Best way to zoom an image

Mihail Naydenov mlists at ymail.com
Thu Jan 20 20:50:31 CET 2011


To the "have I lost something with the compression to make the smaller image" - 
yes, you do, label has a scaled down version of p.
To "is this this the best way to do it" - probably not for your scenario. You 
should drawPixmap() with scaled painter in some reimplementation of 
paintEvent/paint().
I suggest either using QGraphicasView and reimpl an Item and draw in its paint. 
Or reimpl QWidget and draw in paintEvent if you dont need the whole graphics 
scene.
I either case study both the samples and the demos provided with the sdk. There 
are may drawing related samples there.


thumbs up
MihailNaydenov


>
>From: "Cole, Derek" <dcole at integrity-apps.com>
>To: "Cole, Derek" <dcole at integrity-apps.com>; qt-interest at qt.nokia.com
>Sent: Thu, January 20, 2011 8:29:44 PM
>Subject: Re: [Qt-interest] Best way to zoom an image
>
>RE: [Qt-interest] Best way to zoom an image 
>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/d65cf9b8/attachment.html 


More information about the Qt-interest-old mailing list