alternative to assert
[gtkD.git] / src / gdk / ImageGdk.d
blob2d048fceea79c9c114c3e2a028d3dcad264828dc
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-Images.html
26 * outPack = gdk
27 * outFile = ImageGdk
28 * strct = GdkImage
29 * realStrct=
30 * ctorStrct=
31 * clss = ImageGdk
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_image_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gdk.Visual
45 * - gdk.Drawable
46 * - gdk.Colormap
47 * structWrap:
48 * - GdkColormap* -> Colormap
49 * - GdkDrawable* -> Drawable
50 * - GdkVisual* -> Visual
51 * local aliases:
54 module gdk.ImageGdk;
56 private import gdk.gdktypes;
58 private import lib.gdk;
60 private import gdk.Visual;
61 private import gdk.Drawable;
62 private import gdk.Colormap;
64 /**
65 * Description
66 * The GdkImage type represents an area for drawing graphics.
67 * It has now been superceded to a large extent by the much more flexible
68 * GdkRGB functions.
69 * To create an empty GdkImage use gdk_image_new().
70 * To create a GdkImage from bitmap data use gdk_image_new_bitmap().
71 * To create an image from part of a GdkWindow use gdk_drawable_get_image().
72 * The image can be manipulated with gdk_image_get_pixel() and
73 * gdk_image_put_pixel(), or alternatively by changing the actual pixel data.
74 * Though manipulating the pixel data requires complicated code to cope with
75 * the different formats that may be used.
76 * To draw a GdkImage in a GdkWindow or GdkPixmap use gdk_draw_image().
77 * To destroy a GdkImage use gdk_image_destroy().
79 public class ImageGdk
82 /** the main Gtk struct */
83 protected GdkImage* gdkImage;
86 public GdkImage* getImageGdkStruct()
88 return gdkImage;
92 /** the main Gtk struct as a void* */
93 protected void* getStruct()
95 return cast(void*)gdkImage;
98 /**
99 * Sets our main struct and passes it to the parent class
101 public this (GdkImage* gdkImage)
103 this.gdkImage = gdkImage;
111 * Creates a new GdkImage.
112 * type:
113 * the type of the GdkImage, one of GDK_IMAGE_NORMAL, GDK_IMAGE_SHARED
114 * and GDK_IMAGE_FASTEST. GDK_IMAGE_FASTEST is probably the best choice, since
115 * it will try creating a GDK_IMAGE_SHARED image first and if that fails it will
116 * then use GDK_IMAGE_NORMAL.
117 * visual:
118 * the GdkVisual to use for the image.
119 * width:
120 * the width of the image in pixels.
121 * height:
122 * the height of the image in pixels.
123 * Returns:
124 * a new GdkImage, or NULL if the image could not be created.
126 public this (GdkImageType type, Visual visual, int width, int height)
128 // GdkImage* gdk_image_new (GdkImageType type, GdkVisual *visual, gint width, gint height);
129 this(cast(GdkImage*)gdk_image_new(type, (visual is null) ? null : visual.getVisualStruct(), width, height) );
134 * Warning
135 * gdk_image_new_bitmap is deprecated and should not be used in newly-written code.
136 * Creates a new GdkImage with a depth of 1 from the given data.
137 * Warning
138 * THIS FUNCTION IS INCREDIBLY BROKEN. The passed-in data must
139 * be allocated by malloc() (NOT g_malloc()) and will be freed when the
140 * image is freed.
141 * visual:
142 * the GdkVisual to use for the image.
143 * data:
144 * the pixel data.
145 * width:
146 * the width of the image in pixels.
147 * height:
148 * the height of the image in pixels.
149 * Returns:
150 * a new GdkImage.
152 public this (Visual visual, void* data, int width, int height)
154 // GdkImage* gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint width, gint height);
155 this(cast(GdkImage*)gdk_image_new_bitmap((visual is null) ? null : visual.getVisualStruct(), data, width, height) );
159 * Warning
160 * gdk_image_get is deprecated and should not be used in newly-written code.
161 * This is a deprecated wrapper for gdk_drawable_get_image();
162 * gdk_drawable_get_image() should be used instead. Or even better: in
163 * most cases gdk_pixbuf_get_from_drawable() is the most convenient
164 * choice.
165 * drawable:
166 * a GdkDrawable
167 * x:
168 * x coordinate in window
169 * y:
170 * y coordinate in window
171 * width:
172 * width of area in window
173 * height:
174 * height of area in window
175 * Returns:
176 * a new GdkImage or NULL
178 public static GdkImage* get(Drawable drawable, int x, int y, int width, int height)
180 // GdkImage* gdk_image_get (GdkDrawable *drawable, gint x, gint y, gint width, gint height);
181 return gdk_image_get((drawable is null) ? null : drawable.getDrawableStruct(), x, y, width, height);
185 * Warning
186 * gdk_image_ref is deprecated and should not be used in newly-written code.
187 * Deprecated function; use g_object_ref() instead.
188 * image:
189 * a GdkImage
190 * Returns:
191 * the image
193 public GdkImage* ref()
195 // GdkImage* gdk_image_ref (GdkImage *image);
196 return gdk_image_ref(gdkImage);
200 * Warning
201 * gdk_image_unref is deprecated and should not be used in newly-written code.
202 * Deprecated function; use g_object_unref() instead.
203 * image:
204 * a GdkImage
206 public void unref()
208 // void gdk_image_unref (GdkImage *image);
209 gdk_image_unref(gdkImage);
214 * Retrieves the colormap for a given image, if it exists. An image
215 * will have a colormap if the drawable from which it was created has
216 * a colormap, or if a colormap was set explicitely with
217 * gdk_image_set_colormap().
218 * image:
219 * a GdkImage
220 * Returns:
221 * colormap for the image
223 public Colormap getColormap()
225 // GdkColormap* gdk_image_get_colormap (GdkImage *image);
226 return new Colormap( gdk_image_get_colormap(gdkImage) );
230 * Sets the colormap for the image to the given colormap. Normally
231 * there's no need to use this function, images are created with the
232 * correct colormap if you get the image from a drawable. If you
233 * create the image from scratch, use the colormap of the drawable you
234 * intend to render the image to.
235 * image:
236 * a GdkImage
237 * colormap:
238 * a GdkColormap
240 public void setColormap(Colormap colormap)
242 // void gdk_image_set_colormap (GdkImage *image, GdkColormap *colormap);
243 gdk_image_set_colormap(gdkImage, (colormap is null) ? null : colormap.getColormapStruct());
247 * Sets a pixel in a GdkImage to a given pixel value.
248 * image:
249 * a GdkImage.
250 * x:
251 * the x coordinate of the pixel to set.
252 * y:
253 * the y coordinate of the pixel to set.
254 * pixel:
255 * the pixel value to set.
257 public void putPixel(int x, int y, uint pixel)
259 // void gdk_image_put_pixel (GdkImage *image, gint x, gint y, guint32 pixel);
260 gdk_image_put_pixel(gdkImage, x, y, pixel);
264 * Gets a pixel value at a specified position in a GdkImage.
265 * image:
266 * a GdkImage.
267 * x:
268 * the x coordinate of the pixel to get.
269 * y:
270 * the y coordinate of the pixel to get.
271 * Returns:
272 * the pixel value at the given position.
273 * See Also
274 * Bitmaps and Pixmaps
275 * Graphics which are stored on the X Windows server.
276 * Since these are stored on the server they can be drawn very quickly, and all
277 * of the Drawing Primitives can be
278 * used to draw on them. Their main disadvantage is that manipulating individual
279 * pixels can be very slow.
280 * GdkRGB
281 * Built on top of GdkImage, this provides much more functionality,
282 * including the dithering of colors to produce better output on low-color
283 * displays.
285 public uint getPixel(int x, int y)
287 // guint32 gdk_image_get_pixel (GdkImage *image, gint x, gint y);
288 return gdk_image_get_pixel(gdkImage, x, y);