Re: [gtkmm] how to free a pixbuf
- From: Silviu D Minut <minutsil cse msu edu>
- To: Simon Fuhrmann <NightSlayer gmx de>
- Cc: <gtkmm-list gnome org>
- Subject: Re: [gtkmm] how to free a pixbuf
- Date: Wed, 15 Oct 2003 10:26:30 -0400 (EDT)
> management. If the RefPtr goes out of scope, the Pixbuf will be freed.
I know. In your example, the RefPtr is a local variable in some function.
In my case, as I mentioned, it is a member in a class, so it does not go
out of scope right after the image has been read.
How else would I be able to re-draw the image on screen upon expose
events, if I didn't keep the pixbuf RefPtr around? I mean, I have
something like this:
class MyClass : public Gtk::Window
{
Glib::RefPtr<Gdk::Pixbuf> pixbuf_;
Gtk::DrawingArea * Darea;
void load_image(const char * file){
pixbuf_=Gdk::Pixbuf::create_from_file(file);
// more stuff
}
void on_Darea_expose_event() {
// display pixbuf_ here, and other stuff
}
};
> /* This is untested. */
> {
> /* Load the first pixbuf */
> Glib::RefPtr<Gdk::Pixbuf> mypixbuf =
> Gdk::Pixbuf::create_from_file("myicon.png");
> /* Load the second pixbuf, the first one gets destroyed automatically */
> mypixbuf = Gdk::Pixbuf::create_from_file("my_new_icon.png");
> } /* mypixbuf gets out of scope and will be destroyed */
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]