Image scrolling
On 12/14/05, Dov Grobgeld wrote:
The solution only works for uncompressed images. I did not load the
whole image into memory at all, but used the view_changed signal
callback of the GtkImageViewer for fetching a rectangle of data from
the disk which is then immediately displayed. Zoomed out data was
created on the fly as well by reading from the disk and downscaling in
one go.
I do something similar in my application, but maybe even simpler.
Put a drawing area inside a scrolled window, size the drawing area to
6000x6000 (or whatever) connect to the "expose" event, and in the
handler calculate the pixels for that rectangle (perhaps by reading
them from the disc) and paint them to the screen.
I made it a bit smoother by having the expose handler just paint a
background pattern, and then add the exposed area to a list of pending
repaints. A background thread calculates pixels and when they are
ready, it redraws that part of the screen.
I can zoom and pan around 10GB images quite quickly. The only problem
is with win32 GTK: It currently has a limit of 32k by 32k pixels for a
scrolled window :-(
The program and source are here if you're curious:
http://www.vips.ecs.soton.ac.uk
John