[Qt-interest] Interested in Tiling large images
Cole, Derek
dcole at integrity-apps.com
Sat Jun 11 04:42:38 CEST 2011
The more I look at examples, I guess I am leaning towards implementing a separate QGraphicsItem per tile. I do have one question though - if I am first constructing the images, how can I "link" the tiles together, so that when I create say 10 tiles, they are in the right location to make the image look correct? I obviously would need them to oriented in the grid of tiles correctly for the image to be correct. Also, if I move one QGraphicsItem, I need all of them to move in sync so that panning in the scene or moving the entire batch of QGraphicsItems in the scene is continuous.
Is there an easy way to do this, or does each tile just have to know where it is in the grid, and position itself tile_size*tile_number away from the origin?
Thanks
________________________________________
From: Ross Bencina [rossb-lists at audiomulch.com]
Sent: Thursday, June 09, 2011 8:23 PM
To: Cole, Derek
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Interested in Tiling large images
Derek Cole wrote:
> If I am going to implement Tiling from within a
> QGraphicsItem subclass - how could that work?
> I would want to probably pre-load image tiles that
> are just outside the graphics view window, right?
Probably. If you implement things as a cache this would qualify as a
pre-fetching strategy.
I havn't actually implemented exactly what you're looking at, but having
done a few similar things I think it's a good idea to create a layered
implementation where you have a cache of memory-resident tiles keyed by X,Y
and magnification level. If the image isn't in cache, you can request that a
separate worker thread go fetch and decompress/scale it. The rendered needs
to be able to deal with unavailable tiles (perhaps just don't draw them) and
with asynchronous notifications when tiles become available.
Your cache could have a mechanism for requesting pre-fetch of off screen
tiles. You could use reference counting or a LRU queue to work out when to
purge tiles.
> It seems like it would be inefficient to have to
> repaint the entire QGraphicsItem
I'm pretty sure you can perform a partial invalidation by passing a rect to
update()
> essentially if the
> view was zoomed out so far that the entire large
> image(or most of it) fit within the graphics view
It kind of depends how you're going to implement zooming. You probably want
to use a mipmapping strategy where you render lower resolution tiles when
you're zoomed out.
You may want to construct a multi-resolution tree of tiles so that when
you're zoomed out you're only drawing from a low-resolution down-sampled
source.
Check the computer graphics literature for mipmapping and level-of-detail
(LOD) discussions. I think some of the Qt examples implement simple LOD
strategies.
Ross.
More information about the Qt-interest-old
mailing list