[Glade-users] images in gnome canvas

chris! chrisjturner at gmail.com
Wed Jan 2 17:57:01 EST 2008


Hi,

I am trying to load an image and then manipulate it with the use of the
gnome canvas but unfortunately i've found it is making my entire program
quite unresponsive and slow. 

I load the pixbuf form a file and then draw it on the canvas in the main
loop;

map = gdk_pixbuf_new_from_file_at_size ("../pixmaps/map_brisbane.png", 900,
900, NULL);
canvMap = gnome_canvas_item_new(gnome_canvas_root(gnomecanvas),
                             GNOME_TYPE_CANVAS_PIXBUF,
				"anchor",GTK_ANCHOR_CENTER,
				"height-in-pixels",0,
				"width-in-pixels",0,
				"x-in-pixels",0,
				"y-in-pixels",0,
				"pixbuf",map,
				"x", (double)300, 
				"y", (double)300,
				"height",(double)600, 
				"width", (double)600,  
				NULL);

I use an idle_callback function to move the image around and i simply change
the pixels per unit to zoom the entire canvas;

	double xvel; //x velocity
	double yvel; //y velocity
	double vel= gtk_range_get_value(lookup_widget(GTK_WIDGET(app1),
"hscale1"));

	xvel = vel*sin(home_head*C_DEG2RAD);
	yvel = vel*cos(home_head*C_DEG2RAD);
	gnome_canvas_item_move(canvMap,xvel/20,yvel/20);

The problem I am having is when the image is enlarged, when I decrease the
size it seems to function normaly again. Also, without the image the program
functions normally so i'm gussing it has something to do with rendering the
pixbuf to the canvas but i'm not too sure what explicitly would be causing
this problem weather it'd be the image itself or an inherent problem with
the gnome canvas or simply me doing something completely wrong. any help
would be greatly appreciated.

Thanks,

Chris
-- 
View this message in context: http://www.nabble.com/images-in-gnome-canvas-tp14572023p14572023.html
Sent from the Gnome - Glade - User mailing list archive at Nabble.com.



More information about the Glade-users mailing list