alternative to assert
[gtkD.git] / src / gdk / Pixbuf.d
blob1c02647069cf8c6c475af2629a4d9da3970ae0cf
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_pixbuf_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * structWrap:
46 * local aliases:
49 module gdk.Pixbuf;
51 private import gdk.gdktypes;
53 private import lib.gdk;
55 private import glib.Str;
57 /**
58 * Description
59 * These functions allow to render pixbufs on drawables. Pixbufs are
60 * client-side images. For details on how to create and manipulate
61 * pixbufs, see the GdkPixbuf API documentation.
63 public class Pixbuf
66 /** the main Gtk struct */
67 protected GdkPixbuf* gdkPixbuf;
70 public GdkPixbuf* getPixbufStruct()
72 return gdkPixbuf;
76 /** the main Gtk struct as a void* */
77 protected void* getStruct()
79 return cast(void*)gdkPixbuf;
82 /**
83 * Sets our main struct and passes it to the parent class
85 public this (GdkPixbuf* gdkPixbuf)
87 this.gdkPixbuf = gdkPixbuf;
90 /**
91 * Description
92 * The most basic way to create a pixbuf is to wrap an existing pixel
93 * buffer with a GdkPixbuf structure. You can use the
94 * gdk_pixbuf_new_from_data() function to do this You need to specify
95 * the destroy notification function that will be called when the
96 * data buffer needs to be freed; this will happen when a GdkPixbuf
97 * is finalized by the reference counting functions If you have a
98 * chunk of static data compiled into your application, you can pass
99 * in NULL as the destroy notification function so that the data
100 * will not be freed.
101 * The gdk_pixbuf_new() function can be used as a convenience to
102 * create a pixbuf with an empty buffer. This is equivalent to
103 * allocating a data buffer using malloc() and
104 * then wrapping it with gdk_pixbuf_new_from_data(). The gdk_pixbuf_new()
105 * function will compute an optimal rowstride so that rendering can be
106 * performed with an efficient algorithm.
107 * As a special case, you can use the gdk_pixbuf_new_from_xpm_data()
108 * function to create a pixbuf from inline XPM image data.
109 * You can also copy an existing pixbuf with the gdk_pixbuf_copy()
110 * function. This is not the same as just doing a g_object_ref()
111 * on the old pixbuf; the copy function will actually duplicate the
112 * pixel data in memory and create a new GdkPixbuf structure for it.
116 * Description
117 * The GdkPixbuf structure contains
118 * information that describes an image in memory.
119 * Image Data
120 * Image data in a pixbuf is stored in memory in uncompressed,
121 * packed format. Rows in the image are stored top to bottom, and
122 * in each row pixels are stored from left to right. There may be
123 * padding at the end of a row. The "rowstride" value of a pixbuf,
124 * as returned by gdk_pixbuf_get_rowstride(), indicates the number
125 * of bytes between rows.
126 * Example1.put_pixel() example
127 * The following code illustrates a simple put_pixel()
128 * function for RGB pixbufs with 8 bits per channel with an alpha
129 * channel. It is not included in the gdk-pixbuf library for
130 * performance reasons; rather than making several function calls
131 * for each pixel, your own code can take shortcuts.
132 * static void
133 * put_pixel (GdkPixbuf *pixbuf, int x, int y, guchar red, guchar green, guchar blue, guchar alpha)
135 * int width, height, rowstride, n_channels;
136 * guchar *pixels, *p;
137 * n_channels = gdk_pixbuf_get_n_channels (pixbuf);
138 * g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
139 * g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
140 * g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
141 * g_assert (n_channels == 4);
142 * width = gdk_pixbuf_get_width (pixbuf);
143 * height = gdk_pixbuf_get_height (pixbuf);
144 * g_assert (x >= 0 x < width);
145 * g_assert (y >= 0 y < height);
146 * rowstride = gdk_pixbuf_get_rowstride (pixbuf);
147 * pixels = gdk_pixbuf_get_pixels (pixbuf);
148 * p = pixels + y * rowstride + x * n_channels;
149 * p[0] = red;
150 * p[1] = green;
151 * p[2] = blue;
152 * p[3] = alpha;
154 * This function will not work for pixbufs with images that are
155 * other than 8 bits per sample or channel, but it will work for
156 * most of the pixbufs that GTK+ uses.
157 * Note
158 * If you are doing memcpy() of raw pixbuf data, note that the
159 * last row in the pixbuf may not be as wide as the full
160 * rowstride, but rather just as wide as the pixel data needs to
161 * be. That is, it is unsafe to do memcpy (dest,
162 * pixels, rowstride * height) to copy a whole pixbuf.
163 * Use gdk_pixbuf_copy() instead, or compute the width in bytes
164 * of the last row as width * ((n_channels *
165 * bits_per_sample + 7) / 8).
169 * Description
170 * GdkPixbuf structures are reference counted. This means that an
171 * application can share a single pixbuf among many parts of the
172 * code. When a piece of the program needs to keep a pointer to a
173 * pixbuf, it should add a reference to it by calling g_object_ref().
174 * When it no longer needs the pixbuf, it should subtract a reference
175 * by calling g_object_unref(). The pixbuf will be destroyed when
176 * its reference count drops to zero. Newly-created GdkPixbuf
177 * structures start with a reference count of one.
178 * Note
179 * As GdkPixbuf is derived from GObject now, gdk_pixbuf_ref() and
180 * gdk_pixbuf_unref() are deprecated in favour of g_object_ref()
181 * and g_object_unref() resp.
182 * Finalizing a pixbuf means to free its pixel
183 * data and to free the GdkPixbuf structure itself. Most of the
184 * library functions that create GdkPixbuf structures create the
185 * pixel data by themselves and define the way it should be freed;
186 * you do not need to worry about those. The only function that lets
187 * you specify how to free the pixel data is
188 * gdk_pixbuf_new_from_data(). Since you pass it a pre-allocated
189 * pixel buffer, you must also specify a way to free that data. This
190 * is done with a function of type GdkPixbufDestroyNotify. When a
191 * pixbuf created with gdk_pixbuf_new_from_data() is finalized, your
192 * destroy notification function will be called, and it is its
193 * responsibility to free the pixel array.
197 * Description
198 * The gdk-pixbuf library provides a simple mechanism for loading
199 * an image from a file in synchronous fashion. This means that the
200 * library takes control of the application while the file is being
201 * loaded; from the user's point of view, the application will block
202 * until the image is done loading.
203 * This interface can be used by applications in which blocking is
204 * acceptable while an image is being loaded. It can also be used to
205 * load small images in general. Applications that need progressive
206 * loading can use the GdkPixbufLoader functionality instead.
210 * Description
211 * These functions allow to save a GdkPixbuf in a number of
212 * file formats. The formatted data can be written to a file
213 * or to a memory buffer. gdk-pixbuf can also call a user-defined
214 * callback on the data, which allows to e.g. write the image
215 * to a socket or store it in a database.
219 * Description
220 * The gdk-pixbuf contains functions to scale pixbufs, to scale
221 * pixbufs and composite against an existing image, and to scale
222 * pixbufs and composite against a solid color or checkerboard.
223 * Compositing a checkerboard is a common way to show an image with
224 * an alpha channel in image-viewing and editing software.
225 * Since the full-featured functions (gdk_pixbuf_scale(),
226 * gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
227 * rather complex to use and have many arguments, two simple
228 * convenience functions are provided, gdk_pixbuf_scale_simple() and
229 * gdk_pixbuf_composite_color_simple() which create a new pixbuf of a
230 * given size, scale an original image to fit, and then return the
231 * new pixbuf.
232 * The following example demonstrates handling an expose event by
233 * rendering the appropriate area of a source image (which is scaled
234 * to fit the widget) onto the widget's window. The source image is
235 * rendered against a checkerboard, which provides a visual
236 * representation of the alpha channel if the image has one. If the
237 * image doesn't have an alpha channel, calling
238 * gdk_pixbuf_composite_color() function has exactly the same effect
239 * as calling gdk_pixbuf_scale().
240 * Example2.Handling an expose event.
241 * gboolean
242 * expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
244 * GdkPixbuf *dest;
245 * dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
246 * gdk_pixbuf_composite_color (pixbuf, dest,
247 * 0, 0, event->area.width, event->area.height,
248 * -event->area.x, -event->area.y,
249 * (double) widget->allocation.width / gdk_pixbuf_get_width (pixbuf),
250 * (double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf),
251 * GDK_INTERP_BILINEAR, 255,
252 * event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
253 * gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
254 * 0, 0, event->area.x, event->area.y,
255 * event->area.width, event->area.height,
256 * GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
257 * gdk_pixbuf_unref (dest);
258 * return TRUE;
263 * Description
264 * These functions provide miscellaneous utilities for manipulating
265 * pixbufs. The pixel data in pixbufs may of course be manipulated
266 * directly by applications, but several common operations can be
267 * performed by these functions instead.
271 * Takes the opacity values in a rectangular portion of a pixbuf and thresholds
272 * them to produce a bi-level alpha mask that can be used as a clipping mask for
273 * a drawable.
274 * pixbuf:
275 * A pixbuf.
276 * bitmap:
277 * Bitmap where the bilevel mask will be painted to.
278 * src_x:
279 * Source X coordinate.
280 * src_y:
281 * source Y coordinate.
282 * dest_x:
283 * Destination X coordinate.
284 * dest_y:
285 * Destination Y coordinate.
286 * width:
287 * Width of region to threshold, or -1 to use pixbuf width
288 * height:
289 * Height of region to threshold, or -1 to use pixbuf height
290 * alpha_threshold:
291 * Opacity values below this will be painted as zero; all
292 * other values will be painted as one.
294 public void renderThresholdAlpha(GdkBitmap* bitmap, int srcX, int srcY, int destX, int destY, int width, int height, int alphaThreshold)
296 // 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);
297 gdk_pixbuf_render_threshold_alpha(gdkPixbuf, bitmap, srcX, srcY, destX, destY, width, height, alphaThreshold);
301 * Warning
302 * 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.
303 * Renders a rectangular portion of a pixbuf to a drawable while using the
304 * specified GC. This is done using GdkRGB, so the specified drawable must have
305 * the GdkRGB visual and colormap. Note that this function will ignore the
306 * opacity information for images with an alpha channel; the GC must already
307 * have the clipping mask set if you want transparent regions to show through.
308 * For an explanation of dither offsets, see the GdkRGB documentation. In
309 * brief, the dither offset is important when re-rendering partial regions of an
310 * image to a rendered version of the full image, or for when the offsets to a
311 * base position change, as in scrolling. The dither matrix has to be shifted
312 * for consistent visual results. If you do not have any of these cases, the
313 * dither offsets can be both zero.
314 * pixbuf:
315 * A pixbuf.
316 * drawable:
317 * Destination drawable.
318 * gc:
319 * GC used for rendering.
320 * src_x:
321 * Source X coordinate within pixbuf.
322 * src_y:
323 * Source Y coordinate within pixbuf.
324 * dest_x:
325 * Destination X coordinate within drawable.
326 * dest_y:
327 * Destination Y coordinate within drawable.
328 * width:
329 * Width of region to render, in pixels, or -1 to use pixbuf width
330 * height:
331 * Height of region to render, in pixels, or -1 to use pixbuf height
332 * dither:
333 * Dithering mode for GdkRGB.
334 * x_dither:
335 * X offset for dither.
336 * y_dither:
337 * Y offset for dither.
339 public void renderToDrawable(GdkDrawable* drawable, GdkGC* gc, int srcX, int srcY, int destX, int destY, int width, int height, GdkRgbDither dither, int xDither, int yDither)
341 // 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);
342 gdk_pixbuf_render_to_drawable(gdkPixbuf, drawable, gc, srcX, srcY, destX, destY, width, height, dither, xDither, yDither);
346 * Warning
347 * 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.
348 * Renders a rectangular portion of a pixbuf to a drawable. The destination
349 * drawable must have a colormap. All windows have a colormap, however, pixmaps
350 * only have colormap by default if they were created with a non-NULL window argument.
351 * Otherwise a colormap must be set on them with gdk_drawable_set_colormap.
352 * On older X servers, rendering pixbufs with an alpha channel involves round trips
353 * to the X server, and may be somewhat slow.
354 * pixbuf:
355 * A pixbuf.
356 * drawable:
357 * Destination drawable.
358 * src_x:
359 * Source X coordinate within pixbuf.
360 * src_y:
361 * Source Y coordinates within pixbuf.
362 * dest_x:
363 * Destination X coordinate within drawable.
364 * dest_y:
365 * Destination Y coordinate within drawable.
366 * width:
367 * Width of region to render, in pixels, or -1 to use pixbuf width.
368 * height:
369 * Height of region to render, in pixels, or -1 to use pixbuf height.
370 * alpha_mode:
371 * Ignored. Present for backwards compatibility.
372 * alpha_threshold:
373 * Ignored. Present for backwards compatibility
374 * dither:
375 * Dithering mode for GdkRGB.
376 * x_dither:
377 * X offset for dither.
378 * y_dither:
379 * Y offset for dither.
381 public void renderToDrawableAlpha(GdkDrawable* drawable, int srcX, int srcY, int destX, int destY, int width, int height, GdkPixbufAlphaMode alphaMode, int alphaThreshold, GdkRgbDither dither, int xDither, int yDither)
383 // 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);
384 gdk_pixbuf_render_to_drawable_alpha(gdkPixbuf, drawable, srcX, srcY, destX, destY, width, height, alphaMode, alphaThreshold, dither, xDither, yDither);
388 * Creates a pixmap and a mask bitmap which are returned in the pixmap_return
389 * and mask_return arguments, respectively, and renders a pixbuf and its
390 * corresponding thresholded alpha mask to them. This is merely a convenience
391 * function; applications that need to render pixbufs with dither offsets or to
392 * given drawables should use gdk_draw_pixbuf() and gdk_pixbuf_render_threshold_alpha().
393 * The pixmap that is created is created for the colormap returned
394 * by gdk_rgb_get_colormap(). You normally will want to instead use
395 * the actual colormap for a widget, and use
396 * gdk_pixbuf_render_pixmap_and_mask_for_colormap().
397 * If the pixbuf does not have an alpha channel, then *mask_return will be set
398 * to NULL.
399 * pixbuf:
400 * A pixbuf.
401 * pixmap_return:
402 * Location to store a pointer to the created pixmap,
403 * or NULL if the pixmap is not needed.
404 * mask_return:
405 * Location to store a pointer to the created mask,
406 * or NULL if the mask is not needed.
407 * alpha_threshold:
408 * Threshold value for opacity values.
410 public void renderPixmapAndMask(GdkPixmap** pixmapReturn, GdkBitmap** maskReturn, int alphaThreshold)
412 // void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold);
413 gdk_pixbuf_render_pixmap_and_mask(gdkPixbuf, pixmapReturn, maskReturn, alphaThreshold);
417 * Creates a pixmap and a mask bitmap which are returned in the pixmap_return
418 * and mask_return arguments, respectively, and renders a pixbuf and its
419 * corresponding tresholded alpha mask to them. This is merely a convenience
420 * function; applications that need to render pixbufs with dither offsets or to
421 * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha().
422 * The pixmap that is created uses the GdkColormap specified by colormap.
423 * This colormap must match the colormap of the window where the pixmap
424 * will eventually be used or an error will result.
425 * If the pixbuf does not have an alpha channel, then *mask_return will be set
426 * to NULL.
427 * pixbuf:
428 * A pixbuf.
429 * colormap:
430 * A GdkColormap
431 * pixmap_return:
432 * Location to store a pointer to the created pixmap,
433 * or NULL if the pixmap is not needed.
434 * mask_return:
435 * Location to store a pointer to the created mask,
436 * or NULL if the mask is not needed.
437 * alpha_threshold:
438 * Threshold value for opacity values.
440 public void renderPixmapAndMaskForColormap(GdkColormap* colormap, GdkPixmap** pixmapReturn, GdkBitmap** maskReturn, int alphaThreshold)
442 // void gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, GdkColormap *colormap, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold);
443 gdk_pixbuf_render_pixmap_and_mask_for_colormap(gdkPixbuf, colormap, pixmapReturn, maskReturn, alphaThreshold);
447 * Transfers image data from a GdkDrawable and converts it to an RGB(A)
448 * representation inside a GdkPixbuf. In other words, copies
449 * image data from a server-side drawable to a client-side RGB(A) buffer.
450 * This allows you to efficiently read individual pixels on the client side.
451 * If the drawable src has no colormap (gdk_drawable_get_colormap()
452 * returns NULL), then a suitable colormap must be specified.
453 * Typically a GdkWindow or a pixmap created by passing a GdkWindow
454 * to gdk_pixmap_new() will already have a colormap associated with
455 * it. If the drawable has a colormap, the cmap argument will be
456 * ignored. If the drawable is a bitmap (1 bit per pixel pixmap),
457 * then a colormap is not required; pixels with a value of 1 are
458 * assumed to be white, and pixels with a value of 0 are assumed to be
459 * black. For taking screenshots, gdk_colormap_get_system() returns
460 * the correct colormap to use.
461 * If the specified destination pixbuf dest is NULL, then this
462 * function will create an RGB pixbuf with 8 bits per channel and no
463 * alpha, with the same size specified by the width and height
464 * arguments. In this case, the dest_x and dest_y arguments must be
465 * specified as 0. If the specified destination pixbuf is not NULL
466 * and it contains alpha information, then the filled pixels will be
467 * set to full opacity (alpha = 255).
468 * If the specified drawable is a pixmap, then the requested source
469 * rectangle must be completely contained within the pixmap, otherwise
470 * the function will return NULL. For pixmaps only (not for windows)
471 * passing -1 for width or height is allowed to mean the full width
472 * or height of the pixmap.
473 * If the specified drawable is a window, and the window is off the
474 * screen, then there is no image data in the obscured/offscreen
475 * regions to be placed in the pixbuf. The contents of portions of the
476 * pixbuf corresponding to the offscreen region are undefined.
477 * If the window you're obtaining data from is partially obscured by
478 * other windows, then the contents of the pixbuf areas corresponding
479 * to the obscured regions are undefined.
480 * If the target drawable is not mapped (typically because it's
481 * iconified/minimized or not on the current workspace), then NULL
482 * will be returned.
483 * If memory can't be allocated for the return value, NULL will be returned
484 * instead.
485 * (In short, there are several ways this function can fail, and if it fails
486 * it returns NULL; so check the return value.)
487 * This function calls gdk_drawable_get_image() internally and
488 * converts the resulting image to a GdkPixbuf, so the
489 * documentation for gdk_drawable_get_image() may also be relevant.
490 * dest:
491 * Destination pixbuf, or NULL if a new pixbuf should be created.
492 * src:
493 * Source drawable.
494 * cmap:
495 * A colormap if src doesn't have one set.
496 * src_x:
497 * Source X coordinate within drawable.
498 * src_y:
499 * Source Y coordinate within drawable.
500 * dest_x:
501 * Destination X coordinate in pixbuf, or 0 if dest is NULL.
502 * dest_y:
503 * Destination Y coordinate in pixbuf, or 0 if dest is NULL.
504 * width:
505 * Width in pixels of region to get.
506 * height:
507 * Height in pixels of region to get.
508 * Returns:
509 * The same pixbuf as dest if it was non-NULL, or a newly-created
510 * pixbuf with a reference count of 1 if no destination pixbuf was specified, or NULL on error
512 public GdkPixbuf* getFromDrawable(GdkDrawable* src, GdkColormap* cmap, int srcX, int srcY, int destX, int destY, int width, int height)
514 // 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);
515 return gdk_pixbuf_get_from_drawable(gdkPixbuf, src, cmap, srcX, srcY, destX, destY, width, height);
519 * Same as gdk_pixbuf_get_from_drawable() but gets the pixbuf from
520 * an image.
521 * dest:
522 * Destination pixbuf, or NULL if a new pixbuf should be created.
523 * src:
524 * Source GdkImage.
525 * cmap:
526 * A colormap, or NULL to use the one for src
527 * src_x:
528 * Source X coordinate within drawable.
529 * src_y:
530 * Source Y coordinate within drawable.
531 * dest_x:
532 * Destination X coordinate in pixbuf, or 0 if dest is NULL.
533 * dest_y:
534 * Destination Y coordinate in pixbuf, or 0 if dest is NULL.
535 * width:
536 * Width in pixels of region to get.
537 * height:
538 * Height in pixels of region to get.
539 * Returns:
540 * dest, newly-created pixbuf if dest was NULL, NULL on error
542 public GdkPixbuf* getFromImage(GdkImage* src, GdkColormap* cmap, int srcX, int srcY, int destX, int destY, int width, int height)
544 // 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);
545 return gdk_pixbuf_get_from_image(gdkPixbuf, src, cmap, srcX, srcY, destX, destY, width, height);
549 * <hr>
550 * gdk_pixbuf_new ()
551 * GdkPixbuf* gdk_pixbuf_new (GdkColorspace colorspace,
552 * gboolean has_alpha,
553 * int bits_per_sample,
554 * int width,
555 * int height);
556 * Creates a new GdkPixbuf structure and allocates a buffer for it. The
557 * buffer has an optimal rowstride. Note that the buffer is not cleared;
558 * you will have to fill it completely yourself.
559 * colorspace:
560 * Color space for image.
561 * has_alpha:
562 * Whether the image should have transparency information.
563 * bits_per_sample:
564 * Number of bits per color sample.
565 * width:
566 * Width of image in pixels.
567 * height:
568 * Height of image in pixels.
569 * Returns:
570 * A newly-created GdkPixbuf with a reference count of 1, or
571 * NULL if not enough memory could be allocated for the image buffer.
573 public static GType getType()
575 // GType gdk_pixbuf_get_type ();
576 return gdk_pixbuf_get_type();
580 * Creates a new GdkPixbuf out of in-memory image data. Currently only RGB
581 * images with 8 bits per sample are supported.
582 * data:
583 * Image data in 8-bit/sample packed format.
584 * colorspace:
585 * Colorspace for the image data.
586 * has_alpha:
587 * Whether the data has an opacity channel.
588 * bits_per_sample:
589 * Number of bits per sample.
590 * width:
591 * Width of the image in pixels.
592 * height:
593 * Height of the image in pixels.
594 * rowstride:
595 * Distance in bytes between row starts.
596 * destroy_fn:
597 * Function used to free the data when the pixbuf's reference count
598 * drops to zero, or NULL if the data should not be freed.
599 * destroy_fn_data:
600 * Closure data to pass to the destroy notification function.
601 * Returns:
602 * A newly-created GdkPixbuf structure with a reference count of 1.
604 public this (char* data, GdkColorspace colorspace, int hasAlpha, int bitsPerSample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroyFn, void* destroyFnData)
606 // 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);
607 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_data(data, colorspace, hasAlpha, bitsPerSample, width, height, rowstride, destroyFn, destroyFnData) );
611 * Creates a new pixbuf by parsing XPM data in memory. This data is commonly
612 * the result of including an XPM file into a program's C source.
613 * data:
614 * Pointer to inline XPM data.
615 * Returns:
616 * A newly-created pixbuf with a reference count of 1.
618 public this (char** data)
620 // GdkPixbuf* gdk_pixbuf_new_from_xpm_data (const char **data);
621 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_xpm_data(data) );
625 * Create a GdkPixbuf from a flat representation that is suitable for
626 * storing as inline data in a program. This is useful if you want to
627 * ship a program with images, but don't want to depend on any
628 * external files.
629 * GTK+ ships with a program called gdk-pixbuf-csource
630 * which allows for conversion of GdkPixbufs into such a inline representation.
631 * In almost all cases, you should pass the --raw flag to
632 * gdk-pixbuf-csource. A sample invocation would be:
633 * gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
634 * For the typical case where the inline pixbuf is read-only static data,
635 * you don't need to copy the pixel data unless you intend to write to
636 * it, so you can pass FALSE for copy_pixels. (If you pass
637 * --rle to gdk-pixbuf-csource, a copy
638 * will be made even if copy_pixels is FALSE, so using this option is
639 * generally a bad idea.)
640 * If you create a pixbuf from const inline data compiled into your
641 * program, it's probably safe to ignore errors and disable length checks,
642 * since things will always succeed:
643 * pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL);
644 * For non-const inline data, you could get out of memory. For untrusted
645 * inline data located at runtime, you could have corrupt inline data in
646 * addition.
647 * data_length:
648 * Length in bytes of the data argument or -1 to
649 * disable length checks
650 * data:
651 * Byte data containing a serialized GdkPixdata structure
652 * copy_pixels:
653 * Whether to copy the pixel data, or use direct pointers
654 * data for the resulting pixbuf
655 * error:
656 * GError return location, may be NULL to ignore errors
657 * Returns:
658 * A newly-created GdkPixbuf structure with a reference,
659 * count of 1, or NULL if an error occurred.
661 public this (int dataLength, byte* data, int copyPixels, GError** error)
663 // GdkPixbuf* gdk_pixbuf_new_from_inline (gint data_length, const guint8 *data, gboolean copy_pixels, GError **error);
664 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_inline(dataLength, data, copyPixels, error) );
668 * Creates a new pixbuf which represents a sub-region of
669 * src_pixbuf. The new pixbuf shares its pixels with the
670 * original pixbuf, so writing to one affects both.
671 * The new pixbuf holds a reference to src_pixbuf, so
672 * src_pixbuf will not be finalized until the new pixbuf
673 * is finalized.
674 * src_pixbuf:
675 * a GdkPixbuf
676 * src_x:
677 * X coord in src_pixbuf
678 * src_y:
679 * Y coord in src_pixbuf
680 * width:
681 * width of region in src_pixbuf
682 * height:
683 * height of region in src_pixbuf
684 * Returns:
685 * a new pixbuf
687 public this (int srcX, int srcY, int width, int height)
689 // GdkPixbuf* gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf, int src_x, int src_y, int width, int height);
690 this(cast(GdkPixbuf*)gdk_pixbuf_new_subpixbuf(gdkPixbuf, srcX, srcY, width, height) );
694 * Creates a new GdkPixbuf with a copy of the information in the specified
695 * pixbuf.
696 * pixbuf:
697 * A pixbuf.
698 * Returns:
699 * A newly-created pixbuf with a reference count of 1, or NULL if
700 * not enough memory could be allocated.
701 * See Also
702 * gdk_pixbuf_finalize().
704 public Pixbuf copy()
706 // GdkPixbuf* gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
707 return new Pixbuf( gdk_pixbuf_copy(gdkPixbuf) );
716 * Queries the color space of a pixbuf.
717 * pixbuf:
718 * A pixbuf.
719 * Returns:
720 * Color space.
722 public GdkColorspace getColorspace()
724 // GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf);
725 return gdk_pixbuf_get_colorspace(gdkPixbuf);
729 * Queries the number of channels of a pixbuf.
730 * pixbuf:
731 * A pixbuf.
732 * Returns:
733 * Number of channels.
735 public int getNChannels()
737 // int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf);
738 return gdk_pixbuf_get_n_channels(gdkPixbuf);
742 * Queries whether a pixbuf has an alpha channel (opacity information).
743 * pixbuf:
744 * A pixbuf.
745 * Returns:
746 * TRUE if it has an alpha channel, FALSE otherwise.
748 public int getHasAlpha()
750 // gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf);
751 return gdk_pixbuf_get_has_alpha(gdkPixbuf);
755 * Queries the number of bits per color sample in a pixbuf.
756 * pixbuf:
757 * A pixbuf.
758 * Returns:
759 * Number of bits per color sample.
761 public int getBitsPerSample()
763 // int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
764 return gdk_pixbuf_get_bits_per_sample(gdkPixbuf);
768 * Queries a pointer to the pixel data of a pixbuf.
769 * pixbuf:
770 * A pixbuf.
771 * Returns:
772 * A pointer to the pixbuf's pixel data. Please see the section called Image Data
773 * for information about how the pixel data is stored in
774 * memory.
776 public char* getPixels()
778 // guchar* gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf);
779 return gdk_pixbuf_get_pixels(gdkPixbuf);
783 * Queries the width of a pixbuf.
784 * pixbuf:
785 * A pixbuf.
786 * Returns:
787 * Width in pixels.
789 public int getWidth()
791 // int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf);
792 return gdk_pixbuf_get_width(gdkPixbuf);
796 * Queries the height of a pixbuf.
797 * pixbuf:
798 * A pixbuf.
799 * Returns:
800 * Height in pixels.
802 public int getHeight()
804 // int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf);
805 return gdk_pixbuf_get_height(gdkPixbuf);
809 * Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row
810 * and the start of the next row.
811 * pixbuf:
812 * A pixbuf.
813 * Returns:
814 * Distance between row starts.
816 public int getRowstride()
818 // int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf);
819 return gdk_pixbuf_get_rowstride(gdkPixbuf);
823 * Looks up key in the list of options that may have been attached to the
824 * pixbuf when it was loaded.
825 * pixbuf:
826 * a GdkPixbuf
827 * key:
828 * a nul-terminated string.
829 * Returns:
830 * the value associated with key. This is a nul-terminated
831 * string that should not be freed or NULL if key was not found.
832 * Property Details
833 * The "bits-per-sample" property
834 * "bits-per-sample" gint : Read / Write / Construct Only
835 * The number of bits per sample.
836 * Currently only 8 bit per sample are supported.
837 * Allowed values: [1,16]
838 * Default value: 8
840 public char[] getOption(char[] key)
842 // const gchar* gdk_pixbuf_get_option (GdkPixbuf *pixbuf, const gchar *key);
843 return Str.toString(gdk_pixbuf_get_option(gdkPixbuf, Str.toStringz(key)) );
857 * Creates a new pixbuf by loading an image from a file. The file format is
858 * detected automatically. If NULL is returned, then error will be set.
859 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
860 * filename:
861 * Name of file to load, in the GLib file name encoding
862 * error:
863 * Return location for an error
864 * Returns:
865 * A newly-created pixbuf with a reference count of 1, or NULL if
866 * any of several error conditions occurred: the file could not be opened,
867 * there was no loader for the file's format, there was not enough memory to
868 * allocate the image buffer, or the image file contained invalid data.
870 public this (char[] filename, GError** error)
872 // GdkPixbuf* gdk_pixbuf_new_from_file (const char *filename, GError **error);
873 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_file(Str.toStringz(filename), error) );
877 * Creates a new pixbuf by loading an image from a file. The file format is
878 * detected automatically. If NULL is returned, then error will be set.
879 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
880 * The image will be scaled to fit in the requested size, preserving
881 * the image's aspect ratio.
882 * filename:
883 * Name of file to load, in the GLib file name encoding
884 * width:
885 * The width the image should have or -1 to not constrain the width
886 * height:
887 * The height the image should have or -1 to not constrain the height
888 * error:
889 * Return location for an error
890 * Returns:
891 * A newly-created pixbuf with a reference count of 1, or
892 * NULL if any of several error conditions occurred: the file could not
893 * be opened, there was no loader for the file's format, there was not
894 * enough memory to allocate the image buffer, or the image file contained
895 * invalid data.
896 * Since 2.4
898 public this (char[] filename, int width, int height, GError** error)
900 // GdkPixbuf* gdk_pixbuf_new_from_file_at_size (const char *filename, int width, int height, GError **error);
901 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_file_at_size(Str.toStringz(filename), width, height, error) );
905 * Creates a new pixbuf by loading an image from a file. The file format is
906 * detected automatically. If NULL is returned, then error will be set.
907 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
908 * The image will be scaled to fit in the requested size, optionally preserving
909 * the image's aspect ratio.
910 * When preserving the aspect ratio, a width of -1 will cause the image
911 * to be scaled to the exact given height, and a height of -1 will cause
912 * the image to be scaled to the exact given width. When not preserving
913 * aspect ratio, a width or height of -1 means to not scale the image
914 * at all in that dimension. Negative values for width and height are
915 * allowed since 2.8.
916 * filename:
917 * Name of file to load, in the GLib file name encoding
918 * width:
919 * The width the image should have or -1 to not constrain the width
920 * height:
921 * The height the image should have or -1 to not constrain the height
922 * preserve_aspect_ratio:
923 * TRUE to preserve the image's aspect ratio
924 * error:
925 * Return location for an error
926 * Returns:
927 * A newly-created pixbuf with a reference count of 1, or NULL
928 * if any of several error conditions occurred: the file could not be opened,
929 * there was no loader for the file's format, there was not enough memory to
930 * allocate the image buffer, or the image file contained invalid data.
931 * Since 2.6
933 public this (char[] filename, int width, int height, int preserveAspectRatio, GError** error)
935 // GdkPixbuf* gdk_pixbuf_new_from_file_at_scale (const char *filename, int width, int height, gboolean preserve_aspect_ratio, GError **error);
936 this(cast(GdkPixbuf*)gdk_pixbuf_new_from_file_at_scale(Str.toStringz(filename), width, height, preserveAspectRatio, error) );
941 * Saves pixbuf to a file in type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
942 * If error is set, FALSE will be returned.
943 * See gdk_pixbuf_save() for more details.
944 * pixbuf:
945 * a GdkPixbuf.
946 * filename:
947 * name of file to save.
948 * type:
949 * name of file format.
950 * option_keys:
951 * name of options to set, NULL-terminated
952 * option_values:
953 * values for named options
954 * error:
955 * return location for error, or NULL
956 * Returns:
957 * whether an error was set
959 public int savev(char[] filename, char[] type, char** optionKeys, char** optionValues, GError** error)
961 // gboolean gdk_pixbuf_savev (GdkPixbuf *pixbuf, const char *filename, const char *type, char **option_keys, char **option_values, GError **error);
962 return gdk_pixbuf_savev(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), optionKeys, optionValues, error);
966 * Saves pixbuf to a file in format type. By default, "jpeg", "png", "ico"
967 * and "bmp" are possible file formats to save in, but more formats may be
968 * installed. The list of all writable formats can be determined in the
969 * following way:
970 * void add_if_writable (GdkPixbufFormat *data, GSList **list)
972 * if (gdk_pixbuf_format_is_writable (data))
973 * *list = g_slist_prepend (*list, data);
975 * GSList *formats = gdk_pixbuf_get_formats ();
976 * GSList *writable_formats = NULL;
977 * g_slist_foreach (formats, add_if_writable, writable_formats);
978 * g_slist_free (formats);
979 * If error is set, FALSE will be returned. Possible errors include
980 * those in the GDK_PIXBUF_ERROR domain and those in the G_FILE_ERROR domain.
981 * The variable argument list should be NULL-terminated; if not empty,
982 * it should contain pairs of strings that modify the save
983 * parameters. For example:
984 * gdk_pixbuf_save (pixbuf, handle, "jpeg", error,
985 * "quality", "100", NULL);
986 * Currently only few parameters exist. JPEG images can be saved with a
987 * "quality" parameter; its value should be in the range [0,100].
988 * Text chunks can be attached to PNG images by specifying parameters of
989 * the form "tEXt::key", where key is an ASCII string of length 1-79.
990 * The values are UTF-8 encoded strings. The PNG compression level can
991 * be specified using the "compression" parameter; it's value is in an
992 * integer in the range of [0,9].
993 * ICO images can be saved in depth 16, 24, or 32, by using the "depth"
994 * parameter. When the ICO saver is given "x_hot" and "y_hot" parameters,
995 * it produces a CUR instead of an ICO.
996 * pixbuf:
997 * a GdkPixbuf.
998 * filename:
999 * name of file to save.
1000 * type:
1001 * name of file format.
1002 * error:
1003 * return location for error, or NULL
1004 * ...:
1005 * list of key-value save options
1006 * Returns:
1007 * whether an error was set
1009 public int save(char[] filename, char[] type, GError** error, ... )
1011 // gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf, const char *filename, const char *type, GError **error, ...);
1012 return gdk_pixbuf_save(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), error);
1017 * Saves pixbuf in format type by feeding the produced data to a
1018 * callback. Can be used when you want to store the image to something
1019 * other than a file, such as an in-memory buffer or a socket.
1020 * If error is set, FALSE will be returned. Possible errors
1021 * include those in the GDK_PIXBUF_ERROR domain and whatever the save
1022 * function generates.
1023 * See gdk_pixbuf_save() for more details.
1024 * pixbuf:
1025 * a GdkPixbuf.
1026 * save_func:
1027 * a function that is called to save each block of data that
1028 * the save routine generates.
1029 * user_data:
1030 * user data to pass to the save function.
1031 * type:
1032 * name of file format.
1033 * error:
1034 * return location for error, or NULL
1035 * ...:
1036 * list of key-value save options
1037 * Returns:
1038 * whether an error was set
1039 * Since 2.4
1041 public int saveToCallback(GdkPixbufSaveFunc saveFunc, void* userData, char[] type, GError** error, ... )
1043 // gboolean gdk_pixbuf_save_to_callback (GdkPixbuf *pixbuf, GdkPixbufSaveFunc save_func, gpointer user_data, const char *type, GError **error, ...);
1044 return gdk_pixbuf_save_to_callback(gdkPixbuf, saveFunc, userData, Str.toStringz(type), error);
1048 * Saves pixbuf to a callback in format type, which is currently "jpeg",
1049 * "png", "tiff", "ico" or "bmp". If error is set, FALSE will be returned. See
1050 * gdk_pixbuf_save_to_callback() for more details.
1051 * pixbuf:
1052 * a GdkPixbuf.
1053 * save_func:
1054 * a function that is called to save each block of data that
1055 * the save routine generates.
1056 * user_data:
1057 * user data to pass to the save function.
1058 * type:
1059 * name of file format.
1060 * option_keys:
1061 * name of options to set, NULL-terminated
1062 * option_values:
1063 * values for named options
1064 * error:
1065 * return location for error, or NULL
1066 * Returns:
1067 * whether an error was set
1068 * Since 2.4
1070 public int saveToCallbackv(GdkPixbufSaveFunc saveFunc, void* userData, char[] type, char** optionKeys, char** optionValues, GError** error)
1072 // 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);
1073 return gdk_pixbuf_save_to_callbackv(gdkPixbuf, saveFunc, userData, Str.toStringz(type), optionKeys, optionValues, error);
1077 * Saves pixbuf to a new buffer in format type, which is currently "jpeg",
1078 * "png", "tiff", "ico" or "bmp". This is a convenience function that uses
1079 * gdk_pixbuf_save_to_callback() to do the real work. Note that the buffer
1080 * is not nul-terminated and may contain embedded nuls.
1081 * If error is set, FALSE will be returned and string will be set to
1082 * NULL. Possible errors include those in the GDK_PIXBUF_ERROR
1083 * domain.
1084 * See gdk_pixbuf_save() for more details.
1085 * pixbuf:
1086 * a GdkPixbuf.
1087 * buffer:
1088 * location to receive a pointer to the new buffer.
1089 * buffer_size:
1090 * location to receive the size of the new buffer.
1091 * type:
1092 * name of file format.
1093 * error:
1094 * return location for error, or NULL
1095 * ...:
1096 * list of key-value save options
1097 * Returns:
1098 * whether an error was set
1099 * Since 2.4
1101 public int saveToBuffer(char** buffer, uint* bufferSize, char[] type, GError** error, ... )
1103 // gboolean gdk_pixbuf_save_to_buffer (GdkPixbuf *pixbuf, gchar **buffer, gsize *buffer_size, const char *type, GError **error, ...);
1104 return gdk_pixbuf_save_to_buffer(gdkPixbuf, buffer, bufferSize, Str.toStringz(type), error);
1108 * Saves pixbuf to a new buffer in format type, which is currently "jpeg",
1109 * "tiff", "png", "ico" or "bmp". See gdk_pixbuf_save_to_buffer() for more details.
1110 * pixbuf:
1111 * a GdkPixbuf.
1112 * buffer:
1113 * location to receive a pointer to the new buffer.
1114 * buffer_size:
1115 * location to receive the size of the new buffer.
1116 * type:
1117 * name of file format.
1118 * option_keys:
1119 * name of options to set, NULL-terminated
1120 * option_values:
1121 * values for named options
1122 * error:
1123 * return location for error, or NULL
1124 * Returns:
1125 * whether an error was set
1126 * Since 2.4
1128 public int saveToBufferv(char** buffer, uint* bufferSize, char[] type, char** optionKeys, char** optionValues, GError** error)
1130 // gboolean gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf, gchar **buffer, gsize *buffer_size, const char *type, char **option_keys, char **option_values, GError **error);
1131 return gdk_pixbuf_save_to_bufferv(gdkPixbuf, buffer, bufferSize, Str.toStringz(type), optionKeys, optionValues, error);
1136 * Create a new GdkPixbuf containing a copy of src scaled to
1137 * dest_width x dest_height. Leaves src unaffected. interp_type
1138 * should be GDK_INTERP_NEAREST if you want maximum speed (but when
1139 * scaling down GDK_INTERP_NEAREST is usually unusably ugly). The
1140 * default interp_type should be GDK_INTERP_BILINEAR which offers
1141 * reasonable quality and speed.
1142 * You can scale a sub-portion of src by creating a sub-pixbuf
1143 * pointing into src; see gdk_pixbuf_new_subpixbuf().
1144 * For more complicated scaling/compositing see gdk_pixbuf_scale()
1145 * and gdk_pixbuf_composite().
1146 * src:
1147 * a GdkPixbuf
1148 * dest_width:
1149 * the width of destination image
1150 * dest_height:
1151 * the height of destination image
1152 * interp_type:
1153 * the interpolation type for the transformation.
1154 * Returns:
1155 * the new GdkPixbuf, or NULL if not enough memory could be
1156 * allocated for it.
1158 public Pixbuf scaleSimple(int destWidth, int destHeight, GdkInterpType interpType)
1160 // GdkPixbuf* gdk_pixbuf_scale_simple (const GdkPixbuf *src, int dest_width, int dest_height, GdkInterpType interp_type);
1161 return new Pixbuf( gdk_pixbuf_scale_simple(gdkPixbuf, destWidth, destHeight, interpType) );
1165 * Creates a transformation of the source image src by scaling by
1166 * scale_x and scale_y then translating by offset_x and offset_y,
1167 * then renders the rectangle (dest_x, dest_y, dest_width,
1168 * dest_height) of the resulting image onto the destination image
1169 * replacing the previous contents.
1170 * Try to use gdk_pixbuf_scale_simple() first, this function is
1171 * the industrial-strength power tool you can fall back to if
1172 * gdk_pixbuf_scale_simple() isn't powerful enough.
1173 * src:
1174 * a GdkPixbuf
1175 * dest:
1176 * the GdkPixbuf into which to render the results
1177 * dest_x:
1178 * the left coordinate for region to render
1179 * dest_y:
1180 * the top coordinate for region to render
1181 * dest_width:
1182 * the width of the region to render
1183 * dest_height:
1184 * the height of the region to render
1185 * offset_x:
1186 * the offset in the X direction (currently rounded to an integer)
1187 * offset_y:
1188 * the offset in the Y direction (currently rounded to an integer)
1189 * scale_x:
1190 * the scale factor in the X direction
1191 * scale_y:
1192 * the scale factor in the Y direction
1193 * interp_type:
1194 * the interpolation type for the transformation.
1196 public void scale(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType)
1198 // 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);
1199 gdk_pixbuf_scale(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType);
1203 * Creates a new GdkPixbuf by scaling src to dest_width x
1204 * dest_height and compositing the result with a checkboard of colors
1205 * color1 and color2.
1206 * src:
1207 * a GdkPixbuf
1208 * dest_width:
1209 * the width of destination image
1210 * dest_height:
1211 * the height of destination image
1212 * interp_type:
1213 * the interpolation type for the transformation.
1214 * overall_alpha:
1215 * overall alpha for source image (0..255)
1216 * check_size:
1217 * the size of checks in the checkboard (must be a power of two)
1218 * color1:
1219 * the color of check at upper left
1220 * color2:
1221 * the color of the other check
1222 * Returns:
1223 * the new GdkPixbuf, or NULL if not enough memory could be
1224 * allocated for it.
1226 public Pixbuf compositeColorSimple(int destWidth, int destHeight, GdkInterpType interpType, int overallAlpha, int checkSize, uint color1, uint color2)
1228 // 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);
1229 return new Pixbuf( gdk_pixbuf_composite_color_simple(gdkPixbuf, destWidth, destHeight, interpType, overallAlpha, checkSize, color1, color2) );
1233 * Creates a transformation of the source image src by scaling by
1234 * scale_x and scale_y then translating by offset_x and offset_y.
1235 * This gives an image in the coordinates of the destination pixbuf.
1236 * The rectangle (dest_x, dest_y, dest_width, dest_height)
1237 * is then composited onto the corresponding rectangle of the
1238 * original destination image.
1239 * When the destination rectangle contains parts not in the source
1240 * image, the data at the edges of the source image is replicated
1241 * to infinity.
1242 * Figure1.Compositing of pixbufs
1243 * src:
1244 * a GdkPixbuf
1245 * dest:
1246 * the GdkPixbuf into which to render the results
1247 * dest_x:
1248 * the left coordinate for region to render
1249 * dest_y:
1250 * the top coordinate for region to render
1251 * dest_width:
1252 * the width of the region to render
1253 * dest_height:
1254 * the height of the region to render
1255 * offset_x:
1256 * the offset in the X direction (currently rounded to an integer)
1257 * offset_y:
1258 * the offset in the Y direction (currently rounded to an integer)
1259 * scale_x:
1260 * the scale factor in the X direction
1261 * scale_y:
1262 * the scale factor in the Y direction
1263 * interp_type:
1264 * the interpolation type for the transformation.
1265 * overall_alpha:
1266 * overall alpha for source image (0..255)
1268 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)
1270 // 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);
1271 gdk_pixbuf_composite(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType, overallAlpha);
1275 * Creates a transformation of the source image src by scaling by
1276 * scale_x and scale_y then translating by offset_x and offset_y,
1277 * then composites the rectangle (dest_x ,dest_y, dest_width,
1278 * dest_height) of the resulting image with a checkboard of the
1279 * colors color1 and color2 and renders it onto the destination
1280 * image.
1281 * See gdk_pixbuf_composite_color_simple() for a simpler variant of this
1282 * function suitable for many tasks.
1283 * src:
1284 * a GdkPixbuf
1285 * dest:
1286 * the GdkPixbuf into which to render the results
1287 * dest_x:
1288 * the left coordinate for region to render
1289 * dest_y:
1290 * the top coordinate for region to render
1291 * dest_width:
1292 * the width of the region to render
1293 * dest_height:
1294 * the height of the region to render
1295 * offset_x:
1296 * the offset in the X direction (currently rounded to an integer)
1297 * offset_y:
1298 * the offset in the Y direction (currently rounded to an integer)
1299 * scale_x:
1300 * the scale factor in the X direction
1301 * scale_y:
1302 * the scale factor in the Y direction
1303 * interp_type:
1304 * the interpolation type for the transformation.
1305 * overall_alpha:
1306 * overall alpha for source image (0..255)
1307 * check_x:
1308 * the X offset for the checkboard (origin of checkboard is at -check_x, -check_y)
1309 * check_y:
1310 * the Y offset for the checkboard
1311 * check_size:
1312 * the size of checks in the checkboard (must be a power of two)
1313 * color1:
1314 * the color of check at upper left
1315 * color2:
1316 * the color of the other check
1318 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)
1320 // 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);
1321 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);
1326 * Rotates a pixbuf by a multiple of 90 degrees, and returns the
1327 * result in a new pixbuf.
1328 * src:
1329 * a GdkPixbuf
1330 * angle:
1331 * the angle to rotate by
1332 * Returns:
1333 * a new pixbuf
1334 * Since 2.6
1336 public Pixbuf rotateSimple(GdkPixbufRotation angle)
1338 // GdkPixbuf* gdk_pixbuf_rotate_simple (const GdkPixbuf *src, GdkPixbufRotation angle);
1339 return new Pixbuf( gdk_pixbuf_rotate_simple(gdkPixbuf, angle) );
1343 * Flips a pixbuf horizontally or vertically and returns the
1344 * result in a new pixbuf.
1345 * src:
1346 * a GdkPixbuf
1347 * horizontal:
1348 * TRUE to flip horizontally, FALSE to flip vertically
1349 * Returns:
1350 * a new pixbuf.
1351 * Since 2.6
1352 * See Also
1353 * GdkRGB.
1355 public Pixbuf flip(int horizontal)
1357 // GdkPixbuf* gdk_pixbuf_flip (const GdkPixbuf *src, gboolean horizontal);
1358 return new Pixbuf( gdk_pixbuf_flip(gdkPixbuf, horizontal) );
1362 * Takes an existing pixbuf and adds an alpha channel to it.
1363 * If the existing pixbuf already had an alpha channel, the channel
1364 * values are copied from the original; otherwise, the alpha channel
1365 * is initialized to 255 (full opacity).
1366 * If substitute_color is TRUE, then the color specified by (r, g, b) will be
1367 * assigned zero opacity. That is, if you pass (255, 255, 255) for the
1368 * substitute color, all white pixels will become fully transparent.
1369 * pixbuf:
1370 * A GdkPixbuf.
1371 * substitute_color:
1372 * Whether to set a color to zero opacity. If this
1373 * is FALSE, then the (r, g, b) arguments will be ignored.
1374 * r:
1375 * Red value to substitute.
1376 * g:
1377 * Green value to substitute.
1378 * b:
1379 * Blue value to substitute.
1380 * Returns:
1381 * A newly-created pixbuf with a reference count of 1.
1383 public Pixbuf addAlpha(int substituteColor, char r, char g, char b)
1385 // GdkPixbuf* gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color, guchar r, guchar g, guchar b);
1386 return new Pixbuf( gdk_pixbuf_add_alpha(gdkPixbuf, substituteColor, r, g, b) );
1390 * Copies a rectangular area from src_pixbuf to dest_pixbuf. Conversion of
1391 * pixbuf formats is done automatically.
1392 * src_pixbuf:
1393 * Source pixbuf.
1394 * src_x:
1395 * Source X coordinate within src_pixbuf.
1396 * src_y:
1397 * Source Y coordinate within src_pixbuf.
1398 * width:
1399 * Width of the area to copy.
1400 * height:
1401 * Height of the area to copy.
1402 * dest_pixbuf:
1403 * Destination pixbuf.
1404 * dest_x:
1405 * X coordinate within dest_pixbuf.
1406 * dest_y:
1407 * Y coordinate within dest_pixbuf.
1409 public void copyArea(int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY)
1411 // 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);
1412 gdk_pixbuf_copy_area(gdkPixbuf, srcX, srcY, width, height, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct(), destX, destY);
1416 * Modifies saturation and optionally pixelates src, placing the result in
1417 * dest. src and dest may be the same pixbuf with no ill effects. If
1418 * saturation is 1.0 then saturation is not changed. If it's less than 1.0,
1419 * saturation is reduced (the image turns toward grayscale); if greater than
1420 * 1.0, saturation is increased (the image gets more vivid colors). If pixelate
1421 * is TRUE, then pixels are faded in a checkerboard pattern to create a
1422 * pixelated image. src and dest must have the same image format, size, and
1423 * rowstride.
1424 * src:
1425 * source image
1426 * dest:
1427 * place to write modified version of src
1428 * saturation:
1429 * saturation factor
1430 * pixelate:
1431 * whether to pixelate
1433 public void saturateAndPixelate(Pixbuf dest, float saturation, int pixelate)
1435 // void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src, GdkPixbuf *dest, gfloat saturation, gboolean pixelate);
1436 gdk_pixbuf_saturate_and_pixelate(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), saturation, pixelate);
1440 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
1441 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
1442 * doesn't have an alpha channel.
1443 * pixbuf:
1444 * a GdkPixbuf
1445 * pixel:
1446 * RGBA pixel to clear to
1447 * (0xffffffff is opaque white, 0x00000000 transparent black)
1448 * See Also
1449 * GdkPixbuf
1451 public void fill(uint pixel)
1453 // void gdk_pixbuf_fill (GdkPixbuf *pixbuf, guint32 pixel);
1454 gdk_pixbuf_fill(gdkPixbuf, pixel);