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