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.
1065 	 *
1066 	 * Return: A newly-created pixbuf with a reference count of 1, or %NULL if
1067 	 *     not enough memory could be allocated.
1068 	 */
1069 	public Pixbuf copy()
1070 	{
1071 		auto p = gdk_pixbuf_copy(gdkPixbuf);
1072 		
1073 		if(p is null)
1074 		{
1075 			return null;
1076 		}
1077 		
1078 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1079 	}
1080 
1081 	/**
1082 	 * Copies a rectangular area from @src_pixbuf to @dest_pixbuf.  Conversion of
1083 	 * pixbuf formats is done automatically.
1084 	 *
1085 	 * If the source rectangle overlaps the destination rectangle on the
1086 	 * same pixbuf, it will be overwritten during the copy operation.
1087 	 * Therefore, you can not use this function to scroll a pixbuf.
1088 	 *
1089 	 * Params:
1090 	 *     srcX = Source X coordinate within @src_pixbuf.
1091 	 *     srcY = Source Y coordinate within @src_pixbuf.
1092 	 *     width = Width of the area to copy.
1093 	 *     height = Height of the area to copy.
1094 	 *     destPixbuf = Destination pixbuf.
1095 	 *     destX = X coordinate within @dest_pixbuf.
1096 	 *     destY = Y coordinate within @dest_pixbuf.
1097 	 */
1098 	public void copyArea(int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY)
1099 	{
1100 		gdk_pixbuf_copy_area(gdkPixbuf, srcX, srcY, width, height, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct(), destX, destY);
1101 	}
1102 
1103 	/**
1104 	 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
1105 	 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
1106 	 * doesn't have an alpha channel.
1107 	 *
1108 	 * Params:
1109 	 *     pixel = RGBA pixel to clear to
1110 	 *         (0xffffffff is opaque white, 0x00000000 transparent black)
1111 	 */
1112 	public void fill(uint pixel)
1113 	{
1114 		gdk_pixbuf_fill(gdkPixbuf, pixel);
1115 	}
1116 
1117 	/**
1118 	 * Flips a pixbuf horizontally or vertically and returns the
1119 	 * result in a new pixbuf.
1120 	 *
1121 	 * Params:
1122 	 *     horizontal = %TRUE to flip horizontally, %FALSE to flip vertically
1123 	 *
1124 	 * Return: the new #GdkPixbuf, or %NULL
1125 	 *     if not enough memory could be allocated for it.
1126 	 *
1127 	 * Since: 2.6
1128 	 */
1129 	public Pixbuf flip(bool horizontal)
1130 	{
1131 		auto p = gdk_pixbuf_flip(gdkPixbuf, horizontal);
1132 		
1133 		if(p is null)
1134 		{
1135 			return null;
1136 		}
1137 		
1138 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1139 	}
1140 
1141 	/**
1142 	 * Queries the number of bits per color sample in a pixbuf.
1143 	 *
1144 	 * Return: Number of bits per color sample.
1145 	 */
1146 	public int getBitsPerSample()
1147 	{
1148 		return gdk_pixbuf_get_bits_per_sample(gdkPixbuf);
1149 	}
1150 
1151 	/**
1152 	 * Returns the length of the pixel data, in bytes.
1153 	 *
1154 	 * Return: The length of the pixel data.
1155 	 *
1156 	 * Since: 2.26
1157 	 */
1158 	public size_t getByteLength()
1159 	{
1160 		return gdk_pixbuf_get_byte_length(gdkPixbuf);
1161 	}
1162 
1163 	/**
1164 	 * Queries the color space of a pixbuf.
1165 	 *
1166 	 * Return: Color space.
1167 	 */
1168 	public GdkColorspace getColorspace()
1169 	{
1170 		return gdk_pixbuf_get_colorspace(gdkPixbuf);
1171 	}
1172 
1173 	/**
1174 	 * Queries whether a pixbuf has an alpha channel (opacity information).
1175 	 *
1176 	 * Return: %TRUE if it has an alpha channel, %FALSE otherwise.
1177 	 */
1178 	public bool getHasAlpha()
1179 	{
1180 		return gdk_pixbuf_get_has_alpha(gdkPixbuf) != 0;
1181 	}
1182 
1183 	/**
1184 	 * Queries the height of a pixbuf.
1185 	 *
1186 	 * Return: Height in pixels.
1187 	 */
1188 	public int getHeight()
1189 	{
1190 		return gdk_pixbuf_get_height(gdkPixbuf);
1191 	}
1192 
1193 	/**
1194 	 * Queries the number of channels of a pixbuf.
1195 	 *
1196 	 * Return: Number of channels.
1197 	 */
1198 	public int getNChannels()
1199 	{
1200 		return gdk_pixbuf_get_n_channels(gdkPixbuf);
1201 	}
1202 
1203 	/**
1204 	 * Looks up @key in the list of options that may have been attached to the
1205 	 * @pixbuf when it was loaded, or that may have been attached by another
1206 	 * function using gdk_pixbuf_set_option().
1207 	 *
1208 	 * For instance, the ANI loader provides "Title" and "Artist" options.
1209 	 * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot
1210 	 * options for cursor definitions. The PNG loader provides the tEXt ancillary
1211 	 * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
1212 	 * return an "orientation" option string that corresponds to the embedded
1213 	 * TIFF/Exif orientation tag (if present). Since 2.32, the TIFF loader sets
1214 	 * the "multipage" option string to "yes" when a multi-page TIFF is loaded.
1215 	 * Since 2.32 the JPEG and PNG loaders set "x-dpi" and "y-dpi" if the file
1216 	 * contains image density information in dots per inch.
1217 	 *
1218 	 * Params:
1219 	 *     key = a nul-terminated string.
1220 	 *
1221 	 * Return: the value associated with @key. This is a nul-terminated
1222 	 *     string that should not be freed or %NULL if @key was not found.
1223 	 */
1224 	public string getOption(string key)
1225 	{
1226 		return Str.toString(gdk_pixbuf_get_option(gdkPixbuf, Str.toStringz(key)));
1227 	}
1228 
1229 	/**
1230 	 * Returns a #GHashTable with a list of all the options that may have been
1231 	 * attached to the @pixbuf when it was loaded, or that may have been
1232 	 * attached by another function using gdk_pixbuf_set_option().
1233 	 *
1234 	 * See gdk_pixbuf_get_option() for more details.
1235 	 *
1236 	 * Return: a #GHashTable of key/values
1237 	 *
1238 	 * Since: 2.32
1239 	 */
1240 	public HashTable getOptions()
1241 	{
1242 		auto p = gdk_pixbuf_get_options(gdkPixbuf);
1243 		
1244 		if(p is null)
1245 		{
1246 			return null;
1247 		}
1248 		
1249 		return new HashTable(cast(GHashTable*) p);
1250 	}
1251 
1252 	/**
1253 	 * Queries a pointer to the pixel data of a pixbuf.
1254 	 *
1255 	 * Return: A pointer to the pixbuf's
1256 	 *     pixel data.  Please see the section on [image data](image-data)
1257 	 *     for information about how the pixel data is stored in memory.
1258 	 *
1259 	 *     This function will cause an implicit copy of the pixbuf data if the
1260 	 *     pixbuf was created from read-only data.
1261 	 *
1262 	 * Since: 2.26
1263 	 */
1264 	public char[] getPixelsWithLength()
1265 	{
1266 		uint length;
1267 		
1268 		auto p = gdk_pixbuf_get_pixels_with_length(gdkPixbuf, &length);
1269 		
1270 		return p[0 .. length];
1271 	}
1272 
1273 	/**
1274 	 * Queries the rowstride of a pixbuf, which is the number of bytes between
1275 	 * the start of a row and the start of the next row.
1276 	 *
1277 	 * Return: Distance between row starts.
1278 	 */
1279 	public int getRowstride()
1280 	{
1281 		return gdk_pixbuf_get_rowstride(gdkPixbuf);
1282 	}
1283 
1284 	/**
1285 	 * Queries the width of a pixbuf.
1286 	 *
1287 	 * Return: Width in pixels.
1288 	 */
1289 	public int getWidth()
1290 	{
1291 		return gdk_pixbuf_get_width(gdkPixbuf);
1292 	}
1293 
1294 	/**
1295 	 * Creates a new pixbuf which represents a sub-region of @src_pixbuf.
1296 	 * The new pixbuf shares its pixels with the original pixbuf, so
1297 	 * writing to one affects both.  The new pixbuf holds a reference to
1298 	 * @src_pixbuf, so @src_pixbuf will not be finalized until the new
1299 	 * pixbuf is finalized.
1300 	 *
1301 	 * Note that if @src_pixbuf is read-only, this function will force it
1302 	 * to be mutable.
1303 	 *
1304 	 * Params:
1305 	 *     srcX = X coord in @src_pixbuf
1306 	 *     srcY = Y coord in @src_pixbuf
1307 	 *     width = width of region in @src_pixbuf
1308 	 *     height = height of region in @src_pixbuf
1309 	 *
1310 	 * Return: a new pixbuf
1311 	 */
1312 	public Pixbuf newSubpixbuf(int srcX, int srcY, int width, int height)
1313 	{
1314 		auto p = gdk_pixbuf_new_subpixbuf(gdkPixbuf, srcX, srcY, width, height);
1315 		
1316 		if(p is null)
1317 		{
1318 			return null;
1319 		}
1320 		
1321 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1322 	}
1323 
1324 	/**
1325 	 * Return: A new reference to a read-only copy of
1326 	 *     the pixel data.  Note that for mutable pixbufs, this function will
1327 	 *     incur a one-time copy of the pixel data for conversion into the
1328 	 *     returned #GBytes.
1329 	 *
1330 	 * Since: 2.32
1331 	 */
1332 	public Bytes readPixelBytes()
1333 	{
1334 		auto p = gdk_pixbuf_read_pixel_bytes(gdkPixbuf);
1335 		
1336 		if(p is null)
1337 		{
1338 			return null;
1339 		}
1340 		
1341 		return new Bytes(cast(GBytes*) p, true);
1342 	}
1343 
1344 	/**
1345 	 * Returns a read-only pointer to the raw pixel data; must not be
1346 	 * modified.  This function allows skipping the implicit copy that
1347 	 * must be made if gdk_pixbuf_get_pixels() is called on a read-only
1348 	 * pixbuf.
1349 	 *
1350 	 * Since: 2.32
1351 	 */
1352 	public ubyte* readPixels()
1353 	{
1354 		return gdk_pixbuf_read_pixels(gdkPixbuf);
1355 	}
1356 
1357 	/**
1358 	 * Rotates a pixbuf by a multiple of 90 degrees, and returns the
1359 	 * result in a new pixbuf.
1360 	 *
1361 	 * Params:
1362 	 *     angle = the angle to rotate by
1363 	 *
1364 	 * Return: the new #GdkPixbuf, or %NULL
1365 	 *     if not enough memory could be allocated for it.
1366 	 *
1367 	 * Since: 2.6
1368 	 */
1369 	public Pixbuf rotateSimple(GdkPixbufRotation angle)
1370 	{
1371 		auto p = gdk_pixbuf_rotate_simple(gdkPixbuf, angle);
1372 		
1373 		if(p is null)
1374 		{
1375 			return null;
1376 		}
1377 		
1378 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1379 	}
1380 
1381 	/**
1382 	 * Modifies saturation and optionally pixelates @src, placing the result in
1383 	 * @dest. @src and @dest may be the same pixbuf with no ill effects.  If
1384 	 * @saturation is 1.0 then saturation is not changed. If it's less than 1.0,
1385 	 * saturation is reduced (the image turns toward grayscale); if greater than
1386 	 * 1.0, saturation is increased (the image gets more vivid colors). If @pixelate
1387 	 * is %TRUE, then pixels are faded in a checkerboard pattern to create a
1388 	 * pixelated image. @src and @dest must have the same image format, size, and
1389 	 * rowstride.
1390 	 *
1391 	 * Params:
1392 	 *     dest = place to write modified version of @src
1393 	 *     saturation = saturation factor
1394 	 *     pixelate = whether to pixelate
1395 	 */
1396 	public void saturateAndPixelate(Pixbuf dest, float saturation, bool pixelate)
1397 	{
1398 		gdk_pixbuf_saturate_and_pixelate(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), saturation, pixelate);
1399 	}
1400 
1401 	/**
1402 	 * Saves pixbuf to a callback in format @type, which is currently "jpeg",
1403 	 * "png", "tiff", "ico" or "bmp".  If @error is set, %FALSE will be returned. See
1404 	 * gdk_pixbuf_save_to_callback () for more details.
1405 	 *
1406 	 * Params:
1407 	 *     saveFunc = a function that is called to save each block of data that
1408 	 *         the save routine generates.
1409 	 *     userData = user data to pass to the save function.
1410 	 *     type = name of file format.
1411 	 *     optionKeys = name of options to set, %NULL-terminated
1412 	 *     optionValues = values for named options
1413 	 *
1414 	 * Return: whether an error was set
1415 	 *
1416 	 * Since: 2.4
1417 	 *
1418 	 * Throws: GException on failure.
1419 	 */
1420 	public bool saveToCallbackv(GdkPixbufSaveFunc saveFunc, void* userData, string type, string[] optionKeys, string[] optionValues)
1421 	{
1422 		GError* err = null;
1423 		
1424 		auto p = gdk_pixbuf_save_to_callbackv(gdkPixbuf, saveFunc, userData, Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
1425 		
1426 		if (err !is null)
1427 		{
1428 			throw new GException( new ErrorG(err) );
1429 		}
1430 		
1431 		return p;
1432 	}
1433 
1434 	/**
1435 	 * Saves pixbuf to a file in @type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
1436 	 * If @error is set, %FALSE will be returned.
1437 	 * See gdk_pixbuf_save () for more details.
1438 	 *
1439 	 * Params:
1440 	 *     filename = name of file to save.
1441 	 *     type = name of file format.
1442 	 *     optionKeys = name of options to set, %NULL-terminated
1443 	 *     optionValues = values for named options
1444 	 *
1445 	 * Return: whether an error was set
1446 	 *
1447 	 * Throws: GException on failure.
1448 	 */
1449 	public bool savev(string filename, string type, string[] optionKeys, string[] optionValues)
1450 	{
1451 		GError* err = null;
1452 		
1453 		auto p = gdk_pixbuf_savev(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err) != 0;
1454 		
1455 		if (err !is null)
1456 		{
1457 			throw new GException( new ErrorG(err) );
1458 		}
1459 		
1460 		return p;
1461 	}
1462 
1463 	/**
1464 	 * Creates a transformation of the source image @src by scaling by
1465 	 * @scale_x and @scale_y then translating by @offset_x and @offset_y,
1466 	 * then renders the rectangle (@dest_x, @dest_y, @dest_width,
1467 	 * @dest_height) of the resulting image onto the destination image
1468 	 * replacing the previous contents.
1469 	 *
1470 	 * Try to use gdk_pixbuf_scale_simple() first, this function is
1471 	 * the industrial-strength power tool you can fall back to if
1472 	 * gdk_pixbuf_scale_simple() isn't powerful enough.
1473 	 *
1474 	 * If the source rectangle overlaps the destination rectangle on the
1475 	 * same pixbuf, it will be overwritten during the scaling which
1476 	 * results in rendering artifacts.
1477 	 *
1478 	 * Params:
1479 	 *     dest = the #GdkPixbuf into which to render the results
1480 	 *     destX = the left coordinate for region to render
1481 	 *     destY = the top coordinate for region to render
1482 	 *     destWidth = the width of the region to render
1483 	 *     destHeight = the height of the region to render
1484 	 *     offsetX = the offset in the X direction (currently rounded to an integer)
1485 	 *     offsetY = the offset in the Y direction (currently rounded to an integer)
1486 	 *     scaleX = the scale factor in the X direction
1487 	 *     scaleY = the scale factor in the Y direction
1488 	 *     interpType = the interpolation type for the transformation.
1489 	 */
1490 	public void scale(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType)
1491 	{
1492 		gdk_pixbuf_scale(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType);
1493 	}
1494 
1495 	/**
1496 	 * Create a new #GdkPixbuf containing a copy of @src scaled to
1497 	 * @dest_width x @dest_height. Leaves @src unaffected.  @interp_type
1498 	 * should be #GDK_INTERP_NEAREST if you want maximum speed (but when
1499 	 * scaling down #GDK_INTERP_NEAREST is usually unusably ugly).  The
1500 	 * default @interp_type should be #GDK_INTERP_BILINEAR which offers
1501 	 * reasonable quality and speed.
1502 	 *
1503 	 * You can scale a sub-portion of @src by creating a sub-pixbuf
1504 	 * pointing into @src; see gdk_pixbuf_new_subpixbuf().
1505 	 *
1506 	 * For more complicated scaling/compositing see gdk_pixbuf_scale()
1507 	 * and gdk_pixbuf_composite().
1508 	 *
1509 	 * Params:
1510 	 *     destWidth = the width of destination image
1511 	 *     destHeight = the height of destination image
1512 	 *     interpType = the interpolation type for the transformation.
1513 	 *
1514 	 * Return: the new #GdkPixbuf, or %NULL if not enough memory could be
1515 	 *     allocated for it.
1516 	 */
1517 	public Pixbuf scaleSimple(int destWidth, int destHeight, GdkInterpType interpType)
1518 	{
1519 		auto p = gdk_pixbuf_scale_simple(gdkPixbuf, destWidth, destHeight, interpType);
1520 		
1521 		if(p is null)
1522 		{
1523 			return null;
1524 		}
1525 		
1526 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
1527 	}
1528 }