alternative to assert
[gtkD.git] / gtkD / src / gdk / Pixbuf.d
blobf2ac23d1e27b969377819d8accdfbbb810ca4189
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-Pixbufs.html
26 * outPack = gdk
27 * outFile = Pixbuf
28 * strct = GdkPixbuf
29 * realStrct=
30 * ctorStrct=
31 * clss = Pixbuf
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_pixbuf_
40 * - gdk_pixbuf_
41 * omit structs:
42 * omit prefixes:
43 * - gdk_pixbuf_ref
44 * - gdk_pixbuf_unref
45 * omit code:
46 * - gdk_pixbuf_get_from_drawable
47 * imports:
48 * - glib.Str
49 * - glib.Str
50 * - gdkpixbuf.PixbufFormat
51 * - gdk.Drawable
52 * - gdk.Bitmap
53 * - gdk.Colormap
54 * - gdk.ImageGdk
55 * structWrap:
56 * - GdkBitmap* -> Bitmap
57 * - GdkColormap* -> Colormap
58 * - GdkDrawable* -> Drawable
59 * - GdkImage* -> ImageGdk
60 * - GdkPixbuf* -> Pixbuf
61 * - GdkPixbufFormat* -> PixbufFormat
62 * module aliases:
63 * local aliases:
66 module gdk.Pixbuf;
68 version(noAssert)
70 version(Tango)
72 import tango.io.Stdout; // use the tango loging?
76 private import gtkc.gdktypes;
78 private import gtkc.gdk;
81 private import glib.Str;
82 private import glib.Str;
83 private import gdkpixbuf.PixbufFormat;
84 private import gdk.Drawable;
85 private import gdk.Bitmap;
86 private import gdk.Colormap;
87 private import gdk.ImageGdk;
92 /**
93 * Description
94 * These functions allow to render pixbufs on drawables. Pixbufs are
95 * client-side images. For details on how to create and manipulate
96 * pixbufs, see the GdkPixbuf API documentation.
98 public class Pixbuf
101 /** the main Gtk struct */
102 protected GdkPixbuf* gdkPixbuf;
105 public GdkPixbuf* getPixbufStruct()
107 return gdkPixbuf;
111 /** the main Gtk struct as a void* */
112 protected void* getStruct()
114 return cast(void*)gdkPixbuf;
118 * Sets our main struct and passes it to the parent class
120 public this (GdkPixbuf* gdkPixbuf)
122 version(noAssert)
124 if ( gdkPixbuf is null )
126 int zero = 0;
127 version(Tango)
129 Stdout("struct gdkPixbuf is null on constructor").newline;
131 else
133 printf("struct gdkPixbuf is null on constructor");
135 zero = zero / zero;
138 else
140 assert(gdkPixbuf !is null, "struct gdkPixbuf is null on constructor");
142 this.gdkPixbuf = gdkPixbuf;
146 * Transfers image data from a GdkDrawable and converts it to an RGB(A)
147 * representation inside a GdkPixbuf. In other words, copies
148 * image data from a server-side drawable to a client-side RGB(A) buffer.
149 * This allows you to efficiently read individual pixels on the client side.
150 * If the drawable src has no colormap (gdk_drawable_get_colormap()
151 * returns NULL), then a suitable colormap must be specified.
152 * Typically a GdkWindow or a pixmap created by passing a GdkWindow
153 * to gdk_pixmap_new() will already have a colormap associated with
154 * it. If the drawable has a colormap, the cmap argument will be
155 * ignored. If the drawable is a bitmap (1 bit per pixel pixmap),
156 * then a colormap is not required; pixels with a value of 1 are
157 * assumed to be white, and pixels with a value of 0 are assumed to be
158 * black. For taking screenshots, gdk_colormap_get_system() returns
159 * the correct colormap to use.
160 * If the specified destination pixbuf dest is NULL, then this
161 * function will create an RGB pixbuf with 8 bits per channel and no
162 * alpha, with the same size specified by the width and height
163 * arguments. In this case, the dest_x and dest_y arguments must be
164 * specified as 0. If the specified destination pixbuf is not NULL
165 * and it contains alpha information, then the filled pixels will be
166 * set to full opacity (alpha = 255).
167 * If the specified drawable is a pixmap, then the requested source
168 * rectangle must be completely contained within the pixmap, otherwise
169 * the function will return NULL. For pixmaps only (not for windows)
170 * passing -1 for width or height is allowed to mean the full width
171 * or height of the pixmap.
172 * If the specified drawable is a window, and the window is off the
173 * screen, then there is no image data in the obscured/offscreen
174 * regions to be placed in the pixbuf. The contents of portions of the
175 * pixbuf corresponding to the offscreen region are undefined.
176 * If the window you're obtaining data from is partially obscured by
177 * other windows, then the contents of the pixbuf areas corresponding
178 * to the obscured regions are undefined.
179 * If the target drawable is not mapped (typically because it's
180 * iconified/minimized or not on the current workspace), then NULL
181 * will be returned.
182 * If memory can't be allocated for the return value, NULL will be returned
183 * instead.
184 * (In short, there are several ways this function can fail, and if it fails
185 * it returns NULL; so check the return value.)
186 * This function calls gdk_drawable_get_image() internally and
187 * converts the resulting image to a GdkPixbuf, so the
188 * documentation for gdk_drawable_get_image() may also be relevant.
189 * dest:
190 * Destination pixbuf, or NULL if a new pixbuf should be created.
191 * src:
192 * Source drawable.
193 * cmap:
194 * A colormap if src doesn't have one set.
195 * src_x:
196 * Source X coordinate within drawable.
197 * src_y:
198 * Source Y coordinate within drawable.
199 * dest_x:
200 * Destination X coordinate in pixbuf, or 0 if dest is NULL.
201 * dest_y:
202 * Destination Y coordinate in pixbuf, or 0 if dest is NULL.
203 * width:
204 * Width in pixels of region to get.
205 * height:
206 * Height in pixels of region to get.
207 * Returns:
208 * The same pixbuf as dest if it was non-NULL, or a newly-created
209 * pixbuf with a reference count of 1 if no destination pixbuf was specified, or NULL on error
211 public Pixbuf getFromDrawable(Drawable src, Colormap cmap, int srcX, int srcY, int destX, int destY, int width, int height)
213 // GdkPixbuf* gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height);
214 return new Pixbuf( gdk_pixbuf_get_from_drawable(null, (src is null) ? null : src.getDrawableStruct(), (cmap is null) ? null : cmap.getColormapStruct(), srcX, srcY, destX, destY, width, height) );
218 * SetFromDrawable is different from GetFrom Drawable as it doesn't create a new pixbuf
220 public void setFromDrawable(Drawable src, int srcX, int srcY, int width, int height)
222 gdk_pixbuf_get_from_drawable(
223 gdkPixbuf, // gdkPixbuf
224 src.getDrawableStruct(),
225 null, // colormap
226 srcX, srcY,
227 0, 0, // destination x and y
228 width, height);
232 * Creates a new Pixbuf from a drawable.
233 * this is a simplyfied GetFromDrawable
235 this(Drawable src, int srcX, int srcY, int width, int height)
237 GdkPixbuf* pb = gdk_pixbuf_get_from_drawable(
238 null, // gdkPixbuf
239 src.getDrawableStruct(),
240 null, // colormap
241 srcX, srcY,
242 0, 0, // destination x and y
243 width, height);
244 this(pb);
249 * Description
250 * The most basic way to create a pixbuf is to wrap an existing pixel
251 * buffer with a GdkPixbuf structure. You can use the
252 * gdk_pixbuf_new_from_data() function to do this You need to specify
253 * the destroy notification function that will be called when the
254 * data buffer needs to be freed; this will happen when a GdkPixbuf
255 * is finalized by the reference counting functions If you have a
256 * chunk of static data compiled into your application, you can pass
257 * in NULL as the destroy notification function so that the data
258 * will not be freed.
259 * The gdk_pixbuf_new() function can be used as a convenience to
260 * create a pixbuf with an empty buffer. This is equivalent to
261 * allocating a data buffer using malloc() and
262 * then wrapping it with gdk_pixbuf_new_from_data(). The gdk_pixbuf_new()
263 * function will compute an optimal rowstride so that rendering can be
264 * performed with an efficient algorithm.
265 * As a special case, you can use the gdk_pixbuf_new_from_xpm_data()
266 * function to create a pixbuf from inline XPM image data.
267 * You can also copy an existing pixbuf with the gdk_pixbuf_copy()
268 * function. This is not the same as just doing a g_object_ref()
269 * on the old pixbuf; the copy function will actually duplicate the
270 * pixel data in memory and create a new GdkPixbuf structure for it.
274 * Description
275 * The GdkPixbuf structure contains
276 * information that describes an image in memory.
277 * Image Data
278 * Image data in a pixbuf is stored in memory in uncompressed,
279 * packed format. Rows in the image are stored top to bottom, and
280 * in each row pixels are stored from left to right. There may be
281 * padding at the end of a row. The "rowstride" value of a pixbuf,
282 * as returned by gdk_pixbuf_get_rowstride(), indicates the number
283 * of bytes between rows.
284 * Example1.put_pixel() example
285 * The following code illustrates a simple put_pixel()
286 * function for RGB pixbufs with 8 bits per channel with an alpha
287 * channel. It is not included in the gdk-pixbuf library for
288 * performance reasons; rather than making several function calls
289 * for each pixel, your own code can take shortcuts.
290 * static void
291 * put_pixel (GdkPixbuf *pixbuf, int x, int y, guchar red, guchar green, guchar blue, guchar alpha)
293 * int width, height, rowstride, n_channels;
294 * guchar *pixels, *p;
295 * n_channels = gdk_pixbuf_get_n_channels (pixbuf);
296 * g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
297 * g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
298 * g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
299 * g_assert (n_channels == 4);
300 * width = gdk_pixbuf_get_width (pixbuf);
301 * height = gdk_pixbuf_get_height (pixbuf);
302 * g_assert (x >= 0 x < width);
303 * g_assert (y >= 0 y < height);
304 * rowstride = gdk_pixbuf_get_rowstride (pixbuf);
305 * pixels = gdk_pixbuf_get_pixels (pixbuf);
306 * p = pixels + y * rowstride + x * n_channels;
307 * p[0] = red;
308 * p[1] = green;
309 * p[2] = blue;
310 * p[3] = alpha;
312 * This function will not work for pixbufs with images that are
313 * other than 8 bits per sample or channel, but it will work for
314 * most of the pixbufs that GTK+ uses.
315 * Note
316 * If you are doing memcpy() of raw pixbuf data, note that the
317 * last row in the pixbuf may not be as wide as the full
318 * rowstride, but rather just as wide as the pixel data needs to
319 * be. That is, it is unsafe to do memcpy (dest,
320 * pixels, rowstride * height) to copy a whole pixbuf.
321 * Use gdk_pixbuf_copy() instead, or compute the width in bytes
322 * of the last row as width * ((n_channels *
323 * bits_per_sample + 7) / 8).
327 * Description
328 * GdkPixbuf structures are reference counted. This means that an
329 * application can share a single pixbuf among many parts of the
330 * code. When a piece of the program needs to keep a pointer to a
331 * pixbuf, it should add a reference to it by calling g_object_ref().
332 * When it no longer needs the pixbuf, it should subtract a reference
333 * by calling g_object_unref(). The pixbuf will be destroyed when
334 * its reference count drops to zero. Newly-created GdkPixbuf
335 * structures start with a reference count of one.
336 * Note
337 * As GdkPixbuf is derived from GObject now, gdk_pixbuf_ref() and
338 * gdk_pixbuf_unref() are deprecated in favour of g_object_ref()
339 * and g_object_unref() resp.
340 * Finalizing a pixbuf means to free its pixel
341 * data and to free the GdkPixbuf structure itself. Most of the
342 * library functions that create GdkPixbuf structures create the
343 * pixel data by themselves and define the way it should be freed;
344 * you do not need to worry about those. The only function that lets
345 * you specify how to free the pixel data is
346 * gdk_pixbuf_new_from_data(). Since you pass it a pre-allocated
347 * pixel buffer, you must also specify a way to free that data. This
348 * is done with a function of type GdkPixbufDestroyNotify. When a
349 * pixbuf created with gdk_pixbuf_new_from_data() is finalized, your
350 * destroy notification function will be called, and it is its
351 * responsibility to free the pixel array.
355 * Description
356 * The gdk-pixbuf library provides a simple mechanism for loading
357 * an image from a file in synchronous fashion. This means that the
358 * library takes control of the application while the file is being
359 * loaded; from the user's point of view, the application will block
360 * until the image is done loading.
361 * This interface can be used by applications in which blocking is
362 * acceptable while an image is being loaded. It can also be used to
363 * load small images in general. Applications that need progressive
364 * loading can use the GdkPixbufLoader functionality instead.
368 * Description
369 * These functions allow to save a GdkPixbuf in a number of
370 * file formats. The formatted data can be written to a file
371 * or to a memory buffer. gdk-pixbuf can also call a user-defined
372 * callback on the data, which allows to e.g. write the image
373 * to a socket or store it in a database.
377 * Description
378 * The gdk-pixbuf contains functions to scale pixbufs, to scale
379 * pixbufs and composite against an existing image, and to scale
380 * pixbufs and composite against a solid color or checkerboard.
381 * Compositing a checkerboard is a common way to show an image with
382 * an alpha channel in image-viewing and editing software.
383 * Since the full-featured functions (gdk_pixbuf_scale(),
384 * gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
385 * rather complex to use and have many arguments, two simple
386 * convenience functions are provided, gdk_pixbuf_scale_simple() and
387 * gdk_pixbuf_composite_color_simple() which create a new pixbuf of a
388 * given size, scale an original image to fit, and then return the
389 * new pixbuf.
390 * The following example demonstrates handling an expose event by
391 * rendering the appropriate area of a source image (which is scaled
392 * to fit the widget) onto the widget's window. The source image is
393 * rendered against a checkerboard, which provides a visual
394 * representation of the alpha channel if the image has one. If the
395 * image doesn't have an alpha channel, calling
396 * gdk_pixbuf_composite_color() function has exactly the same effect
397 * as calling gdk_pixbuf_scale().
398 * Example2.Handling an expose event.
399 * gboolean
400 * expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
402 * GdkPixbuf *dest;
403 * dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
404 * gdk_pixbuf_composite_color (pixbuf, dest,
405 * 0, 0, event->area.width, event->area.height,
406 * -event->area.x, -event->area.y,
407 * (double) widget->allocation.width / gdk_pixbuf_get_width (pixbuf),
408 * (double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf),
409 * GDK_INTERP_BILINEAR, 255,
410 * event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
411 * gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
412 * 0, 0, event->area.x, event->area.y,
413 * event->area.width, event->area.height,
414 * GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
415 * gdk_pixbuf_unref (dest);
416 * return TRUE;
421 * Description
422 * These functions provide miscellaneous utilities for manipulating
423 * pixbufs. The pixel data in pixbufs may of course be manipulated
424 * directly by applications, but several common operations can be
425 * performed by these functions instead.
429 * Takes the opacity values in a rectangular portion of a pixbuf and thresholds
430 * them to produce a bi-level alpha mask that can be used as a clipping mask for
431 * a drawable.
432 * pixbuf:
433 * A pixbuf.
434 * bitmap:
435 * Bitmap where the bilevel mask will be painted to.
436 * src_x:
437 * Source X coordinate.
438 * src_y:
439 * source Y coordinate.
440 * dest_x:
441 * Destination X coordinate.
442 * dest_y:
443 * Destination Y coordinate.
444 * width:
445 * Width of region to threshold, or -1 to use pixbuf width
446 * height:
447 * Height of region to threshold, or -1 to use pixbuf height
448 * alpha_threshold:
449 * Opacity values below this will be painted as zero; all
450 * other values will be painted as one.
452 public void renderThresholdAlpha(Bitmap bitmap, int srcX, int srcY, int destX, int destY, int width, int height, int alphaThreshold)
454 // void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int alpha_threshold);
455 gdk_pixbuf_render_threshold_alpha(gdkPixbuf, (bitmap is null) ? null : bitmap.getBitmapStruct(), srcX, srcY, destX, destY, width, height, alphaThreshold);
459 * Warning
460 * gdk_pixbuf_render_to_drawable has been deprecated since version 2.4 and should not be used in newly-written code. This function is obsolete. Use gdk_draw_pixbuf() instead.
461 * Renders a rectangular portion of a pixbuf to a drawable while using the
462 * specified GC. This is done using GdkRGB, so the specified drawable must have
463 * the GdkRGB visual and colormap. Note that this function will ignore the
464 * opacity information for images with an alpha channel; the GC must already
465 * have the clipping mask set if you want transparent regions to show through.
466 * For an explanation of dither offsets, see the GdkRGB documentation. In
467 * brief, the dither offset is important when re-rendering partial regions of an
468 * image to a rendered version of the full image, or for when the offsets to a
469 * base position change, as in scrolling. The dither matrix has to be shifted
470 * for consistent visual results. If you do not have any of these cases, the
471 * dither offsets can be both zero.
472 * pixbuf:
473 * A pixbuf.
474 * drawable:
475 * Destination drawable.
476 * gc:
477 * GC used for rendering.
478 * src_x:
479 * Source X coordinate within pixbuf.
480 * src_y:
481 * Source Y coordinate within pixbuf.
482 * dest_x:
483 * Destination X coordinate within drawable.
484 * dest_y:
485 * Destination Y coordinate within drawable.
486 * width:
487 * Width of region to render, in pixels, or -1 to use pixbuf width
488 * height:
489 * Height of region to render, in pixels, or -1 to use pixbuf height
490 * dither:
491 * Dithering mode for GdkRGB.
492 * x_dither:
493 * X offset for dither.
494 * y_dither:
495 * Y offset for dither.
497 public void renderToDrawable(Drawable drawable, GdkGC* gc, int srcX, int srcY, int destX, int destY, int width, int height, GdkRgbDither dither, int xDither, int yDither)
499 // void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, GdkDrawable *drawable, GdkGC *gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkRgbDither dither, int x_dither, int y_dither);
500 gdk_pixbuf_render_to_drawable(gdkPixbuf, (drawable is null) ? null : drawable.getDrawableStruct(), gc, srcX, srcY, destX, destY, width, height, dither, xDither, yDither);
504 * Warning
505 * gdk_pixbuf_render_to_drawable_alpha has been deprecated since version 2.4 and should not be used in newly-written code. This function is obsolete. Use gdk_draw_pixbuf() instead.
506 * Renders a rectangular portion of a pixbuf to a drawable. The destination
507 * drawable must have a colormap. All windows have a colormap, however, pixmaps
508 * only have colormap by default if they were created with a non-NULL window argument.
509 * Otherwise a colormap must be set on them with gdk_drawable_set_colormap.
510 * On older X servers, rendering pixbufs with an alpha channel involves round trips
511 * to the X server, and may be somewhat slow.
512 * pixbuf:
513 * A pixbuf.
514 * drawable:
515 * Destination drawable.
516 * src_x:
517 * Source X coordinate within pixbuf.
518 * src_y:
519 * Source Y coordinates within pixbuf.
520 * dest_x:
521 * Destination X coordinate within drawable.
522 * dest_y:
523 * Destination Y coordinate within drawable.
524 * width:
525 * Width of region to render, in pixels, or -1 to use pixbuf width.
526 * height:
527 * Height of region to render, in pixels, or -1 to use pixbuf height.
528 * alpha_mode:
529 * Ignored. Present for backwards compatibility.
530 * alpha_threshold:
531 * Ignored. Present for backwards compatibility
532 * dither:
533 * Dithering mode for GdkRGB.
534 * x_dither:
535 * X offset for dither.
536 * y_dither:
537 * Y offset for dither.
539 public void renderToDrawableAlpha(Drawable drawable, int srcX, int srcY, int destX, int destY, int width, int height, GdkPixbufAlphaMode alphaMode, int alphaThreshold, GdkRgbDither dither, int xDither, int yDither)
541 // void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkPixbufAlphaMode alpha_mode, int alpha_threshold, GdkRgbDither dither, int x_dither, int y_dither);
542 gdk_pixbuf_render_to_drawable_alpha(gdkPixbuf, (drawable is null) ? null : drawable.getDrawableStruct(), srcX, srcY, destX, destY, width, height, alphaMode, alphaThreshold, dither, xDither, yDither);
546 * Creates a pixmap and a mask bitmap which are returned in the pixmap_return
547 * and mask_return arguments, respectively, and renders a pixbuf and its
548 * corresponding thresholded alpha mask to them. This is merely a convenience
549 * function; applications that need to render pixbufs with dither offsets or to
550 * given drawables should use gdk_draw_pixbuf() and gdk_pixbuf_render_threshold_alpha().
551 * The pixmap that is created is created for the colormap returned
552 * by gdk_rgb_get_colormap(). You normally will want to instead use
553 * the actual colormap for a widget, and use
554 * gdk_pixbuf_render_pixmap_and_mask_for_colormap().
555 * If the pixbuf does not have an alpha channel, then *mask_return will be set
556 * to NULL.
557 * pixbuf:
558 * A pixbuf.
559 * pixmap_return:
560 * Location to store a pointer to the created pixmap,
561 * or NULL if the pixmap is not needed.
562 * mask_return:
563 * Location to store a pointer to the created mask,
564 * or NULL if the mask is not needed.
565 * alpha_threshold:
566 * Threshold value for opacity values.
568 public void renderPixmapAndMask(GdkPixmap** pixmapReturn, GdkBitmap** maskReturn, int alphaThreshold)
570 // void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold);
571 gdk_pixbuf_render_pixmap_and_mask(gdkPixbuf, pixmapReturn, maskReturn, alphaThreshold);
575 * Creates a pixmap and a mask bitmap which are returned in the pixmap_return
576 * and mask_return arguments, respectively, and renders a pixbuf and its
577 * corresponding tresholded alpha mask to them. This is merely a convenience
578 * function; applications that need to render pixbufs with dither offsets or to
579 * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha().
580 * The pixmap that is created uses the GdkColormap specified by colormap.
581 * This colormap must match the colormap of the window where the pixmap
582 * will eventually be used or an error will result.
583 * If the pixbuf does not have an alpha channel, then *mask_return will be set
584 * to NULL.
585 * pixbuf:
586 * A pixbuf.
587 * colormap:
588 * A GdkColormap
589 * pixmap_return:
590 * Location to store a pointer to the created pixmap,
591 * or NULL if the pixmap is not needed.
592 * mask_return:
593 * Location to store a pointer to the created mask,
594 * or NULL if the mask is not needed.
595 * alpha_threshold:
596 * Threshold value for opacity values.
598 public void renderPixmapAndMaskForColormap(Colormap colormap, GdkPixmap** pixmapReturn, GdkBitmap** maskReturn, int alphaThreshold)
600 // void gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, GdkColormap *colormap, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold);
601 gdk_pixbuf_render_pixmap_and_mask_for_colormap(gdkPixbuf, (colormap is null) ? null : colormap.getColormapStruct(), pixmapReturn, maskReturn, alphaThreshold);
606 * Same as gdk_pixbuf_get_from_drawable() but gets the pixbuf from
607 * an image.
608 * dest:
609 * Destination pixbuf, or NULL if a new pixbuf should be created.
610 * src:
611 * Source GdkImage.
612 * cmap:
613 * A colormap, or NULL to use the one for src
614 * src_x:
615 * Source X coordinate within drawable.
616 * src_y:
617 * Source Y coordinate within drawable.
618 * dest_x:
619 * Destination X coordinate in pixbuf, or 0 if dest is NULL.
620 * dest_y:
621 * Destination Y coordinate in pixbuf, or 0 if dest is NULL.
622 * width:
623 * Width in pixels of region to get.
624 * height:
625 * Height in pixels of region to get.
626 * Returns:
627 * dest, newly-created pixbuf if dest was NULL, NULL on error
629 public Pixbuf getFromImage(ImageGdk src, Colormap cmap, int srcX, int srcY, int destX, int destY, int width, int height)
631 // GdkPixbuf* gdk_pixbuf_get_from_image (GdkPixbuf *dest, GdkImage *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height);
632 return new Pixbuf( gdk_pixbuf_get_from_image(gdkPixbuf, (src is null) ? null : src.getImageGdkStruct(), (cmap is null) ? null : cmap.getColormapStruct(), srcX, srcY, destX, destY, width, height) );
636 * <hr>
637 * gdk_pixbuf_new ()
638 * GdkPixbuf* gdk_pixbuf_new (GdkColorspace colorspace,
639 * gboolean has_alpha,
640 * int bits_per_sample,
641 * int width,
642 * int height);
643 * Creates a new GdkPixbuf structure and allocates a buffer for it. The
644 * buffer has an optimal rowstride. Note that the buffer is not cleared;
645 * you will have to fill it completely yourself.
646 * colorspace:
647 * Color space for image
648 * has_alpha:
649 * Whether the image should have transparency information
650 * bits_per_sample:
651 * Number of bits per color sample
652 * width:
653 * Width of image in pixels, must be > 0
654 * height:
655 * Height of image in pixels, must be > 0
656 * Returns:
657 * A newly-created GdkPixbuf with a reference count of 1, or
658 * NULL if not enough memory could be allocated for the image buffer.
660 public static GType getType()
662 // GType gdk_pixbuf_get_type ();
663 return gdk_pixbuf_get_type();
667 * Creates a new GdkPixbuf out of in-memory image data. Currently only RGB
668 * images with 8 bits per sample are supported.
669 * data:
670 * Image data in 8-bit/sample packed format
671 * colorspace:
672 * Colorspace for the image data
673 * has_alpha:
674 * Whether the data has an opacity channel
675 * bits_per_sample:
676 * Number of bits per sample
677 * width:
678 * Width of the image in pixels, must be > 0
679 * height:
680 * Height of the image in pixels, must be > 0
681 * rowstride:
682 * Distance in bytes between row starts
683 * destroy_fn:
684 * Function used to free the data when the pixbuf's reference count
685 * drops to zero, or NULL if the data should not be freed
686 * destroy_fn_data:
687 * Closure data to pass to the destroy notification function
688 * Returns:
689 * A newly-created GdkPixbuf structure with a reference count of 1.
691 public this (char* data, GdkColorspace colorspace, int hasAlpha, int bitsPerSample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroyFn, void* destroyFnData)
693 // GdkPixbuf* gdk_pixbuf_new_from_data (const guchar *data, GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroy_fn, gpointer destroy_fn_data);
694 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_data(data, colorspace, hasAlpha, bitsPerSample, width, height, rowstride, destroyFn, destroyFnData) );
698 * Creates a new pixbuf by parsing XPM data in memory. This data is commonly
699 * the result of including an XPM file into a program's C source.
700 * data:
701 * Pointer to inline XPM data.
702 * Returns:
703 * A newly-created pixbuf with a reference count of 1.
705 public this (char** data)
707 // GdkPixbuf* gdk_pixbuf_new_from_xpm_data (const char **data);
708 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_xpm_data(data) );
712 * Create a GdkPixbuf from a flat representation that is suitable for
713 * storing as inline data in a program. This is useful if you want to
714 * ship a program with images, but don't want to depend on any
715 * external files.
716 * GTK+ ships with a program called gdk-pixbuf-csource
717 * which allows for conversion of GdkPixbufs into such a inline representation.
718 * In almost all cases, you should pass the --raw flag to
719 * gdk-pixbuf-csource. A sample invocation would be:
720 * gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
721 * For the typical case where the inline pixbuf is read-only static data,
722 * you don't need to copy the pixel data unless you intend to write to
723 * it, so you can pass FALSE for copy_pixels. (If you pass
724 * --rle to gdk-pixbuf-csource, a copy
725 * will be made even if copy_pixels is FALSE, so using this option is
726 * generally a bad idea.)
727 * If you create a pixbuf from const inline data compiled into your
728 * program, it's probably safe to ignore errors and disable length checks,
729 * since things will always succeed:
730 * pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL);
731 * For non-const inline data, you could get out of memory. For untrusted
732 * inline data located at runtime, you could have corrupt inline data in
733 * addition.
734 * data_length:
735 * Length in bytes of the data argument or -1 to
736 * disable length checks
737 * data:
738 * Byte data containing a serialized GdkPixdata structure
739 * copy_pixels:
740 * Whether to copy the pixel data, or use direct pointers
741 * data for the resulting pixbuf
742 * error:
743 * GError return location, may be NULL to ignore errors
744 * Returns:
745 * A newly-created GdkPixbuf structure with a reference,
746 * count of 1, or NULL if an error occurred.
748 public this (int dataLength, byte* data, int copyPixels, GError** error)
750 // GdkPixbuf* gdk_pixbuf_new_from_inline (gint data_length, const guint8 *data, gboolean copy_pixels, GError **error);
751 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_inline(dataLength, data, copyPixels, error) );
755 * Creates a new pixbuf which represents a sub-region of
756 * src_pixbuf. The new pixbuf shares its pixels with the
757 * original pixbuf, so writing to one affects both.
758 * The new pixbuf holds a reference to src_pixbuf, so
759 * src_pixbuf will not be finalized until the new pixbuf
760 * is finalized.
761 * src_pixbuf:
762 * a GdkPixbuf
763 * src_x:
764 * X coord in src_pixbuf
765 * src_y:
766 * Y coord in src_pixbuf
767 * width:
768 * width of region in src_pixbuf
769 * height:
770 * height of region in src_pixbuf
771 * Returns:
772 * a new pixbuf
774 public this (int srcX, int srcY, int width, int height)
776 // GdkPixbuf* gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf, int src_x, int src_y, int width, int height);
777 this(cast(GdkPixbuf*)gdk_pixbuf_new_subpixbuf(gdkPixbuf, srcX, srcY, width, height) );
781 * Creates a new GdkPixbuf with a copy of the information in the specified
782 * pixbuf.
783 * pixbuf:
784 * A pixbuf.
785 * Returns:
786 * A newly-created pixbuf with a reference count of 1, or NULL if
787 * not enough memory could be allocated.
788 * See Also
789 * gdk_pixbuf_finalize().
791 public Pixbuf copy()
793 // GdkPixbuf* gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
794 return new Pixbuf( gdk_pixbuf_copy(gdkPixbuf) );
803 * Queries the color space of a pixbuf.
804 * pixbuf:
805 * A pixbuf.
806 * Returns:
807 * Color space.
809 public GdkColorspace getColorspace()
811 // GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf);
812 return gdk_pixbuf_get_colorspace(gdkPixbuf);
816 * Queries the number of channels of a pixbuf.
817 * pixbuf:
818 * A pixbuf.
819 * Returns:
820 * Number of channels.
822 public int getNChannels()
824 // int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf);
825 return gdk_pixbuf_get_n_channels(gdkPixbuf);
829 * Queries whether a pixbuf has an alpha channel (opacity information).
830 * pixbuf:
831 * A pixbuf.
832 * Returns:
833 * TRUE if it has an alpha channel, FALSE otherwise.
835 public int getHasAlpha()
837 // gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf);
838 return gdk_pixbuf_get_has_alpha(gdkPixbuf);
842 * Queries the number of bits per color sample in a pixbuf.
843 * pixbuf:
844 * A pixbuf.
845 * Returns:
846 * Number of bits per color sample.
848 public int getBitsPerSample()
850 // int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
851 return gdk_pixbuf_get_bits_per_sample(gdkPixbuf);
855 * Queries a pointer to the pixel data of a pixbuf.
856 * pixbuf:
857 * A pixbuf.
858 * Returns:
859 * A pointer to the pixbuf's pixel data. Please see the section called Image Data
860 * for information about how the pixel data is stored in
861 * memory.
863 public char* getPixels()
865 // guchar* gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf);
866 return gdk_pixbuf_get_pixels(gdkPixbuf);
870 * Queries the width of a pixbuf.
871 * pixbuf:
872 * A pixbuf.
873 * Returns:
874 * Width in pixels.
876 public int getWidth()
878 // int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf);
879 return gdk_pixbuf_get_width(gdkPixbuf);
883 * Queries the height of a pixbuf.
884 * pixbuf:
885 * A pixbuf.
886 * Returns:
887 * Height in pixels.
889 public int getHeight()
891 // int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf);
892 return gdk_pixbuf_get_height(gdkPixbuf);
896 * Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row
897 * and the start of the next row.
898 * pixbuf:
899 * A pixbuf.
900 * Returns:
901 * Distance between row starts.
903 public int getRowstride()
905 // int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf);
906 return gdk_pixbuf_get_rowstride(gdkPixbuf);
910 * Looks up key in the list of options that may have been attached to the
911 * pixbuf when it was loaded.
912 * pixbuf:
913 * a GdkPixbuf
914 * key:
915 * a nul-terminated string.
916 * Returns:
917 * the value associated with key. This is a nul-terminated
918 * string that should not be freed or NULL if key was not found.
919 * Property Details
920 * The "bits-per-sample" property
921 * "bits-per-sample" gint : Read / Write / Construct Only
922 * The number of bits per sample.
923 * Currently only 8 bit per sample are supported.
924 * Allowed values: [1,16]
925 * Default value: 8
927 public char[] getOption(char[] key)
929 // const gchar* gdk_pixbuf_get_option (GdkPixbuf *pixbuf, const gchar *key);
930 return Str.toString(gdk_pixbuf_get_option(gdkPixbuf, Str.toStringz(key)) );
944 * Creates a new pixbuf by loading an image from a file. The file format is
945 * detected automatically. If NULL is returned, then error will be set.
946 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
947 * filename:
948 * Name of file to load, in the GLib file name encoding
949 * error:
950 * Return location for an error
951 * Returns:
952 * A newly-created pixbuf with a reference count of 1, or NULL if
953 * any of several error conditions occurred: the file could not be opened,
954 * there was no loader for the file's format, there was not enough memory to
955 * allocate the image buffer, or the image file contained invalid data.
957 public this (char[] filename, GError** error)
959 // GdkPixbuf* gdk_pixbuf_new_from_file (const char *filename, GError **error);
960 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_file(Str.toStringz(filename), error) );
964 * Creates a new pixbuf by loading an image from a file. The file format is
965 * detected automatically. If NULL is returned, then error will be set.
966 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
967 * The image will be scaled to fit in the requested size, preserving
968 * the image's aspect ratio.
969 * filename:
970 * Name of file to load, in the GLib file name encoding
971 * width:
972 * The width the image should have or -1 to not constrain the width
973 * height:
974 * The height the image should have or -1 to not constrain the height
975 * error:
976 * Return location for an error
977 * Returns:
978 * A newly-created pixbuf with a reference count of 1, or
979 * NULL if any of several error conditions occurred: the file could not
980 * be opened, there was no loader for the file's format, there was not
981 * enough memory to allocate the image buffer, or the image file contained
982 * invalid data.
983 * Since 2.4
985 public this (char[] filename, int width, int height, GError** error)
987 // GdkPixbuf* gdk_pixbuf_new_from_file_at_size (const char *filename, int width, int height, GError **error);
988 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_file_at_size(Str.toStringz(filename), width, height, error) );
992 * Creates a new pixbuf by loading an image from a file. The file format is
993 * detected automatically. If NULL is returned, then error will be set.
994 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
995 * The image will be scaled to fit in the requested size, optionally preserving
996 * the image's aspect ratio.
997 * When preserving the aspect ratio, a width of -1 will cause the image
998 * to be scaled to the exact given height, and a height of -1 will cause
999 * the image to be scaled to the exact given width. When not preserving
1000 * aspect ratio, a width or height of -1 means to not scale the image
1001 * at all in that dimension. Negative values for width and height are
1002 * allowed since 2.8.
1003 * filename:
1004 * Name of file to load, in the GLib file name encoding
1005 * width:
1006 * The width the image should have or -1 to not constrain the width
1007 * height:
1008 * The height the image should have or -1 to not constrain the height
1009 * preserve_aspect_ratio:
1010 * TRUE to preserve the image's aspect ratio
1011 * error:
1012 * Return location for an error
1013 * Returns:
1014 * A newly-created pixbuf with a reference count of 1, or NULL
1015 * if any of several error conditions occurred: the file could not be opened,
1016 * there was no loader for the file's format, there was not enough memory to
1017 * allocate the image buffer, or the image file contained invalid data.
1018 * Since 2.6
1020 public this (char[] filename, int width, int height, int preserveAspectRatio, GError** error)
1022 // GdkPixbuf* gdk_pixbuf_new_from_file_at_scale (const char *filename, int width, int height, gboolean preserve_aspect_ratio, GError **error);
1023 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_file_at_scale(Str.toStringz(filename), width, height, preserveAspectRatio, error) );
1028 * Saves pixbuf to a file in type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
1029 * If error is set, FALSE will be returned.
1030 * See gdk_pixbuf_save() for more details.
1031 * pixbuf:
1032 * a GdkPixbuf.
1033 * filename:
1034 * name of file to save.
1035 * type:
1036 * name of file format.
1037 * option_keys:
1038 * name of options to set, NULL-terminated
1039 * option_values:
1040 * values for named options
1041 * error:
1042 * return location for error, or NULL
1043 * Returns:
1044 * whether an error was set
1046 public int savev(char[] filename, char[] type, char** optionKeys, char** optionValues, GError** error)
1048 // gboolean gdk_pixbuf_savev (GdkPixbuf *pixbuf, const char *filename, const char *type, char **option_keys, char **option_values, GError **error);
1049 return gdk_pixbuf_savev(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), optionKeys, optionValues, error);
1053 * Saves pixbuf to a file in format type. By default, "jpeg", "png", "ico"
1054 * and "bmp" are possible file formats to save in, but more formats may be
1055 * installed. The list of all writable formats can be determined in the
1056 * following way:
1057 * void add_if_writable (GdkPixbufFormat *data, GSList **list)
1059 * if (gdk_pixbuf_format_is_writable (data))
1060 * *list = g_slist_prepend (*list, data);
1062 * GSList *formats = gdk_pixbuf_get_formats ();
1063 * GSList *writable_formats = NULL;
1064 * g_slist_foreach (formats, add_if_writable, writable_formats);
1065 * g_slist_free (formats);
1066 * If error is set, FALSE will be returned. Possible errors include
1067 * those in the GDK_PIXBUF_ERROR domain and those in the G_FILE_ERROR domain.
1068 * The variable argument list should be NULL-terminated; if not empty,
1069 * it should contain pairs of strings that modify the save
1070 * parameters. For example:
1071 * gdk_pixbuf_save (pixbuf, handle, "jpeg", error,
1072 * "quality", "100", NULL);
1073 * Currently only few parameters exist. JPEG images can be saved with a
1074 * "quality" parameter; its value should be in the range [0,100].
1075 * Text chunks can be attached to PNG images by specifying parameters of
1076 * the form "tEXt::key", where key is an ASCII string of length 1-79.
1077 * The values are UTF-8 encoded strings. The PNG compression level can
1078 * be specified using the "compression" parameter; it's value is in an
1079 * integer in the range of [0,9].
1080 * ICO images can be saved in depth 16, 24, or 32, by using the "depth"
1081 * parameter. When the ICO saver is given "x_hot" and "y_hot" parameters,
1082 * it produces a CUR instead of an ICO.
1083 * pixbuf:
1084 * a GdkPixbuf.
1085 * filename:
1086 * name of file to save.
1087 * type:
1088 * name of file format.
1089 * error:
1090 * return location for error, or NULL
1091 * ...:
1092 * list of key-value save options
1093 * Returns:
1094 * whether an error was set
1096 public int save(char[] filename, char[] type, GError** error, ... )
1098 // gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf, const char *filename, const char *type, GError **error, ...);
1099 return gdk_pixbuf_save(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), error);
1104 * Saves pixbuf in format type by feeding the produced data to a
1105 * callback. Can be used when you want to store the image to something
1106 * other than a file, such as an in-memory buffer or a socket.
1107 * If error is set, FALSE will be returned. Possible errors
1108 * include those in the GDK_PIXBUF_ERROR domain and whatever the save
1109 * function generates.
1110 * See gdk_pixbuf_save() for more details.
1111 * pixbuf:
1112 * a GdkPixbuf.
1113 * save_func:
1114 * a function that is called to save each block of data that
1115 * the save routine generates.
1116 * user_data:
1117 * user data to pass to the save function.
1118 * type:
1119 * name of file format.
1120 * error:
1121 * return location for error, or NULL
1122 * ...:
1123 * list of key-value save options
1124 * Returns:
1125 * whether an error was set
1126 * Since 2.4
1128 public int saveToCallback(GdkPixbufSaveFunc saveFunc, void* userData, char[] type, GError** error, ... )
1130 // gboolean gdk_pixbuf_save_to_callback (GdkPixbuf *pixbuf, GdkPixbufSaveFunc save_func, gpointer user_data, const char *type, GError **error, ...);
1131 return gdk_pixbuf_save_to_callback(gdkPixbuf, saveFunc, userData, Str.toStringz(type), error);
1135 * Saves pixbuf to a callback in format type, which is currently "jpeg",
1136 * "png", "tiff", "ico" or "bmp". If error is set, FALSE will be returned. See
1137 * gdk_pixbuf_save_to_callback() for more details.
1138 * pixbuf:
1139 * a GdkPixbuf.
1140 * save_func:
1141 * a function that is called to save each block of data that
1142 * the save routine generates.
1143 * user_data:
1144 * user data to pass to the save function.
1145 * type:
1146 * name of file format.
1147 * option_keys:
1148 * name of options to set, NULL-terminated
1149 * option_values:
1150 * values for named options
1151 * error:
1152 * return location for error, or NULL
1153 * Returns:
1154 * whether an error was set
1155 * Since 2.4
1157 public int saveToCallbackv(GdkPixbufSaveFunc saveFunc, void* userData, char[] type, char** optionKeys, char** optionValues, GError** error)
1159 // gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf, GdkPixbufSaveFunc save_func, gpointer user_data, const char *type, char **option_keys, char **option_values, GError **error);
1160 return gdk_pixbuf_save_to_callbackv(gdkPixbuf, saveFunc, userData, Str.toStringz(type), optionKeys, optionValues, error);
1164 * Saves pixbuf to a new buffer in format type, which is currently "jpeg",
1165 * "png", "tiff", "ico" or "bmp". This is a convenience function that uses
1166 * gdk_pixbuf_save_to_callback() to do the real work. Note that the buffer
1167 * is not nul-terminated and may contain embedded nuls.
1168 * If error is set, FALSE will be returned and string will be set to
1169 * NULL. Possible errors include those in the GDK_PIXBUF_ERROR
1170 * domain.
1171 * See gdk_pixbuf_save() for more details.
1172 * pixbuf:
1173 * a GdkPixbuf.
1174 * buffer:
1175 * location to receive a pointer to the new buffer.
1176 * buffer_size:
1177 * location to receive the size of the new buffer.
1178 * type:
1179 * name of file format.
1180 * error:
1181 * return location for error, or NULL
1182 * ...:
1183 * list of key-value save options
1184 * Returns:
1185 * whether an error was set
1186 * Since 2.4
1188 public int saveToBuffer(char** buffer, uint* bufferSize, char[] type, GError** error, ... )
1190 // gboolean gdk_pixbuf_save_to_buffer (GdkPixbuf *pixbuf, gchar **buffer, gsize *buffer_size, const char *type, GError **error, ...);
1191 return gdk_pixbuf_save_to_buffer(gdkPixbuf, buffer, bufferSize, Str.toStringz(type), error);
1195 * Saves pixbuf to a new buffer in format type, which is currently "jpeg",
1196 * "tiff", "png", "ico" or "bmp". See gdk_pixbuf_save_to_buffer() for more details.
1197 * pixbuf:
1198 * a GdkPixbuf.
1199 * buffer:
1200 * location to receive a pointer to the new buffer.
1201 * buffer_size:
1202 * location to receive the size of the new buffer.
1203 * type:
1204 * name of file format.
1205 * option_keys:
1206 * name of options to set, NULL-terminated
1207 * option_values:
1208 * values for named options
1209 * error:
1210 * return location for error, or NULL
1211 * Returns:
1212 * whether an error was set
1213 * Since 2.4
1215 public int saveToBufferv(char** buffer, uint* bufferSize, char[] type, char** optionKeys, char** optionValues, GError** error)
1217 // gboolean gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf, gchar **buffer, gsize *buffer_size, const char *type, char **option_keys, char **option_values, GError **error);
1218 return gdk_pixbuf_save_to_bufferv(gdkPixbuf, buffer, bufferSize, Str.toStringz(type), optionKeys, optionValues, error);
1223 * Create a new GdkPixbuf containing a copy of src scaled to
1224 * dest_width x dest_height. Leaves src unaffected. interp_type
1225 * should be GDK_INTERP_NEAREST if you want maximum speed (but when
1226 * scaling down GDK_INTERP_NEAREST is usually unusably ugly). The
1227 * default interp_type should be GDK_INTERP_BILINEAR which offers
1228 * reasonable quality and speed.
1229 * You can scale a sub-portion of src by creating a sub-pixbuf
1230 * pointing into src; see gdk_pixbuf_new_subpixbuf().
1231 * For more complicated scaling/compositing see gdk_pixbuf_scale()
1232 * and gdk_pixbuf_composite().
1233 * src:
1234 * a GdkPixbuf
1235 * dest_width:
1236 * the width of destination image
1237 * dest_height:
1238 * the height of destination image
1239 * interp_type:
1240 * the interpolation type for the transformation.
1241 * Returns:
1242 * the new GdkPixbuf, or NULL if not enough memory could be
1243 * allocated for it.
1245 public Pixbuf scaleSimple(int destWidth, int destHeight, GdkInterpType interpType)
1247 // GdkPixbuf* gdk_pixbuf_scale_simple (const GdkPixbuf *src, int dest_width, int dest_height, GdkInterpType interp_type);
1248 return new Pixbuf( gdk_pixbuf_scale_simple(gdkPixbuf, destWidth, destHeight, interpType) );
1252 * Creates a transformation of the source image src by scaling by
1253 * scale_x and scale_y then translating by offset_x and offset_y,
1254 * then renders the rectangle (dest_x, dest_y, dest_width,
1255 * dest_height) of the resulting image onto the destination image
1256 * replacing the previous contents.
1257 * Try to use gdk_pixbuf_scale_simple() first, this function is
1258 * the industrial-strength power tool you can fall back to if
1259 * gdk_pixbuf_scale_simple() isn't powerful enough.
1260 * src:
1261 * a GdkPixbuf
1262 * dest:
1263 * the GdkPixbuf into which to render the results
1264 * dest_x:
1265 * the left coordinate for region to render
1266 * dest_y:
1267 * the top coordinate for region to render
1268 * dest_width:
1269 * the width of the region to render
1270 * dest_height:
1271 * the height of the region to render
1272 * offset_x:
1273 * the offset in the X direction (currently rounded to an integer)
1274 * offset_y:
1275 * the offset in the Y direction (currently rounded to an integer)
1276 * scale_x:
1277 * the scale factor in the X direction
1278 * scale_y:
1279 * the scale factor in the Y direction
1280 * interp_type:
1281 * the interpolation type for the transformation.
1283 public void scale(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType)
1285 // void gdk_pixbuf_scale (const GdkPixbuf *src, GdkPixbuf *dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type);
1286 gdk_pixbuf_scale(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType);
1290 * Creates a new GdkPixbuf by scaling src to dest_width x
1291 * dest_height and compositing the result with a checkboard of colors
1292 * color1 and color2.
1293 * src:
1294 * a GdkPixbuf
1295 * dest_width:
1296 * the width of destination image
1297 * dest_height:
1298 * the height of destination image
1299 * interp_type:
1300 * the interpolation type for the transformation.
1301 * overall_alpha:
1302 * overall alpha for source image (0..255)
1303 * check_size:
1304 * the size of checks in the checkboard (must be a power of two)
1305 * color1:
1306 * the color of check at upper left
1307 * color2:
1308 * the color of the other check
1309 * Returns:
1310 * the new GdkPixbuf, or NULL if not enough memory could be
1311 * allocated for it.
1313 public Pixbuf compositeColorSimple(int destWidth, int destHeight, GdkInterpType interpType, int overallAlpha, int checkSize, uint color1, uint color2)
1315 // GdkPixbuf* gdk_pixbuf_composite_color_simple (const GdkPixbuf *src, int dest_width, int dest_height, GdkInterpType interp_type, int overall_alpha, int check_size, guint32 color1, guint32 color2);
1316 return new Pixbuf( gdk_pixbuf_composite_color_simple(gdkPixbuf, destWidth, destHeight, interpType, overallAlpha, checkSize, color1, color2) );
1320 * Creates a transformation of the source image src by scaling by
1321 * scale_x and scale_y then translating by offset_x and offset_y.
1322 * This gives an image in the coordinates of the destination pixbuf.
1323 * The rectangle (dest_x, dest_y, dest_width, dest_height)
1324 * is then composited onto the corresponding rectangle of the
1325 * original destination image.
1326 * When the destination rectangle contains parts not in the source
1327 * image, the data at the edges of the source image is replicated
1328 * to infinity.
1329 * Figure1.Compositing of pixbufs
1330 * src:
1331 * a GdkPixbuf
1332 * dest:
1333 * the GdkPixbuf into which to render the results
1334 * dest_x:
1335 * the left coordinate for region to render
1336 * dest_y:
1337 * the top coordinate for region to render
1338 * dest_width:
1339 * the width of the region to render
1340 * dest_height:
1341 * the height of the region to render
1342 * offset_x:
1343 * the offset in the X direction (currently rounded to an integer)
1344 * offset_y:
1345 * the offset in the Y direction (currently rounded to an integer)
1346 * scale_x:
1347 * the scale factor in the X direction
1348 * scale_y:
1349 * the scale factor in the Y direction
1350 * interp_type:
1351 * the interpolation type for the transformation.
1352 * overall_alpha:
1353 * overall alpha for source image (0..255)
1355 public void composite(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType, int overallAlpha)
1357 // void gdk_pixbuf_composite (const GdkPixbuf *src, GdkPixbuf *dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type, int overall_alpha);
1358 gdk_pixbuf_composite(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType, overallAlpha);
1362 * Creates a transformation of the source image src by scaling by
1363 * scale_x and scale_y then translating by offset_x and offset_y,
1364 * then composites the rectangle (dest_x ,dest_y, dest_width,
1365 * dest_height) of the resulting image with a checkboard of the
1366 * colors color1 and color2 and renders it onto the destination
1367 * image.
1368 * See gdk_pixbuf_composite_color_simple() for a simpler variant of this
1369 * function suitable for many tasks.
1370 * src:
1371 * a GdkPixbuf
1372 * dest:
1373 * the GdkPixbuf into which to render the results
1374 * dest_x:
1375 * the left coordinate for region to render
1376 * dest_y:
1377 * the top coordinate for region to render
1378 * dest_width:
1379 * the width of the region to render
1380 * dest_height:
1381 * the height of the region to render
1382 * offset_x:
1383 * the offset in the X direction (currently rounded to an integer)
1384 * offset_y:
1385 * the offset in the Y direction (currently rounded to an integer)
1386 * scale_x:
1387 * the scale factor in the X direction
1388 * scale_y:
1389 * the scale factor in the Y direction
1390 * interp_type:
1391 * the interpolation type for the transformation.
1392 * overall_alpha:
1393 * overall alpha for source image (0..255)
1394 * check_x:
1395 * the X offset for the checkboard (origin of checkboard is at -check_x, -check_y)
1396 * check_y:
1397 * the Y offset for the checkboard
1398 * check_size:
1399 * the size of checks in the checkboard (must be a power of two)
1400 * color1:
1401 * the color of check at upper left
1402 * color2:
1403 * the color of the other check
1405 public void compositeColor(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType, int overallAlpha, int checkX, int checkY, int checkSize, uint color1, uint color2)
1407 // void gdk_pixbuf_composite_color (const GdkPixbuf *src, GdkPixbuf *dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type, int overall_alpha, int check_x, int check_y, int check_size, guint32 color1, guint32 color2);
1408 gdk_pixbuf_composite_color(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType, overallAlpha, checkX, checkY, checkSize, color1, color2);
1413 * Rotates a pixbuf by a multiple of 90 degrees, and returns the
1414 * result in a new pixbuf.
1415 * src:
1416 * a GdkPixbuf
1417 * angle:
1418 * the angle to rotate by
1419 * Returns:
1420 * a new pixbuf
1421 * Since 2.6
1423 public Pixbuf rotateSimple(GdkPixbufRotation angle)
1425 // GdkPixbuf* gdk_pixbuf_rotate_simple (const GdkPixbuf *src, GdkPixbufRotation angle);
1426 return new Pixbuf( gdk_pixbuf_rotate_simple(gdkPixbuf, angle) );
1430 * Flips a pixbuf horizontally or vertically and returns the
1431 * result in a new pixbuf.
1432 * src:
1433 * a GdkPixbuf
1434 * horizontal:
1435 * TRUE to flip horizontally, FALSE to flip vertically
1436 * Returns:
1437 * a new pixbuf.
1438 * Since 2.6
1439 * See Also
1440 * GdkRGB.
1442 public Pixbuf flip(int horizontal)
1444 // GdkPixbuf* gdk_pixbuf_flip (const GdkPixbuf *src, gboolean horizontal);
1445 return new Pixbuf( gdk_pixbuf_flip(gdkPixbuf, horizontal) );
1449 * Takes an existing pixbuf and adds an alpha channel to it.
1450 * If the existing pixbuf already had an alpha channel, the channel
1451 * values are copied from the original; otherwise, the alpha channel
1452 * is initialized to 255 (full opacity).
1453 * If substitute_color is TRUE, then the color specified by (r, g, b) will be
1454 * assigned zero opacity. That is, if you pass (255, 255, 255) for the
1455 * substitute color, all white pixels will become fully transparent.
1456 * pixbuf:
1457 * A GdkPixbuf.
1458 * substitute_color:
1459 * Whether to set a color to zero opacity. If this
1460 * is FALSE, then the (r, g, b) arguments will be ignored.
1461 * r:
1462 * Red value to substitute.
1463 * g:
1464 * Green value to substitute.
1465 * b:
1466 * Blue value to substitute.
1467 * Returns:
1468 * A newly-created pixbuf with a reference count of 1.
1470 public Pixbuf addAlpha(int substituteColor, char r, char g, char b)
1472 // GdkPixbuf* gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color, guchar r, guchar g, guchar b);
1473 return new Pixbuf( gdk_pixbuf_add_alpha(gdkPixbuf, substituteColor, r, g, b) );
1477 * Copies a rectangular area from src_pixbuf to dest_pixbuf. Conversion of
1478 * pixbuf formats is done automatically.
1479 * src_pixbuf:
1480 * Source pixbuf.
1481 * src_x:
1482 * Source X coordinate within src_pixbuf.
1483 * src_y:
1484 * Source Y coordinate within src_pixbuf.
1485 * width:
1486 * Width of the area to copy.
1487 * height:
1488 * Height of the area to copy.
1489 * dest_pixbuf:
1490 * Destination pixbuf.
1491 * dest_x:
1492 * X coordinate within dest_pixbuf.
1493 * dest_y:
1494 * Y coordinate within dest_pixbuf.
1496 public void copyArea(int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY)
1498 // void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf, int src_x, int src_y, int width, int height, GdkPixbuf *dest_pixbuf, int dest_x, int dest_y);
1499 gdk_pixbuf_copy_area(gdkPixbuf, srcX, srcY, width, height, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct(), destX, destY);
1503 * Modifies saturation and optionally pixelates src, placing the result in
1504 * dest. src and dest may be the same pixbuf with no ill effects. If
1505 * saturation is 1.0 then saturation is not changed. If it's less than 1.0,
1506 * saturation is reduced (the image turns toward grayscale); if greater than
1507 * 1.0, saturation is increased (the image gets more vivid colors). If pixelate
1508 * is TRUE, then pixels are faded in a checkerboard pattern to create a
1509 * pixelated image. src and dest must have the same image format, size, and
1510 * rowstride.
1511 * src:
1512 * source image
1513 * dest:
1514 * place to write modified version of src
1515 * saturation:
1516 * saturation factor
1517 * pixelate:
1518 * whether to pixelate
1520 public void saturateAndPixelate(Pixbuf dest, float saturation, int pixelate)
1522 // void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src, GdkPixbuf *dest, gfloat saturation, gboolean pixelate);
1523 gdk_pixbuf_saturate_and_pixelate(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), saturation, pixelate);
1527 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
1528 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
1529 * doesn't have an alpha channel.
1530 * pixbuf:
1531 * a GdkPixbuf
1532 * pixel:
1533 * RGBA pixel to clear to
1534 * (0xffffffff is opaque white, 0x00000000 transparent black)
1535 * See Also
1536 * GdkPixbuf
1538 public void fill(uint pixel)
1540 // void gdk_pixbuf_fill (GdkPixbuf *pixbuf, guint32 pixel);
1541 gdk_pixbuf_fill(gdkPixbuf, pixel);