reload image from a file into a pixbuffer



Hi,

a very simple question.... but I cannot find an answer in the api.... How do
I load a picture from a file into a pixbuffer? I tried with g_timeout_add
and using the following code (which obviously not only does not work but has
memory leak problems)....

gboolean
draw_image()
{
 GdkPixbuf *arena;
 GString *str = g_string_new("");

 if (Counter % 2)
     g_string_assign(str, "img1.jpg");
 else
     g_string_assign(str, "img2.jpg");
 arena = gdk_pixbuf_new_from_file(str->str, NULL);
 gtk_widget_set_size_request(lookup_widget(RootWindow,
"drawingareaDisplay"), gdk_pixbuf_get_width(arena),
gdk_pixbuf_get_height(arena));
 Counter++;
 g_string_free(str, TRUE);
 return TRUE;
}

Any help please? Thanks.
--
-- Yianni



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