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