Nyaruko
Nyaruko

Reputation: 4479

Qt: pull a section of image data on the fly

I have a very large image(10000*10000) and for several reasons I cannot modify it (like chop it into smaller tiles.)

I don't want to display the whole image but a small section of it to improve the GUI efficiency. But when the user click and drag it around, new part of image will be displayed in the viewport. So, how could I pull a section of image data on the fly?

Upvotes: 0

Views: 89

Answers (1)

dtech
dtech

Reputation: 49289

I don't recall Qt providing any support for working with partial images in case of really high resolutions. Maybe look into libtiff.

Basically, the image will be composed of either strips or tiles, so you can use the tiffreadscanline() or tiffreadencodedstrip() respectively to load portions of the image. The from that you can compose another image with the appropriate resolution for your viewport.

Alternatively, you could take a look at the QTiffHandler class, it is a private class in Qt so it is not directly accessible, but you could just copy it and if necessary modify the source to expose its functionality. Internally it uses libtiff as well.

Upvotes: 1

Related Questions