Re: Gdk::Pixbuf::create_from_data strange behaviour
- From: "Jonathon Jongsma" <jonathon jongsma gmail com>
- To: "Aurélien KAMEL" <aurelien kamel gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Gdk::Pixbuf::create_from_data strange behaviour
- Date: Wed, 10 May 2006 13:56:32 -0500
On 5/10/06, Aurélien KAMEL <aurelien kamel gmail com> wrote:
Hello,
I'm creating a pixbuf from a pixel array like this :
Glib::RefPtr<Gdk::Pixbuf> =
Gdk::Pixbuf::create_from_data(array,Gdk::COLORSPACE_RGB,false,
8,sizeX,sizeY,sizeX*3);
The problem is that if after this call to create_from_data() I do a
free() on the pixel array then the program crash when I try to use
the Pixbuf... If I don't free() the pixel array then I can use my
Pixbuf normally, display it etc.
I believe this is intentional. Consider the use case where you have a
pixel array that is created or managed by a different object, and you
want to use that data with a Gdk::Pixbuf. You want these two
different objects to use the exact same data source so that, for
example, when the other object modifies some of the raw data, it's
also updated in the Pixbuf. At least that's my understanding of this
function.
And, I see that there is a create_from_inline() which take as
argument a bool copy_pixels ? Can I use this function (how?) so that
I can free() the pixel array after Pixbuf was created ?
It looks to me like this function expects the data formatted in a
slightly different way than create_from_data() (see
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGdk_1_1Pixbuf.html#aac78677d8310866334827db2a9f753c).
If you can get your data into that format, you might be able to use
it.
Otherwise, do you need to free the pixel array right away? Maybe you
could use the create_from_data() function that takes a SlotDestroyData
argument. That way you don't have to worry about when to free it
because it will be automatically freed when the pixbuf is destroyed.
Jonner
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]