PATH:
usr
/
share
/
gtk-doc
/
html
/
gdk-pixbuf
<!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.27 (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 <gdk-pixbuf/gdk-pixbuf.h> </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 <code class="literal">NULL</code> 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 <code class="function">g_object_ref()</code> 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><span class="type">gboolean</span> 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 > 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 > 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 <code class="literal">NULL</code> 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><span class="type">GBytes</span> *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><span class="type">gboolean</span> 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 <span class="type">GBytes</span> 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 <span class="type">GBytes</span></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 > 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 > 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 <span class="type">guchar</span> *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><span class="type">gboolean</span> 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><span class="type">gpointer</span> 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 > 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 > 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 <code class="literal">NULL</code> 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><span class="type">gint</span> data_length</code></em>, <em class="parameter"><code>const <span class="type">guint8</span> *data</code></em>, <em class="parameter"><code><span class="type">gboolean</span> copy_pixels</code></em>, <em class="parameter"><code><span class="type">GError</span> **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 <span class="type">GResource</span> 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"><span class="normal">gdk</span><span class="symbol">-</span><span class="normal">pixbuf</span><span class="symbol">-</span><span class="normal">csource </span><span class="symbol">--</span><span class="normal">raw </span><span class="symbol">--</span><span class="normal">name</span><span class="symbol">=</span><span class="usertype">myimage_inline</span><span class="normal"> myimage</span><span class="symbol">.</span><span class="normal">png</span></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 <code class="literal">FALSE</code> 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 <code class="literal">FALSE</code>, 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"><span class="normal">pixbuf </span><span class="symbol">=</span><span class="normal"> </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="normal"> </span><span class="symbol">(-</span><span class="number">1</span><span class="symbol">,</span><span class="normal"> myimage_inline</span><span class="symbol">,</span><span class="normal"> FALSE</span><span class="symbol">,</span><span class="normal"> NULL</span><span class="symbol">);</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><span class="type">GError</span> return location, may be <code class="literal">NULL</code> 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 <code class="literal">NULL</code> 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 <code class="literal">NULL</code> 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.27</div> </body> </html>
[-] gdk-pixbuf-Reference-Counting-and-Memory-Mangement.html
[edit]
[-] license.html
[edit]
[-] gdk-pixbuf-XlibRGB.html
[edit]
[-] gdk-pixbuf-csource.html
[edit]
[-] gdk-pixbuf-Xlib-Rendering.html
[edit]
[-] gdk-pixbuf-Module-Interface.html
[edit]
[-] gdk-pixbuf-Image-Data-in-Memory.html
[edit]
[-] up-insensitive.png
[edit]
[-] gdk-pixbuf-File-saving.html
[edit]
[-] home.png
[edit]
[+]
..
[-] annotation-glossary.html
[edit]
[-] gdk-pixbuf-X-Drawables-to-Pixbufs.html
[edit]
[-] right-insensitive.png
[edit]
[-] left-insensitive.png
[edit]
[-] gdk-pixbuf-File-Loading.html
[edit]
[-] gdk-pixbuf-gdk-pixbuf-Xlib-initialization.html
[edit]
[-] up.png
[edit]
[-] gdk-pixbuf-query-loaders.html
[edit]
[-] right.png
[edit]
[-] index.html
[edit]
[-] api-index-full.html
[edit]
[-] composite.png
[edit]
[-] rn02.html
[edit]
[-] style.css
[edit]
[-] gdk-pixbuf-Animations.html
[edit]
[-] rn01.html
[edit]
[-] gdk-pixbuf-Versioning.html
[edit]
[-] gdk-pixbuf.devhelp2
[edit]
[-] gdk-pixbuf-gdk-pixbuf-from-drawables.html
[edit]
[-] gdk-pixbuf-Utilities.html
[edit]
[-] gdk-pixbuf-The-GdkPixbuf-Structure.html
[edit]
[-] left.png
[edit]
[-] GdkPixbufLoader.html
[edit]
[-] gdk-pixbuf-gdk-pixbuf-rendering.html
[edit]
[-] gdk-pixbuf-Scaling.html
[edit]
[-] gdk-pixbuf-Inline-data.html
[edit]