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