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 * Conversion parameters: 26 * inFile = gdk3-Pixbufs.html 27 * outPack = gdk 28 * outFile = Pixbuf 29 * strct = GdkPixbuf 30 * realStrct= 31 * ctorStrct= 32 * clss = Pixbuf 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = GObject 38 * implements: 39 * - IconIF 40 * - LoadableIconIF 41 * prefixes: 42 * - gdk_pixbuf_ 43 * omit structs: 44 * omit prefixes: 45 * omit code: 46 * omit signals: 47 * imports: 48 * - cairo.Surface 49 * - glib.Str 50 * - glib.ErrorG 51 * - glib.GException 52 * - gio.AsyncResultIF 53 * - gio.Cancellable 54 * - gio.InputStream 55 * - gdk.Window 56 * - gdkpixbuf.PixbufFormat 57 * - gio.IconT 58 * - gio.IconIF 59 * - gio.LoadableIconT 60 * - gio.LoadableIconIF 61 * structWrap: 62 * - GAsyncResult* -> AsyncResultIF 63 * - GCancellable* -> Cancellable 64 * - GInputStream* -> InputStream 65 * - GdkPixbuf* -> Pixbuf 66 * - GdkPixbufFormat* -> PixbufFormat 67 * - GdkWindow* -> Window 68 * - cairo_surface_t* -> Surface 69 * module aliases: 70 * local aliases: 71 * overrides: 72 */ 73 74 module gdk.Pixbuf; 75 76 public import gtkc.gdktypes; 77 78 private import gtkc.gdk; 79 private import glib.ConstructionException; 80 private import gobject.ObjectG; 81 82 private import cairo.Surface; 83 private import glib.Str; 84 private import glib.ErrorG; 85 private import glib.GException; 86 private import gio.AsyncResultIF; 87 private import gio.Cancellable; 88 private import gio.InputStream; 89 private import gdk.Window; 90 private import gdkpixbuf.PixbufFormat; 91 private import gio.IconT; 92 private import gio.IconIF; 93 private import gio.LoadableIconT; 94 private import gio.LoadableIconIF; 95 96 97 private import gobject.ObjectG; 98 99 /** 100 * Pixbufs are client-side images. For details on how to create 101 * and manipulate pixbufs, see the GdkPixbuf API documentation. 102 * 103 * The functions described here allow to obtain pixbufs from 104 * GdkWindows and cairo surfaces. 105 */ 106 public class Pixbuf : ObjectG, IconIF, LoadableIconIF 107 { 108 109 /** the main Gtk struct */ 110 protected GdkPixbuf* gdkPixbuf; 111 112 113 /** Get the main Gtk struct */ 114 public GdkPixbuf* getPixbufStruct() 115 { 116 return gdkPixbuf; 117 } 118 119 120 /** the main Gtk struct as a void* */ 121 protected override void* getStruct() 122 { 123 return cast(void*)gdkPixbuf; 124 } 125 126 /** 127 * Sets our main struct and passes it to the parent class 128 */ 129 public this (GdkPixbuf* gdkPixbuf) 130 { 131 super(cast(GObject*)gdkPixbuf); 132 this.gdkPixbuf = gdkPixbuf; 133 } 134 135 protected override void setStruct(GObject* obj) 136 { 137 super.setStruct(obj); 138 gdkPixbuf = cast(GdkPixbuf*)obj; 139 } 140 141 // Minimal implementation. 142 mixin IconT!(GdkPixbuf); 143 144 // add the LoadableIcon capabilities 145 mixin LoadableIconT!(GdkPixbuf); 146 147 /** 148 * Saves pixbuf to a new buffer in format type, which is currently "jpeg", 149 * "tiff", "png", "ico" or "bmp". See gdk_pixbuf_save_to_buffer() for more details. 150 * Since 2.4 151 * Params: 152 * buffer = location to receive a pointer to the new buffer. 153 * type = name of file format. 154 * optionKeys = name of options to set, NULL-terminated 155 * optionValues = values for named options 156 * Returns: whether an error was set 157 * Throws: GException on failure. 158 */ 159 public int saveToBuffer(out ubyte[] buffer, string type, string[] optionKeys, string[] optionValues) 160 { 161 gchar* outbuffer = null; 162 gsize bufferSize; 163 GError* err = null; 164 165 // gboolean gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf, gchar **buffer, gsize *buffer_size, const char *type, char **option_keys, char **option_values, GError **error); 166 auto p = gdk_pixbuf_save_to_bufferv(gdkPixbuf, &outbuffer, &bufferSize, Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err); 167 168 if (err !is null) 169 { 170 throw new GException( new ErrorG(err) ); 171 } 172 173 buffer = (cast(ubyte*)outbuffer)[0 .. bufferSize]; 174 return p; 175 } 176 177 /** 178 * The most basic way to create a pixbuf is to wrap an existing pixel 179 * buffer with a GdkPixbuf structure. You can use the 180 * gdk_pixbuf_new_from_data() function to do this You need to specify 181 * the destroy notification function that will be called when the 182 * data buffer needs to be freed; this will happen when a GdkPixbuf 183 * is finalized by the reference counting functions If you have a 184 * chunk of static data compiled into your application, you can pass 185 * in NULL as the destroy notification function so that the data 186 * will not be freed. 187 * 188 * The gdk_pixbuf_new() function can be used as a convenience to 189 * create a pixbuf with an empty buffer. This is equivalent to 190 * allocating a data buffer using malloc() and 191 * then wrapping it with gdk_pixbuf_new_from_data(). The gdk_pixbuf_new() 192 * function will compute an optimal rowstride so that rendering can be 193 * performed with an efficient algorithm. 194 * 195 * As a special case, you can use the gdk_pixbuf_new_from_xpm_data() 196 * function to create a pixbuf from inline XPM image data. 197 * 198 * You can also copy an existing pixbuf with the gdk_pixbuf_copy() 199 * function. This is not the same as just doing a g_object_ref() 200 * on the old pixbuf; the copy function will actually duplicate the 201 * pixel data in memory and create a new GdkPixbuf structure for it. 202 */ 203 204 /** 205 * The GdkPixbuf structure contains 206 * information that describes an image in memory. 207 * 208 * Image Data 209 * 210 * Image data in a pixbuf is stored in memory in uncompressed, 211 * packed format. Rows in the image are stored top to bottom, and 212 * in each row pixels are stored from left to right. There may be 213 * padding at the end of a row. The "rowstride" value of a pixbuf, 214 * as returned by gdk_pixbuf_get_rowstride(), indicates the number 215 * of bytes between rows. 216 * 217 * $(DDOC_COMMENT example) 218 * 219 * Note 220 * 221 * If you are doing memcpy() of raw pixbuf data, note that the 222 * last row in the pixbuf may not be as wide as the full 223 * rowstride, but rather just as wide as the pixel data needs to 224 * be. That is, it is unsafe to do memcpy (dest, 225 * pixels, rowstride * height) to copy a whole pixbuf. 226 * Use gdk_pixbuf_copy() instead, or compute the width in bytes 227 * of the last row as width * ((n_channels * 228 * bits_per_sample + 7) / 8). 229 */ 230 231 /** 232 * GdkPixbuf structures are reference counted. This means that an 233 * application can share a single pixbuf among many parts of the 234 * code. When a piece of the program needs to keep a pointer to a 235 * pixbuf, it should add a reference to it by calling g_object_ref(). 236 * When it no longer needs the pixbuf, it should subtract a reference 237 * by calling g_object_unref(). The pixbuf will be destroyed when 238 * its reference count drops to zero. Newly-created GdkPixbuf 239 * structures start with a reference count of one. 240 * 241 * Note 242 * 243 * As GdkPixbuf is derived from GObject now, gdk_pixbuf_ref() and 244 * gdk_pixbuf_unref() are deprecated in favour of g_object_ref() 245 * and g_object_unref() resp. 246 * 247 * Finalizing a pixbuf means to free its pixel 248 * data and to free the GdkPixbuf structure itself. Most of the 249 * library functions that create GdkPixbuf structures create the 250 * pixel data by themselves and define the way it should be freed; 251 * you do not need to worry about those. The only function that lets 252 * you specify how to free the pixel data is 253 * gdk_pixbuf_new_from_data(). Since you pass it a pre-allocated 254 * pixel buffer, you must also specify a way to free that data. This 255 * is done with a function of type GdkPixbufDestroyNotify. When a 256 * pixbuf created with gdk_pixbuf_new_from_data() is finalized, your 257 * destroy notification function will be called, and it is its 258 * responsibility to free the pixel array. 259 */ 260 261 /** 262 * The GdkPixBuf library provides a simple mechanism for loading 263 * an image from a file in synchronous fashion. This means that the 264 * library takes control of the application while the file is being 265 * loaded; from the user's point of view, the application will block 266 * until the image is done loading. 267 * 268 * This interface can be used by applications in which blocking is 269 * acceptable while an image is being loaded. It can also be used to 270 * load small images in general. Applications that need progressive 271 * loading can use the GdkPixbufLoader functionality instead. 272 */ 273 274 /** 275 * These functions allow to save a GdkPixbuf in a number of 276 * file formats. The formatted data can be written to a file 277 * or to a memory buffer. GdkPixBuf can also call a user-defined 278 * callback on the data, which allows to e.g. write the image 279 * to a socket or store it in a database. 280 */ 281 282 /** 283 * The GdkPixBuf contains functions to scale pixbufs, to scale 284 * pixbufs and composite against an existing image, and to scale 285 * pixbufs and composite against a solid color or checkerboard. 286 * Compositing a checkerboard is a common way to show an image with 287 * an alpha channel in image-viewing and editing software. 288 * 289 * Since the full-featured functions (gdk_pixbuf_scale(), 290 * gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are 291 * rather complex to use and have many arguments, two simple 292 * convenience functions are provided, gdk_pixbuf_scale_simple() and 293 * gdk_pixbuf_composite_color_simple() which create a new pixbuf of a 294 * given size, scale an original image to fit, and then return the 295 * new pixbuf. 296 * 297 * Scaling and compositing functions take advantage of MMX hardware 298 * acceleration on systems where MMX is supported. If gdk-pixbuf is built 299 * with the Sun mediaLib library, these functions are instead accelerated 300 * using mediaLib, which provides hardware acceleration on Intel, AMD, 301 * and Sparc chipsets. If desired, mediaLib support can be turned off by 302 * setting the GDK_DISABLE_MEDIALIB environment variable. 303 * 304 * The following example demonstrates handling an expose event by 305 * rendering the appropriate area of a source image (which is scaled 306 * to fit the widget) onto the widget's window. The source image is 307 * rendered against a checkerboard, which provides a visual 308 * representation of the alpha channel if the image has one. If the 309 * image doesn't have an alpha channel, calling 310 * gdk_pixbuf_composite_color() function has exactly the same effect 311 * as calling gdk_pixbuf_scale(). 312 * 313 * $(DDOC_COMMENT example) 314 */ 315 316 /** 317 * These functions provide miscellaneous utilities for manipulating 318 * pixbufs. The pixel data in pixbufs may of course be manipulated 319 * directly by applications, but several common operations can be 320 * performed by these functions instead. 321 */ 322 323 /** 324 * Transfers image data from a GdkWindow and converts it to an RGB(A) 325 * representation inside a GdkPixbuf. In other words, copies 326 * image data from a server-side drawable to a client-side RGB(A) buffer. 327 * This allows you to efficiently read individual pixels on the client side. 328 * This function will create an RGB pixbuf with 8 bits per channel with 329 * the same size specified by the width and height arguments. The pixbuf 330 * will contain an alpha channel if the window contains one. 331 * If the window is off the screen, then there is no image data in the 332 * obscured/offscreen regions to be placed in the pixbuf. The contents of 333 * portions of the pixbuf corresponding to the offscreen region are undefined. 334 * If the window you're obtaining data from is partially obscured by 335 * other windows, then the contents of the pixbuf areas corresponding 336 * to the obscured regions are undefined. 337 * If the window is not mapped (typically because it's iconified/minimized 338 * or not on the current workspace), then NULL will be returned. 339 * If memory can't be allocated for the return value, NULL will be returned 340 * instead. 341 * (In short, there are several ways this function can fail, and if it fails 342 * it returns NULL; so check the return value.) 343 * Params: 344 * window = Source window 345 * srcX = Source X coordinate within window 346 * srcY = Source Y coordinate within window 347 * width = Width in pixels of region to get 348 * height = Height in pixels of region to get 349 * Returns: A newly-created pixbuf with a reference count of 1, or NULL on error. [transfer full] 350 */ 351 public static Pixbuf getFromWindow(Window window, int srcX, int srcY, int width, int height) 352 { 353 // GdkPixbuf * gdk_pixbuf_get_from_window (GdkWindow *window, gint src_x, gint src_y, gint width, gint height); 354 auto p = gdk_pixbuf_get_from_window((window is null) ? null : window.getWindowStruct(), srcX, srcY, width, height); 355 356 if(p is null) 357 { 358 return null; 359 } 360 361 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 362 } 363 364 /** 365 * Transfers image data from a cairo_surface_t and converts it to an RGB(A) 366 * representation inside a GdkPixbuf. This allows you to efficiently read 367 * individual pixels from cairo surfaces. For GdkWindows, use 368 * gdk_pixbuf_get_from_window() instead. 369 * This function will create an RGB pixbuf with 8 bits per channel. 370 * The pixbuf will contain an alpha channel if the surface contains one. 371 * Params: 372 * surface = surface to copy from 373 * srcX = Source X coordinate within surface 374 * srcY = Source Y coordinate within surface 375 * width = Width in pixels of region to get 376 * height = Height in pixels of region to get 377 * Returns: A newly-created pixbuf with a reference count of 1, or NULL on error. [transfer full] 378 */ 379 public static Pixbuf getFromSurface(Surface surface, int srcX, int srcY, int width, int height) 380 { 381 // GdkPixbuf * gdk_pixbuf_get_from_surface (cairo_surface_t *surface, gint src_x, gint src_y, gint width, gint height); 382 auto p = gdk_pixbuf_get_from_surface((surface is null) ? null : surface.getSurfaceStruct(), srcX, srcY, width, height); 383 384 if(p is null) 385 { 386 return null; 387 } 388 389 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 390 } 391 392 /** 393 */ 394 public static GType getType() 395 { 396 // GType gdk_pixbuf_get_type (); 397 return gdk_pixbuf_get_type(); 398 } 399 400 /** 401 * Creates a new GdkPixbuf structure and allocates a buffer for it. The 402 * buffer has an optimal rowstride. Note that the buffer is not cleared; 403 * you will have to fill it completely yourself. 404 * Params: 405 * colorspace = Color space for image 406 * hasAlpha = Whether the image should have transparency information 407 * bitsPerSample = Number of bits per color sample 408 * width = Width of image in pixels, must be > 0 409 * height = Height of image in pixels, must be > 0 410 * Throws: ConstructionException GTK+ fails to create the object. 411 */ 412 public this (GdkColorspace colorspace, int hasAlpha, int bitsPerSample, int width, int height) 413 { 414 // GdkPixbuf * gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height); 415 auto p = gdk_pixbuf_new(colorspace, hasAlpha, bitsPerSample, width, height); 416 if(p is null) 417 { 418 throw new ConstructionException("null returned by gdk_pixbuf_new(colorspace, hasAlpha, bitsPerSample, width, height)"); 419 } 420 this(cast(GdkPixbuf*) p); 421 } 422 423 /** 424 * Creates a new GdkPixbuf out of in-memory image data. Currently only RGB 425 * images with 8 bits per sample are supported. 426 * Params: 427 * data = Image data in 8-bit/sample packed format. [array] 428 * colorspace = Colorspace for the image data 429 * hasAlpha = Whether the data has an opacity channel 430 * bitsPerSample = Number of bits per sample 431 * width = Width of the image in pixels, must be > 0 432 * height = Height of the image in pixels, must be > 0 433 * rowstride = Distance in bytes between row starts 434 * destroyFn = Function used to free the data when the pixbuf's reference count 435 * drops to zero, or NULL if the data should not be freed. [scope async][allow-none] 436 * destroyFnData = Closure data to pass to the destroy notification function. [closure] 437 * Throws: ConstructionException GTK+ fails to create the object. 438 */ 439 public this (char* data, GdkColorspace colorspace, int hasAlpha, int bitsPerSample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroyFn, void* destroyFnData) 440 { 441 // GdkPixbuf * gdk_pixbuf_new_from_data (const guchar *data, GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroy_fn, gpointer destroy_fn_data); 442 auto p = gdk_pixbuf_new_from_data(data, colorspace, hasAlpha, bitsPerSample, width, height, rowstride, destroyFn, destroyFnData); 443 if(p is null) 444 { 445 throw new ConstructionException("null returned by gdk_pixbuf_new_from_data(data, colorspace, hasAlpha, bitsPerSample, width, height, rowstride, destroyFn, destroyFnData)"); 446 } 447 this(cast(GdkPixbuf*) p); 448 } 449 450 /** 451 * Creates a new pixbuf by parsing XPM data in memory. This data is commonly 452 * the result of including an XPM file into a program's C source. 453 * Params: 454 * data = Pointer to inline XPM data. [array zero-terminated=1] 455 * Throws: ConstructionException GTK+ fails to create the object. 456 */ 457 public this (string[] data) 458 { 459 // GdkPixbuf * gdk_pixbuf_new_from_xpm_data (const char **data); 460 auto p = gdk_pixbuf_new_from_xpm_data(Str.toStringzArray(data)); 461 if(p is null) 462 { 463 throw new ConstructionException("null returned by gdk_pixbuf_new_from_xpm_data(Str.toStringzArray(data))"); 464 } 465 this(cast(GdkPixbuf*) p); 466 } 467 468 /** 469 * Create a GdkPixbuf from a flat representation that is suitable for 470 * storing as inline data in a program. This is useful if you want to 471 * ship a program with images, but don't want to depend on any 472 * external files. 473 * gdk-pixbuf ships with a program called gdk-pixbuf-csource 474 * which allows for conversion of GdkPixbufs into such a inline representation. 475 * In almost all cases, you should pass the --raw flag to 476 * Params: 477 * data = Byte data containing a 478 * serialized GdkPixdata structure. [array length=data_length] 479 * copyPixels = Whether to copy the pixel data, or use direct pointers 480 * data for the resulting pixbuf 481 * Throws: GException on failure. 482 * Throws: ConstructionException GTK+ fails to create the object. 483 */ 484 public this (ubyte[] data, int copyPixels) 485 { 486 // GdkPixbuf * gdk_pixbuf_new_from_inline (gint data_length, const guint8 *data, gboolean copy_pixels, GError **error); 487 GError* err = null; 488 489 auto p = gdk_pixbuf_new_from_inline(cast(int) data.length, data.ptr, copyPixels, &err); 490 491 if (err !is null) 492 { 493 throw new GException( new ErrorG(err) ); 494 } 495 496 if(p is null) 497 { 498 throw new ConstructionException("null returned by gdk_pixbuf_new_from_inline(cast(int) data.length, data.ptr, copyPixels, &err)"); 499 } 500 this(cast(GdkPixbuf*) p); 501 } 502 503 /** 504 * Creates a new pixbuf which represents a sub-region of 505 * src_pixbuf. The new pixbuf shares its pixels with the 506 * original pixbuf, so writing to one affects both. 507 * The new pixbuf holds a reference to src_pixbuf, so 508 * src_pixbuf will not be finalized until the new pixbuf 509 * is finalized. 510 * Params: 511 * srcPixbuf = a GdkPixbuf 512 * srcX = X coord in src_pixbuf 513 * srcY = Y coord in src_pixbuf 514 * width = width of region in src_pixbuf 515 * height = height of region in src_pixbuf 516 * Throws: ConstructionException GTK+ fails to create the object. 517 */ 518 public this (Pixbuf srcPixbuf, int srcX, int srcY, int width, int height) 519 { 520 // GdkPixbuf * gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf, int src_x, int src_y, int width, int height); 521 auto p = gdk_pixbuf_new_subpixbuf((srcPixbuf is null) ? null : srcPixbuf.getPixbufStruct(), srcX, srcY, width, height); 522 if(p is null) 523 { 524 throw new ConstructionException("null returned by gdk_pixbuf_new_subpixbuf((srcPixbuf is null) ? null : srcPixbuf.getPixbufStruct(), srcX, srcY, width, height)"); 525 } 526 this(cast(GdkPixbuf*) p); 527 } 528 529 /** 530 * Creates a new GdkPixbuf with a copy of the information in the specified 531 * pixbuf. 532 * Returns: A newly-created pixbuf with a reference count of 1, or NULL if not enough memory could be allocated. [transfer full] 533 */ 534 public Pixbuf copy() 535 { 536 // GdkPixbuf * gdk_pixbuf_copy (const GdkPixbuf *pixbuf); 537 auto p = gdk_pixbuf_copy(gdkPixbuf); 538 539 if(p is null) 540 { 541 return null; 542 } 543 544 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 545 } 546 547 /** 548 * Queries the color space of a pixbuf. 549 * Returns: Color space. 550 */ 551 public GdkColorspace getColorspace() 552 { 553 // GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf); 554 return gdk_pixbuf_get_colorspace(gdkPixbuf); 555 } 556 557 /** 558 * Queries the number of channels of a pixbuf. 559 * Returns: Number of channels. 560 */ 561 public int getNChannels() 562 { 563 // int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf); 564 return gdk_pixbuf_get_n_channels(gdkPixbuf); 565 } 566 567 /** 568 * Queries whether a pixbuf has an alpha channel (opacity information). 569 * Returns: TRUE if it has an alpha channel, FALSE otherwise. 570 */ 571 public int getHasAlpha() 572 { 573 // gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf); 574 return gdk_pixbuf_get_has_alpha(gdkPixbuf); 575 } 576 577 /** 578 * Queries the number of bits per color sample in a pixbuf. 579 * Returns: Number of bits per color sample. 580 */ 581 public int getBitsPerSample() 582 { 583 // int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf); 584 return gdk_pixbuf_get_bits_per_sample(gdkPixbuf); 585 } 586 587 /** 588 * Queries a pointer to the pixel data of a pixbuf. 589 * Returns: A pointer to the pixbuf's pixel data. Please see the section called “Image Data” for information about how the pixel data is stored in memory. [array] 590 */ 591 public char* getPixels() 592 { 593 // guchar * gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf); 594 return gdk_pixbuf_get_pixels(gdkPixbuf); 595 } 596 597 /** 598 * Queries a pointer to the pixel data of a pixbuf. 599 * Since 2.26 600 * Returns: A pointer to the pixbuf's pixel data. Please see the section called “Image Data” for information about how the pixel data is stored in memory. Rename to: gdk_pixbuf_get_pixels. [array length=length] 601 */ 602 public char[] getPixelsWithLength() 603 { 604 // guchar * gdk_pixbuf_get_pixels_with_length (const GdkPixbuf *pixbuf, guint *length); 605 uint length; 606 auto p = gdk_pixbuf_get_pixels_with_length(gdkPixbuf, &length); 607 608 if(p is null) 609 { 610 return null; 611 } 612 613 return p[0 .. length]; 614 } 615 616 /** 617 * Queries the width of a pixbuf. 618 * Returns: Width in pixels. 619 */ 620 public int getWidth() 621 { 622 // int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf); 623 return gdk_pixbuf_get_width(gdkPixbuf); 624 } 625 626 /** 627 * Queries the height of a pixbuf. 628 * Returns: Height in pixels. 629 */ 630 public int getHeight() 631 { 632 // int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf); 633 return gdk_pixbuf_get_height(gdkPixbuf); 634 } 635 636 /** 637 * Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row 638 * and the start of the next row. 639 * Returns: Distance between row starts. 640 */ 641 public int getRowstride() 642 { 643 // int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf); 644 return gdk_pixbuf_get_rowstride(gdkPixbuf); 645 } 646 647 /** 648 * Returns the length of the pixel data, in bytes. 649 * Since 2.26 650 * Returns: The length of the pixel data. 651 */ 652 public gsize getByteLength() 653 { 654 // gsize gdk_pixbuf_get_byte_length (const GdkPixbuf *pixbuf); 655 return gdk_pixbuf_get_byte_length(gdkPixbuf); 656 } 657 658 /** 659 * Looks up key in the list of options that may have been attached to the 660 * pixbuf when it was loaded, or that may have been attached by another 661 * function using gdk_pixbuf_set_option(). 662 * For instance, the ANI loader provides "Title" and "Artist" options. 663 * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot 664 * options for cursor definitions. The PNG loader provides the tEXt ancillary 665 * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders 666 * return an "orientation" option string that corresponds to the embedded 667 * TIFF/Exif orientation tag (if present). 668 * Params: 669 * key = a nul-terminated string. 670 * Returns: the value associated with key. This is a nul-terminated string that should not be freed or NULL if key was not found. 671 */ 672 public string getOption(string key) 673 { 674 // const gchar * gdk_pixbuf_get_option (GdkPixbuf *pixbuf, const gchar *key); 675 return Str.toString(gdk_pixbuf_get_option(gdkPixbuf, Str.toStringz(key))); 676 } 677 678 /** 679 * Creates a new pixbuf by loading an image from a file. The file format is 680 * detected automatically. If NULL is returned, then error will be set. 681 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. 682 * Params: 683 * filename = Name of file to load, in the GLib file name encoding 684 * Throws: GException on failure. 685 * Throws: ConstructionException GTK+ fails to create the object. 686 */ 687 public this (string filename) 688 { 689 // GdkPixbuf * gdk_pixbuf_new_from_file (const char *filename, GError **error); 690 GError* err = null; 691 692 auto p = gdk_pixbuf_new_from_file(Str.toStringz(filename), &err); 693 694 if (err !is null) 695 { 696 throw new GException( new ErrorG(err) ); 697 } 698 699 if(p is null) 700 { 701 throw new ConstructionException("null returned by gdk_pixbuf_new_from_file(Str.toStringz(filename), &err)"); 702 } 703 this(cast(GdkPixbuf*) p); 704 } 705 706 /** 707 * Creates a new pixbuf by loading an image from a file. 708 * The file format is detected automatically. If NULL is returned, then 709 * error will be set. Possible errors are in the GDK_PIXBUF_ERROR and 710 * G_FILE_ERROR domains. 711 * The image will be scaled to fit in the requested size, preserving 712 * the image's aspect ratio. Note that the returned pixbuf may be smaller 713 * than width x height, if the aspect ratio requires it. To load 714 * and image at the requested size, regardless of aspect ratio, use 715 * gdk_pixbuf_new_from_file_at_scale(). 716 * Since 2.4 717 * Params: 718 * filename = Name of file to load, in the GLib file name encoding 719 * width = The width the image should have or -1 to not constrain the width 720 * height = The height the image should have or -1 to not constrain the height 721 * Throws: GException on failure. 722 * Throws: ConstructionException GTK+ fails to create the object. 723 */ 724 public this (string filename, int width, int height) 725 { 726 // GdkPixbuf * gdk_pixbuf_new_from_file_at_size (const char *filename, int width, int height, GError **error); 727 GError* err = null; 728 729 auto p = gdk_pixbuf_new_from_file_at_size(Str.toStringz(filename), width, height, &err); 730 731 if (err !is null) 732 { 733 throw new GException( new ErrorG(err) ); 734 } 735 736 if(p is null) 737 { 738 throw new ConstructionException("null returned by gdk_pixbuf_new_from_file_at_size(Str.toStringz(filename), width, height, &err)"); 739 } 740 this(cast(GdkPixbuf*) p); 741 } 742 743 /** 744 * Creates a new pixbuf by loading an image from a file. The file format is 745 * detected automatically. If NULL is returned, then error will be set. 746 * Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. 747 * The image will be scaled to fit in the requested size, optionally preserving 748 * the image's aspect ratio. 749 * When preserving the aspect ratio, a width of -1 will cause the image 750 * to be scaled to the exact given height, and a height of -1 will cause 751 * the image to be scaled to the exact given width. When not preserving 752 * aspect ratio, a width or height of -1 means to not scale the image 753 * at all in that dimension. Negative values for width and height are 754 * allowed since 2.8. 755 * Since 2.6 756 * Params: 757 * filename = Name of file to load, in the GLib file name encoding 758 * width = The width the image should have or -1 to not constrain the width 759 * height = The height the image should have or -1 to not constrain the height 760 * preserveAspectRatio = TRUE to preserve the image's aspect ratio 761 * Throws: GException on failure. 762 * Throws: ConstructionException GTK+ fails to create the object. 763 */ 764 public this (string filename, int width, int height, int preserveAspectRatio) 765 { 766 // GdkPixbuf * gdk_pixbuf_new_from_file_at_scale (const char *filename, int width, int height, gboolean preserve_aspect_ratio, GError **error); 767 GError* err = null; 768 769 auto p = gdk_pixbuf_new_from_file_at_scale(Str.toStringz(filename), width, height, preserveAspectRatio, &err); 770 771 if (err !is null) 772 { 773 throw new GException( new ErrorG(err) ); 774 } 775 776 if(p is null) 777 { 778 throw new ConstructionException("null returned by gdk_pixbuf_new_from_file_at_scale(Str.toStringz(filename), width, height, preserveAspectRatio, &err)"); 779 } 780 this(cast(GdkPixbuf*) p); 781 } 782 783 /** 784 * Parses an image file far enough to determine its format and size. 785 * Since 2.4 786 * Params: 787 * filename = The name of the file to identify. 788 * width = Return location for the width of the image, or NULL. [out] 789 * height = Return location for the height of the image, or NULL. [out] 790 * Returns: A GdkPixbufFormat describing the image format of the file or NULL if the image format wasn't recognized. The return value is owned by GdkPixbuf and should not be freed. [transfer none] 791 */ 792 public static PixbufFormat getFileInfo(string filename, out int width, out int height) 793 { 794 // GdkPixbufFormat * gdk_pixbuf_get_file_info (const gchar *filename, gint *width, gint *height); 795 auto p = gdk_pixbuf_get_file_info(Str.toStringz(filename), &width, &height); 796 797 if(p is null) 798 { 799 return null; 800 } 801 802 return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p); 803 } 804 805 /** 806 * Creates a new pixbuf by loading an image from an input stream. 807 * The file format is detected automatically. If NULL is returned, then 808 * error will be set. The cancellable can be used to abort the operation 809 * from another thread. If the operation was cancelled, the error 810 * G_IO_ERROR_CANCELLED will be returned. Other possible errors are in 811 * the GDK_PIXBUF_ERROR and G_IO_ERROR domains. 812 * The stream is not closed. 813 * Since 2.14 814 * Params: 815 * stream = a GInputStream to load the pixbuf from 816 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 817 * Throws: GException on failure. 818 * Throws: ConstructionException GTK+ fails to create the object. 819 */ 820 public this (InputStream stream, Cancellable cancellable) 821 { 822 // GdkPixbuf * gdk_pixbuf_new_from_stream (GInputStream *stream, GCancellable *cancellable, GError **error); 823 GError* err = null; 824 825 auto p = gdk_pixbuf_new_from_stream((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 826 827 if (err !is null) 828 { 829 throw new GException( new ErrorG(err) ); 830 } 831 832 if(p is null) 833 { 834 throw new ConstructionException("null returned by gdk_pixbuf_new_from_stream((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); 835 } 836 this(cast(GdkPixbuf*) p); 837 } 838 839 /** 840 * Creates a new pixbuf by asynchronously loading an image from an input stream. 841 * For more details see gdk_pixbuf_new_from_stream(), which is the synchronous 842 * version of this function. 843 * When the operation is finished, callback will be called in the main thread. 844 * You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation. 845 * Since 2.24 846 * Params: 847 * stream = a GInputStream from which to load the pixbuf 848 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 849 * callback = a GAsyncReadyCallback to call when the the pixbuf is loaded 850 * userData = the data to pass to the callback function 851 */ 852 public static void newFromStreamAsync(InputStream stream, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 853 { 854 // void gdk_pixbuf_new_from_stream_async (GInputStream *stream, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 855 gdk_pixbuf_new_from_stream_async((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 856 } 857 858 /** 859 * Finishes an asynchronous pixbuf creation operation started with 860 * gdk_pixbuf_new_from_stream_async(). 861 * Since 2.24 862 * Params: 863 * asyncResult = a GAsyncResult 864 * Throws: GException on failure. 865 * Throws: ConstructionException GTK+ fails to create the object. 866 */ 867 public this (AsyncResultIF asyncResult) 868 { 869 // GdkPixbuf * gdk_pixbuf_new_from_stream_finish (GAsyncResult *async_result, GError **error); 870 GError* err = null; 871 872 auto p = gdk_pixbuf_new_from_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultTStruct(), &err); 873 874 if (err !is null) 875 { 876 throw new GException( new ErrorG(err) ); 877 } 878 879 if(p is null) 880 { 881 throw new ConstructionException("null returned by gdk_pixbuf_new_from_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultTStruct(), &err)"); 882 } 883 this(cast(GdkPixbuf*) p); 884 } 885 886 /** 887 * Creates a new pixbuf by loading an image from an input stream. 888 * The file format is detected automatically. If NULL is returned, then 889 * error will be set. The cancellable can be used to abort the operation 890 * from another thread. If the operation was cancelled, the error 891 * G_IO_ERROR_CANCELLED will be returned. Other possible errors are in 892 * the GDK_PIXBUF_ERROR and G_IO_ERROR domains. 893 * The image will be scaled to fit in the requested size, optionally 894 * preserving the image's aspect ratio. When preserving the aspect ratio, 895 * a width of -1 will cause the image to be scaled to the exact given 896 * height, and a height of -1 will cause the image to be scaled to the 897 * exact given width. When not preserving aspect ratio, a width or 898 * height of -1 means to not scale the image at all in that dimension. 899 * The stream is not closed. 900 * Since 2.14 901 * Params: 902 * stream = a GInputStream to load the pixbuf from 903 * width = The width the image should have or -1 to not constrain the width 904 * height = The height the image should have or -1 to not constrain the height 905 * preserveAspectRatio = TRUE to preserve the image's aspect ratio 906 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 907 * Throws: GException on failure. 908 * Throws: ConstructionException GTK+ fails to create the object. 909 */ 910 public this (InputStream stream, int width, int height, int preserveAspectRatio, Cancellable cancellable) 911 { 912 // GdkPixbuf * gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream, gint width, gint height, gboolean preserve_aspect_ratio, GCancellable *cancellable, GError **error); 913 GError* err = null; 914 915 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); 916 917 if (err !is null) 918 { 919 throw new GException( new ErrorG(err) ); 920 } 921 922 if(p is null) 923 { 924 throw new ConstructionException("null returned by gdk_pixbuf_new_from_stream_at_scale((stream is null) ? null : stream.getInputStreamStruct(), width, height, preserveAspectRatio, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); 925 } 926 this(cast(GdkPixbuf*) p); 927 } 928 929 /** 930 * Creates a new pixbuf by asynchronously loading an image from an input stream. 931 * For more details see gdk_pixbuf_new_from_stream_at_scale(), which is the synchronous 932 * version of this function. 933 * When the operation is finished, callback will be called in the main thread. 934 * You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation. 935 * Since 2.24 936 * Params: 937 * stream = a GInputStream from which to load the pixbuf 938 * width = the width the image should have or -1 to not constrain the width 939 * height = the height the image should have or -1 to not constrain the height 940 * preserveAspectRatio = TRUE to preserve the image's aspect ratio 941 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 942 * callback = a GAsyncReadyCallback to call when the the pixbuf is loaded 943 * userData = the data to pass to the callback function 944 */ 945 public static void newFromStreamAtScaleAsync(InputStream stream, int width, int height, int preserveAspectRatio, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 946 { 947 // void gdk_pixbuf_new_from_stream_at_scale_async (GInputStream *stream, gint width, gint height, gboolean preserve_aspect_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 948 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); 949 } 950 951 /** 952 * Saves pixbuf to a file in type, which is currently "jpeg", "png", "tiff", "ico" or "bmp". 953 * If error is set, FALSE will be returned. 954 * See gdk_pixbuf_save() for more details. 955 * Params: 956 * filename = name of file to save. 957 * type = name of file format. 958 * optionKeys = name of options to set, NULL-terminated. [array zero-terminated=1] 959 * optionValues = values for named options. [array zero-terminated=1] 960 * Returns: whether an error was set 961 * Throws: GException on failure. 962 */ 963 public int savev(string filename, string type, string[] optionKeys, string[] optionValues) 964 { 965 // gboolean gdk_pixbuf_savev (GdkPixbuf *pixbuf, const char *filename, const char *type, char **option_keys, char **option_values, GError **error); 966 GError* err = null; 967 968 auto p = gdk_pixbuf_savev(gdkPixbuf, Str.toStringz(filename), Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err); 969 970 if (err !is null) 971 { 972 throw new GException( new ErrorG(err) ); 973 } 974 975 return p; 976 } 977 978 /** 979 * Saves pixbuf to a callback in format type, which is currently "jpeg", 980 * "png", "tiff", "ico" or "bmp". If error is set, FALSE will be returned. See 981 * gdk_pixbuf_save_to_callback() for more details. 982 * Since 2.4 983 * Params: 984 * saveFunc = a function that is called to save each block of data that 985 * the save routine generates. [scope call] 986 * userData = user data to pass to the save function. [closure] 987 * type = name of file format. 988 * optionKeys = name of options to set, NULL-terminated. [array zero-terminated=1][element-type utf8] 989 * optionValues = values for named options. [array zero-terminated=1][element-type utf8] 990 * Returns: whether an error was set 991 * Throws: GException on failure. 992 */ 993 public int saveToCallbackv(GdkPixbufSaveFunc saveFunc, void* userData, string type, string[] optionKeys, string[] optionValues) 994 { 995 // gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf, GdkPixbufSaveFunc save_func, gpointer user_data, const char *type, char **option_keys, char **option_values, GError **error); 996 GError* err = null; 997 998 auto p = gdk_pixbuf_save_to_callbackv(gdkPixbuf, saveFunc, userData, Str.toStringz(type), Str.toStringzArray(optionKeys), Str.toStringzArray(optionValues), &err); 999 1000 if (err !is null) 1001 { 1002 throw new GException( new ErrorG(err) ); 1003 } 1004 1005 return p; 1006 } 1007 1008 /** 1009 * Finishes an asynchronous pixbuf save operation started with 1010 * gdk_pixbuf_save_to_stream_async(). 1011 * Since 2.24 1012 * Params: 1013 * asyncResult = a GAsyncResult 1014 * Returns: TRUE if the pixbuf was saved successfully, FALSE if an error was set. 1015 * Throws: GException on failure. 1016 */ 1017 public static int saveToStreamFinish(AsyncResultIF asyncResult) 1018 { 1019 // gboolean gdk_pixbuf_save_to_stream_finish (GAsyncResult *async_result, GError **error); 1020 GError* err = null; 1021 1022 auto p = gdk_pixbuf_save_to_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultTStruct(), &err); 1023 1024 if (err !is null) 1025 { 1026 throw new GException( new ErrorG(err) ); 1027 } 1028 1029 return p; 1030 } 1031 1032 /** 1033 * Create a new GdkPixbuf containing a copy of src scaled to 1034 * dest_width x dest_height. Leaves src unaffected. interp_type 1035 * should be GDK_INTERP_NEAREST if you want maximum speed (but when 1036 * scaling down GDK_INTERP_NEAREST is usually unusably ugly). The 1037 * default interp_type should be GDK_INTERP_BILINEAR which offers 1038 * reasonable quality and speed. 1039 * You can scale a sub-portion of src by creating a sub-pixbuf 1040 * pointing into src; see gdk_pixbuf_new_subpixbuf(). 1041 * For more complicated scaling/compositing see gdk_pixbuf_scale() 1042 * and gdk_pixbuf_composite(). 1043 * Params: 1044 * destWidth = the width of destination image 1045 * destHeight = the height of destination image 1046 * interpType = the interpolation type for the transformation. 1047 * Returns: the new GdkPixbuf, or NULL if not enough memory could be allocated for it. [transfer full] 1048 */ 1049 public Pixbuf scaleSimple(int destWidth, int destHeight, GdkInterpType interpType) 1050 { 1051 // GdkPixbuf * gdk_pixbuf_scale_simple (const GdkPixbuf *src, int dest_width, int dest_height, GdkInterpType interp_type); 1052 auto p = gdk_pixbuf_scale_simple(gdkPixbuf, destWidth, destHeight, interpType); 1053 1054 if(p is null) 1055 { 1056 return null; 1057 } 1058 1059 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1060 } 1061 1062 /** 1063 * Creates a transformation of the source image src by scaling by 1064 * scale_x and scale_y then translating by offset_x and offset_y, 1065 * then renders the rectangle (dest_x, dest_y, dest_width, 1066 * dest_height) of the resulting image onto the destination image 1067 * replacing the previous contents. 1068 * Try to use gdk_pixbuf_scale_simple() first, this function is 1069 * the industrial-strength power tool you can fall back to if 1070 * gdk_pixbuf_scale_simple() isn't powerful enough. 1071 * If the source rectangle overlaps the destination rectangle on the 1072 * same pixbuf, it will be overwritten during the scaling which 1073 * results in rendering artifacts. 1074 * Params: 1075 * dest = the GdkPixbuf into which to render the results 1076 * destX = the left coordinate for region to render 1077 * destY = the top coordinate for region to render 1078 * destWidth = the width of the region to render 1079 * destHeight = the height of the region to render 1080 * offsetX = the offset in the X direction (currently rounded to an integer) 1081 * offsetY = the offset in the Y direction (currently rounded to an integer) 1082 * scaleX = the scale factor in the X direction 1083 * scaleY = the scale factor in the Y direction 1084 * interpType = the interpolation type for the transformation. 1085 */ 1086 public void scale(Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType) 1087 { 1088 // void gdk_pixbuf_scale (const GdkPixbuf *src, GdkPixbuf *dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type); 1089 gdk_pixbuf_scale(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType); 1090 } 1091 1092 /** 1093 * Creates a new GdkPixbuf by scaling src to dest_width x 1094 * dest_height and compositing the result with a checkboard of colors 1095 * color1 and color2. 1096 * Params: 1097 * destWidth = the width of destination image 1098 * destHeight = the height of destination image 1099 * interpType = the interpolation type for the transformation. 1100 * overallAlpha = overall alpha for source image (0..255) 1101 * checkSize = the size of checks in the checkboard (must be a power of two) 1102 * color1 = the color of check at upper left 1103 * color2 = the color of the other check 1104 * Returns: the new GdkPixbuf, or NULL if not enough memory could be allocated for it. [transfer full] 1105 */ 1106 public Pixbuf compositeColorSimple(int destWidth, int destHeight, GdkInterpType interpType, int overallAlpha, int checkSize, uint color1, uint color2) 1107 { 1108 // GdkPixbuf * gdk_pixbuf_composite_color_simple (const GdkPixbuf *src, int dest_width, int dest_height, GdkInterpType interp_type, int overall_alpha, int check_size, guint32 color1, guint32 color2); 1109 auto p = gdk_pixbuf_composite_color_simple(gdkPixbuf, destWidth, destHeight, interpType, overallAlpha, checkSize, color1, color2); 1110 1111 if(p is null) 1112 { 1113 return null; 1114 } 1115 1116 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1117 } 1118 1119 /** 1120 * Creates a transformation of the source image src by scaling by 1121 * scale_x and scale_y then translating by offset_x and offset_y. 1122 * This gives an image in the coordinates of the destination pixbuf. 1123 * The rectangle (dest_x, dest_y, dest_width, dest_height) 1124 * is then composited onto the corresponding rectangle of the 1125 * original destination image. 1126 * When the destination rectangle contains parts not in the source 1127 * image, the data at the edges of the source image is replicated 1128 * to infinity. 1129 * Figure 1. Compositing of pixbufs 1130 * Params: 1131 * dest = the GdkPixbuf into which to render the results 1132 * destX = the left coordinate for region to render 1133 * destY = the top coordinate for region to render 1134 * destWidth = the width of the region to render 1135 * destHeight = the height of the region to render 1136 * offsetX = the offset in the X direction (currently rounded to an integer) 1137 * offsetY = the offset in the Y direction (currently rounded to an integer) 1138 * scaleX = the scale factor in the X direction 1139 * scaleY = the scale factor in the Y direction 1140 * interpType = the interpolation type for the transformation. 1141 * overallAlpha = overall alpha for source image (0..255) 1142 */ 1143 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) 1144 { 1145 // void gdk_pixbuf_composite (const GdkPixbuf *src, GdkPixbuf *dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type, int overall_alpha); 1146 gdk_pixbuf_composite(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), destX, destY, destWidth, destHeight, offsetX, offsetY, scaleX, scaleY, interpType, overallAlpha); 1147 } 1148 1149 /** 1150 * Creates a transformation of the source image src by scaling by 1151 * scale_x and scale_y then translating by offset_x and offset_y, 1152 * then composites the rectangle (dest_x ,dest_y, dest_width, 1153 * dest_height) of the resulting image with a checkboard of the 1154 * colors color1 and color2 and renders it onto the destination 1155 * image. 1156 * See gdk_pixbuf_composite_color_simple() for a simpler variant of this 1157 * function suitable for many tasks. 1158 * Params: 1159 * dest = the GdkPixbuf into which to render the results 1160 * destX = the left coordinate for region to render 1161 * destY = the top coordinate for region to render 1162 * destWidth = the width of the region to render 1163 * destHeight = the height of the region to render 1164 * offsetX = the offset in the X direction (currently rounded to an integer) 1165 * offsetY = the offset in the Y direction (currently rounded to an integer) 1166 * scaleX = the scale factor in the X direction 1167 * scaleY = the scale factor in the Y direction 1168 * interpType = the interpolation type for the transformation. 1169 * overallAlpha = overall alpha for source image (0..255) 1170 * checkX = the X offset for the checkboard (origin of checkboard is at -check_x, -check_y) 1171 * checkY = the Y offset for the checkboard 1172 * checkSize = the size of checks in the checkboard (must be a power of two) 1173 * color1 = the color of check at upper left 1174 * color2 = the color of the other check 1175 */ 1176 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) 1177 { 1178 // void gdk_pixbuf_composite_color (const GdkPixbuf *src, GdkPixbuf *dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type, int overall_alpha, int check_x, int check_y, int check_size, guint32 color1, guint32 color2); 1179 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); 1180 } 1181 1182 /** 1183 * Rotates a pixbuf by a multiple of 90 degrees, and returns the 1184 * result in a new pixbuf. 1185 * Since 2.6 1186 * Params: 1187 * angle = the angle to rotate by 1188 * Returns: the new GdkPixbuf, or NULL if not enough memory could be allocated for it. [transfer full] 1189 */ 1190 public Pixbuf rotateSimple(GdkPixbufRotation angle) 1191 { 1192 // GdkPixbuf * gdk_pixbuf_rotate_simple (const GdkPixbuf *src, GdkPixbufRotation angle); 1193 auto p = gdk_pixbuf_rotate_simple(gdkPixbuf, angle); 1194 1195 if(p is null) 1196 { 1197 return null; 1198 } 1199 1200 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1201 } 1202 1203 /** 1204 * Flips a pixbuf horizontally or vertically and returns the 1205 * result in a new pixbuf. 1206 * Since 2.6 1207 * Params: 1208 * horizontal = TRUE to flip horizontally, FALSE to flip vertically 1209 * Returns: the new GdkPixbuf, or NULL if not enough memory could be allocated for it. [transfer full] 1210 */ 1211 public Pixbuf flip(int horizontal) 1212 { 1213 // GdkPixbuf * gdk_pixbuf_flip (const GdkPixbuf *src, gboolean horizontal); 1214 auto p = gdk_pixbuf_flip(gdkPixbuf, horizontal); 1215 1216 if(p is null) 1217 { 1218 return null; 1219 } 1220 1221 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1222 } 1223 1224 /** 1225 * Takes an existing pixbuf and adds an alpha channel to it. 1226 * If the existing pixbuf already had an alpha channel, the channel 1227 * values are copied from the original; otherwise, the alpha channel 1228 * is initialized to 255 (full opacity). 1229 * If substitute_color is TRUE, then the color specified by (r, g, b) will be 1230 * assigned zero opacity. That is, if you pass (255, 255, 255) for the 1231 * substitute color, all white pixels will become fully transparent. 1232 * Params: 1233 * substituteColor = Whether to set a color to zero opacity. If this 1234 * is FALSE, then the (r, g, b) arguments will be ignored. 1235 * r = Red value to substitute. 1236 * g = Green value to substitute. 1237 * b = Blue value to substitute. 1238 * Returns: A newly-created pixbuf with a reference count of 1. [transfer full] 1239 */ 1240 public Pixbuf addAlpha(int substituteColor, char r, char g, char b) 1241 { 1242 // GdkPixbuf * gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color, guchar r, guchar g, guchar b); 1243 auto p = gdk_pixbuf_add_alpha(gdkPixbuf, substituteColor, r, g, b); 1244 1245 if(p is null) 1246 { 1247 return null; 1248 } 1249 1250 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1251 } 1252 1253 /** 1254 * Copies a rectangular area from src_pixbuf to dest_pixbuf. Conversion of 1255 * pixbuf formats is done automatically. 1256 * If the source rectangle overlaps the destination rectangle on the 1257 * same pixbuf, it will be overwritten during the copy operation. 1258 * Therefore, you can not use this function to scroll a pixbuf. 1259 * Params: 1260 * srcX = Source X coordinate within src_pixbuf. 1261 * srcY = Source Y coordinate within src_pixbuf. 1262 * width = Width of the area to copy. 1263 * height = Height of the area to copy. 1264 * destPixbuf = Destination pixbuf. 1265 * destX = X coordinate within dest_pixbuf. 1266 * destY = Y coordinate within dest_pixbuf. 1267 */ 1268 public void copyArea(int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY) 1269 { 1270 // void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf, int src_x, int src_y, int width, int height, GdkPixbuf *dest_pixbuf, int dest_x, int dest_y); 1271 gdk_pixbuf_copy_area(gdkPixbuf, srcX, srcY, width, height, (destPixbuf is null) ? null : destPixbuf.getPixbufStruct(), destX, destY); 1272 } 1273 1274 /** 1275 * Modifies saturation and optionally pixelates src, placing the result in 1276 * dest. src and dest may be the same pixbuf with no ill effects. If 1277 * saturation is 1.0 then saturation is not changed. If it's less than 1.0, 1278 * saturation is reduced (the image turns toward grayscale); if greater than 1279 * 1.0, saturation is increased (the image gets more vivid colors). If pixelate 1280 * is TRUE, then pixels are faded in a checkerboard pattern to create a 1281 * pixelated image. src and dest must have the same image format, size, and 1282 * rowstride. 1283 * Params: 1284 * dest = place to write modified version of src 1285 * saturation = saturation factor 1286 * pixelate = whether to pixelate 1287 */ 1288 public void saturateAndPixelate(Pixbuf dest, float saturation, int pixelate) 1289 { 1290 // void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src, GdkPixbuf *dest, gfloat saturation, gboolean pixelate); 1291 gdk_pixbuf_saturate_and_pixelate(gdkPixbuf, (dest is null) ? null : dest.getPixbufStruct(), saturation, pixelate); 1292 } 1293 1294 /** 1295 * Takes an existing pixbuf and checks for the presence of an 1296 * associated "orientation" option, which may be provided by the 1297 * jpeg loader (which reads the exif orientation tag) or the 1298 * tiff loader (which reads the tiff orientation tag, and 1299 * compensates it for the partial transforms performed by 1300 * libtiff). If an orientation option/tag is present, the 1301 * appropriate transform will be performed so that the pixbuf 1302 * is oriented correctly. 1303 * Since 2.12 1304 * Returns: A newly-created pixbuf, or a reference to the input pixbuf (with an increased reference count). [transfer full] 1305 */ 1306 public Pixbuf applyEmbeddedOrientation() 1307 { 1308 // GdkPixbuf * gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src); 1309 auto p = gdk_pixbuf_apply_embedded_orientation(gdkPixbuf); 1310 1311 if(p is null) 1312 { 1313 return null; 1314 } 1315 1316 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 1317 } 1318 1319 /** 1320 * Clears a pixbuf to the given RGBA value, converting the RGBA value into 1321 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf 1322 * doesn't have an alpha channel. 1323 * Params: 1324 * pixel = RGBA pixel to clear to 1325 * (0xffffffff is opaque white, 0x00000000 transparent black) 1326 */ 1327 public void fill(uint pixel) 1328 { 1329 // void gdk_pixbuf_fill (GdkPixbuf *pixbuf, guint32 pixel); 1330 gdk_pixbuf_fill(gdkPixbuf, pixel); 1331 } 1332 }