Memory management with GdkPixbuf
- From: "Luis M. Fuentes" <luis fuentes gmx co uk>
- To: gtk-app-devel-list gnome org
- Subject: Memory management with GdkPixbuf
- Date: Tue, 30 Sep 2003 13:04:25 +0200
Hi!
I am developing an image processing application under GTK. I've just migrated
from Windows-based Visual studio, so my knowledge of GTK+ is very reduced.
I am using the GdkPixbuf function
wPixbuf = gdk_pixbuf_new_from_file ( path , NULL ) ;
to read jpeg files as follows. After copying the image bytes, I try to
liberate the memory with
g_object_unref (wPixbuf);
but checking the system memory it's clear that the program is not freeing the
allocated memory and because I work with video sequences, it ens up running
out of memory. Could anyone possibly tell me what I'm doing wrong? Thak you
for your help!!
Luis
PD: Here is the complete code of the function
bool Image::loadImage ( const char *path )
{
gint nrws , nysz ;
if ( g_file_test (path, G_FILE_TEST_EXISTS) != TRUE ) return false ;
GdkPixbuf *wPixbuf = gdk_pixbuf_new_from_file ( path , NULL ) ;
if ( wPixbuf == NULL ) return false ;
nrws = gdk_pixbuf_get_rowstride (wPixbuf) ;
nysz = gdk_pixbuf_get_height (wPixbuf) ;
if ( nrws != rws || nysz != ysz )
{
xsz = gdk_pixbuf_get_width (wPixbuf) ;
ysz = nysz ; rws = nrws ;
nch = gdk_pixbuf_get_n_channels (wPixbuf) ;
bps = gdk_pixbuf_get_bits_per_sample (wPixbuf) ;
imgbsz = (glong)(rws) * ysz ;
if ( pixBuf != NULL ) g_free((gpointer)(pixBuf)) ;
}
pixBuf = (guchar*) g_memdup (
(gconstpointer)gdk_pixbuf_get_pixels(wPixbuf),imgbsz) ;
g_string_assign (fileN,path);
g_object_unref (wPixbuf);
if ( pixBuf == NULL ) return bready=false ;
return bready=true ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]