gdk_pixbuf_loader_write memory leak
- From: milton soto <miltonpsoto yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: gdk_pixbuf_loader_write memory leak
- Date: Mon, 1 Dec 2003 18:36:30 -0800 (PST)
Hello
I desperately need some help.
The following coded works, but has a memory leak.
Code Description:
The coded will get a raw gray picture from a camera every
30 millisecond . Each image is converted into a jpeg image
(raw_to_jpeg). The jpeg image is then loaded into the loader,
passed to the pixbuf, and render to the display window.
Any help will be gladly appreciated.
Also, is this the quickest way to display a jpeg image???
Any other examples would be appreciated.
Thank You
Milton Soto
miltonpsoto yahoo com
static gboolean update_display (gpointer user_data)
{
// Get a raw gray picture from the camera size 640*480
getframe(0x01, 1, 0, 0, 640, 480, gray_Image.data, 640*480,
"Grey");
// Convert the raw picture from camera to a jpeg image
raw_to_jpeg(&gray_Image,&jpeg_Image);
loader = gdk_pixbuf_loader_new();
// Load the converted jpeg image from the jpeg_Image.data buffer
if (!gdk_pixbuf_loader_write(loader, jpeg_Image.data,
jpeg_Image.size,&err))
g_warning("Loader write failed!!");
loader_pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
gdk_pixbuf_loader_close(loader,&err);
gdk_pixbuf_ref(loader_pixbuf);
gdk_pixbuf_render_to_drawable(loader_pixbuf,
display_area->window,display_area->style->fg_gc[GTK_STATE_NORMAL], 0,
0, 0, 0, 640, 480, GDK_RGB_DITHER_NONE, 0, 0);
gdk_pixbuf_unref(loader_pixbuf);
}
static void CloseTheApp ( GtkWidget * window, gpointer data )
{
gdk_pixbuf_loader_close(loader,&err);
gtk_main_quit ();
}
int
main (int argc, char *argv[])
{
gtk_init (&argc, &argv);
gdk_rgb_init();
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
display_area = gtk_drawing_area_new();
gtk_drawing_area_size (GTK_DRAWING_AREA (display_area), 640, 480);
gtk_container_add (GTK_CONTAINER (main_window), display_area);
g_signal_connect (G_OBJECT ( main_window ), "destroy", G_CALLBACK (
CloseTheApp ), NULL);
gtk_widget_show_all (main_window);
g_timeout_add (30, (GtkFunction) update_display, NULL);
gtk_main();
}
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]