[Gtk-sharp-list] Best way to continuously update a Gtk.Image (V4L)
Sebastian
scut@nb.in-berlin.de
Sat, 17 Apr 2004 12:47:37 +0800
Hi everybody,
I am really happy that Debian/sid now has up to date gtk# packages (thanks
to Mr. Bloch) and it is really fun to code with gtk#. Thanks gtk# guys! :)
I am planning to use Gtk# as GUI framework for a video4linux related
application. I use a small C glue to the v4l interface and a Gdk.Pixbuf
within Gtk.Image to display a continously updated image.
Currently, it looks like this, within Main() of my test application:
...
vl.StartCapture ();
while (true) {
vl.GetFrame ();
conv.ConvertCurrentFrame ();
img.QueueDraw ();
// Free frame buffer and process GTK events, because we have some
// free time now until the next frame is catched.
vl.FreeFrame ();
while (Application.EventsPending ())
Application.RunIteration ();
}
...
The conv.ConvertCurrentFrame function just overwrites/updates the Pixels
array within the Gdk.Pixbuf that is displayed by the GUI and then calls a
QueueDraw on the wrapped Gtk.Image.
The while loop is from the Gtk# documentation, albeit I think its not the
normal usage here.
Now, here come the questions:
1. Is just overwriting the Pixbuf byte array and queuing a redraw the
proper way or may this pointer change somehow?
2. How to call this from the Gtk# main loop? There is no main loop at the
moment, and if I try to close the window, I get this message:
(<unknown>:1970): Gtk-CRITICAL **: file gtkmain.c: line 1151
(gtk_main_quit): assertion `main_loops != NULL' failed
I do not want the user to have to click a start-button or the like.
3. As the GetFrame() function in my glue calls an ioctl that blocks, I will
have to run it in another thread. Is it still ok for Gtk# to just let
this thread continuously overwrite the Pixels array? How to call the
QueueDraw method so it is queued within the Gtk# mainloop thread and not
the ioctl-thread?
Thanks for bearing with my newbie questions in advance,
Sebastian
--
|\ _,,,--,,_ ,) scut@nb.in-berlin.de, http://segfault.net/~scut/pgp
/,`.-'`' -, ;-;;' 5453 AC95 1E02 FDA7 50D2 A42D 427E 6DEF 745A 8E07
_ |,4- ) )-,_ ) /\__________________________________________________________
~'---''(_/--' (_/-'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~