1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gdkpixbuf.Pixbuf;
26 
27 private import gdkpixbuf.PixbufFormat;
28 private import gdkpixbuf.Pixdata;
29 private import gdkpixbuf.c.functions;
30 public  import gdkpixbuf.c.types;
31 private import gio.AsyncResultIF;
32 private import gio.Cancellable;
33 private import gio.IconIF;
34 private import gio.IconT;
35 private import gio.InputStream;
36 private import gio.LoadableIconIF;
37 private import gio.LoadableIconT;
38 private import gio.OutputStream;
39 private import glib.Bytes;
40 private import glib.ConstructionException;
41 private import glib.ErrorG;
42 private import glib.GException;
43 private import glib.HashTable;
44 private import glib.ListSG;
45 private import glib.Str;
46 private import gobject.ObjectG;
47 public  import gtkc.gdkpixbuftypes;
48 
49 
50 /**
51  * This is the main structure in the gdk-pixbuf library.  It is
52  * used to represent images.  It contains information about the
53  * image's pixel data, its color space, bits per sample, width and
54  * height, and the rowstride (the number of bytes between the start of
55  * one row and the start of the next).
56  */
57 public class Pixbuf : ObjectG, IconIF, LoadableIconIF
58 {
59 	/** the main Gtk struct */
60 	protected GdkPixbuf* gdkPixbuf;
61 
62 	/** Get the main Gtk struct */
63 	public GdkPixbuf* getPixbufStruct(bool transferOwnership = false)
64 	{
65 		if (transferOwnership)
66 			ownedRef = false;
67 		return gdkPixbuf;
68 	}
69 
70 	/** the main Gtk struct as a void* */
71 	protected override void* getStruct()
72 	{
73 		return cast(void*)gdkPixbuf;
74 	}
75 
76 	/**
77 	 * Sets our main struct and passes it to the parent class.
78 	 */
79 	public this (GdkPixbuf* gdkPixbuf, bool ownedRef = false)
80 	{
81 		this.gdkPixbuf = gdkPixbuf;
82 		super(cast(GObject*)gdkPixbuf, ownedRef);
83 	}
84 
85 	// add the Icon capabilities
86 	mixin IconT!(GdkPixbuf);
87 
88 	// add the LoadableIcon capabilities
89 	mixin LoadableIconT!(GdkPixbuf);
90 
91 	/**
92 	 * Saves pixbuf to a new buffer in format @type, which is currently "jpeg",
93 	 * "tiff", "png", "ico" or "bmp".  See gdk_pixbuf_save_to_buffer()
94 	 * for more details.
95 	 *
96 	 * Params:
97 	 *     buffer = location to receive a pointer to the new buffer.
98 	 *     bufferSize = location to receive the size of the new buffer.
99 	 *     type = name of file format.
100 	 *     optionKeys = name of options to set, %NULL-terminated
101 	 *     optionValues = values for named options
102 	 *
103 	 * Return: whether an error was set
104 	 *
105 	 * Since: 2.4
106 	 *
107 	 * Throws: GException on failure.
108 	 */
109 	public bool saveToBuffer(out ubyte[] buffer, string type, string[] optionKeys, string[] optionValues)
110 	{
111 		char* outbuffer = null;
112 		size_t bufferSize;
113 		GError* err = null;
114 
115 		auto p = gdk_pixbuf_save_to_bufferv(gdkPixbuf, &outbuffer, &bufferSize, Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
116 
117 		if (err !is null)
118 		{
119 			throw new GException( new ErrorG(err) );
120 		}
121 
122 		buffer = (cast(ubyte*)outbuffer)[0 .. bufferSize];
123 
124 		return p;
125 	}
126 
127 	/**
128 	 * Creates a new pixbuf by loading an image from an resource.
129 	 *
130 	 * The file format is detected automatically.
131 	 *
132 	 * Params:
133 	 *     resourcePath = the path of the resource file
134 	 *
135 	 * Return: A newly-created pixbuf, or null if any of several error
136 	 *     conditions occurred: the file could not be opened, the image format is
137 	 *     not supported, there was not enough memory to allocate the image buffer,
138 	 *     the stream contained invalid data, or the operation was cancelled.
139 	 *
140 	 * Since: 2.26
141 	 *
142 	 * Throws: GException on failure.
143 	 */
144 	public static Pixbuf newFromResource(string resourcePath)
145 	{
146 		GError* err = null;
147 
148 		auto p = gdk_pixbuf_new_from_resource(Str.toStringz(resourcePath), &err);
149 
150 		if (err !is null)
151 		{
152 			throw new GException( new ErrorG(err) );
153 		}
154 
155 		return new Pixbuf(cast(GdkPixbuf*) p, true);
156 	}
157 
158 	/**
159 	 * Creates a new pixbuf by loading an image from an resource.
160 	 *
161 	 * The file format is detected automatically.
162 	 *
163 	 * The image will be scaled to fit in the requested size, optionally
164 	 * preserving the image's aspect ratio. When preserving the aspect ratio,
165 	 * a width of -1 will cause the image to be scaled to the exact given
166 	 * height, and a height of -1 will cause the image to be scaled to the
167 	 * exact given width. When not preserving aspect ratio, a width or
168 	 * height of -1 means to not scale the image at all in that dimension.
169 	 *
170 	 * The stream is not closed.
171 	 *
172 	 * Params:
173 	 *     resourcePath = the path of the resource file
174 	 *     width = The width the image should have or -1 to not constrain the width
175 	 *     height = The height the image should have or -1 to not constrain the height
176 	 *     preserveAspectRatio = true to preserve the image's aspect ratio
177 	 *
178 	 * Return: A newly-created pixbuf, or null if any of several error
179 	 *     conditions occurred: the file could not be opened, the image format is
180 	 *     not supported, there was not enough memory to allocate the image buffer,
181 	 *     the stream contained invalid data, or the operation was cancelled.
182 	 *
183 	 * Since: 2.26
184 	 *
185 	 * Throws: GException on failure.
186 	 */
187 	public static Pixbuf newFromResource(string resourcePath, int width, int height, bool preserveAspectRatio)
188 	{
189 		GError* err = null;
190 
191 		auto p = gdk_pixbuf_new_from_resource_at_scale(Str.toStringz(resourcePath), width, height, preserveAspectRatio, &err);
192 
193 		if (err !is null)
194 		{
195 			throw new GException( new ErrorG(err) );
196 		}
197 
198 		return new Pixbuf(cast(GdkPixbuf*) p, true);
199 	}
200 
201 	/**
202 	 * Queries a pointer to the pixel data of a pixbuf.
203 	 *
204 	 * Return: A pointer to the pixbuf's pixel data.
205 	 *     Please see the section on [image data](image-data) for information
206 	 *     about how the pixel data is stored in memory.
207 	 *
208 	 *     This function will cause an implicit copy of the pixbuf data if the
209 	 *     pixbuf was created from read-only data.
210 	 */
211 	public char* getPixels()
212 	{
213 		return gdk_pixbuf_get_pixels(gdkPixbuf);
214 	}
215 
216 	/**
217 	 */
218 
219 	/** */
220 	public static GType getType()
221 	{
222 		return gdk_pixbuf_get_type();
223 	}
224 
225 	/**
226 	 * Creates a new #GdkPixbuf structure and allocates a buffer for it.  The
227 	 * buffer has an optimal rowstride.  Note that the buffer is not cleared;
228 	 * you will have to fill it completely yourself.
229 	 *
230 	 * Params:
231 	 *     colorspace = Color space for image
232 	 *     hasAlpha = Whether the image should have transparency information
233 	 *     bitsPerSample = Number of bits per color sample
234 	 *     width = Width of image in pixels, must be > 0
235 	 *     height = Height of image in pixels, must be > 0
236 	 *
237 	 * Returns: A newly-created #GdkPixbuf with a reference count of 1, or
238 	 *     %NULL if not enough memory could be allocated for the image buffer.
239 	 *
240 	 * Throws: ConstructionException GTK+ fails to create the object.
241 	 */
242 	public this(GdkColorspace colorspace, bool hasAlpha, int bitsPerSample, int width, int height)
243 	{
244 		auto p = gdk_pixbuf_new(colorspace, hasAlpha, bitsPerSample, width, height);
245 
246 		if(p is null)
247 		{
248 			throw new ConstructionException("null returned by new");
249 		}
250 
251 		this(cast(GdkPixbuf*) p, true);
252 	}
253 
254 	/**
255 	 * Creates a new #GdkPixbuf out of in-memory readonly image data.
256 	 * Currently only RGB images with 8 bits per sample are supported.
257 	 * This is the #GBytes variant of gdk_pixbuf_new_from_data().
258 	 *
259 	 * Params:
260 	 *     data = Image data in 8-bit/sample packed format inside a #GBytes
261 	 *     colorspace = Colorspace for the image data
262 	 *     hasAlpha = Whether the data has an opacity channel
263 	 *     bitsPerSample = Number of bits per sample
264 	 *     width = Width of the image in pixels, must be > 0
265 	 *     height = Height of the image in pixels, must be > 0
266 	 *     rowstride = Distance in bytes between row starts
267 	 *
268 	 * Returns: A newly-created #GdkPixbuf structure with a reference count of 1.
269 	 *
270 	 * Since: 2.32
271 	 *
272 	 * Throws: ConstructionException GTK+ fails to create the object.
273 	 */
274 	public this(Bytes data, GdkColorspace colorspace, bool hasAlpha, int bitsPerSample, int width, int height, int rowstride)
275 	{
276 		auto p = gdk_pixbuf_new_from_bytes((data is null) ? null : data.getBytesStruct(), colorspace, hasAlpha, bitsPerSample, width, height, rowstride);
277 
278 		if(p is null)
279 		{
280 			throw new ConstructionException("null returned by new_from_bytes");
281 		}
282 
283 		this(cast(GdkPixbuf*) p, true);
284 	}
285 
286 	/**
287 	 * Creates a new #GdkPixbuf out of in-memory image data.  Currently only RGB
288 	 * images with 8 bits per sample are supported.
289 	 *
290 	 * Since you are providing a pre-allocated pixel buffer, you must also
291 	 * specify a way to free that data.  This is done with a function of
292 	 * type #GdkPixbufDestroyNotify.  When a pixbuf created with is
293 	 * finalized, your destroy notification function will be called, and
294 	 * it is its responsibility to free the pixel array.
295 	 *
296 	 * See also gdk_pixbuf_new_from_bytes().
297 	 *
298 	 * Params:
299 	 *     data = Image data in 8-bit/sample packed format
300 	 *     colorspace = Colorspace for the image data
301 	 *     hasAlpha = Whether the data has an opacity channel
302 	 *     bitsPerSample = Number of bits per sample
303 	 *     width = Width of the image in pixels, must be > 0
304 	 *     height = Height of the image in pixels, must be > 0
305 	 *     rowstride = Distance in bytes between row starts
306 	 *     destroyFn = Function used to free the data when the pixbuf's reference count
307 	 *         drops to zero, or %NULL if the data should not be freed
308 	 *     destroyFnData = Closure data to pass to the destroy notification function
309 	 *
310 	 * Returns: A newly-created #GdkPixbuf structure with a reference count of 1.
311 	 *
312 	 * Throws: ConstructionException GTK+ fails to create the object.
313 	 */
314 	public this(char[] data, GdkColorspace colorspace, bool hasAlpha, int bitsPerSample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroyFn, void* destroyFnData)
315 	{
316 		auto p = gdk_pixbuf_new_from_data(data.ptr, colorspace, hasAlpha, bitsPerSample, width, height, rowstride, destroyFn, destroyFnData);
317 
318 		if(p is null)
319 		{
320 			throw new ConstructionException("null returned by new_from_data");
321 		}
322 
323 		this(cast(GdkPixbuf*) p, true);
324 	}
325 
326 	/**
327 	 * Creates a new pixbuf by loading an image from a file.  The file format is
328 	 * detected automatically. If %NULL is returned, then @error will be set.
329 	 * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
330 	 *
331 	 * Params:
332 	 *     filename = Name of file to load, in the GLib file name encoding
333 	 *
334 	 * Returns: A newly-created pixbuf with a reference count of 1, or %NULL if
335 	 *     any of several error conditions occurred:  the file could not be opened,
336 	 *     there was no loader for the file's format, there was not enough memory to
337 	 *     allocate the image buffer, or the image file contained invalid data.
338 	 *
339 	 * Throws: GException on failure.
340 	 * Throws: ConstructionException GTK+ fails to create the object.
341 	 */
342 	public this(string filename)
343 	{
344 		GError* err = null;
345 
346 		auto p = gdk_pixbuf_new_from_file(Str.toStringz(filename), &err);
347 
348 		if (err !is null)
349 		{
350 			throw new GException( new ErrorG(err) );
351 		}
352 
353 		if(p is null)
354 		{
355 			throw new ConstructionException("null returned by new_from_file");
356 		}
357 
358 		this(cast(GdkPixbuf*) p, true);
359 	}
360 
361 	/**
362 	 * Creates a new pixbuf by loading an image from a file.  The file format is
363 	 * detected automatically. If %NULL is returned, then @error will be set.
364 	 * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
365 	 * The image will be scaled to fit in the requested size, optionally preserving
366 	 * the image's aspect ratio.
367 	 *
368 	 * When preserving the aspect ratio, a @width of -1 will cause the image
369 	 * to be scaled to the exact given height, and a @height of -1 will cause
370 	 * the image to be scaled to the exact given width. When not preserving
371 	 * aspect ratio, a @width or @height of -1 means to not scale the image
372 	 * at all in that dimension. Negative values for @width and @height are
373 	 * allowed since 2.8.
374 	 *
375 	 * Params:
376 	 *     filename = Name of file to load, in the GLib file name encoding
377 	 *     width = The width the image should have or -1 to not constrain the width
378 	 *     height = The height the image should have or -1 to not constrain the height
379 	 *     preserveAspectRatio = %TRUE to preserve the image's aspect ratio
380 	 *
381 	 * Returns: A newly-created pixbuf with a reference count of 1, or %NULL
382 	 *     if any of several error conditions occurred:  the file could not be opened,
383 	 *     there was no loader for the file's format, there was not enough memory to
384 	 *     allocate the image buffer, or the image file contained invalid data.
385 	 *
386 	 * Since: 2.6
387 	 *
388 	 * Throws: GException on failure.
389 	 * Throws: ConstructionException GTK+ fails to create the object.
390 	 */
391 	public this(string filename, int width, int height, bool preserveAspectRatio)
392 	{
393 		GError* err = null;
394 
395 		auto p = gdk_pixbuf_new_from_file_at_scale(Str.toStringz(filename), width, height, preserveAspectRatio, &err);
396 
397 		if (err !is null)
398 		{
399 			throw new GException( new ErrorG(err) );
400 		}
401 
402 		if(p is null)
403 		{
404 			throw new ConstructionException("null returned by new_from_file_at_scale");
405 		}
406 
407 		this(cast(GdkPixbuf*) p, true);
408 	}
409 
410 	/**
411 	 * Creates a new pixbuf by loading an image from a file.
412 	 * The file format is detected automatically. If %NULL is returned, then
413 	 * @error will be set. Possible errors are in the #GDK_PIXBUF_ERROR and
414 	 * #G_FILE_ERROR domains.
415 	 *
416 	 * The image will be scaled to fit in the requested size, preserving
417 	 * the image's aspect ratio. Note that the returned pixbuf may be smaller
418 	 * than @width x @height, if the aspect ratio requires it. To load
419 	 * and image at the requested size, regardless of aspect ratio, use
420 	 * gdk_pixbuf_new_from_file_at_scale().
421 	 *
422 	 * Params:
423 	 *     filename = Name of file to load, in the GLib file name encoding
424 	 *     width = The width the image should have or -1 to not constrain the width
425 	 *     height = The height the image should have or -1 to not constrain the height
426 	 *
427 	 * Returns: A newly-created pixbuf with a reference count of 1, or
428 	 *     %NULL if any of several error conditions occurred:  the file could not
429 	 *     be opened, there was no loader for the file's format, there was not
430 	 *     enough memory to allocate the image buffer, or the image file contained
431 	 *     invalid data.
432 	 *
433 	 * Since: 2.4
434 	 *
435 	 * Throws: GException on failure.
436 	 * Throws: ConstructionException GTK+ fails to create the object.
437 	 */
438 	public this(string filename, int width, int height)
439 	{
440 		GError* err = null;
441 
442 		auto p = gdk_pixbuf_new_from_file_at_size(Str.toStringz(filename), width, height, &err);
443 
444 		if (err !is null)
445 		{
446 			throw new GException( new ErrorG(err) );
447 		}
448 
449 		if(p is null)
450 		{
451 			throw new ConstructionException("null returned by new_from_file_at_size");
452 		}
453 
454 		this(cast(GdkPixbuf*) p, true);
455 	}
456 
457 	/**
458 	 * Create a #GdkPixbuf from a flat representation that is suitable for
459 	 * storing as inline data in a program. This is useful if you want to
460 	 * ship a program with images, but don't want to depend on any
461 	 * external files.
462 	 *
463 	 * gdk-pixbuf ships with a program called [gdk-pixbuf-csource][gdk-pixbuf-csource],
464 	 * which allows for conversion of #GdkPixbufs into such a inline representation.
465 	 * In almost all cases, you should pass the `--raw` option to
466 	 * `gdk-pixbuf-csource`. A sample invocation would be:
467 	 *
468 	 * |[
469 	 * gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
470 	 * ]|
471 	 *
472 	 * For the typical case where the inline pixbuf is read-only static data,
473 	 * you don't need to copy the pixel data unless you intend to write to
474 	 * it, so you can pass %FALSE for @copy_pixels.  (If you pass `--rle` to
475 	 * `gdk-pixbuf-csource`, a copy will be made even if @copy_pixels is %FALSE,
476 	 * so using this option is generally a bad idea.)
477 	 *
478 	 * If you create a pixbuf from const inline data compiled into your
479 	 * program, it's probably safe to ignore errors and disable length checks,
480 	 * since things will always succeed:
481 	 * |[
482 	 * pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL);
483 	 * ]|
484 	 *
485 	 * For non-const inline data, you could get out of memory. For untrusted
486 	 * inline data located at runtime, you could have corrupt inline data in
487 	 * addition.
488 	 *
489 	 * Deprecated: Use #GResource instead.
490 	 *
491 	 * Params:
492 	 *     data = Byte data containing a
493 	 *         serialized #GdkPixdata structure
494 	 *     copyPixels = Whether to copy the pixel data, or use direct pointers
495 	 *         @data for the resulting pixbuf
496 	 *
497 	 * Returns: A newly-created #GdkPixbuf structure with a reference,
498 	 *     count of 1, or %NULL if an error occurred.
499 	 *
500 	 * Throws: GException on failure.
501 	 * Throws: ConstructionException GTK+ fails to create the object.
502 	 */
503 	public this(ubyte[] data, bool copyPixels)
504 	{
505 		GError* err = null;
506 
507 		auto p = gdk_pixbuf_new_from_inline(cast(int)data.length, data.ptr, copyPixels, &err);
508 
509 		if (err !is null)
510 		{
511 			throw new GException( new ErrorG(err) );
512 		}
513 
514 		if(p is null)
515 		{
516 			throw new ConstructionException("null returned by new_from_inline");
517 		}
518 
519 		this(cast(GdkPixbuf*) p, true);
520 	}
521 
522 	/**
523 	 * Creates a new pixbuf by loading an image from an input stream.
524 	 *
525 	 * The file format is detected automatically. If %NULL is returned, then
526 	 * @error will be set. The @cancellable can be used to abort the operation
527 	 * from another thread. If the operation was cancelled, the error
528 	 * %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in
529 	 * the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.
530 	 *
531 	 * The stream is not closed.
532 	 *
533 	 * Params:
534 	 *     stream = a #GInputStream to load the pixbuf from
535 	 *     cancellable = optional #GCancellable object, %NULL to ignore
536 	 *
537 	 * Returns: A newly-created pixbuf, or %NULL if any of several error
538 	 *     conditions occurred: the file could not be opened, the image format is
539 	 *     not supported, there was not enough memory to allocate the image buffer,
540 	 *     the stream contained invalid data, or the operation was cancelled.
541 	 *
542 	 * Since: 2.14
543 	 *
544 	 * Throws: GException on failure.
545 	 * Throws: ConstructionException GTK+ fails to create the object.
546 	 */
547 	public this(InputStream stream, Cancellable cancellable)
548 	{
549 		GError* err = null;
550 
551 		auto p = gdk_pixbuf_new_from_stream((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
552 
553 		if (err !is null)
554 		{
555 			throw new GException( new ErrorG(err) );
556 		}
557 
558 		if(p is null)
559 		{
560 			throw new ConstructionException("null returned by new_from_stream");
561 		}
562 
563 		this(cast(GdkPixbuf*) p, true);
564 	}
565 
566 	/**
567 	 * Creates a new pixbuf by loading an image from an input stream.
568 	 *
569 	 * The file format is detected automatically. If %NULL is returned, then
570 	 * @error will be set. The @cancellable can be used to abort the operation
571 	 * from another thread. If the operation was cancelled, the error
572 	 * %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in
573 	 * the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.
574 	 *
575 	 * The image will be scaled to fit in the requested size, optionally
576 	 * preserving the image's aspect ratio.
577 	 *
578 	 * When preserving the aspect ratio, a @width of -1 will cause the image to be
579 	 * scaled to the exact given height, and a @height of -1 will cause the image
580 	 * to be scaled to the exact given width. If both @width and @height are
581 	 * given, this function will behave as if the smaller of the two values
582 	 * is passed as -1.
583 	 *
584 	 * When not preserving aspect ratio, a @width or @height of -1 means to not
585 	 * scale the image at all in that dimension.
586 	 *
587 	 * The stream is not closed.
588 	 *
589 	 * Params:
590 	 *     stream = a #GInputStream to load the pixbuf from
591 	 *     width = The width the image should have or -1 to not constrain the width
592 	 *     height = The height the image should have or -1 to not constrain the height
593 	 *     preserveAspectRatio = %TRUE to preserve the image's aspect ratio
594 	 *     cancellable = optional #GCancellable object, %NULL to ignore
595 	 *
596 	 * Returns: A newly-created pixbuf, or %NULL if any of several error
597 	 *     conditions occurred: the file could not be opened, the image format is
598 	 *     not supported, there was not enough memory to allocate the image buffer,
599 	 *     the stream contained invalid data, or the operation was cancelled.
600 	 *
601 	 * Since: 2.14
602 	 *
603 	 * Throws: GException on failure.
604 	 * Throws: ConstructionException GTK+ fails to create the object.
605 	 */
606 	public this(InputStream stream, int width, int height, bool preserveAspectRatio, Cancellable cancellable)
607 	{
608 		GError* err = null;
609 
610 		auto p = gdk_pixbuf_new_from_stream_at_scale((stream is null) ? null : stream.getInputStreamStruct(), width, height, preserveAspectRatio, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
611 
612 		if (err !is null)
613 		{
614 			throw new GException( new ErrorG(err) );
615 		}
616 
617 		if(p is null)
618 		{
619 			throw new ConstructionException("null returned by new_from_stream_at_scale");
620 		}
621 
622 		this(cast(GdkPixbuf*) p, true);
623 	}
624 
625 	/**
626 	 * Finishes an asynchronous pixbuf creation operation started with
627 	 * gdk_pixbuf_new_from_stream_async().
628 	 *
629 	 * Params:
630 	 *     asyncResult = a #GAsyncResult
631 	 *
632 	 * Returns: a #GdkPixbuf or %NULL on error. Free the returned
633 	 *     object with g_object_unref().
634 	 *
635 	 * Since: 2.24
636 	 *
637 	 * Throws: GException on failure.
638 	 * Throws: ConstructionException GTK+ fails to create the object.
639 	 */
640 	public this(AsyncResultIF asyncResult)
641 	{
642 		GError* err = null;
643 
644 		auto p = gdk_pixbuf_new_from_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultStruct(), &err);
645 
646 		if (err !is null)
647 		{
648 			throw new GException( new ErrorG(err) );
649 		}
650 
651 		if(p is null)
652 		{
653 			throw new ConstructionException("null returned by new_from_stream_finish");
654 		}
655 
656 		this(cast(GdkPixbuf*) p, true);
657 	}
658 
659 	/**
660 	 * Creates a new pixbuf by parsing XPM data in memory.  This data is commonly
661 	 * the result of including an XPM file into a program's C source.
662 	 *
663 	 * Params:
664 	 *     data = Pointer to inline XPM data.
665 	 *
666 	 * Returns: A newly-created pixbuf with a reference count of 1.
667 	 *
668 	 * Throws: ConstructionException GTK+ fails to create the object.
669 	 */
670 	public this(string[] data)
671 	{
672 		auto p = gdk_pixbuf_new_from_xpm_data(Str.toStringzArray(data));
673 
674 		if(p is null)
675 		{
676 			throw new ConstructionException("null returned by new_from_xpm_data");
677 		}
678 
679 		this(cast(GdkPixbuf*) p, true);
680 	}
681 
682 	/**
683 	 * Calculates the rowstride that an image created with those values would
684 	 * have. This is useful for front-ends and backends that want to sanity
685 	 * check image values without needing to create them.
686 	 *
687 	 * Params:
688 	 *     colorspace = Color space for image
689 	 *     hasAlpha = Whether the image should have transparency information
690 	 *     bitsPerSample = Number of bits per color sample
691 	 *     width = Width of image in pixels, must be > 0
692 	 *     height = Height of image in pixels, must be > 0
693 	 *
694 	 * Returns: the rowstride for the given values, or -1 in case of error.
695 	 *
696 	 * Since: 2.36.8
697 	 */
698 	public static int calculateRowstride(GdkColorspace colorspace, bool hasAlpha, int bitsPerSample, int width, int height)
699 	{
700 		return gdk_pixbuf_calculate_rowstride(colorspace, hasAlpha, bitsPerSample, width, height);
701 	}
702 
703 	/**
704 	 * Converts a #GdkPixdata to a #GdkPixbuf. If @copy_pixels is %TRUE or
705 	 * if the pixel data is run-length-encoded, the pixel data is copied into
706 	 * newly-allocated memory; otherwise it is reused.
707 	 *
708 	 * Deprecated: Use #GResource instead.
709 	 *
710 	 * Params:
711 	 *     pixdata = a #GdkPixdata to convert into a #GdkPixbuf.
712 	 *     copyPixels = whether to copy raw pixel data; run-length encoded
713 	 *         pixel data is always copied.
714 	 *
715 	 * Returns: a new #GdkPixbuf.
716 	 *
717 	 * Throws: GException on failure.
718 	 */
719 	public static Pixbuf fromPixdata(Pixdata pixdata, bool copyPixels)
720 	{
721 		GError* err = null;
722 
723 		auto p = gdk_pixbuf_from_pixdata((pixdata is null) ? null : pixdata.getPixdataStruct(), copyPixels, &err);
724 
725 		if (err !is null)
726 		{
727 			throw new GException( new ErrorG(err) );
728 		}
729 
730 		if(p is null)
731 		{
732 			return null;
733 		}
734 
735 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
736 	}
737 
738 	/**
739 	 * Parses an image file far enough to determine its format and size.
740 	 *
741 	 * Params:
742 	 *     filename = The name of the file to identify.
743 	 *     width = Return location for the width of the
744 	 *         image, or %NULL
745 	 *     height = Return location for the height of the
746 	 *         image, or %NULL
747 	 *
748 	 * Returns: A #GdkPixbufFormat describing
749 	 *     the image format of the file or %NULL if the image format wasn't
750 	 *     recognized. The return value is owned by #GdkPixbuf and should
751 	 *     not be freed.
752 	 *
753 	 * Since: 2.4
754 	 */
755 	public static PixbufFormat getFileInfo(string filename, out int width, out int height)
756 	{
757 		auto p = gdk_pixbuf_get_file_info(Str.toStringz(filename), &width, &height);
758 
759 		if(p is null)
760 		{
761 			return null;
762 		}
763 
764 		return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p);
765 	}
766 
767 	/**
768 	 * Asynchronously parses an image file far enough to determine its
769 	 * format and size.
770 	 *
771 	 * For more details see gdk_pixbuf_get_file_info(), which is the synchronous
772 	 * version of this function.
773 	 *
774 	 * When the operation is finished, @callback will be called in the
775 	 * main thread. You can then call gdk_pixbuf_get_file_info_finish() to
776 	 * get the result of the operation.
777 	 *
778 	 * Params:
779 	 *     filename = The name of the file to identify
780 	 *     cancellable = optional #GCancellable object, %NULL to ignore
781 	 *     callback = a #GAsyncReadyCallback to call when the file info is available
782 	 *     userData = the data to pass to the callback function
783 	 *
784 	 * Since: 2.32
785 	 */
786 	public static void getFileInfoAsync(string filename, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
787 	{
788 		gdk_pixbuf_get_file_info_async(Str.toStringz(filename), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
789 	}
790 
791 	/**
792 	 * Finishes an asynchronous pixbuf parsing operation started with
793 	 * gdk_pixbuf_get_file_info_async().
794 	 *
795 	 * Params:
796 	 *     asyncResult = a #GAsyncResult
797 	 *     width = Return location for the width of the image, or %NULL
798 	 *     height = Return location for the height of the image, or %NULL
799 	 *
800 	 * Returns: A #GdkPixbufFormat describing the image
801 	 *     format of the file or %NULL if the image format wasn't
802 	 *     recognized. The return value is owned by GdkPixbuf and should
803 	 *     not be freed.
804 	 *
805 	 * Since: 2.32
806 	 *
807 	 * Throws: GException on failure.
808 	 */
809 	public static PixbufFormat getFileInfoFinish(AsyncResultIF asyncResult, out int width, out int height)
810 	{
811 		GError* err = null;
812 
813 		auto p = gdk_pixbuf_get_file_info_finish((asyncResult is null) ? null : asyncResult.getAsyncResultStruct(), &width, &height, &err);
814 
815 		if (err !is null)
816 		{
817 			throw new GException( new ErrorG(err) );
818 		}
819 
820 		if(p is null)
821 		{
822 			return null;
823 		}
824 
825 		return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p);
826 	}
827 
828 	/**
829 	 * Obtains the available information about the image formats supported
830 	 * by GdkPixbuf.
831 	 *
832 	 * Returns: A list of
833 	 *     #GdkPixbufFormats describing the supported image formats. The list should
834 	 *     be freed when it is no longer needed, but the structures themselves are
835 	 *     owned by #GdkPixbuf and should not be freed.
836 	 *
837 	 * Since: 2.2
838 	 */
839 	public static ListSG getFormats()
840 	{
841 		auto p = gdk_pixbuf_get_formats();
842 
843 		if(p is null)
844 		{
845 			return null;
846 		}
847 
848 		return new ListSG(cast(GSList*) p);
849 	}
850 
851 	/**
852 	 * Creates a new pixbuf by asynchronously loading an image from an input stream.
853 	 *
854 	 * For more details see gdk_pixbuf_new_from_stream(), which is the synchronous
855 	 * version of this function.
856 	 *
857 	 * When the operation is finished, @callback will be called in the main thread.
858 	 * You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation.
859 	 *
860 	 * Params:
861 	 *     stream = a #GInputStream from which to load the pixbuf
862 	 *     cancellable = optional #GCancellable object, %NULL to ignore
863 	 *     callback = a #GAsyncReadyCallback to call when the pixbuf is loaded
864 	 *     userData = the data to pass to the callback function
865 	 *
866 	 * Since: 2.24
867 	 */
868 	public static void newFromStreamAsync(InputStream stream, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
869 	{
870 		gdk_pixbuf_new_from_stream_async((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
871 	}
872 
873 	/**
874 	 * Creates a new pixbuf by asynchronously loading an image from an input stream.
875 	 *
876 	 * For more details see gdk_pixbuf_new_from_stream_at_scale(), which is the synchronous
877 	 * version of this function.
878 	 *
879 	 * When the operation is finished, @callback will be called in the main thread.
880 	 * You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation.
881 	 *
882 	 * Params:
883 	 *     stream = a #GInputStream from which to load the pixbuf
884 	 *     width = the width the image should have or -1 to not constrain the width
885 	 *     height = the height the image should have or -1 to not constrain the height
886 	 *     preserveAspectRatio = %TRUE to preserve the image's aspect ratio
887 	 *     cancellable = optional #GCancellable object, %NULL to ignore
888 	 *     callback = a #GAsyncReadyCallback to call when the pixbuf is loaded
889 	 *     userData = the data to pass to the callback function
890 	 *
891 	 * Since: 2.24
892 	 */
893 	public static void newFromStreamAtScaleAsync(InputStream stream, int width, int height, bool preserveAspectRatio, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
894 	{
895 		gdk_pixbuf_new_from_stream_at_scale_async((stream is null) ? null : stream.getInputStreamStruct(), width, height, preserveAspectRatio, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
896 	}
897 
898 	/**
899 	 * Finishes an asynchronous pixbuf save operation started with
900 	 * gdk_pixbuf_save_to_stream_async().
901 	 *
902 	 * Params:
903 	 *     asyncResult = a #GAsyncResult
904 	 *
905 	 * Returns: %TRUE if the pixbuf was saved successfully, %FALSE if an error was set.
906 	 *
907 	 * Since: 2.24
908 	 *
909 	 * Throws: GException on failure.
910 	 */
911 	public static bool saveToStreamFinish(AsyncResultIF asyncResult)
912 	{
913 		GError* err = null;
914 
915 		auto p = gdk_pixbuf_save_to_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultStruct(), &err) != 0;
916 
917 		if (err !is null)
918 		{
919 			throw new GException( new ErrorG(err) );
920 		}
921 
922 		return p;
923 	}
924 
925 	/**
926 	 * Takes an existing pixbuf and adds an alpha channel to it.
927 	 * If the existing pixbuf already had an alpha channel, the channel
928 	 * values are copied from the original; otherwise, the alpha channel
929 	 * is initialized to 255 (full opacity).
930 	 *
931 	 * If @substitute_color is %TRUE, then the color specified by (@r, @g, @b) will be
932 	 * assigned zero opacity. That is, if you pass (255, 255, 255) for the
933 	 * substitute color, all white pixels will become fully transparent.
934 	 *
935 	 * Params:
936 	 *     substituteColor = Whether to set a color to zero opacity.  If this
937 	 *         is %FALSE, then the (@r, @g, @b) arguments will be ignored.
938 	 *     r = Red value to substitute.
939 	 *     g = Green value to substitute.
940 	 *     b = Blue value to substitute.
941 	 *
942 	 * Returns: A newly-created pixbuf with a reference count of 1.
943 	 */
944 	public Pixbuf addAlpha(bool substituteColor, char r, char g, char b)
945 	{
946 		auto p = gdk_pixbuf_add_alpha(gdkPixbuf, substituteColor, r, g, b);
947 
948 		if(p is null)
949 		{
950 			return null;
951 		}
952 
953 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
954 	}
955 
956 	/**
957 	 * Takes an existing pixbuf and checks for the presence of an
958 	 * associated "orientation" option, which may be provided by the
959 	 * jpeg loader (which reads the exif orientation tag) or the
960 	 * tiff loader (which reads the tiff orientation tag, and
961 	 * compensates it for the partial transforms performed by
962 	 * libtiff). If an orientation option/tag is present, the
963 	 * appropriate transform will be performed so that the pixbuf
964 	 * is oriented correctly.
965 	 *
966 	 * Returns: A newly-created pixbuf, %NULL if
967 	 *     not enough memory could be allocated for it, or a reference to the
968 	 *     input pixbuf (with an increased reference count).
969 	 *
970 	 * Since: 2.12
971 	 */
972 	public Pixbuf applyEmbeddedOrientation()
973 	{
974 		auto p = gdk_pixbuf_apply_embedded_orientation(gdkPixbuf);
975 
976 		if(p is null)
977 		{
978 			return null;
979 		}
980 
981 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
982 	}
983 
984 	/**
985 	 * Creates a transformation of the source image @src by scaling by
986 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y.
987 	 * This gives an image in the coordinates of the destination pixbuf.
988 	 * The rectangle (@dest_x, @dest_y, @dest_width, @dest_height)
989 	 * is then alpha blended onto the corresponding rectangle of the
990 	 * original destination image.
991 	 *
992 	 * When the destination rectangle contains parts not in the source
993 	 * image, the data at the edges of the source image is replicated
994 	 * to infinity.
995 	 *
996 	 * ![](composite.png)
997 	 *
998 	 * Params:
999 	 *     dest = the #GdkPixbuf into which to render the results
1000 	 *     destX = the left coordinate for region to render
1001 	 *     destY = the top coordinate for region to render
1002 	 *     destWidth = the width of the region to render
1003 	 *     destHeight = the height of the region to render
1004 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1005 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1006 	 *     scaleX = the scale factor in the X direction
1007 	 *     scaleY = the scale factor in the Y direction
1008 	 *     interpType = the interpolation type for the transformation.
1009 	 *     overallAlpha = overall alpha for source image (0..255)
1010 	 */
1011 	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)
1012 	{
1013 		gdk_pixbuf_composite(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType, overallAlpha);
1014 	}
1015 
1016 	/**
1017 	 * Creates a transformation of the source image @src by scaling by
1018 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y,
1019 	 * then alpha blends the rectangle (@dest_x ,@dest_y, @dest_width,
1020 	 * @dest_height) of the resulting image with a checkboard of the
1021 	 * colors @color1 and @color2 and renders it onto the destination
1022 	 * image.
1023 	 *
1024 	 * If the source image has no alpha channel, and @overall_alpha is 255, a fast
1025 	 * path is used which omits the alpha blending and just performs the scaling.
1026 	 *
1027 	 * See gdk_pixbuf_composite_color_simple() for a simpler variant of this
1028 	 * function suitable for many tasks.
1029 	 *
1030 	 * Params:
1031 	 *     dest = the #GdkPixbuf into which to render the results
1032 	 *     destX = the left coordinate for region to render
1033 	 *     destY = the top coordinate for region to render
1034 	 *     destWidth = the width of the region to render
1035 	 *     destHeight = the height of the region to render
1036 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1037 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1038 	 *     scaleX = the scale factor in the X direction
1039 	 *     scaleY = the scale factor in the Y direction
1040 	 *     interpType = the interpolation type for the transformation.
1041 	 *     overallAlpha = overall alpha for source image (0..255)
1042 	 *     checkX = the X offset for the checkboard (origin of checkboard is at -@check_x, -@check_y)
1043 	 *     checkY = the Y offset for the checkboard
1044 	 *     checkSize = the size of checks in the checkboard (must be a power of two)
1045 	 *     color1 = the color of check at upper left
1046 	 *     color2 = the color of the other check
1047 	 */
1048 	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)
1049 	{
1050 		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);
1051 	}
1052 
1053 	/**
1054 	 * Creates a new #GdkPixbuf by scaling @src to @dest_width x
1055 	 * @dest_height and alpha blending the result with a checkboard of colors
1056 	 * @color1 and @color2.
1057 	 *
1058 	 * Params:
1059 	 *     destWidth = the width of destination image
1060 	 *     destHeight = the height of destination image
1061 	 *     interpType = the interpolation type for the transformation.
1062 	 *     overallAlpha = overall alpha for source image (0..255)
1063 	 *     checkSize = the size of checks in the checkboard (must be a power of two)
1064 	 *     color1 = the color of check at upper left
1065 	 *     color2 = the color of the other check
1066 	 *
1067 	 * Returns: the new #GdkPixbuf, or %NULL if not enough memory could be
1068 	 *     allocated for it.
1069 	 */
1070 	public Pixbuf compositeColorSimple(int destWidth, int destHeight, GdkInterpType interpType, int overallAlpha, int checkSize, uint color1, uint color2)
1071 	{
1072 		auto p = gdk_pixbuf_composite_color_simple(gdkPixbuf, destWidth, destHeight, interpType, overallAlpha, checkSize, color1, color2);
1073 
1074 		if(p is null)
1075 		{
1076 			return null;
1077 		}
1078 
1079 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1080 	}
1081 
1082 	/**
1083 	 * Creates a new #GdkPixbuf with a copy of the information in the specified
1084 	 * @pixbuf. Note that this does not copy the options set on the original #GdkPixbuf,
1085 	 * use gdk_pixbuf_copy_options() for this.
1086 	 *
1087 	 * Returns: A newly-created pixbuf with a reference count of 1, or %NULL if
1088 	 *     not enough memory could be allocated.
1089 	 */
1090 	public Pixbuf copy()
1091 	{
1092 		auto p = gdk_pixbuf_copy(gdkPixbuf);
1093 
1094 		if(p is null)
1095 		{
1096 			return null;
1097 		}
1098 
1099 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1100 	}
1101 
1102 	/**
1103 	 * Copies a rectangular area from @src_pixbuf to @dest_pixbuf.  Conversion of
1104 	 * pixbuf formats is done automatically.
1105 	 *
1106 	 * If the source rectangle overlaps the destination rectangle on the
1107 	 * same pixbuf, it will be overwritten during the copy operation.
1108 	 * Therefore, you can not use this function to scroll a pixbuf.
1109 	 *
1110 	 * Params:
1111 	 *     srcX = Source X coordinate within @src_pixbuf.
1112 	 *     srcY = Source Y coordinate within @src_pixbuf.
1113 	 *     width = Width of the area to copy.
1114 	 *     height = Height of the area to copy.
1115 	 *     destPixbuf = Destination pixbuf.
1116 	 *     destX = X coordinate within @dest_pixbuf.
1117 	 *     destY = Y coordinate within @dest_pixbuf.
1118 	 */
1119 	public void copyArea(int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY)
1120 	{
1121 		gdk_pixbuf_copy_area(gdkPixbuf, srcX, srcY, width, height, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct(), destX, destY);
1122 	}
1123 
1124 	/**
1125 	 * Copy the key/value pair options attached to a #GdkPixbuf to another.
1126 	 * This is useful to keep original metadata after having manipulated
1127 	 * a file. However be careful to remove metadata which you've already
1128 	 * applied, such as the "orientation" option after rotating the image.
1129 	 *
1130 	 * Params:
1131 	 *     destPixbuf = the #GdkPixbuf to copy options to
1132 	 *
1133 	 * Returns: %TRUE on success.
1134 	 *
1135 	 * Since: 2.36
1136 	 */
1137 	public bool copyOptions(Pixbuf destPixbuf)
1138 	{
1139 		return gdk_pixbuf_copy_options(gdkPixbuf, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct()) != 0;
1140 	}
1141 
1142 	/**
1143 	 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
1144 	 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
1145 	 * doesn't have an alpha channel.
1146 	 *
1147 	 * Params:
1148 	 *     pixel = RGBA pixel to clear to
1149 	 *         (0xffffffff is opaque white, 0x00000000 transparent black)
1150 	 */
1151 	public void fill(uint pixel)
1152 	{
1153 		gdk_pixbuf_fill(gdkPixbuf, pixel);
1154 	}
1155 
1156 	/**
1157 	 * Flips a pixbuf horizontally or vertically and returns the
1158 	 * result in a new pixbuf.
1159 	 *
1160 	 * Params:
1161 	 *     horizontal = %TRUE to flip horizontally, %FALSE to flip vertically
1162 	 *
1163 	 * Returns: the new #GdkPixbuf, or %NULL
1164 	 *     if not enough memory could be allocated for it.
1165 	 *
1166 	 * Since: 2.6
1167 	 */
1168 	public Pixbuf flip(bool horizontal)
1169 	{
1170 		auto p = gdk_pixbuf_flip(gdkPixbuf, horizontal);
1171 
1172 		if(p is null)
1173 		{
1174 			return null;
1175 		}
1176 
1177 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1178 	}
1179 
1180 	/**
1181 	 * Queries the number of bits per color sample in a pixbuf.
1182 	 *
1183 	 * Returns: Number of bits per color sample.
1184 	 */
1185 	public int getBitsPerSample()
1186 	{
1187 		return gdk_pixbuf_get_bits_per_sample(gdkPixbuf);
1188 	}
1189 
1190 	/**
1191 	 * Returns the length of the pixel data, in bytes.
1192 	 *
1193 	 * Returns: The length of the pixel data.
1194 	 *
1195 	 * Since: 2.26
1196 	 */
1197 	public size_t getByteLength()
1198 	{
1199 		return gdk_pixbuf_get_byte_length(gdkPixbuf);
1200 	}
1201 
1202 	/**
1203 	 * Queries the color space of a pixbuf.
1204 	 *
1205 	 * Returns: Color space.
1206 	 */
1207 	public GdkColorspace getColorspace()
1208 	{
1209 		return gdk_pixbuf_get_colorspace(gdkPixbuf);
1210 	}
1211 
1212 	/**
1213 	 * Queries whether a pixbuf has an alpha channel (opacity information).
1214 	 *
1215 	 * Returns: %TRUE if it has an alpha channel, %FALSE otherwise.
1216 	 */
1217 	public bool getHasAlpha()
1218 	{
1219 		return gdk_pixbuf_get_has_alpha(gdkPixbuf) != 0;
1220 	}
1221 
1222 	/**
1223 	 * Queries the height of a pixbuf.
1224 	 *
1225 	 * Returns: Height in pixels.
1226 	 */
1227 	public int getHeight()
1228 	{
1229 		return gdk_pixbuf_get_height(gdkPixbuf);
1230 	}
1231 
1232 	/**
1233 	 * Queries the number of channels of a pixbuf.
1234 	 *
1235 	 * Returns: Number of channels.
1236 	 */
1237 	public int getNChannels()
1238 	{
1239 		return gdk_pixbuf_get_n_channels(gdkPixbuf);
1240 	}
1241 
1242 	/**
1243 	 * Looks up @key in the list of options that may have been attached to the
1244 	 * @pixbuf when it was loaded, or that may have been attached by another
1245 	 * function using gdk_pixbuf_set_option().
1246 	 *
1247 	 * For instance, the ANI loader provides "Title" and "Artist" options.
1248 	 * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot
1249 	 * options for cursor definitions. The PNG loader provides the tEXt ancillary
1250 	 * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
1251 	 * return an "orientation" option string that corresponds to the embedded
1252 	 * TIFF/Exif orientation tag (if present). Since 2.32, the TIFF loader sets
1253 	 * the "multipage" option string to "yes" when a multi-page TIFF is loaded.
1254 	 * Since 2.32 the JPEG and PNG loaders set "x-dpi" and "y-dpi" if the file
1255 	 * contains image density information in dots per inch.
1256 	 * Since 2.36.6, the JPEG loader sets the "comment" option with the comment
1257 	 * EXIF tag.
1258 	 *
1259 	 * Params:
1260 	 *     key = a nul-terminated string.
1261 	 *
1262 	 * Returns: the value associated with @key. This is a nul-terminated
1263 	 *     string that should not be freed or %NULL if @key was not found.
1264 	 */
1265 	public string getOption(string key)
1266 	{
1267 		return Str.toString(gdk_pixbuf_get_option(gdkPixbuf, Str.toStringz(key)));
1268 	}
1269 
1270 	/**
1271 	 * Returns a #GHashTable with a list of all the options that may have been
1272 	 * attached to the @pixbuf when it was loaded, or that may have been
1273 	 * attached by another function using gdk_pixbuf_set_option().
1274 	 *
1275 	 * See gdk_pixbuf_get_option() for more details.
1276 	 *
1277 	 * Returns: a #GHashTable of key/values
1278 	 *
1279 	 * Since: 2.32
1280 	 */
1281 	public HashTable getOptions()
1282 	{
1283 		auto p = gdk_pixbuf_get_options(gdkPixbuf);
1284 
1285 		if(p is null)
1286 		{
1287 			return null;
1288 		}
1289 
1290 		return new HashTable(cast(GHashTable*) p);
1291 	}
1292 
1293 	/**
1294 	 * Queries a pointer to the pixel data of a pixbuf.
1295 	 *
1296 	 * Returns: A pointer to the pixbuf's
1297 	 *     pixel data.  Please see the section on [image data](image-data)
1298 	 *     for information about how the pixel data is stored in memory.
1299 	 *
1300 	 *     This function will cause an implicit copy of the pixbuf data if the
1301 	 *     pixbuf was created from read-only data.
1302 	 *
1303 	 * Since: 2.26
1304 	 */
1305 	public char[] getPixelsWithLength()
1306 	{
1307 		uint length;
1308 
1309 		auto p = gdk_pixbuf_get_pixels_with_length(gdkPixbuf, &length);
1310 
1311 		return p[0 .. length];
1312 	}
1313 
1314 	/**
1315 	 * Queries the rowstride of a pixbuf, which is the number of bytes between
1316 	 * the start of a row and the start of the next row.
1317 	 *
1318 	 * Returns: Distance between row starts.
1319 	 */
1320 	public int getRowstride()
1321 	{
1322 		return gdk_pixbuf_get_rowstride(gdkPixbuf);
1323 	}
1324 
1325 	/**
1326 	 * Queries the width of a pixbuf.
1327 	 *
1328 	 * Returns: Width in pixels.
1329 	 */
1330 	public int getWidth()
1331 	{
1332 		return gdk_pixbuf_get_width(gdkPixbuf);
1333 	}
1334 
1335 	/**
1336 	 * Creates a new pixbuf which represents a sub-region of @src_pixbuf.
1337 	 * The new pixbuf shares its pixels with the original pixbuf, so
1338 	 * writing to one affects both.  The new pixbuf holds a reference to
1339 	 * @src_pixbuf, so @src_pixbuf will not be finalized until the new
1340 	 * pixbuf is finalized.
1341 	 *
1342 	 * Note that if @src_pixbuf is read-only, this function will force it
1343 	 * to be mutable.
1344 	 *
1345 	 * Params:
1346 	 *     srcX = X coord in @src_pixbuf
1347 	 *     srcY = Y coord in @src_pixbuf
1348 	 *     width = width of region in @src_pixbuf
1349 	 *     height = height of region in @src_pixbuf
1350 	 *
1351 	 * Returns: a new pixbuf
1352 	 */
1353 	public Pixbuf newSubpixbuf(int srcX, int srcY, int width, int height)
1354 	{
1355 		auto p = gdk_pixbuf_new_subpixbuf(gdkPixbuf, srcX, srcY, width, height);
1356 
1357 		if(p is null)
1358 		{
1359 			return null;
1360 		}
1361 
1362 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1363 	}
1364 
1365 	/**
1366 	 * Returns: A new reference to a read-only copy of
1367 	 *     the pixel data.  Note that for mutable pixbufs, this function will
1368 	 *     incur a one-time copy of the pixel data for conversion into the
1369 	 *     returned #GBytes.
1370 	 *
1371 	 * Since: 2.32
1372 	 */
1373 	public Bytes readPixelBytes()
1374 	{
1375 		auto p = gdk_pixbuf_read_pixel_bytes(gdkPixbuf);
1376 
1377 		if(p is null)
1378 		{
1379 			return null;
1380 		}
1381 
1382 		return new Bytes(cast(GBytes*) p, true);
1383 	}
1384 
1385 	/**
1386 	 * Returns a read-only pointer to the raw pixel data; must not be
1387 	 * modified.  This function allows skipping the implicit copy that
1388 	 * must be made if gdk_pixbuf_get_pixels() is called on a read-only
1389 	 * pixbuf.
1390 	 *
1391 	 * Since: 2.32
1392 	 */
1393 	public ubyte* readPixels()
1394 	{
1395 		return gdk_pixbuf_read_pixels(gdkPixbuf);
1396 	}
1397 
1398 	/**
1399 	 * Remove the key/value pair option attached to a #GdkPixbuf.
1400 	 *
1401 	 * Params:
1402 	 *     key = a nul-terminated string representing the key to remove.
1403 	 *
1404 	 * Returns: %TRUE if an option was removed, %FALSE if not.
1405 	 *
1406 	 * Since: 2.36
1407 	 */
1408 	public bool removeOption(string key)
1409 	{
1410 		return gdk_pixbuf_remove_option(gdkPixbuf, Str.toStringz(key)) != 0;
1411 	}
1412 
1413 	/**
1414 	 * Rotates a pixbuf by a multiple of 90 degrees, and returns the
1415 	 * result in a new pixbuf.
1416 	 *
1417 	 * If @angle is 0, a copy of @src is returned, avoiding any rotation.
1418 	 *
1419 	 * Params:
1420 	 *     angle = the angle to rotate by
1421 	 *
1422 	 * Returns: the new #GdkPixbuf, or %NULL
1423 	 *     if not enough memory could be allocated for it.
1424 	 *
1425 	 * Since: 2.6
1426 	 */
1427 	public Pixbuf rotateSimple(GdkPixbufRotation angle)
1428 	{
1429 		auto p = gdk_pixbuf_rotate_simple(gdkPixbuf, angle);
1430 
1431 		if(p is null)
1432 		{
1433 			return null;
1434 		}
1435 
1436 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1437 	}
1438 
1439 	/**
1440 	 * Modifies saturation and optionally pixelates @src, placing the result in
1441 	 * @dest. @src and @dest may be the same pixbuf with no ill effects.  If
1442 	 * @saturation is 1.0 then saturation is not changed. If it's less than 1.0,
1443 	 * saturation is reduced (the image turns toward grayscale); if greater than
1444 	 * 1.0, saturation is increased (the image gets more vivid colors). If @pixelate
1445 	 * is %TRUE, then pixels are faded in a checkerboard pattern to create a
1446 	 * pixelated image. @src and @dest must have the same image format, size, and
1447 	 * rowstride.
1448 	 *
1449 	 * Params:
1450 	 *     dest = place to write modified version of @src
1451 	 *     saturation = saturation factor
1452 	 *     pixelate = whether to pixelate
1453 	 */
1454 	public void saturateAndPixelate(Pixbuf dest, float saturation, bool pixelate)
1455 	{
1456 		gdk_pixbuf_saturate_and_pixelate(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), saturation, pixelate);
1457 	}
1458 
1459 	/**
1460 	 * Saves pixbuf to a callback in format @type, which is currently "jpeg",
1461 	 * "png", "tiff", "ico" or "bmp".  If @error is set, %FALSE will be returned. See
1462 	 * gdk_pixbuf_save_to_callback () for more details.
1463 	 *
1464 	 * Params:
1465 	 *     saveFunc = a function that is called to save each block of data that
1466 	 *         the save routine generates.
1467 	 *     userData = user data to pass to the save function.
1468 	 *     type = name of file format.
1469 	 *     optionKeys = name of options to set, %NULL-terminated
1470 	 *     optionValues = values for named options
1471 	 *
1472 	 * Returns: whether an error was set
1473 	 *
1474 	 * Since: 2.4
1475 	 *
1476 	 * Throws: GException on failure.
1477 	 */
1478 	public bool saveToCallbackv(GdkPixbufSaveFunc saveFunc, void* userData, string type, string[] optionKeys, string[] optionValues)
1479 	{
1480 		GError* err = null;
1481 
1482 		auto p = gdk_pixbuf_save_to_callbackv(gdkPixbuf, saveFunc, userData, Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
1483 
1484 		if (err !is null)
1485 		{
1486 			throw new GException( new ErrorG(err) );
1487 		}
1488 
1489 		return p;
1490 	}
1491 
1492 	/**
1493 	 * Saves @pixbuf to an output stream.
1494 	 *
1495 	 * Supported file formats are currently "jpeg", "tiff", "png", "ico" or
1496 	 * "bmp". See gdk_pixbuf_save_to_stream() for more details.
1497 	 *
1498 	 * Params:
1499 	 *     stream = a #GOutputStream to save the pixbuf to
1500 	 *     type = name of file format
1501 	 *     optionKeys = name of options to set, %NULL-terminated
1502 	 *     optionValues = values for named options
1503 	 *     cancellable = optional #GCancellable object, %NULL to ignore
1504 	 *
1505 	 * Returns: %TRUE if the pixbuf was saved successfully, %FALSE if an
1506 	 *     error was set.
1507 	 *
1508 	 * Since: 2.36
1509 	 *
1510 	 * Throws: GException on failure.
1511 	 */
1512 	public bool saveToStreamv(OutputStream stream, string type, string[] optionKeys, string[] optionValues, Cancellable cancellable)
1513 	{
1514 		GError* err = null;
1515 
1516 		auto p = gdk_pixbuf_save_to_streamv(gdkPixbuf, (stream is null) ? null : stream.getOutputStreamStruct(), Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
1517 
1518 		if (err !is null)
1519 		{
1520 			throw new GException( new ErrorG(err) );
1521 		}
1522 
1523 		return p;
1524 	}
1525 
1526 	/**
1527 	 * Saves @pixbuf to an output stream asynchronously.
1528 	 *
1529 	 * For more details see gdk_pixbuf_save_to_streamv(), which is the synchronous
1530 	 * version of this function.
1531 	 *
1532 	 * When the operation is finished, @callback will be called in the main thread.
1533 	 * You can then call gdk_pixbuf_save_to_stream_finish() to get the result of the operation.
1534 	 *
1535 	 * Params:
1536 	 *     stream = a #GOutputStream to which to save the pixbuf
1537 	 *     type = name of file format
1538 	 *     optionKeys = name of options to set, %NULL-terminated
1539 	 *     optionValues = values for named options
1540 	 *     cancellable = optional #GCancellable object, %NULL to ignore
1541 	 *     callback = a #GAsyncReadyCallback to call when the pixbuf is saved
1542 	 *     userData = the data to pass to the callback function
1543 	 *
1544 	 * Since: 2.36
1545 	 */
1546 	public void saveToStreamvAsync(OutputStream stream, string type, string[] optionKeys, string[] optionValues, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
1547 	{
1548 		gdk_pixbuf_save_to_streamv_async(gdkPixbuf, (stream is null) ? null : stream.getOutputStreamStruct(), Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
1549 	}
1550 
1551 	/**
1552 	 * Saves pixbuf to a file in @type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
1553 	 * If @error is set, %FALSE will be returned.
1554 	 * See gdk_pixbuf_save () for more details.
1555 	 *
1556 	 * Params:
1557 	 *     filename = name of file to save.
1558 	 *     type = name of file format.
1559 	 *     optionKeys = name of options to set, %NULL-terminated
1560 	 *     optionValues = values for named options
1561 	 *
1562 	 * Returns: whether an error was set
1563 	 *
1564 	 * Throws: GException on failure.
1565 	 */
1566 	public bool savev(string filename, string type, string[] optionKeys, string[] optionValues)
1567 	{
1568 		GError* err = null;
1569 
1570 		auto p = gdk_pixbuf_savev(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
1571 
1572 		if (err !is null)
1573 		{
1574 			throw new GException( new ErrorG(err) );
1575 		}
1576 
1577 		return p;
1578 	}
1579 
1580 	/**
1581 	 * Creates a transformation of the source image @src by scaling by
1582 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y,
1583 	 * then renders the rectangle (@dest_x, @dest_y, @dest_width,
1584 	 * @dest_height) of the resulting image onto the destination image
1585 	 * replacing the previous contents.
1586 	 *
1587 	 * Try to use gdk_pixbuf_scale_simple() first, this function is
1588 	 * the industrial-strength power tool you can fall back to if
1589 	 * gdk_pixbuf_scale_simple() isn't powerful enough.
1590 	 *
1591 	 * If the source rectangle overlaps the destination rectangle on the
1592 	 * same pixbuf, it will be overwritten during the scaling which
1593 	 * results in rendering artifacts.
1594 	 *
1595 	 * Params:
1596 	 *     dest = the #GdkPixbuf into which to render the results
1597 	 *     destX = the left coordinate for region to render
1598 	 *     destY = the top coordinate for region to render
1599 	 *     destWidth = the width of the region to render
1600 	 *     destHeight = the height of the region to render
1601 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1602 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1603 	 *     scaleX = the scale factor in the X direction
1604 	 *     scaleY = the scale factor in the Y direction
1605 	 *     interpType = the interpolation type for the transformation.
1606 	 */
1607 	public void scale(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType)
1608 	{
1609 		gdk_pixbuf_scale(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType);
1610 	}
1611 
1612 	/**
1613 	 * Create a new #GdkPixbuf containing a copy of @src scaled to
1614 	 * @dest_width x @dest_height. Leaves @src unaffected.  @interp_type
1615 	 * should be #GDK_INTERP_NEAREST if you want maximum speed (but when
1616 	 * scaling down #GDK_INTERP_NEAREST is usually unusably ugly).  The
1617 	 * default @interp_type should be #GDK_INTERP_BILINEAR which offers
1618 	 * reasonable quality and speed.
1619 	 *
1620 	 * You can scale a sub-portion of @src by creating a sub-pixbuf
1621 	 * pointing into @src; see gdk_pixbuf_new_subpixbuf().
1622 	 *
1623 	 * If @dest_width and @dest_height are equal to the @src width and height, a
1624 	 * copy of @src is returned, avoiding any scaling.
1625 	 *
1626 	 * For more complicated scaling/alpha blending see gdk_pixbuf_scale()
1627 	 * and gdk_pixbuf_composite().
1628 	 *
1629 	 * Params:
1630 	 *     destWidth = the width of destination image
1631 	 *     destHeight = the height of destination image
1632 	 *     interpType = the interpolation type for the transformation.
1633 	 *
1634 	 * Returns: the new #GdkPixbuf, or %NULL if not enough memory could be
1635 	 *     allocated for it.
1636 	 */
1637 	public Pixbuf scaleSimple(int destWidth, int destHeight, GdkInterpType interpType)
1638 	{
1639 		auto p = gdk_pixbuf_scale_simple(gdkPixbuf, destWidth, destHeight, interpType);
1640 
1641 		if(p is null)
1642 		{
1643 			return null;
1644 		}
1645 
1646 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1647 	}
1648 
1649 	/**
1650 	 * Attaches a key/value pair as an option to a #GdkPixbuf. If @key already
1651 	 * exists in the list of options attached to @pixbuf, the new value is
1652 	 * ignored and %FALSE is returned.
1653 	 *
1654 	 * Params:
1655 	 *     key = a nul-terminated string.
1656 	 *     value = a nul-terminated string.
1657 	 *
1658 	 * Returns: %TRUE on success.
1659 	 *
1660 	 * Since: 2.2
1661 	 */
1662 	public bool setOption(string key, string value)
1663 	{
1664 		return gdk_pixbuf_set_option(gdkPixbuf, Str.toStringz(key), Str.toStringz(value)) != 0;
1665 	}
1666 }