
@c %start of fragment

@node Image Data in Memory
@chapter Image Data in Memory
Creating a pixbuf from image data that is already in memory.

@section Overview
The most basic way to create a pixbuf is to wrap an existing pixel buffer with a
@code{<gdk-pixbuf>} structure. You can use the @code{gdk-pixbuf-new-from-data}
function to do this You need to specify the destroy notification function that
will be called when the data buffer needs to be freed; this will happen when a
@code{<gdk-pixbuf>} is finalized by the reference counting functions If you have
a chunk of static data compiled into your application, you can pass in
@samp{@code{#f}} as the destroy notification function so that the data will not
be freed.

The @code{gdk-pixbuf-new} function can be used as a convenience to create a
pixbuf with an empty buffer. This is equivalent to allocating a data buffer
using @code{@code{malloc}} and then wrapping it with
@code{gdk-pixbuf-new-from-data}. The @code{gdk-pixbuf-new} function will compute
an optimal rowstride so that rendering can be performed with an efficient
algorithm.

As a special case, you can use the @code{gdk-pixbuf-new-from-xpm-data} function
to create a pixbuf from inline XPM image data.

You can also copy an existing pixbuf with the @code{gdk-pixbuf-copy} function.
This is not the same as just doing a @code{g-object-ref} on the old pixbuf; the
copy function will actually duplicate the pixel data in memory and create a new
@code{<gdk-pixbuf>} structure for it.

@section Usage
@include defuns-creating.xml.texi

@c %end of fragment
