Problem adding GdkRGB access to backing pixmap in scribble-simple





Hi,

All/most/some of you know the scribble-simple example
program supplied with the GTK distribution. I've been
playing around with the code, trying to write to the
pixmap buffer using GdkRGB, but have so far only managed
to produce core dumps. I tried to change the function
draw_brush to the following (my changes are between
the // RNG comments):


static void
draw_brush (GtkWidget *widget, gdouble x, gdouble y)
{
     GdkRectangle update_rect;
     // RNG
     char      buf[200*3];
     char val=0;
     int  i;
     // RNG end

     update_rect.x = x - 5;
     update_rect.y = y - 5;
     update_rect.width = 10;
     update_rect.height = 10;
     gdk_draw_rectangle (pixmap, widget->style->black_gc,
          TRUE, update_rect.x, update_rect.y,
          update_rect.width, update_rect.height);

     // RNG
     for (i=0; i<200*3; i++)
          {
          val = (val + ((val + (rand () & 0xff)) >> 1)) >> 1;
          buf[i]=val;
          }
     gdk_draw_rgb_image (pixmap,
          widget->style->black_gc,
          0, y-10, 200, 1, GDK_RGB_DITHER_NONE, buf, 200*3);
     update_rect.x = 0;
     update_rect.y = 0;
     update_rect.width = 200;
     update_rect.height = 200;
     // RNG end

     gtk_widget_draw (widget, &update_rect);
}

Unfortunateley, this dumps core. gdk_draw_rgb_image expects a
drawable but doesn't seem to like being passed a pixmap. Is
drawing to a pixmap via GdkRGB functions possible at all?
draw_point is very slow and I'd like to use something
faster ...

Thanks
--> Robert




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