I load a big picture into QGraphicsView. Then I zoom it to 3x. But it is too slow. Are there some solutions to this problem.
I have to use QImage format in my case.
I load a big picture into QGraphicsView. Then I zoom it to 3x. But it is too slow. Are there some solutions to this problem.
I have to use QImage format in my case.
Divide the image into smaller pieces.
Thanks!
How can divide? Then I need to arrange those small images in a certain order. Could you please give some examples?
Hi,
Have you tried to use OpenGL on the viewport?
Òscar Llarch i Galán
No, I have not tried OpenGL for zooming in QGraphicsView.
When I run OpenGL examples with Ubuntu, I always have the problem:
Xlib: extension "GLX" missing on display ":0.0".
How can I resolve it?
Hi,
You have to install GLX for X Window. It is the openGL eXtension for X Window System.
Òscar Llarch i Galán
Thanks!
I have installed libgl1-mesa-glx and nvidia-glx. But the problems is still there. what else libs should i install?
Hi,
You have installed GLX but I think that you don't have X Window configured to use it. I really don't know how to activate it but you can search it on the web.
Òscar Llarch i Galán
Yes, you then need to arrange items but this is trivial so it should take you no more than 2 minutes to do it - load your image and create items from it where each item contains a 200x200 block of pixels, then set position of the images according to their offsets from the top left corner of the image.
You experience slowdowns because zooming causes your image to be scaled while being painted and because the image is big, it takes time. Furthermore as you zoom in closer and closer, regions of the image are moved out of the viewport but as the image is still one big item, the whole item (hence the whole image) has to be repainted. Dividing into tiles yields two benefits - items scale faster and there are less items to draw as those that move out of the viewport are ignored while updating the view.
This won't change much.
Edit:
Here is something to play with. If you compile it with OpenGL support (qmake QT+=opengl) it will use the OpenGL viewport. Run it without parameters to see the usage help. In general it gives quite nice results for me, the scrolling is smooth while the image is zoomed in. I tested it using images roughly 2000x2000 in size but for bigger images the gain should be even bigger (at the expense of memory usage).
Last edited by wysota; 4th December 2008 at 00:38. Reason: Added the file archive
learning_qt (4th December 2008)
Thanks!
But there is still one problem. When I zoom out, there are always white lines among tiles. I suppose those areas are not covered.
How can we resolve this problem?
You have to implement your own pixmap item. I guess the effect is caused by how QRect works or rounding problems. Providing your own proper implementation of a pixmap item should fix the problem. At worst you can use a bigger overlap between items (I used 1x1 overlap which already helped, if you use 2x2 it should be much better).
Bookmarks