Re: how to draw ?


So you have to draw RGB data onto X display? What you need, is
Gtk/Gdk (Gnome display foundation) libraries, and later you can add
Gnome things for extra sugar.

Gtk uses Gdk, that is a bit more convenient than plain X, but
you still have to keep X display model in mind. X deals with
server-side objects, you certainly have video frame in program
adress space.
There is not single best technique, but for 99% of uses you can
just rely on GdkRGB calls, that (if everything goes well) use
fast shared-memory images to transfer data back and forth.

You can draw 3x8 bit pixel RGB image with:

gdk_draw_rgb_image (GdkDrawable *drawable, GdkGC *gc,
                    gint x, y, width, height,
                    GdkRgbDither dith,
                    guchar *rgb_buf,
                    gint rowstride);

There are more in <gdk/gdkrgb.h>

GdkDrawable is just GdkWindow or GdkPixmap (wrappers around XWindow). 
Most often you want to draw into Gtk widget, in which case you should 
use widget's window (widget->window) and keep in mind, that given widget
may allocate smaller area of bigger GdkWindow (look widget->allocation).
GdkGC is wrapper for X graphic context. If not having extra needs,
people often use widget->style->black_gc (it paints only shapes and 
lines black, RGB data will still be in full color).

There is lot more, but most things can be found from any Gtk
tutorial. I.e. you have to create GtkWindow (application main window),
insert some drawing space into it (for example GdkDrawingArea) and so 
But trust me, as soon as you'll get started with your first Gtk
program, thing will become fun :-)

Look at for more information. Gnome is higher-level
layer using Gtk extensively, so Gtk basics are required anyways.

Best wishes,
Lauris Kaplinski

On Mon, 2001-10-01 at 14:34, Samu wrote:
> hi,
> i'm making a program that takes a unknow video format and tries to play it 
> this video has a bitmap so it was easy for me to make a frame, like a ppm
> file.
> Now i would like to play every frame on my X-window box ( have you ever see
> amor ? something like that ) but i don't know where to start to draw it .
> i looked to Xlib but it seem a little difficult.
> i wonder know how i could do with gnome 
> thanks
> Samuele 
> -- 
> Samuele Tonon  <samu linuxasylum net>
> Undergraduate Student  of  Computer Science at  University of Bologna, Italy    
> System administrator at Computer Science Lab's, University of Bologna, Italy  
> Founder & Member of A.A.H.T.
> UIN 3155609 
>           	Acid -- better living through chemistry.
> 			       Timothy Leary
> _______________________________________________
> gnome-devel-list mailing list
> gnome-devel-list gnome org

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