RSS/Atom feed Twitter
Site is read-only, email is disabled

Image scrolling

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Image scrolling Glenn Pierce 14 Dec 13:17
Image scrolling Dov Grobgeld 14 Dec 14:02
  Image scrolling John Cupitt 14 Dec 14:52
Glenn Pierce
2005-12-14 13:17:56 UTC (almost 19 years ago)

Image scrolling

Hi I am wondering if someone can point me to the location in the source code that deals with the main image display / scrolling.

I am creating an image viewer that needs to load very large images of say 6000x6000 pixels and the Gimp is able to scroll these images perfectly, and I am trying to understand how.

My code and GtkImageViewer becomes jerky and slow when scrolling these large images.
Currently I have a large buffer in which I copy sections into, as the user moves to a section not in the buffer I the stretch new image data into this buffer.
Finally I bitbly this buffer onto the window. But when I need to refill this buffer the jerky / slow response is still present.

I can only assume The gimp does something quite clever to solve this. If anyone knows the technique used or could point me to the section of the code that does this I would be very grateful.

Thanks a lot

Glenn.

Dov Grobgeld
2005-12-14 14:02:13 UTC (almost 19 years ago)

Image scrolling

Hi Glenn,

This answer has nothing to do with gimp, but as the author of the GtkImageViewer widget who has dealt with a similar problem - the display of 600MB pbm images - I thought I would tell you about my solution.

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.

Even smooth scrolling worked surprisingly fast. There is a small delay as the disk is accessed, but it is a lot less annoying then the swapping and paging that will take place if you try to read the whole image at once into memory.

Hope this helps. If you want to hear more about this solution, perhaps we should move the discussion to gtk-app or privately, as it has nothing to do with gimp.

Regards, Dov

John Cupitt
2005-12-14 14:52:00 UTC (almost 19 years ago)

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