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