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