gdk_draw_gray_image.



I am attempting to draw an image line-by-line from data received one row at
a time. Currently, I am reading the data from a file, one line at a time,
and I either get an empty window that hangs, or a "BadMatch (invalid
parameter attributes)" error: "serial 119  error_code 8  request _code 72
minor_code 0". I know that the error has something to do with the
combination of the imagewidth, imageheight, and stride parameters to
gdk_draw_gray_image(). I used GLADE to create a window and a drawing_area
with an expose_event signal callback (code follows).

gboolean on_drawingarea1_expose_event (GtkWidget *widget, GdkEventExpose
*event, gpointer user_data)
{
  FILE *fd;
  int count=0, i;
  unsigned char inbuf[43];
  guchar *pixbuf;

  /* Data file which is 43 columns wide and very long */
  fd = fopen("datafile.dat", "r");
  /* Read fifty lines of data from file as a test */
  for(i=0; i<50; i++)
  {
    /* Each element in file is an 8-bit grayscale value */
    count = fread(inbuf, sizeof(unsigned char), 43, fd);
    pixbuf = inbuf;
    gdk_draw_gray_image(widget->window,
widget->style->fg_gc[GTK_STATE_NORMAL],
                                      0, i, 43, 1,GDK_RGB_DITHER_NORMAL,
pixbuf, 43);
  }

  return FALSE;

}

I think the problem might be that the function is meant to draw an entire
image at once and fill the drawable space. I have exhausted my resources, so
any insight anyone might provide would be helpful. Thanks.

Lisa



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