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 = gdk-Images.html 27 * outPack = gdk 28 * outFile = ImageGdk 29 * strct = GdkImage 30 * realStrct= 31 * ctorStrct= 32 * clss = ImageGdk 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_image_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gdk.Visual 47 * - gdk.Drawable 48 * - gdk.Colormap 49 * structWrap: 50 * - GdkColormap* -> Colormap 51 * - GdkDrawable* -> Drawable 52 * - GdkImage* -> ImageGdk 53 * - GdkVisual* -> Visual 54 * module aliases: 55 * local aliases: 56 * overrides: 57 */ 58 59 module gdk.ImageGdk; 60 61 public import gtkc.gdktypes; 62 63 private import gtkc.gdk; 64 private import glib.ConstructionException; 65 private import gobject.ObjectG; 66 67 68 private import gdk.Visual; 69 private import gdk.Drawable; 70 private import gdk.Colormap; 71 72 73 74 75 /** 76 * Description 77 * The GdkImage type represents an area for drawing graphics. 78 * It has now been superceded to a large extent by the much more flexible 79 * GdkRGB functions. 80 * To create an empty GdkImage use gdk_image_new(). 81 * To create a GdkImage from bitmap data use gdk_image_new_bitmap(). 82 * To create an image from part of a GdkWindow use gdk_drawable_get_image(). 83 * The image can be manipulated with gdk_image_get_pixel() and 84 * gdk_image_put_pixel(), or alternatively by changing the actual pixel data. 85 * Though manipulating the pixel data requires complicated code to cope with 86 * the different formats that may be used. 87 * To draw a GdkImage in a GdkWindow or GdkPixmap use gdk_draw_image(). 88 * To destroy a GdkImage use gdk_image_destroy(). 89 */ 90 public class ImageGdk 91 { 92 93 /** the main Gtk struct */ 94 protected GdkImage* gdkImage; 95 96 97 public GdkImage* getImageGdkStruct() 98 { 99 return gdkImage; 100 } 101 102 103 /** the main Gtk struct as a void* */ 104 protected void* getStruct() 105 { 106 return cast(void*)gdkImage; 107 } 108 109 /** 110 * Sets our main struct and passes it to the parent class 111 */ 112 public this (GdkImage* gdkImage) 113 { 114 this.gdkImage = gdkImage; 115 } 116 117 /** 118 */ 119 120 /** 121 * Warning 122 * gdk_image_new is deprecated and should not be used in newly-written code. 123 * Creates a new GdkImage. 124 * Params: 125 * type = the type of the GdkImage, one of GDK_IMAGE_NORMAL, GDK_IMAGE_SHARED 126 * and GDK_IMAGE_FASTEST. GDK_IMAGE_FASTEST is probably the best choice, since 127 * it will try creating a GDK_IMAGE_SHARED image first and if that fails it will 128 * then use GDK_IMAGE_NORMAL. 129 * visual = the GdkVisual to use for the image. 130 * width = the width of the image in pixels. 131 * height = the height of the image in pixels. 132 * Throws: ConstructionException GTK+ fails to create the object. 133 */ 134 public this (GdkImageType type, Visual visual, int width, int height) 135 { 136 // GdkImage * gdk_image_new (GdkImageType type, GdkVisual *visual, gint width, gint height); 137 auto p = gdk_image_new(type, (visual is null) ? null : visual.getVisualStruct(), width, height); 138 if(p is null) 139 { 140 throw new ConstructionException("null returned by gdk_image_new(type, (visual is null) ? null : visual.getVisualStruct(), width, height)"); 141 } 142 this(cast(GdkImage*) p); 143 } 144 145 /** 146 * Warning 147 * gdk_image_new_bitmap is deprecated and should not be used in newly-written code. 148 * Creates a new GdkImage with a depth of 1 from the given data. 149 * Warning 150 * THIS FUNCTION IS INCREDIBLY BROKEN. The passed-in data must 151 * be allocated by malloc() (NOT g_malloc()) and will be freed when the 152 * image is freed. 153 * Params: 154 * visual = the GdkVisual to use for the image. 155 * data = the pixel data. 156 * width = the width of the image in pixels. 157 * height = the height of the image in pixels. 158 * Throws: ConstructionException GTK+ fails to create the object. 159 */ 160 public this (Visual visual, void* data, int width, int height) 161 { 162 // GdkImage * gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint width, gint height); 163 auto p = gdk_image_new_bitmap((visual is null) ? null : visual.getVisualStruct(), data, width, height); 164 if(p is null) 165 { 166 throw new ConstructionException("null returned by gdk_image_new_bitmap((visual is null) ? null : visual.getVisualStruct(), data, width, height)"); 167 } 168 this(cast(GdkImage*) p); 169 } 170 171 /** 172 * Warning 173 * gdk_image_get is deprecated and should not be used in newly-written code. 174 * This is a deprecated wrapper for gdk_drawable_get_image(); 175 * gdk_drawable_get_image() should be used instead. Or even better: in 176 * most cases gdk_pixbuf_get_from_drawable() is the most convenient 177 * choice. 178 * Params: 179 * drawable = a GdkDrawable 180 * x = x coordinate in window 181 * y = y coordinate in window 182 * width = width of area in window 183 * height = height of area in window 184 * Returns: a new GdkImage or NULL 185 */ 186 public static ImageGdk get(Drawable drawable, int x, int y, int width, int height) 187 { 188 // GdkImage * gdk_image_get (GdkDrawable *drawable, gint x, gint y, gint width, gint height); 189 auto p = gdk_image_get((drawable is null) ? null : drawable.getDrawableStruct(), x, y, width, height); 190 191 if(p is null) 192 { 193 return null; 194 } 195 196 return ObjectG.getDObject!(ImageGdk)(cast(GdkImage*) p); 197 } 198 199 /** 200 * Warning 201 * gdk_image_ref has been deprecated since version 2.0 and should not be used in newly-written code. Use g_object_ref() instead. 202 * Deprecated function; use g_object_ref() instead. 203 * Returns: the image 204 */ 205 public ImageGdk doref() 206 { 207 // GdkImage * gdk_image_ref (GdkImage *image); 208 auto p = gdk_image_ref(gdkImage); 209 210 if(p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(ImageGdk)(cast(GdkImage*) p); 216 } 217 218 /** 219 * Warning 220 * gdk_image_unref has been deprecated since version 2.0 and should not be used in newly-written code. Use g_object_unref() instead. 221 * Deprecated function; use g_object_unref() instead. 222 */ 223 public void unref() 224 { 225 // void gdk_image_unref (GdkImage *image); 226 gdk_image_unref(gdkImage); 227 } 228 229 /** 230 * Warning 231 * gdk_image_get_colormap has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 232 * Retrieves the colormap for a given image, if it exists. An image 233 * will have a colormap if the drawable from which it was created has 234 * a colormap, or if a colormap was set explicitely with 235 * gdk_image_set_colormap(). 236 * Returns: colormap for the image 237 */ 238 public Colormap getColormap() 239 { 240 // GdkColormap * gdk_image_get_colormap (GdkImage *image); 241 auto p = gdk_image_get_colormap(gdkImage); 242 243 if(p is null) 244 { 245 return null; 246 } 247 248 return ObjectG.getDObject!(Colormap)(cast(GdkColormap*) p); 249 } 250 251 /** 252 * Warning 253 * gdk_image_set_colormap has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 254 * Sets the colormap for the image to the given colormap. Normally 255 * there's no need to use this function, images are created with the 256 * correct colormap if you get the image from a drawable. If you 257 * create the image from scratch, use the colormap of the drawable you 258 * intend to render the image to. 259 * Params: 260 * colormap = a GdkColormap 261 */ 262 public void setColormap(Colormap colormap) 263 { 264 // void gdk_image_set_colormap (GdkImage *image, GdkColormap *colormap); 265 gdk_image_set_colormap(gdkImage, (colormap is null) ? null : colormap.getColormapStruct()); 266 } 267 268 /** 269 * Warning 270 * gdk_image_get_bits_per_pixel has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 271 * Determines the number of bits per pixel of the image. 272 * Since 2.22 273 * Returns: the bits per pixel 274 */ 275 public ushort getBitsPerPixel() 276 { 277 // guint16 gdk_image_get_bits_per_pixel (GdkImage *image); 278 return gdk_image_get_bits_per_pixel(gdkImage); 279 } 280 281 /** 282 * Warning 283 * gdk_image_get_bytes_per_pixel has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 284 * Determines the number of bytes per pixel of the image. 285 * Since 2.22 286 * Returns: the bytes per pixel 287 */ 288 public ushort getBytesPerPixel() 289 { 290 // guint16 gdk_image_get_bytes_per_pixel (GdkImage *image); 291 return gdk_image_get_bytes_per_pixel(gdkImage); 292 } 293 294 /** 295 * Warning 296 * gdk_image_get_bytes_per_line has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 297 * Determines the number of bytes per line of the image. 298 * Since 2.22 299 * Returns: the bytes per line 300 */ 301 public ushort getBytesPerLine() 302 { 303 // guint16 gdk_image_get_bytes_per_line (GdkImage *image); 304 return gdk_image_get_bytes_per_line(gdkImage); 305 } 306 307 /** 308 * Warning 309 * gdk_image_get_byte_order has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 310 * Determines the byte order of the image. 311 * Since 2.22 312 * Returns: a GdkVisual 313 */ 314 public GdkByteOrder getByteOrder() 315 { 316 // GdkByteOrder gdk_image_get_byte_order (GdkImage *image); 317 return gdk_image_get_byte_order(gdkImage); 318 } 319 320 /** 321 * Warning 322 * gdk_image_get_depth has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 323 * Determines the depth of the image. 324 * Since 2.22 325 * Returns: the depth 326 */ 327 public ushort getDepth() 328 { 329 // guint16 gdk_image_get_depth (GdkImage *image); 330 return gdk_image_get_depth(gdkImage); 331 } 332 333 /** 334 * Warning 335 * gdk_image_get_height has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 336 * Determines the height of the image. 337 * Since 2.22 338 * Returns: the height 339 */ 340 public int getHeight() 341 { 342 // gint gdk_image_get_height (GdkImage *image); 343 return gdk_image_get_height(gdkImage); 344 } 345 346 /** 347 * Warning 348 * gdk_image_get_image_type has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 349 * Determines the type of a given image. 350 * Since 2.22 351 * Returns: the GdkImageType of the image 352 */ 353 public GdkImageType getImageType() 354 { 355 // GdkImageType gdk_image_get_image_type (GdkImage *image); 356 return gdk_image_get_image_type(gdkImage); 357 } 358 359 /** 360 * Warning 361 * gdk_image_get_visual has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 362 * Determines the visual that was used to create the image. 363 * Since 2.22 364 * Returns: a GdkVisual 365 */ 366 public Visual getVisual() 367 { 368 // GdkVisual * gdk_image_get_visual (GdkImage *image); 369 auto p = gdk_image_get_visual(gdkImage); 370 371 if(p is null) 372 { 373 return null; 374 } 375 376 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 377 } 378 379 /** 380 * Warning 381 * gdk_image_get_width has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 382 * Determines the width of the image. 383 * Since 2.22 384 * Returns: the width 385 */ 386 public int getWidth() 387 { 388 // gint gdk_image_get_width (GdkImage *image); 389 return gdk_image_get_width(gdkImage); 390 } 391 392 /** 393 * Warning 394 * gdk_image_get_pixels has been deprecated since version 2.22 and should not be used in newly-written code. GdkImage should not be used anymore. 395 * Returns a pointer to the pixel data of the image. 396 * Since 2.22 397 * Returns: the pixel data of the image 398 */ 399 public void* getPixels() 400 { 401 // gpointer gdk_image_get_pixels (GdkImage *image); 402 return gdk_image_get_pixels(gdkImage); 403 } 404 405 /** 406 * Warning 407 * gdk_image_put_pixel is deprecated and should not be used in newly-written code. 408 * Sets a pixel in a GdkImage to a given pixel value. 409 * Params: 410 * x = the x coordinate of the pixel to set. 411 * y = the y coordinate of the pixel to set. 412 * pixel = the pixel value to set. 413 */ 414 public void putPixel(int x, int y, uint pixel) 415 { 416 // void gdk_image_put_pixel (GdkImage *image, gint x, gint y, guint32 pixel); 417 gdk_image_put_pixel(gdkImage, x, y, pixel); 418 } 419 420 /** 421 * Warning 422 * gdk_image_get_pixel is deprecated and should not be used in newly-written code. 423 * Gets a pixel value at a specified position in a GdkImage. 424 * Params: 425 * x = the x coordinate of the pixel to get. 426 * y = the y coordinate of the pixel to get. 427 * Returns: the pixel value at the given position. 428 */ 429 public uint getPixel(int x, int y) 430 { 431 // guint32 gdk_image_get_pixel (GdkImage *image, gint x, gint y); 432 return gdk_image_get_pixel(gdkImage, x, y); 433 } 434 }