[Qt-interest] Interested in Tiling large images

Ross Bencina rossb-lists at audiomulch.com
Fri Jun 10 02:23:12 CEST 2011


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