Re: GdkPixbuf questions



On Wed, 2007-03-21 at 15:50 +0800, s88 wrote:
> First, I'm building a data analyzer under thr Linux, so there is a
> process to generate the data and  my analyzer display the data. 
> My idea is to use a drawable area(I use the GtkDrawingArea) and get
> the pix buffer of it by the gdk_pixbuf_get_from_drawable(), then my
> background program can fill the pix buffer pix by pix. 
> 
> Question 1: anytime I fill to the pixbuf, it will rendering the
> drawing area immediately? 

As Yeti pointed out, there is no such thing as the "pixbuf of the
drawable".  gdk_pixbuf_get_from_drawable() is only to capture a snapshot
of a drawable's current state (it's particularly useful when you're
working with offscreen drawables).

If you want to draw in the drawing area, you can either do what Yeti
suggested, building a pixbuf and drawing it with gdk_draw_pixbuf().
However, unless you must build pixel-by-pixel, this is likely to be
slow.  If you can draw in lines, rectangles, curves, etc., it's probably
better to use the appropriate Cairo calls (or gdk_draw_*(), if you must
target GTK+ < 2.8) in the expose handler of your drawing area, or use
them on an off-screen drawable (GdkPixmap) and then send this to your
drawing area with gdk_draw_drawable() in the expose handler.

- Michael

-- 
Michael Ekstrand
Research Assistant, Scalable Computing Laboratory
Goanna, compute cluster and InfiniBand network monitor tool:
        http://www.scl.ameslab.gov/Projects/Monitor/




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