Pan, Zoom | GTK, QT

One of the selling points for choosing Matlab when implementing the phenological annotation tool was the ease with which one could create pan zoom actions on an image. Now that I have fresh ideas to continue the annotation tool development, I wanted to give other frameworks a try. So I set off to try to implement (or download an implementation) of a pan/zoom mini application. I needed something that could zoom in/out smoothly while at the same time pan the image in whatever zoom level. These two functionalities had to work for images that were a bit on the big side: 22 megs (I know that this is nothing compared to GIS images, but it still needs to be done correctly).

I started with Qt and found an example here. I was very excited to see that it was very smooth on the example. But when I replaced the generated image with one of my 22 meg pictures, I got a disappointing surprise: When scaled out of its original zoom level, the pan and the zoom where very jumpy. I threw all kinds of tricks at it too see if I could make it smoother. Along the way I found some people who were having the same problem (herehere and here). None of those links gave me a solution that was satisfactory.

Today, after getting extremely frustrated with the QT example, I decided to switch to Gtk and see what it had to offer. I manged to create a working example with a very smooth zooming and panning of my 22 meg picture. The code I used is part of the test directory of the GtkImageViewer project. I still have to see how easy it is to place (and keep track) of additional objects in the canvas; but I think that Gtk is the way to go.

About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.
This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Pan, Zoom | GTK, QT

  1. Dov Grobgeld says:

    Nice that you found my gtk image viewer widget. I was in the same situation as you a number of years ago when I found that nothing was fast and smooth enough for me, which is why I wrote my own widget.

    Note that I have recently ported the gtk-image-viewer to Qt, which you may find at https://github.com/dov/Qviv .

    Good luck!

  2. Pingback: Pan, Zoom with Qt | Joel's Blog

Leave a comment