Re: [gtk-list] Newbie plotting question



>>>>> "SA" == Square Avenue <dfinton@d.umn.edu> writes:

  SA> I'm just learning GTK+ and I figured the best way to learn it
  SA> was by the "Trial by Fire": creating a simple widget.

  SA> Armed with nothing but the on-line GTK tutorial (somewhat out of
  SA> date) and the source code, I tried something that I thought
  SA> would be relatively simple: A modified Drawing Area widget where
  SA> my program can write to, a pixel at a time, in any color I want.

I found the easiest way to do this was to do something like this in
the configure_event:


picture = gdk_image_new(GDK_IMAGE_FASTEST, visual, 320, 240);
gdk_draw_image(picture_window, gc, picture, 0, 0, 0, 0, 320, 240);

Where picture_window is my drawing area, gc is the window's
style->black_gc, and visual is grabbed with gdk_visual_get_best() or
it's friends. Then, to draw a pixel:

pixel = gdk_color_context_get_pixel(cc, r, g, b, &failed);
gdk_image_put_pixel(picture, i, j, pixel);

and then another call to gdk_draw_image() to commit the draw.

It works for me, anyways :)

Of course, I'm a newbie too, so there may be much better ways to do
it.

-Larry

-- 
  Larry Daffner        |  Linux: Unleash the workstation in your PC!
  vizzie@airmail.net / http://web2.airmail.net/vizzie/
It is important to keep an open mind, but not so open that your brains fall
out.  --Stephen A. Kallis, Jr.



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