Re: gdk_draw_gray_image crashes



Hi,

I think the problem is that your window doesn't exist yet for your X
server at the time you use gdk_draw_gray_image. Instead, you might
want to use it from a callback for the "expose_event" or the "show"
signals...

W.


Not really. I can extend the example a little further (see below). But the problem is specifically with 
"gdk_draw_gray_image". The "gdk_draw_text" for example works fine in the same place.

Jan

P.S. Again error the code for this example is:
serial 116 error_code 8 request_code 130 minor_code 3


#include <gtk/gtk.h>
#include <gdk/gdk.h>

guchar buf[]={255};  

static gint expose_event (GtkWidget *widget, GdkEventExpose *event)
{
  gint x, y, w, h, rowstride; 
  GdkRgbDither dith; 
  GdkFont* font;
  x = 0; 
  y = 0; 
  w = 1; 
  h = 1; 
  rowstride = 1; 
  dith = GDK_RGB_DITHER_NONE;
 
  font = gdk_font_load("-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
  gdk_draw_text (widget->window,
                 font,
                 widget->style->black_gc,
                 40,
                 40,
                 "Hello",
                 5);
  
  gdk_draw_gray_image(widget->window, 
                      widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                      x,y,w,h,dith,buf,rowstride);
  

  return FALSE;
}

int main(int argc, char **argv)
{
  gint x, y, w, h, rowstride; 
  GtkWidget *window, *drawing_area;

  gtk_init(&argc, &argv);
  gdk_rgb_init();

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  drawing_area = gtk_drawing_area_new ();
  gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
                      GTK_SIGNAL_FUNC (expose_event),
                      NULL);
  
  gtk_container_add (GTK_CONTAINER (window), drawing_area);
  gtk_widget_show(drawing_area);
  gtk_widget_show(window);

  gtk_main();

  return 0;
}

-- 
-----------------------------------------------------------------
    _/_/_/ _/  _/        Jan Boehm  Dipl.-Inform. M.Sc.
   _/_/_/    _/   _/_/   Institut fuer Photogrammetrie
  _/_/_/ _/ _/_/ _/ _/   Universitaet Stuttgart
 _/_/_/ _/ _/   _/_/     Geschwister-Scholl-Str. 24
          _/   _/        D-70174 Stuttgart
-----------------------------------------------------------------
Tel : +49-711-121-4110   Email : jan boehm ifp uni-stuttgart de 
Fax : +49-711-121-3297   WWW   : www.ifp.uni-stuttgart.de
-----------------------------------------------------------------

Attachment: jan.boehm.vcf
Description: Card for Jan Böhm



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