1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
|
<!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</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<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.html" title="Inline data">
<meta name="generator" content="GTK-Doc V1.14 (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="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk-pixbuf-file-saving.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK-PixBuf Reference Manual</th>
<td><a accesskey="n" href="gdk-pixbuf-inline.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk-pixbuf-creating.synopsis" class="shortcut">Top</a>
|
<a href="#gdk-pixbuf-creating.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry" title="Image Data in Memory">
<a name="gdk-pixbuf-creating"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-pixbuf-creating.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 valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="gdk-pixbuf-creating.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include <gdk-pixbuf/gdk-pixbuf.h>
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()">gdk_pixbuf_new</a> (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/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>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()">gdk_pixbuf_new_from_data</a> (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/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-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/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-refcounting.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> destroy_fn_data</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()">gdk_pixbuf_new_from_xpm_data</a> (<em class="parameter"><code>const <span class="type">char</span> **data</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a>* <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-inline" title="gdk_pixbuf_new_from_inline ()">gdk_pixbuf_new_from_inline</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> data_length</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint8"><span class="type">guint8</span></a> *data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> copy_pixels</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-subpixbuf" title="gdk_pixbuf_new_subpixbuf ()">gdk_pixbuf_new_subpixbuf</a> (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.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>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()">gdk_pixbuf_copy</a> (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);
</pre>
</div>
<div class="refsect1" title="Description">
<a name="gdk-pixbuf-creating.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-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure. You can use the
<a class="link" href="gdk-pixbuf-creating.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-gdk-pixbuf.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="/usr/share/gtk-doc/html/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-creating.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"><code class="function">malloc()</code></code> and
then wrapping it with <a class="link" href="gdk-pixbuf-creating.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-creating.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-creating.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-creating.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="/usr/share/gtk-doc/html/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-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure for it.
</p>
</div>
<div class="refsect1" title="Details">
<a name="gdk-pixbuf-creating.details"></a><h2>Details</h2>
<div class="refsect2" title="gdk_pixbuf_new ()">
<a name="gdk-pixbuf-new"></a><h3>gdk_pixbuf_new ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * gdk_pixbuf_new (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/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-gdk-pixbuf.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="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorspace</code></em> :</span></p></td>
<td>Color space for image
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>has_alpha</code></em> :</span></p></td>
<td>Whether the image should have transparency information
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>bits_per_sample</code></em> :</span></p></td>
<td>Number of bits per color sample
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>Width of image in pixels, must be > 0
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>Height of image in pixels, must be > 0
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> A newly-created <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> with a reference count of 1, or
<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if not enough memory could be allocated for the image buffer.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="gdk_pixbuf_new_from_data ()">
<a name="gdk-pixbuf-new-from-data"></a><h3>gdk_pixbuf_new_from_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * gdk_pixbuf_new_from_data (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/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-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/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-refcounting.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/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-gdk-pixbuf.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>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Image data in 8-bit/sample packed format
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorspace</code></em> :</span></p></td>
<td>Colorspace for the image data
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>has_alpha</code></em> :</span></p></td>
<td>Whether the data has an opacity channel
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>bits_per_sample</code></em> :</span></p></td>
<td>Number of bits per sample
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>Width of the image in pixels, must be > 0
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>Height of the image in pixels, must be > 0
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>rowstride</code></em> :</span></p></td>
<td>Distance in bytes between row starts
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_fn</code></em> :</span></p></td>
<td>Function used to free the data when the pixbuf's reference count
drops to zero, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the data should not be freed
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_fn_data</code></em> :</span></p></td>
<td>Closure data to pass to the destroy notification function
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> A newly-created <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference count of 1.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="gdk_pixbuf_new_from_xpm_data ()">
<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-gdk-pixbuf.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="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Pointer to inline XPM data.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> A newly-created pixbuf with a reference count of 1.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="gdk_pixbuf_new_from_inline ()">
<a name="gdk-pixbuf-new-from-inline"></a><h3>gdk_pixbuf_new_from_inline ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a>* gdk_pixbuf_new_from_inline (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> data_length</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint8"><span class="type">guint8</span></a> *data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> copy_pixels</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Create a <a class="link" href="gdk-pixbuf-gdk-pixbuf.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>
GTK+ ships with a program called <span class="command"><strong>gdk-pixbuf-csource</strong></span>
which allows for conversion of <a href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbufs</span></a> into such a inline representation.
In almost all cases, you should pass the <code class="option">--raw</code> flag to
<span class="command"><strong>gdk-pixbuf-csource</strong></span>. A sample invocation would be:
</p>
<p>
</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="normal">myimage_inline 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 <a href="/usr/share/gtk-doc/html/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="option">--rle</code> to <span class="command"><strong>gdk-pixbuf-csource</strong></span>, a copy
will be made even if <em class="parameter"><code>copy_pixels</code></em> is <a href="/usr/share/gtk-doc/html/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"><span class="normal">pixbuf </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="gdk-pixbuf-creating.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"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></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="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_length</code></em> :</span></p></td>
<td>Length in bytes of the <em class="parameter"><code>data</code></em> argument or -1 to
disable length checks
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Byte data containing a serialized <a class="link" href="gdk-pixbuf-inline.html#GdkPixdata" title="GdkPixdata"><span class="type">GdkPixdata</span></a> structure
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>copy_pixels</code></em> :</span></p></td>
<td>Whether to copy the pixel data, or use direct pointers
<em class="parameter"><code>data</code></em> for the resulting pixbuf
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>
<a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> return location, may be <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore errors
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> A newly-created <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference,
count of 1, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if an error occurred.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="gdk_pixbuf_new_subpixbuf ()">
<a name="gdk-pixbuf-new-subpixbuf"></a><h3>gdk_pixbuf_new_subpixbuf ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * gdk_pixbuf_new_subpixbuf (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.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>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_pixbuf</code></em> :</span></p></td>
<td>a <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_x</code></em> :</span></p></td>
<td>X coord in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_y</code></em> :</span></p></td>
<td>Y coord in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>width of region in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>height of region in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a new pixbuf
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="gdk_pixbuf_copy ()">
<a name="gdk-pixbuf-copy"></a><h3>gdk_pixbuf_copy ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> * gdk_pixbuf_copy (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);</pre>
<p>
Creates a new <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> with a copy of the information in the specified
<em class="parameter"><code>pixbuf</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>A pixbuf.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> A newly-created pixbuf with a reference count of 1, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if
not enough memory could be allocated.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1" title="See Also">
<a name="gdk-pixbuf-creating.see-also"></a><h2>See Also</h2>
<p>
<code class="function">gdk_pixbuf_finalize()</code>.
</p>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.14</div>
</body>
</html>
|