TP a écrit :
Yes, it is ...for meOn Tue, Mar 9, 2010 at 3:54 PM, TP <wing...@gmail.com> wrote:On Tue, Mar 9, 2010 at 9:27 AM, Vincent Vande Vyvre <vincent.vandevy...@swing.be> wrote:TP a écrit :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 PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqtSee attachement, it's an images viewer + zoom with QGraphicScene. Before use, change the line 63 Vincent _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqtThank 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? If you resize the current view the degradation is exponantial.Ooops. I meant to say: Instead of scaling (and therefore recreating the Pixmap), one should presumably use the QGraphicsView scale() and translate() methods. If you like mosaics ... It's necessary to re-create the view from the original for each step of zoom. For your second idea, you can change the function like this: def zoom(self, step): w = (1 + self.zoom_step*step) self.view.scale(w, w) and see the result. All the areas with hight contrast are in staircase. I don't say my method is the best way, but is a good compromise between speed and quality. Vincent |
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt