Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Image Data in Memory: GDK-PixBuf Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GDK-PixBuf Reference Manual">
<link rel="up" href="rn01.html" title="API Reference">
<link rel="prev" href="gdk-pixbuf-File-saving.html" title="File saving">
<link rel="next" href="gdk-pixbuf-Inline-data.html" title="Inline data">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#gdk-pixbuf-Image-Data-in-Memory.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="gdk-pixbuf-File-saving.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="gdk-pixbuf-Inline-data.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="gdk-pixbuf-Image-Data-in-Memory"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-pixbuf-Image-Data-in-Memory.top_of_page"></a>Image Data in Memory</span></h2>
<p>Image Data in Memory — Creating a pixbuf from image data that is already in memory.</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()">gdk_pixbuf_new</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-bytes" title="gdk_pixbuf_new_from_bytes ()">gdk_pixbuf_new_from_bytes</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()">gdk_pixbuf_new_from_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()">gdk_pixbuf_new_from_xpm_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-inline" title="gdk_pixbuf_new_from_inline ()">gdk_pixbuf_new_from_inline</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-subpixbuf" title="gdk_pixbuf_new_subpixbuf ()">gdk_pixbuf_new_subpixbuf</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
</td>
<td class="function_name">
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()">gdk_pixbuf_copy</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.description"></a><h2>Description</h2>
<p>The most basic way to create a pixbuf is to wrap an existing pixel
buffer with a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure.  You can use the
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a> 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 <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>
is finalized by the reference counting functions If you have a
chunk of static data compiled into your application, you can pass
in <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> as the destroy notification function so that the data
will not be freed.</p>
<p>The <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()"><code class="function">gdk_pixbuf_new()</code></a> 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 class="function">malloc()</code> and then wrapping it with
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a>. The <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()"><code class="function">gdk_pixbuf_new()</code></a> function will
compute an optimal rowstride so that rendering can be performed
with an efficient algorithm.</p>
<p>As a special case, you can use the <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()"><code class="function">gdk_pixbuf_new_from_xpm_data()</code></a>
function to create a pixbuf from inline XPM image data.</p>
<p>You can also copy an existing pixbuf with the <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()"><code class="function">gdk_pixbuf_copy()</code></a>
function.  This is not the same as just doing a <a href="../gobject/gobject-The-Base-Object-Type.html#g-object-ref"><code class="function">g_object_ref()</code></a>
on the old pixbuf; the copy function will actually duplicate the
pixel data in memory and create a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure for it.</p>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="gdk-pixbuf-new"></a><h3>gdk_pixbuf_new ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_new (<em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                <em class="parameter"><code><span class="type">int</span> width</code></em>,
                <em class="parameter"><code><span class="type">int</span> height</code></em>);</pre>
<p>Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure and allocates a buffer for it.  The 
buffer has an optimal rowstride.  Note that the buffer is not cleared;
you will have to fill it completely yourself.</p>
<div class="refsect3">
<a name="gdk-pixbuf-new.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>colorspace</p></td>
<td class="parameter_description"><p>Color space for image</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>has_alpha</p></td>
<td class="parameter_description"><p>Whether the image should have transparency information</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>bits_per_sample</p></td>
<td class="parameter_description"><p>Number of bits per color sample</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>width</p></td>
<td class="parameter_description"><p>Width of image in pixels, must be &gt; 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>height</p></td>
<td class="parameter_description"><p>Height of image in pixels, must be &gt; 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-new.returns"></a><h4>Returns</h4>
<p> A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> with a reference count of 1, or
<a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if not enough memory could be allocated for the image buffer.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-bytes"></a><h3>gdk_pixbuf_new_from_bytes ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_new_from_bytes (<em class="parameter"><code><a href="../glib/glib-Byte-Arrays.html#GBytes"><span class="type">GBytes</span></a> *data</code></em>,
                           <em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                           <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                           <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                           <em class="parameter"><code><span class="type">int</span> width</code></em>,
                           <em class="parameter"><code><span class="type">int</span> height</code></em>,
                           <em class="parameter"><code><span class="type">int</span> rowstride</code></em>);</pre>
<p>Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> out of in-memory readonly image data.
Currently only RGB images with 8 bits per sample are supported.
This is the <a href="../glib/glib-Byte-Arrays.html#GBytes"><span class="type">GBytes</span></a> variant of <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a>.</p>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-bytes.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>Image data in 8-bit/sample packed format inside a <a href="../glib/glib-Byte-Arrays.html#GBytes"><span class="type">GBytes</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>colorspace</p></td>
<td class="parameter_description"><p>Colorspace for the image data</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>has_alpha</p></td>
<td class="parameter_description"><p>Whether the data has an opacity channel</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>bits_per_sample</p></td>
<td class="parameter_description"><p>Number of bits per sample</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>width</p></td>
<td class="parameter_description"><p>Width of the image in pixels, must be &gt; 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>height</p></td>
<td class="parameter_description"><p>Height of the image in pixels, must be &gt; 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>rowstride</p></td>
<td class="parameter_description"><p>Distance in bytes between row starts</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-bytes.returns"></a><h4>Returns</h4>
<p> A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference count of 1. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-data"></a><h3>gdk_pixbuf_new_from_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_new_from_data (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
                          <em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                          <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                          <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                          <em class="parameter"><code><span class="type">int</span> width</code></em>,
                          <em class="parameter"><code><span class="type">int</span> height</code></em>,
                          <em class="parameter"><code><span class="type">int</span> rowstride</code></em>,
                          <em class="parameter"><code><a class="link" href="gdk-pixbuf-Reference-Counting-and-Memory-Mangement.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
                          <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> destroy_fn_data</code></em>);</pre>
<p>Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> out of in-memory image data.  Currently only RGB
images with 8 bits per sample are supported.</p>
<p>Since you are providing a pre-allocated pixel buffer, you must also
specify a way to free that data.  This is done with a function of
type <a class="link" href="gdk-pixbuf-Reference-Counting-and-Memory-Mangement.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a>.  When a pixbuf created with is
finalized, your destroy notification function will be called, and
it is its responsibility to free the pixel array.</p>
<p>See also <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-bytes" title="gdk_pixbuf_new_from_bytes ()"><code class="function">gdk_pixbuf_new_from_bytes()</code></a>.</p>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p> Image data in 8-bit/sample packed format. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>colorspace</p></td>
<td class="parameter_description"><p>Colorspace for the image data</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>has_alpha</p></td>
<td class="parameter_description"><p>Whether the data has an opacity channel</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>bits_per_sample</p></td>
<td class="parameter_description"><p>Number of bits per sample</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>width</p></td>
<td class="parameter_description"><p>Width of the image in pixels, must be &gt; 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>height</p></td>
<td class="parameter_description"><p>Height of the image in pixels, must be &gt; 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>rowstride</p></td>
<td class="parameter_description"><p>Distance in bytes between row starts</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>destroy_fn</p></td>
<td class="parameter_description"><p> Function used to free the data when the pixbuf's reference count
drops to zero, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the data should not be freed. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>destroy_fn_data</p></td>
<td class="parameter_description"><p> Closure data to pass to the destroy notification function. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="This parameter is a 'user_data', for callbacks; many bindings can pass NULL here."><span class="acronym">closure</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-data.returns"></a><h4>Returns</h4>
<p> A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference count of 1. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-xpm-data"></a><h3>gdk_pixbuf_new_from_xpm_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_new_from_xpm_data (<em class="parameter"><code>const <span class="type">char</span> **data</code></em>);</pre>
<p>Creates a new pixbuf by parsing XPM data in memory.  This data is commonly
the result of including an XPM file into a program's C source.</p>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-xpm-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p> Pointer to inline XPM data. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> zero-terminated=1]</span></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-xpm-data.returns"></a><h4>Returns</h4>
<p> A newly-created pixbuf with a reference count of 1.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-inline"></a><h3>gdk_pixbuf_new_from_inline ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_new_from_inline (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> data_length</code></em>,
                            <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#guint8"><span class="type">guint8</span></a> *data</code></em>,
                            <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> copy_pixels</code></em>,
                            <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<div class="warning">
<p><code class="literal">gdk_pixbuf_new_from_inline</code> has been deprecated since version 2.32 and should not be used in newly-written code.</p>
<p>Use <a href="../gio/GResource.html#GResource-struct"><span class="type">GResource</span></a> instead.</p>
</div>
<p>Create a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> from a flat representation that is suitable for
storing as inline data in a program. This is useful if you want to
ship a program with images, but don't want to depend on any
external files.</p>
<p>gdk-pixbuf ships with a program called <a class="link" href="gdk-pixbuf-csource.html" title="gdk-pixbuf-csource">gdk-pixbuf-csource</a>,
which allows for conversion of <a href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct"><span class="type">GdkPixbufs</span></a> into such a inline representation.
In almost all cases, you should pass the <code class="literal">--raw</code> option to
<code class="literal">gdk-pixbuf-csource</code>. A sample invocation would be:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting">gdk<span class="gtkdoc opt">-</span>pixbuf<span class="gtkdoc opt">-</span>csource <span class="gtkdoc opt">--</span>raw <span class="gtkdoc opt">--</span>name<span class="gtkdoc opt">=</span>myimage_inline myimage<span class="gtkdoc opt">.</span>png</pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>For the typical case where the inline pixbuf is read-only static data,
you don't need to copy the pixel data unless you intend to write to
it, so you can pass <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> for <em class="parameter"><code>copy_pixels</code></em>
.  (If you pass <code class="literal">--rle</code> to
<code class="literal">gdk-pixbuf-csource</code>, a copy will be made even if <em class="parameter"><code>copy_pixels</code></em>
 is <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>,
so using this option is generally a bad idea.)</p>
<p>If you create a pixbuf from const inline data compiled into your
program, it's probably safe to ignore errors and disable length checks, 
since things will always succeed:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting">pixbuf <span class="gtkdoc opt">=</span> <span class="function"><a href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-inline">gdk_pixbuf_new_from_inline</a></span> <span class="gtkdoc opt">(-</span><span class="number">1</span><span class="gtkdoc opt">,</span> myimage_inline<span class="gtkdoc opt">,</span> FALSE<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>For non-const inline data, you could get out of memory. For untrusted 
inline data located at runtime, you could have corrupt inline data in 
addition.</p>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-inline.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>data_length</p></td>
<td class="parameter_description"><p>Length in bytes of the <em class="parameter"><code>data</code></em>
argument or -1 to
disable length checks</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p> Byte data containing a
serialized <a class="link" href="gdk-pixbuf-Inline-data.html#GdkPixdata" title="struct GdkPixdata"><span class="type">GdkPixdata</span></a> structure. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=data_length]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>copy_pixels</p></td>
<td class="parameter_description"><p>Whether to copy the pixel data, or use direct pointers
<em class="parameter"><code>data</code></em>
for the resulting pixbuf</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> return location, may be <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore errors</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-new-from-inline.returns"></a><h4>Returns</h4>
<p> A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference,
count of 1, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if an error occurred.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-subpixbuf"></a><h3>gdk_pixbuf_new_subpixbuf ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_new_subpixbuf (<em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *src_pixbuf</code></em>,
                          <em class="parameter"><code><span class="type">int</span> src_x</code></em>,
                          <em class="parameter"><code><span class="type">int</span> src_y</code></em>,
                          <em class="parameter"><code><span class="type">int</span> width</code></em>,
                          <em class="parameter"><code><span class="type">int</span> height</code></em>);</pre>
<p>Creates a new pixbuf which represents a sub-region of <em class="parameter"><code>src_pixbuf</code></em>
.
The new pixbuf shares its pixels with the original pixbuf, so
writing to one affects both.  The new pixbuf holds a reference to
<em class="parameter"><code>src_pixbuf</code></em>
, so <em class="parameter"><code>src_pixbuf</code></em>
 will not be finalized until the new
pixbuf is finalized.</p>
<p>Note that if <em class="parameter"><code>src_pixbuf</code></em>
 is read-only, this function will force it
to be mutable.</p>
<div class="refsect3">
<a name="gdk-pixbuf-new-subpixbuf.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>src_pixbuf</p></td>
<td class="parameter_description"><p>a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>src_x</p></td>
<td class="parameter_description"><p>X coord in <em class="parameter"><code>src_pixbuf</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>src_y</p></td>
<td class="parameter_description"><p>Y coord in <em class="parameter"><code>src_pixbuf</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>width</p></td>
<td class="parameter_description"><p>width of region in <em class="parameter"><code>src_pixbuf</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>height</p></td>
<td class="parameter_description"><p>height of region in <em class="parameter"><code>src_pixbuf</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-new-subpixbuf.returns"></a><h4>Returns</h4>
<p> a new pixbuf. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-copy"></a><h3>gdk_pixbuf_copy ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *
gdk_pixbuf_copy (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);</pre>
<p>Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> with a copy of the information in the specified
<em class="parameter"><code>pixbuf</code></em>
. Note that this does not copy the options set on the original <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>,
use <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#gdk-pixbuf-copy-options" title="gdk_pixbuf_copy_options ()"><code class="function">gdk_pixbuf_copy_options()</code></a> for this.</p>
<div class="refsect3">
<a name="gdk-pixbuf-copy.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>pixbuf</p></td>
<td class="parameter_description"><p>A pixbuf.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="gdk-pixbuf-copy.returns"></a><h4>Returns</h4>
<p> A newly-created pixbuf with a reference count of 1, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if
not enough memory could be allocated. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
</div>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.other_details"></a><h2>Types and Values</h2>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.see-also"></a><h2>See Also</h2>
<p>gdk_pixbuf_finalize().</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>