need help for: GnomeCanvasImage



Hello,

I need some help for the use of the GnomeCanvasImage.

First I need a "GdkImlibImage" right ?
  GdkImlibImage *gimg;
  gimg = gdk_imlib_load_image("test.xpm");

Then a "gnome_canvas_item_new" of type "NOME_TYPE_CANVAS_IMAGE":
  GnomeCanvasItem *item2 = gnome_canvas_item_new(gnome_canvas_root(
GNOME_CANVAS(area)),
						 GNOME_TYPE_CANVAS_IMAGE,
						 "image", gimg,
						 "x", 20.0,
						 "y", 20.0,

My (wrong) example, first a test of my GnomeCanvas:

...
  /* pack the table into the scrolled window */
  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
(scrollarea), table);
  
  gtk_widget_push_visual(gdk_imlib_get_visual());
  gtk_widget_push_colormap(gdk_imlib_get_colormap());
  area = gnome_canvas_new();
  gtk_widget_pop_visual();
  gtk_widget_pop_colormap();

  gnome_canvas_set_pixels_per_unit( GNOME_CANVAS(area), 1);
  gnome_canvas_set_scroll_region( GNOME_CANVAS(area),
0.0,0.0,500.0,500.0);

  static double xy[] = { 1.,5.,100.,200. }; 
  static GnomeCanvasPoints pn = { 2, xy, 0 };
  GnomeCanvasItem *iteml = gnome_canvas_item_new(gnome_canvas_root(
GNOME_CANVAS(area)),
			       GNOME_TYPE_CANVAS_LINE,
			       "points",&pn,
			       NULL);
  gtk_timeout_add(300, (GtkFunction) line_loop, iteml); // do some
rotating ...
// this works well.

// Then I like to do something like:
  GdkImlibImage *gimg;
  gimg = gdk_imlib_load_image("test.xpm");
  cout << gimg->rgb_width << " WWW " << gimg->rgb_height << " HHH " <<
endl;

  GnomeCanvasItem *item2 = gnome_canvas_item_new(gnome_canvas_root(
GNOME_CANVAS(area)),
						 GNOME_TYPE_CANVAS_IMAGE,
						 "image", gimg,
						 "x", 20.0,
						 "y", 20.0,
						 //"width", img->rgb_width,
						 //"height", img->rgb_height,
						 //"anchor", GTK_ANCHOR_NORTH_WEST,
						 NULL);

  cout << "Image OK" << endl;
//
  gtk_table_attach( GTK_TABLE(table), area, 1, 2, 1, 2,
		    GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0 );
...

This results in:
-----------
365 WWW 154 HHH 
Image OK

GnomeUI-ERROR **: file gnome-canvas-image.c: line 461
(recalc_if_needed): assertion failed: (image->pixmap != NULL)
aborting...
Aborted
-----------

What is wrong here ?
How I can do it right ?

-- 
with friendly regards / mit freundlichem Gruss,
                   Percy Zahl
Email: zahl@fkp.uni-hannover.de
Dipl.Phys. P.Zahl: http://www.fkp.uni-hannover.de/~zahl/main.html
Institut f"ur Festk"orperphysik, Appelstr. 2, D-30167 Hannover
Tel.Labor: +49 (0)511/762-4825, Fax: -4877



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]