Re: gqview image visualization widget in other applications
John Ellis <[email protected]> Wed, 07 Apr 2004 07:50:54 -0400
| Newsgroups | gmane.comp.gnome.apps.gqview.devel |
|---|---|
| Message-ID | <[email protected]> |
DANIELLLANO wrote: > > I'm coding a map viewer in gtk. > Right now it's pretty lame as it only allows to move very slow in the > map. > I'd like the gqview image visualization widget to be usable in my application. > I'd like it to be tile based with a cache (memory and disk). > This way I could pan the image and when there's a need to display a tile > it queries the database. > > Just being able to use the gqview image visualization widget instead of: > http://developer.gnome.org/doc/API/2.0/gtk/GtkImage.html > with > http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/index.html > would be a good start. GQview's image display is designed with a single GdkPixbuf representing the image. For fun, I tried to hack in support for a tile based image representation, the very rough result is available as a patch to GQview 1.5.1, available here: http://gqview.sourceforge.net/gqview_1_5_1_source_tile_patch.tar.gz This is merely a proof of concept, to get the point across that it can be done if someone were to take the time to fix all the bugs I introduced :) About the patch: The archive contains three files: two are the replacements for image.c and typedefs.h; the third, gqview_source_tile_test.patch, is a diff file from the original 1.5.1 source for the first two files. Compiling and running GQview with the patch will result in the image area containing an image 30,000 by 100,000 pixels, composed of a grid of smaller tiles each 640x480. The tiles are created(allocated) when needed for display, the recently created tiles are cached for efficiency. The test_requested_tile_cb() fuction is called when a tile needs to be rendered. This is where the application needs to fill the GdkPixbuf representing the tile. In this example each tile is filled with a random color and some text representing the tile's coordinates. Problems of note: * Slow panning when zoomed in (increasing IMAGE_TILE_SIZE, this is not related to the tiles we are talking about above, will help here) * Memory hog when zoomed out - it needs to keep all visible tiles available in memory, zooming to 1:8 includes a lot of 640x480 tiles scaled to the screen :). * It will crash when the zoom quality is set to nearest, and you zoom in or out a few times, not sure why - the bilinear scaler doesn't have this problem... Greetings, John -- John Ellis <[email protected]> http://gqview.sourceforge.net <GQview> | http://gqapplets.sourceforge.net http://gqmpeg.sourceforge.net <GQmpeg> | <panel applets> ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click