Pavel Strakhov
Pavel Strakhov

Reputation: 40512

Build and draw big image on Qt

My program creates an image using complicated rules, then displays it in QScrollArea. Currently I do it this way:

Is it simpliest way to display generated image?

Now I have a problem. The image can be very large. QImage stores data in memory and can't store big images. I want to store generated image on disk and draw any part of it with any zoom fastly. How can I do this?

Upvotes: 2

Views: 2436

Answers (2)

You probably want to check into this article describing some of the differences between QPixmap and QImage:

http://techbase.kde.org/Development/Tutorials/Graphics/Performance#QPixmap_vs._QImage

If you want to zoom very large images fast, there is a methodology for that, called "Deep Zooming" and "Zoomable User Interfaces" (ZUI):

http://en.wikipedia.org/wiki/Deep_Zoom

QScrollArea is not designed to do this out of the box. I don't know about Qt implementations, but personally I played with an open-source Flash one called OpenZoom. You can see my results:

http://hostilefork.com/2010/09/12/imagination-squared-plus-openzoom/

It would be nice to see someone tackling this in a reusable fashion for Qt.

Upvotes: 3

Raiv
Raiv

Reputation: 5781

the simpliest way to display generated image would be assigning it to QLabel. Use QLabel::SetPixmap() instead of your own widget.

How would I do that task...

First, create many separate images with the good enough size (1024x1024, or even smaller).

After that make a matrix of that images. you may read and write its images to file one-by-one. if you need to display some part of your image - just read needed images from file.

for positioning in file use simple lookup table, with fields like xId yId offset length

To work with zoom fast - just add more matrixes - next one should be two times smaller then base, and so on, until you has single image left(for the most far zoom).

Upvotes: 1

Related Questions