<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
TP a écrit :
<blockquote
cite="mid:fe0b845a1003091557m158cc73apa59372eae1ed498c@mail.gmail.com"
type="cite">
<pre wrap="">On Tue, Mar 9, 2010 at 3:54 PM, TP <a class="moz-txt-link-rfc2396E" href="mailto:wingusr@gmail.com"><wingusr@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On Tue, Mar 9, 2010 at 9:27 AM, Vincent Vande Vyvre
<a class="moz-txt-link-rfc2396E" href="mailto:vincent.vandevyvre@swing.be"><vincent.vandevyvre@swing.be></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">TP a écrit :
</pre>
<blockquote type="cite">
<pre wrap="">I'm using Windows XP, Python 2.6.4, and PyQt 4.7.1.
While trying out the example
C:\Python26\Lib\site-packages\PyQt4\examples\widgets\imageviewer.pyw,
I notice that the more I zoom into an 1553x2653 B&W PNG image, the
longer it takes to display. This becomes unacceptably long (on the
order of a few seconds) at the not so high 3x zoom factor.
Intuitively, I would have thought it would be *faster* since the more
I zoom in the fewer image pixels need to be displayed. I think what's
happening is the entire QLabel widget is getting enlarged then
cropped, rather than just displaying a sub-portion of the image:
def scaleImage(self, factor):
self.scaleFactor *= factor
self.imageLabel.resize(self.scaleFactor *
self.imageLabel.pixmap().size())
I want to create an app to help people explore various image
processing operations. Fast & flexible image display is essential.
Some features I like to have:
* Zoom In/Out quickly. I can see zooming *out* being slower since more
image pixels would be involved. Once past the 1x zoom-in factor, I'd
rather have the pixels as raw as possible to avoid blurring edges
like the Image Viewer example currently does.
* Compare transformations by having multiple views of images that are
synchronized as to pan position and zoom factor. Dragging the mouse
in any of the views should pan all the views.
* Multi-screen support.
I started off by modifying the PyQt4 Image Viewer example, but now I'm
having second thoughts. Should I really be basing my Image Viewer on a
QLabel?
Should I instead be using a QGraphicsView (even though I'll probably
only have a single image, not lots of 2D objects)?
Maybe I should use a QGLWidget (I'd rather not).
Or perhaps I have to write my own custom widget and draw using a
QPainter object?
Any tips or pointers to other PyQt-based Image Viewers would be
appreciated.
_______________________________________________
PyQt mailing list <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a>
</pre>
</blockquote>
<pre wrap="">See attachement, it's an images viewer + zoom with QGraphicScene.
Before use, change the line 63
Vincent
_______________________________________________
PyQt mailing list <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a>
</pre>
</blockquote>
<pre wrap="">Thank you. Your example does indeed zoom in/out quickly.
However, delving into it I see it basically doing something like this:
scaledPixmap = pixmap.scaled(newWidth, newHeight,
QtCore.Qt.KeepAspectRatio,
QtCore.Qt.FastTransformation)
self.scene.clear()
self.scene.setSceneRect(0, 0, newWidth, newHeight)
self.scene.addPixmap(scaledPixmap)
And if I change QtCore.Qt.FastTransformation to
QtCore.Qt.SmoothTransformation things become as slow as using a
QLabel.
It seems to me that doing things this way completely ignores the
advantage of using a QGraphicsScene? Instead of scaling (and therefore
recreating the Pixmap), one should presumably use the QGraphicsScene scale() and
translate() methods.
Anyway, my original question remains. Is the best approach to use a
QGraphicsView or one of the other options previously mentioned?
</pre>
</blockquote>
</blockquote>
Yes, it is ...for me<br>
<blockquote
cite="mid:fe0b845a1003091557m158cc73apa59372eae1ed498c@mail.gmail.com"
type="cite">
<blockquote type="cite">
<pre wrap="">
</pre>
</blockquote>
<pre wrap=""><!---->
Ooops. I meant to say:
Instead of scaling (and therefore recreating the Pixmap), one should
presumably use the QGraphicsView scale() and translate() methods.
</pre>
</blockquote>
If you resize the current view the degradation is exponantial.<br>
If you like mosaics ...<br>
<br>
It's necessary to re-create the view from the original for each step of
zoom.<br>
<br>
For your second idea, you can change the function like this:<br>
<br>
def zoom(self, step):<br>
w = (1 + self.zoom_step*step)<br>
self.view.scale(w, w)<br>
<br>
and see the result.<br>
All the areas with hight contrast are in staircase.<br>
<br>
I don't say my method is the best way, but is a good compromise between
speed and quality.<br>
<br>
Vincent<br>
</body>
</html>