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 	 * Converts a #GdkPixdata to a #GdkPixbuf. If @copy_pixels is %TRUE or
708 	 * if the pixel data is run-length-encoded, the pixel data is copied into
709 	 * newly-allocated memory; otherwise it is reused.
710 	 *
711 	 * Deprecated: Use #GResource instead.
712 	 *
713 	 * Params:
714 	 *     pixdata = a #GdkPixdata to convert into a #GdkPixbuf.
715 	 *     copyPixels = whether to copy raw pixel data; run-length encoded
716 	 *         pixel data is always copied.
717 	 *
718 	 * Returns: a new #GdkPixbuf.
719 	 *
720 	 * Throws: GException on failure.
721 	 */
722 	public static Pixbuf fromPixdata(Pixdata pixdata, bool copyPixels)
723 	{
724 		GError* err = null;
725 
726 		auto p = gdk_pixbuf_from_pixdata((pixdata is null) ? null : pixdata.getPixdataStruct(), copyPixels, &err);
727 
728 		if (err !is null)
729 		{
730 			throw new GException( new ErrorG(err) );
731 		}
732 
733 		if(p is null)
734 		{
735 			return null;
736 		}
737 
738 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
739 	}
740 
741 	/**
742 	 * Parses an image file far enough to determine its format and size.
743 	 *
744 	 * Params:
745 	 *     filename = The name of the file to identify.
746 	 *     width = Return location for the width of the
747 	 *         image, or %NULL
748 	 *     height = Return location for the height of the
749 	 *         image, or %NULL
750 	 *
751 	 * Returns: A #GdkPixbufFormat describing
752 	 *     the image format of the file or %NULL if the image format wasn't
753 	 *     recognized. The return value is owned by #GdkPixbuf and should
754 	 *     not be freed.
755 	 *
756 	 * Since: 2.4
757 	 */
758 	public static PixbufFormat getFileInfo(string filename, out int width, out int height)
759 	{
760 		auto p = gdk_pixbuf_get_file_info(Str.toStringz(filename), &width, &height);
761 
762 		if(p is null)
763 		{
764 			return null;
765 		}
766 
767 		return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p);
768 	}
769 
770 	/**
771 	 * Asynchronously parses an image file far enough to determine its
772 	 * format and size.
773 	 *
774 	 * For more details see gdk_pixbuf_get_file_info(), which is the synchronous
775 	 * version of this function.
776 	 *
777 	 * When the operation is finished, @callback will be called in the
778 	 * main thread. You can then call gdk_pixbuf_get_file_info_finish() to
779 	 * get the result of the operation.
780 	 *
781 	 * Params:
782 	 *     filename = The name of the file to identify
783 	 *     cancellable = optional #GCancellable object, %NULL to ignore
784 	 *     callback = a #GAsyncReadyCallback to call when the file info is available
785 	 *     userData = the data to pass to the callback function
786 	 *
787 	 * Since: 2.32
788 	 */
789 	public static void getFileInfoAsync(string filename, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
790 	{
791 		gdk_pixbuf_get_file_info_async(Str.toStringz(filename), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
792 	}
793 
794 	/**
795 	 * Finishes an asynchronous pixbuf parsing operation started with
796 	 * gdk_pixbuf_get_file_info_async().
797 	 *
798 	 * Params:
799 	 *     asyncResult = a #GAsyncResult
800 	 *     width = Return location for the width of the image, or %NULL
801 	 *     height = Return location for the height of the image, or %NULL
802 	 *
803 	 * Returns: A #GdkPixbufFormat describing the image
804 	 *     format of the file or %NULL if the image format wasn't
805 	 *     recognized. The return value is owned by GdkPixbuf and should
806 	 *     not be freed.
807 	 *
808 	 * Since: 2.32
809 	 *
810 	 * Throws: GException on failure.
811 	 */
812 	public static PixbufFormat getFileInfoFinish(AsyncResultIF asyncResult, out int width, out int height)
813 	{
814 		GError* err = null;
815 
816 		auto p = gdk_pixbuf_get_file_info_finish((asyncResult is null) ? null : asyncResult.getAsyncResultStruct(), &width, &height, &err);
817 
818 		if (err !is null)
819 		{
820 			throw new GException( new ErrorG(err) );
821 		}
822 
823 		if(p is null)
824 		{
825 			return null;
826 		}
827 
828 		return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p);
829 	}
830 
831 	/**
832 	 * Obtains the available information about the image formats supported
833 	 * by GdkPixbuf.
834 	 *
835 	 * Returns: A list of
836 	 *     #GdkPixbufFormats describing the supported image formats. The list should
837 	 *     be freed when it is no longer needed, but the structures themselves are
838 	 *     owned by #GdkPixbuf and should not be freed.
839 	 *
840 	 * Since: 2.2
841 	 */
842 	public static ListSG getFormats()
843 	{
844 		auto p = gdk_pixbuf_get_formats();
845 
846 		if(p is null)
847 		{
848 			return null;
849 		}
850 
851 		return new ListSG(cast(GSList*) p);
852 	}
853 
854 	/**
855 	 * Creates a new pixbuf by asynchronously loading an image from an input stream.
856 	 *
857 	 * For more details see gdk_pixbuf_new_from_stream(), which is the synchronous
858 	 * version of this function.
859 	 *
860 	 * When the operation is finished, @callback will be called in the main thread.
861 	 * You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation.
862 	 *
863 	 * Params:
864 	 *     stream = a #GInputStream from which to load the pixbuf
865 	 *     cancellable = optional #GCancellable object, %NULL to ignore
866 	 *     callback = a #GAsyncReadyCallback to call when the pixbuf is loaded
867 	 *     userData = the data to pass to the callback function
868 	 *
869 	 * Since: 2.24
870 	 */
871 	public static void newFromStreamAsync(InputStream stream, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
872 	{
873 		gdk_pixbuf_new_from_stream_async((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
874 	}
875 
876 	/**
877 	 * Creates a new pixbuf by asynchronously loading an image from an input stream.
878 	 *
879 	 * For more details see gdk_pixbuf_new_from_stream_at_scale(), which is the synchronous
880 	 * version of this function.
881 	 *
882 	 * When the operation is finished, @callback will be called in the main thread.
883 	 * You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation.
884 	 *
885 	 * Params:
886 	 *     stream = a #GInputStream from which to load the pixbuf
887 	 *     width = the width the image should have or -1 to not constrain the width
888 	 *     height = the height the image should have or -1 to not constrain the height
889 	 *     preserveAspectRatio = %TRUE to preserve the image's aspect ratio
890 	 *     cancellable = optional #GCancellable object, %NULL to ignore
891 	 *     callback = a #GAsyncReadyCallback to call when the pixbuf is loaded
892 	 *     userData = the data to pass to the callback function
893 	 *
894 	 * Since: 2.24
895 	 */
896 	public static void newFromStreamAtScaleAsync(InputStream stream, int width, int height, bool preserveAspectRatio, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
897 	{
898 		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);
899 	}
900 
901 	/**
902 	 * Finishes an asynchronous pixbuf save operation started with
903 	 * gdk_pixbuf_save_to_stream_async().
904 	 *
905 	 * Params:
906 	 *     asyncResult = a #GAsyncResult
907 	 *
908 	 * Returns: %TRUE if the pixbuf was saved successfully, %FALSE if an error was set.
909 	 *
910 	 * Since: 2.24
911 	 *
912 	 * Throws: GException on failure.
913 	 */
914 	public static bool saveToStreamFinish(AsyncResultIF asyncResult)
915 	{
916 		GError* err = null;
917 
918 		auto p = gdk_pixbuf_save_to_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultStruct(), &err) != 0;
919 
920 		if (err !is null)
921 		{
922 			throw new GException( new ErrorG(err) );
923 		}
924 
925 		return p;
926 	}
927 
928 	/**
929 	 * Takes an existing pixbuf and adds an alpha channel to it.
930 	 * If the existing pixbuf already had an alpha channel, the channel
931 	 * values are copied from the original; otherwise, the alpha channel
932 	 * is initialized to 255 (full opacity).
933 	 *
934 	 * If @substitute_color is %TRUE, then the color specified by (@r, @g, @b) will be
935 	 * assigned zero opacity. That is, if you pass (255, 255, 255) for the
936 	 * substitute color, all white pixels will become fully transparent.
937 	 *
938 	 * Params:
939 	 *     substituteColor = Whether to set a color to zero opacity.  If this
940 	 *         is %FALSE, then the (@r, @g, @b) arguments will be ignored.
941 	 *     r = Red value to substitute.
942 	 *     g = Green value to substitute.
943 	 *     b = Blue value to substitute.
944 	 *
945 	 * Returns: A newly-created pixbuf with a reference count of 1.
946 	 */
947 	public Pixbuf addAlpha(bool substituteColor, char r, char g, char b)
948 	{
949 		auto p = gdk_pixbuf_add_alpha(gdkPixbuf, substituteColor, r, g, b);
950 
951 		if(p is null)
952 		{
953 			return null;
954 		}
955 
956 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
957 	}
958 
959 	/**
960 	 * Takes an existing pixbuf and checks for the presence of an
961 	 * associated "orientation" option, which may be provided by the
962 	 * jpeg loader (which reads the exif orientation tag) or the
963 	 * tiff loader (which reads the tiff orientation tag, and
964 	 * compensates it for the partial transforms performed by
965 	 * libtiff). If an orientation option/tag is present, the
966 	 * appropriate transform will be performed so that the pixbuf
967 	 * is oriented correctly.
968 	 *
969 	 * Returns: A newly-created pixbuf, %NULL if
970 	 *     not enough memory could be allocated for it, or a reference to the
971 	 *     input pixbuf (with an increased reference count).
972 	 *
973 	 * Since: 2.12
974 	 */
975 	public Pixbuf applyEmbeddedOrientation()
976 	{
977 		auto p = gdk_pixbuf_apply_embedded_orientation(gdkPixbuf);
978 
979 		if(p is null)
980 		{
981 			return null;
982 		}
983 
984 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
985 	}
986 
987 	/**
988 	 * Creates a transformation of the source image @src by scaling by
989 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y.
990 	 * This gives an image in the coordinates of the destination pixbuf.
991 	 * The rectangle (@dest_x, @dest_y, @dest_width, @dest_height)
992 	 * is then alpha blended onto the corresponding rectangle of the
993 	 * original destination image.
994 	 *
995 	 * When the destination rectangle contains parts not in the source
996 	 * image, the data at the edges of the source image is replicated
997 	 * to infinity.
998 	 *
999 	 * ![](composite.png)
1000 	 *
1001 	 * Params:
1002 	 *     dest = the #GdkPixbuf into which to render the results
1003 	 *     destX = the left coordinate for region to render
1004 	 *     destY = the top coordinate for region to render
1005 	 *     destWidth = the width of the region to render
1006 	 *     destHeight = the height of the region to render
1007 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1008 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1009 	 *     scaleX = the scale factor in the X direction
1010 	 *     scaleY = the scale factor in the Y direction
1011 	 *     interpType = the interpolation type for the transformation.
1012 	 *     overallAlpha = overall alpha for source image (0..255)
1013 	 */
1014 	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)
1015 	{
1016 		gdk_pixbuf_composite(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType, overallAlpha);
1017 	}
1018 
1019 	/**
1020 	 * Creates a transformation of the source image @src by scaling by
1021 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y,
1022 	 * then alpha blends the rectangle (@dest_x ,@dest_y, @dest_width,
1023 	 * @dest_height) of the resulting image with a checkboard of the
1024 	 * colors @color1 and @color2 and renders it onto the destination
1025 	 * image.
1026 	 *
1027 	 * If the source image has no alpha channel, and @overall_alpha is 255, a fast
1028 	 * path is used which omits the alpha blending and just performs the scaling.
1029 	 *
1030 	 * See gdk_pixbuf_composite_color_simple() for a simpler variant of this
1031 	 * function suitable for many tasks.
1032 	 *
1033 	 * Params:
1034 	 *     dest = the #GdkPixbuf into which to render the results
1035 	 *     destX = the left coordinate for region to render
1036 	 *     destY = the top coordinate for region to render
1037 	 *     destWidth = the width of the region to render
1038 	 *     destHeight = the height of the region to render
1039 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1040 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1041 	 *     scaleX = the scale factor in the X direction
1042 	 *     scaleY = the scale factor in the Y direction
1043 	 *     interpType = the interpolation type for the transformation.
1044 	 *     overallAlpha = overall alpha for source image (0..255)
1045 	 *     checkX = the X offset for the checkboard (origin of checkboard is at -@check_x, -@check_y)
1046 	 *     checkY = the Y offset for the checkboard
1047 	 *     checkSize = the size of checks in the checkboard (must be a power of two)
1048 	 *     color1 = the color of check at upper left
1049 	 *     color2 = the color of the other check
1050 	 */
1051 	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)
1052 	{
1053 		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);
1054 	}
1055 
1056 	/**
1057 	 * Creates a new #GdkPixbuf by scaling @src to @dest_width x
1058 	 * @dest_height and alpha blending the result with a checkboard of colors
1059 	 * @color1 and @color2.
1060 	 *
1061 	 * Params:
1062 	 *     destWidth = the width of destination image
1063 	 *     destHeight = the height of destination image
1064 	 *     interpType = the interpolation type for the transformation.
1065 	 *     overallAlpha = overall alpha for source image (0..255)
1066 	 *     checkSize = the size of checks in the checkboard (must be a power of two)
1067 	 *     color1 = the color of check at upper left
1068 	 *     color2 = the color of the other check
1069 	 *
1070 	 * Returns: the new #GdkPixbuf, or %NULL if not enough memory could be
1071 	 *     allocated for it.
1072 	 */
1073 	public Pixbuf compositeColorSimple(int destWidth, int destHeight, GdkInterpType interpType, int overallAlpha, int checkSize, uint color1, uint color2)
1074 	{
1075 		auto p = gdk_pixbuf_composite_color_simple(gdkPixbuf, destWidth, destHeight, interpType, overallAlpha, checkSize, color1, color2);
1076 
1077 		if(p is null)
1078 		{
1079 			return null;
1080 		}
1081 
1082 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1083 	}
1084 
1085 	/**
1086 	 * Creates a new #GdkPixbuf with a copy of the information in the specified
1087 	 * @pixbuf. Note that this does not copy the options set on the original #GdkPixbuf,
1088 	 * use gdk_pixbuf_copy_options() for this.
1089 	 *
1090 	 * Returns: A newly-created pixbuf with a reference count of 1, or %NULL if
1091 	 *     not enough memory could be allocated.
1092 	 */
1093 	public Pixbuf copy()
1094 	{
1095 		auto p = gdk_pixbuf_copy(gdkPixbuf);
1096 
1097 		if(p is null)
1098 		{
1099 			return null;
1100 		}
1101 
1102 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1103 	}
1104 
1105 	/**
1106 	 * Copies a rectangular area from @src_pixbuf to @dest_pixbuf.  Conversion of
1107 	 * pixbuf formats is done automatically.
1108 	 *
1109 	 * If the source rectangle overlaps the destination rectangle on the
1110 	 * same pixbuf, it will be overwritten during the copy operation.
1111 	 * Therefore, you can not use this function to scroll a pixbuf.
1112 	 *
1113 	 * Params:
1114 	 *     srcX = Source X coordinate within @src_pixbuf.
1115 	 *     srcY = Source Y coordinate within @src_pixbuf.
1116 	 *     width = Width of the area to copy.
1117 	 *     height = Height of the area to copy.
1118 	 *     destPixbuf = Destination pixbuf.
1119 	 *     destX = X coordinate within @dest_pixbuf.
1120 	 *     destY = Y coordinate within @dest_pixbuf.
1121 	 */
1122 	public void copyArea(int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY)
1123 	{
1124 		gdk_pixbuf_copy_area(gdkPixbuf, srcX, srcY, width, height, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct(), destX, destY);
1125 	}
1126 
1127 	/**
1128 	 * Copy the key/value pair options attached to a #GdkPixbuf to another.
1129 	 * This is useful to keep original metadata after having manipulated
1130 	 * a file. However be careful to remove metadata which you've already
1131 	 * applied, such as the "orientation" option after rotating the image.
1132 	 *
1133 	 * Params:
1134 	 *     destPixbuf = the #GdkPixbuf to copy options to
1135 	 *
1136 	 * Returns: %TRUE on success.
1137 	 *
1138 	 * Since: 2.36
1139 	 */
1140 	public bool copyOptions(Pixbuf destPixbuf)
1141 	{
1142 		return gdk_pixbuf_copy_options(gdkPixbuf, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct()) != 0;
1143 	}
1144 
1145 	/**
1146 	 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
1147 	 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
1148 	 * doesn't have an alpha channel.
1149 	 *
1150 	 * Params:
1151 	 *     pixel = RGBA pixel to clear to
1152 	 *         (0xffffffff is opaque white, 0x00000000 transparent black)
1153 	 */
1154 	public void fill(uint pixel)
1155 	{
1156 		gdk_pixbuf_fill(gdkPixbuf, pixel);
1157 	}
1158 
1159 	/**
1160 	 * Flips a pixbuf horizontally or vertically and returns the
1161 	 * result in a new pixbuf.
1162 	 *
1163 	 * Params:
1164 	 *     horizontal = %TRUE to flip horizontally, %FALSE to flip vertically
1165 	 *
1166 	 * Returns: the new #GdkPixbuf, or %NULL
1167 	 *     if not enough memory could be allocated for it.
1168 	 *
1169 	 * Since: 2.6
1170 	 */
1171 	public Pixbuf flip(bool horizontal)
1172 	{
1173 		auto p = gdk_pixbuf_flip(gdkPixbuf, horizontal);
1174 
1175 		if(p is null)
1176 		{
1177 			return null;
1178 		}
1179 
1180 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1181 	}
1182 
1183 	/**
1184 	 * Queries the number of bits per color sample in a pixbuf.
1185 	 *
1186 	 * Returns: Number of bits per color sample.
1187 	 */
1188 	public int getBitsPerSample()
1189 	{
1190 		return gdk_pixbuf_get_bits_per_sample(gdkPixbuf);
1191 	}
1192 
1193 	/**
1194 	 * Returns the length of the pixel data, in bytes.
1195 	 *
1196 	 * Returns: The length of the pixel data.
1197 	 *
1198 	 * Since: 2.26
1199 	 */
1200 	public size_t getByteLength()
1201 	{
1202 		return gdk_pixbuf_get_byte_length(gdkPixbuf);
1203 	}
1204 
1205 	/**
1206 	 * Queries the color space of a pixbuf.
1207 	 *
1208 	 * Returns: Color space.
1209 	 */
1210 	public GdkColorspace getColorspace()
1211 	{
1212 		return gdk_pixbuf_get_colorspace(gdkPixbuf);
1213 	}
1214 
1215 	/**
1216 	 * Queries whether a pixbuf has an alpha channel (opacity information).
1217 	 *
1218 	 * Returns: %TRUE if it has an alpha channel, %FALSE otherwise.
1219 	 */
1220 	public bool getHasAlpha()
1221 	{
1222 		return gdk_pixbuf_get_has_alpha(gdkPixbuf) != 0;
1223 	}
1224 
1225 	/**
1226 	 * Queries the height of a pixbuf.
1227 	 *
1228 	 * Returns: Height in pixels.
1229 	 */
1230 	public int getHeight()
1231 	{
1232 		return gdk_pixbuf_get_height(gdkPixbuf);
1233 	}
1234 
1235 	/**
1236 	 * Queries the number of channels of a pixbuf.
1237 	 *
1238 	 * Returns: Number of channels.
1239 	 */
1240 	public int getNChannels()
1241 	{
1242 		return gdk_pixbuf_get_n_channels(gdkPixbuf);
1243 	}
1244 
1245 	/**
1246 	 * Looks up @key in the list of options that may have been attached to the
1247 	 * @pixbuf when it was loaded, or that may have been attached by another
1248 	 * function using gdk_pixbuf_set_option().
1249 	 *
1250 	 * For instance, the ANI loader provides "Title" and "Artist" options.
1251 	 * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot
1252 	 * options for cursor definitions. The PNG loader provides the tEXt ancillary
1253 	 * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
1254 	 * return an "orientation" option string that corresponds to the embedded
1255 	 * TIFF/Exif orientation tag (if present). Since 2.32, the TIFF loader sets
1256 	 * the "multipage" option string to "yes" when a multi-page TIFF is loaded.
1257 	 * Since 2.32 the JPEG and PNG loaders set "x-dpi" and "y-dpi" if the file
1258 	 * contains image density information in dots per inch.
1259 	 * Since 2.36.6, the JPEG loader sets the "comment" option with the comment
1260 	 * EXIF tag.
1261 	 *
1262 	 * Params:
1263 	 *     key = a nul-terminated string.
1264 	 *
1265 	 * Returns: the value associated with @key. This is a nul-terminated
1266 	 *     string that should not be freed or %NULL if @key was not found.
1267 	 */
1268 	public string getOption(string key)
1269 	{
1270 		return Str.toString(gdk_pixbuf_get_option(gdkPixbuf, Str.toStringz(key)));
1271 	}
1272 
1273 	/**
1274 	 * Returns a #GHashTable with a list of all the options that may have been
1275 	 * attached to the @pixbuf when it was loaded, or that may have been
1276 	 * attached by another function using gdk_pixbuf_set_option().
1277 	 *
1278 	 * See gdk_pixbuf_get_option() for more details.
1279 	 *
1280 	 * Returns: a #GHashTable of key/values
1281 	 *
1282 	 * Since: 2.32
1283 	 */
1284 	public HashTable getOptions()
1285 	{
1286 		auto p = gdk_pixbuf_get_options(gdkPixbuf);
1287 
1288 		if(p is null)
1289 		{
1290 			return null;
1291 		}
1292 
1293 		return new HashTable(cast(GHashTable*) p);
1294 	}
1295 
1296 	/**
1297 	 * Queries a pointer to the pixel data of a pixbuf.
1298 	 *
1299 	 * Returns: A pointer to the pixbuf's
1300 	 *     pixel data.  Please see the section on [image data][image-data]
1301 	 *     for information about how the pixel data is stored in memory.
1302 	 *
1303 	 *     This function will cause an implicit copy of the pixbuf data if the
1304 	 *     pixbuf was created from read-only data.
1305 	 *
1306 	 * Since: 2.26
1307 	 */
1308 	public char[] getPixelsWithLength()
1309 	{
1310 		uint length;
1311 
1312 		auto p = gdk_pixbuf_get_pixels_with_length(gdkPixbuf, &length);
1313 
1314 		return p[0 .. length];
1315 	}
1316 
1317 	/**
1318 	 * Queries the rowstride of a pixbuf, which is the number of bytes between
1319 	 * the start of a row and the start of the next row.
1320 	 *
1321 	 * Returns: Distance between row starts.
1322 	 */
1323 	public int getRowstride()
1324 	{
1325 		return gdk_pixbuf_get_rowstride(gdkPixbuf);
1326 	}
1327 
1328 	/**
1329 	 * Queries the width of a pixbuf.
1330 	 *
1331 	 * Returns: Width in pixels.
1332 	 */
1333 	public int getWidth()
1334 	{
1335 		return gdk_pixbuf_get_width(gdkPixbuf);
1336 	}
1337 
1338 	/**
1339 	 * Creates a new pixbuf which represents a sub-region of @src_pixbuf.
1340 	 * The new pixbuf shares its pixels with the original pixbuf, so
1341 	 * writing to one affects both.  The new pixbuf holds a reference to
1342 	 * @src_pixbuf, so @src_pixbuf will not be finalized until the new
1343 	 * pixbuf is finalized.
1344 	 *
1345 	 * Note that if @src_pixbuf is read-only, this function will force it
1346 	 * to be mutable.
1347 	 *
1348 	 * Params:
1349 	 *     srcX = X coord in @src_pixbuf
1350 	 *     srcY = Y coord in @src_pixbuf
1351 	 *     width = width of region in @src_pixbuf
1352 	 *     height = height of region in @src_pixbuf
1353 	 *
1354 	 * Returns: a new pixbuf
1355 	 */
1356 	public Pixbuf newSubpixbuf(int srcX, int srcY, int width, int height)
1357 	{
1358 		auto p = gdk_pixbuf_new_subpixbuf(gdkPixbuf, srcX, srcY, width, height);
1359 
1360 		if(p is null)
1361 		{
1362 			return null;
1363 		}
1364 
1365 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1366 	}
1367 
1368 	/**
1369 	 * Returns: A new reference to a read-only copy of
1370 	 *     the pixel data.  Note that for mutable pixbufs, this function will
1371 	 *     incur a one-time copy of the pixel data for conversion into the
1372 	 *     returned #GBytes.
1373 	 *
1374 	 * Since: 2.32
1375 	 */
1376 	public Bytes readPixelBytes()
1377 	{
1378 		auto p = gdk_pixbuf_read_pixel_bytes(gdkPixbuf);
1379 
1380 		if(p is null)
1381 		{
1382 			return null;
1383 		}
1384 
1385 		return new Bytes(cast(GBytes*) p, true);
1386 	}
1387 
1388 	/**
1389 	 * Returns a read-only pointer to the raw pixel data; must not be
1390 	 * modified.  This function allows skipping the implicit copy that
1391 	 * must be made if gdk_pixbuf_get_pixels() is called on a read-only
1392 	 * pixbuf.
1393 	 *
1394 	 * Since: 2.32
1395 	 */
1396 	public ubyte* readPixels()
1397 	{
1398 		return gdk_pixbuf_read_pixels(gdkPixbuf);
1399 	}
1400 
1401 	/**
1402 	 * Remove the key/value pair option attached to a #GdkPixbuf.
1403 	 *
1404 	 * Params:
1405 	 *     key = a nul-terminated string representing the key to remove.
1406 	 *
1407 	 * Returns: %TRUE if an option was removed, %FALSE if not.
1408 	 *
1409 	 * Since: 2.36
1410 	 */
1411 	public bool removeOption(string key)
1412 	{
1413 		return gdk_pixbuf_remove_option(gdkPixbuf, Str.toStringz(key)) != 0;
1414 	}
1415 
1416 	/**
1417 	 * Rotates a pixbuf by a multiple of 90 degrees, and returns the
1418 	 * result in a new pixbuf.
1419 	 *
1420 	 * If @angle is 0, a copy of @src is returned, avoiding any rotation.
1421 	 *
1422 	 * Params:
1423 	 *     angle = the angle to rotate by
1424 	 *
1425 	 * Returns: the new #GdkPixbuf, or %NULL
1426 	 *     if not enough memory could be allocated for it.
1427 	 *
1428 	 * Since: 2.6
1429 	 */
1430 	public Pixbuf rotateSimple(GdkPixbufRotation angle)
1431 	{
1432 		auto p = gdk_pixbuf_rotate_simple(gdkPixbuf, angle);
1433 
1434 		if(p is null)
1435 		{
1436 			return null;
1437 		}
1438 
1439 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1440 	}
1441 
1442 	/**
1443 	 * Modifies saturation and optionally pixelates @src, placing the result in
1444 	 * @dest. @src and @dest may be the same pixbuf with no ill effects.  If
1445 	 * @saturation is 1.0 then saturation is not changed. If it's less than 1.0,
1446 	 * saturation is reduced (the image turns toward grayscale); if greater than
1447 	 * 1.0, saturation is increased (the image gets more vivid colors). If @pixelate
1448 	 * is %TRUE, then pixels are faded in a checkerboard pattern to create a
1449 	 * pixelated image. @src and @dest must have the same image format, size, and
1450 	 * rowstride.
1451 	 *
1452 	 * Params:
1453 	 *     dest = place to write modified version of @src
1454 	 *     saturation = saturation factor
1455 	 *     pixelate = whether to pixelate
1456 	 */
1457 	public void saturateAndPixelate(Pixbuf dest, float saturation, bool pixelate)
1458 	{
1459 		gdk_pixbuf_saturate_and_pixelate(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), saturation, pixelate);
1460 	}
1461 
1462 	/**
1463 	 * Saves pixbuf to a callback in format @type, which is currently "jpeg",
1464 	 * "png", "tiff", "ico" or "bmp".  If @error is set, %FALSE will be returned. See
1465 	 * gdk_pixbuf_save_to_callback () for more details.
1466 	 *
1467 	 * Params:
1468 	 *     saveFunc = a function that is called to save each block of data that
1469 	 *         the save routine generates.
1470 	 *     userData = user data to pass to the save function.
1471 	 *     type = name of file format.
1472 	 *     optionKeys = name of options to set, %NULL-terminated
1473 	 *     optionValues = values for named options
1474 	 *
1475 	 * Returns: whether an error was set
1476 	 *
1477 	 * Since: 2.4
1478 	 *
1479 	 * Throws: GException on failure.
1480 	 */
1481 	public bool saveToCallbackv(GdkPixbufSaveFunc saveFunc, void* userData, string type, string[] optionKeys, string[] optionValues)
1482 	{
1483 		GError* err = null;
1484 
1485 		auto p = gdk_pixbuf_save_to_callbackv(gdkPixbuf, saveFunc, userData, Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
1486 
1487 		if (err !is null)
1488 		{
1489 			throw new GException( new ErrorG(err) );
1490 		}
1491 
1492 		return p;
1493 	}
1494 
1495 	/**
1496 	 * Saves @pixbuf to an output stream.
1497 	 *
1498 	 * Supported file formats are currently "jpeg", "tiff", "png", "ico" or
1499 	 * "bmp". See gdk_pixbuf_save_to_stream() for more details.
1500 	 *
1501 	 * Params:
1502 	 *     stream = a #GOutputStream to save the pixbuf to
1503 	 *     type = name of file format
1504 	 *     optionKeys = name of options to set, %NULL-terminated
1505 	 *     optionValues = values for named options
1506 	 *     cancellable = optional #GCancellable object, %NULL to ignore
1507 	 *
1508 	 * Returns: %TRUE if the pixbuf was saved successfully, %FALSE if an
1509 	 *     error was set.
1510 	 *
1511 	 * Since: 2.36
1512 	 *
1513 	 * Throws: GException on failure.
1514 	 */
1515 	public bool saveToStreamv(OutputStream stream, string type, string[] optionKeys, string[] optionValues, Cancellable cancellable)
1516 	{
1517 		GError* err = null;
1518 
1519 		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;
1520 
1521 		if (err !is null)
1522 		{
1523 			throw new GException( new ErrorG(err) );
1524 		}
1525 
1526 		return p;
1527 	}
1528 
1529 	/**
1530 	 * Saves @pixbuf to an output stream asynchronously.
1531 	 *
1532 	 * For more details see gdk_pixbuf_save_to_streamv(), which is the synchronous
1533 	 * version of this function.
1534 	 *
1535 	 * When the operation is finished, @callback will be called in the main thread.
1536 	 * You can then call gdk_pixbuf_save_to_stream_finish() to get the result of the operation.
1537 	 *
1538 	 * Params:
1539 	 *     stream = a #GOutputStream to which to save the pixbuf
1540 	 *     type = name of file format
1541 	 *     optionKeys = name of options to set, %NULL-terminated
1542 	 *     optionValues = values for named options
1543 	 *     cancellable = optional #GCancellable object, %NULL to ignore
1544 	 *     callback = a #GAsyncReadyCallback to call when the pixbuf is saved
1545 	 *     userData = the data to pass to the callback function
1546 	 *
1547 	 * Since: 2.36
1548 	 */
1549 	public void saveToStreamvAsync(OutputStream stream, string type, string[] optionKeys, string[] optionValues, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
1550 	{
1551 		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);
1552 	}
1553 
1554 	/**
1555 	 * Saves pixbuf to a file in @type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
1556 	 * If @error is set, %FALSE will be returned.
1557 	 * See gdk_pixbuf_save () for more details.
1558 	 *
1559 	 * Params:
1560 	 *     filename = name of file to save.
1561 	 *     type = name of file format.
1562 	 *     optionKeys = name of options to set, %NULL-terminated
1563 	 *     optionValues = values for named options
1564 	 *
1565 	 * Returns: whether an error was set
1566 	 *
1567 	 * Throws: GException on failure.
1568 	 */
1569 	public bool savev(string filename, string type, string[] optionKeys, string[] optionValues)
1570 	{
1571 		GError* err = null;
1572 
1573 		auto p = gdk_pixbuf_savev(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
1574 
1575 		if (err !is null)
1576 		{
1577 			throw new GException( new ErrorG(err) );
1578 		}
1579 
1580 		return p;
1581 	}
1582 
1583 	/**
1584 	 * Creates a transformation of the source image @src by scaling by
1585 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y,
1586 	 * then renders the rectangle (@dest_x, @dest_y, @dest_width,
1587 	 * @dest_height) of the resulting image onto the destination image
1588 	 * replacing the previous contents.
1589 	 *
1590 	 * Try to use gdk_pixbuf_scale_simple() first, this function is
1591 	 * the industrial-strength power tool you can fall back to if
1592 	 * gdk_pixbuf_scale_simple() isn't powerful enough.
1593 	 *
1594 	 * If the source rectangle overlaps the destination rectangle on the
1595 	 * same pixbuf, it will be overwritten during the scaling which
1596 	 * results in rendering artifacts.
1597 	 *
1598 	 * Params:
1599 	 *     dest = the #GdkPixbuf into which to render the results
1600 	 *     destX = the left coordinate for region to render
1601 	 *     destY = the top coordinate for region to render
1602 	 *     destWidth = the width of the region to render
1603 	 *     destHeight = the height of the region to render
1604 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1605 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1606 	 *     scaleX = the scale factor in the X direction
1607 	 *     scaleY = the scale factor in the Y direction
1608 	 *     interpType = the interpolation type for the transformation.
1609 	 */
1610 	public void scale(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType)
1611 	{
1612 		gdk_pixbuf_scale(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType);
1613 	}
1614 
1615 	/**
1616 	 * Create a new #GdkPixbuf containing a copy of @src scaled to
1617 	 * @dest_width x @dest_height. Leaves @src unaffected.  @interp_type
1618 	 * should be #GDK_INTERP_NEAREST if you want maximum speed (but when
1619 	 * scaling down #GDK_INTERP_NEAREST is usually unusably ugly).  The
1620 	 * default @interp_type should be #GDK_INTERP_BILINEAR which offers
1621 	 * reasonable quality and speed.
1622 	 *
1623 	 * You can scale a sub-portion of @src by creating a sub-pixbuf
1624 	 * pointing into @src; see gdk_pixbuf_new_subpixbuf().
1625 	 *
1626 	 * If @dest_width and @dest_height are equal to the @src width and height, a
1627 	 * copy of @src is returned, avoiding any scaling.
1628 	 *
1629 	 * For more complicated scaling/alpha blending see gdk_pixbuf_scale()
1630 	 * and gdk_pixbuf_composite().
1631 	 *
1632 	 * Params:
1633 	 *     destWidth = the width of destination image
1634 	 *     destHeight = the height of destination image
1635 	 *     interpType = the interpolation type for the transformation.
1636 	 *
1637 	 * Returns: the new #GdkPixbuf, or %NULL if not enough memory could be
1638 	 *     allocated for it.
1639 	 */
1640 	public Pixbuf scaleSimple(int destWidth, int destHeight, GdkInterpType interpType)
1641 	{
1642 		auto p = gdk_pixbuf_scale_simple(gdkPixbuf, destWidth, destHeight, interpType);
1643 
1644 		if(p is null)
1645 		{
1646 			return null;
1647 		}
1648 
1649 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1650 	}
1651 
1652 	/**
1653 	 * Attaches a key/value pair as an option to a #GdkPixbuf. If @key already
1654 	 * exists in the list of options attached to @pixbuf, the new value is
1655 	 * ignored and %FALSE is returned.
1656 	 *
1657 	 * Params:
1658 	 *     key = a nul-terminated string.
1659 	 *     value = a nul-terminated string.
1660 	 *
1661 	 * Returns: %TRUE on success.
1662 	 *
1663 	 * Since: 2.2
1664 	 */
1665 	public bool setOption(string key, string value)
1666 	{
1667 		return gdk_pixbuf_set_option(gdkPixbuf, Str.toStringz(key), Str.toStringz(value)) != 0;
1668 	}
1669 }