Re: Refreshing an Image



Hi,

Matt Sampson <matt met fsu edu> writes:

> First of all I am brand new to GTK+, but not C.  After banging my head
> against a wall for a week I feel I am no closer to a solution, so that's
> why I'm here.  Now that's out of the way... I am trying to write a
> program that will grab an image from file display it then (by using a
> g_timeout_add()) call a function that grabs another image from file and
> display it in the same window as the first image (replacing the first
> image being shown).  So the program is just going to cycle showing a new
> picture every 3 seconds. Similar to looking a radar picture (i.e. it is
> displayed taking up the whole monitor screen and the picture just keeps
> refreshing every second or so showing movement of the front or
> whatever).  I have gotten the program to work very cruedly... I create a
> widget (window), a widget (vbox), and a widget (image).  I assign them
> values using the gtk_*_new() functions. I then gtk_container_add(window,
> vbox), then pack in the image to the vbox.  The only way I could get it
> to grab new pictures and redisplay them was to destroy the window widget
> reassign values to all my widgets and do conatainer add and pack the
> image in the vbox again.  I know this is very crude and I am sure that
> some other functions, or processes will afford me to do this in a better
> way, ie having just the image widget refresh in the window, but I have
> been unable to make it work using gtk_widget_queue_draw(), or about any
> number of other methods, which I admit I don't fully understand, (i.e.
> pixmaps, pixbufs, copying to drawing area, etc.) Sorry for the long
> windedness but I wanted to display exactly what I'm trying to do and the
> only way I could make it work, if anyone can offer advice on how to
> successfully tackle this please advise.  Any help is much appreciated
> and I thank you in advance.

Simply set a new image on the GtkImage widget. You just need to make
sure that your program becomes idle so that the image is actually
redrawn.


Sven



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