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-GdkRGB.html
50 * - GdkColor* -> Color
51 * - GdkColormap* -> Colormap
52 * - GdkDrawable* -> Drawable
54 * - GdkVisual* -> Visual
60 private import gdk
.gdktypes
;
62 private import lib
.gdk
;
64 private import gdk
.Drawable
;
65 private import gdk
.GC
;
66 private import gdk
.Colormap
;
67 private import gdk
.Color
;
68 private import gdk
.Visual
;
72 * GdkRGB is a low-level module which renders RGB, grayscale, and indexed
73 * colormap images to a GdkDrawable. It does this as efficiently as
74 * possible, handling issues such as colormaps, visuals, dithering,
75 * temporary buffers, and so on. Most code should use the higher-level
76 * GdkPixbuf features in place of this module; for example,
77 * gdk_pixbuf_render_to_drawable() uses GdkRGB in its implementation.
78 * GdkRGB allocates a color cube to use when rendering images. You can
79 * set the threshold for installing colormaps with
80 * gdk_rgb_set_min_colors(). The default is 5x5x5 (125). If a colorcube
81 * of this size or larger can be allocated in the default colormap, then
82 * that's done. Otherwise, GdkRGB creates its own private colormap.
83 * Setting it to 0 means that it always tries to use the default
84 * colormap, and setting it to 216 means that it always creates a private
85 * one if it cannot allocate the 6x6x6 colormap in the default. If you
86 * always want a private colormap (to avoid consuming too many colormap
87 * entries for other apps, say), you can use
88 * gdk_rgb_set_install(TRUE).
89 * Setting the value greater than 216 exercises a bug in older versions
90 * of GdkRGB. Note, however, that setting it to 0 doesn't let you get
91 * away with ignoring the colormap and visual - a colormap is always
92 * created in grayscale and direct color modes, and the visual is changed
93 * in cases where a "better" visual than the default is available.
94 * Example4.A simple example program using GdkRGB
95 * #include <gtk/gtk.h>
96 * #define IMAGE_WIDTH 256
97 * #define IMAGE_HEIGHT 256
98 * guchar rgbbuf[IMAGE_WIDTH * IMAGE_HEIGHT * 3];
99 * gboolean on_darea_expose (GtkWidget *widget,
100 * GdkEventExpose *event,
101 * gpointer user_data);
103 * main (int argc, char *argv[])
105 * GtkWidget *window, *darea;
108 * gtk_init (argc, argv);
109 * window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
110 * darea = gtk_drawing_area_new ();
111 * gtk_widget_set_size_request (darea, IMAGE_WIDTH, IMAGE_HEIGHT);
112 * gtk_container_add (GTK_CONTAINER (window), darea);
113 * gtk_signal_connect (GTK_OBJECT (darea), "expose-event",
114 * GTK_SIGNAL_FUNC (on_darea_expose), NULL);
115 * gtk_widget_show_all (window);
116 * /+* Set up the RGB buffer. +/
118 * for (y = 0; y < IMAGE_HEIGHT; y++)
120 * for (x = 0; x < IMAGE_WIDTH; x++)
122 * *pos++ = x - x % 32; /+* Red. +/
123 * *pos++ = (x / 32) * 4 + y - y % 32; /+* Green. +/
124 * *pos++ = y - y % 32; /+* Blue. +/
131 * on_darea_expose (GtkWidget *widget,
132 * GdkEventExpose *event,
133 * gpointer user_data)
135 * gdk_draw_rgb_image (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
136 * 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
137 * GDK_RGB_DITHER_MAX, rgbbuf, IMAGE_WIDTH * 3);
149 * gdk_rgb_init is deprecated and should not be used in newly-written code.
150 * This function no longer does anything at all. It's completely useless
153 public static void rgbInit()
155 // void gdk_rgb_init (void);
160 * Draws an RGB image in the drawable. This is the core GdkRGB
161 * function, and likely the only one you will need to use.
162 * The rowstride parameter allows for lines to be aligned more flexibly.
163 * For example, lines may be allocated to begin on 32-bit boundaries,
164 * even if the width of the rectangle is odd. Rowstride is also useful
165 * when drawing a subrectangle of a larger image in memory. Finally, to
166 * replicate the same line a number of times, the trick of setting
167 * rowstride to 0 is allowed.
168 * In general, for 0 <= i < width and 0 <= j < height,
169 * the pixel (x + i, y + j) is colored with red value rgb_buf[j *
170 * rowstride + i * 3], green value rgb_buf[j * rowstride + i * 3 +
171 * 1], and blue value rgb_buf[j * rowstride + i * 3 + 2].
173 * The GdkDrawable to draw in (usually a GdkWindow).
175 * The graphics context (all GDK drawing operations require one; its
176 * contents are ignored).
178 * The x coordinate of the top-left corner in the drawable.
180 * The y coordinate of the top-left corner in the drawable.
182 * The width of the rectangle to be drawn.
184 * The height of the rectangle to be drawn.
186 * A GdkRgbDither value, selecting the desired dither mode.
188 * The pixel data, represented as packed 24-bit data.
190 * The number of bytes from the start of one row in rgb_buf to the
193 public static void drawRgbImage(Drawable drawable
, GC gc
, int x
, int y
, int width
, int height
, GdkRgbDither dith
, char* rgbBuf
, int rowstride
)
195 // void gdk_draw_rgb_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *rgb_buf, gint rowstride);
196 gdk_draw_rgb_image((drawable
is null) ?
null : drawable
.getDrawableStruct(), (gc
is null) ?
null : gc
.getGCStruct(), x
, y
, width
, height
, dith
, rgbBuf
, rowstride
);
200 * Draws an RGB image in the drawable, with an adjustment for dither alignment.
201 * This function is useful when drawing dithered images into a window
202 * that may be scrolled. Pixel (x, y) will be drawn dithered as if its
203 * actual location is (x + xdith, y + ydith). Thus, if you draw an
204 * image into a window using zero dither alignment, then scroll up one
205 * pixel, subsequent draws to the window should have ydith = 1.
206 * Setting the dither alignment correctly allows updating of small parts
207 * of the screen while avoiding visible "seams" between the different
210 * The GdkDrawable to draw in (usually a GdkWindow).
212 * The graphics context.
214 * The x coordinate of the top-left corner in the drawable.
216 * The y coordinate of the top-left corner in the drawable.
218 * The width of the rectangle to be drawn.
220 * The height of the rectangle to be drawn.
222 * A GdkRgbDither value, selecting the desired dither mode.
224 * The pixel data, represented as packed 24-bit data.
226 * The number of bytes from the start of one row in rgb_buf to the
229 * An x offset for dither alignment.
231 * A y offset for dither alignment.
233 public static void drawRgbImageDithalign(Drawable drawable
, GC gc
, int x
, int y
, int width
, int height
, GdkRgbDither dith
, char* rgbBuf
, int rowstride
, int xdith
, int ydith
)
235 // void gdk_draw_rgb_image_dithalign (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *rgb_buf, gint rowstride, gint xdith, gint ydith);
236 gdk_draw_rgb_image_dithalign((drawable
is null) ?
null : drawable
.getDrawableStruct(), (gc
is null) ?
null : gc
.getGCStruct(), x
, y
, width
, height
, dith
, rgbBuf
, rowstride
, xdith
, ydith
);
240 * Draws an indexed image in the drawable, using a GdkRgbCmap to assign
241 * actual colors to the color indices.
243 * The GdkDrawable to draw in (usually a GdkWindow).
245 * The graphics context.
247 * The x coordinate of the top-left corner in the drawable.
249 * The y coordinate of the top-left corner in the drawable.
251 * The width of the rectangle to be drawn.
253 * The height of the rectangle to be drawn.
255 * A GdkRgbDither value, selecting the desired dither mode.
257 * The pixel data, represented as 8-bit color indices.
259 * The number of bytes from the start of one row in buf to the
262 * The GdkRgbCmap used to assign colors to the color indices.
264 public static void drawIndexedImage(Drawable drawable
, GC gc
, int x
, int y
, int width
, int height
, GdkRgbDither dith
, char* buf
, int rowstride
, GdkRgbCmap
* cmap
)
266 // void gdk_draw_indexed_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride, GdkRgbCmap *cmap);
267 gdk_draw_indexed_image((drawable
is null) ?
null : drawable
.getDrawableStruct(), (gc
is null) ?
null : gc
.getGCStruct(), x
, y
, width
, height
, dith
, buf
, rowstride
, cmap
);
271 * Draws a grayscale image in the drawable.
273 * The GdkDrawable to draw in (usually a GdkWindow).
275 * The graphics context.
277 * The x coordinate of the top-left corner in the drawable.
279 * The y coordinate of the top-left corner in the drawable.
281 * The width of the rectangle to be drawn.
283 * The height of the rectangle to be drawn.
285 * A GdkRgbDither value, selecting the desired dither mode.
287 * The pixel data, represented as 8-bit gray values.
289 * The number of bytes from the start of one row in buf to the
292 public static void drawGrayImage(Drawable drawable
, GC gc
, int x
, int y
, int width
, int height
, GdkRgbDither dith
, char* buf
, int rowstride
)
294 // void gdk_draw_gray_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride);
295 gdk_draw_gray_image((drawable
is null) ?
null : drawable
.getDrawableStruct(), (gc
is null) ?
null : gc
.getGCStruct(), x
, y
, width
, height
, dith
, buf
, rowstride
);
299 * Draws a padded RGB image in the drawable. The image is stored as one
300 * pixel per 32-bit word. It is laid out as a red byte, a green byte, a
301 * blue byte, and a padding byte.
302 * It's unlikely that this function will give significant performance
303 * gains in practice. In my experience, the performance gain from having
304 * pixels aligned to 32-bit boundaries is cancelled out by the increased
307 * The GdkDrawable to draw in (usually a GdkWindow).
309 * The graphics context.
311 * The x coordinate of the top-left corner in the drawable.
313 * The y coordinate of the top-left corner in the drawable.
315 * The width of the rectangle to be drawn.
317 * The height of the rectangle to be drawn.
319 * A GdkRgbDither value, selecting the desired dither mode.
321 * The pixel data, represented as padded 32-bit data.
323 * The number of bytes from the start of one row in buf to the
326 public static void drawRgb32_Image(Drawable drawable
, GC gc
, int x
, int y
, int width
, int height
, GdkRgbDither dith
, char* buf
, int rowstride
)
328 // void gdk_draw_rgb_32_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride);
329 gdk_draw_rgb_32_image((drawable
is null) ?
null : drawable
.getDrawableStruct(), (gc
is null) ?
null : gc
.getGCStruct(), x
, y
, width
, height
, dith
, buf
, rowstride
);
333 * Like gdk_draw_rgb_32_image(), but allows you to specify the dither
334 * offsets. See gdk_draw_rgb_image_dithalign() for more details.
340 * X coordinate on drawable where image should go
342 * Y coordinate on drawable where image should go
344 * width of area of image to draw
346 * height of area of image to draw
352 * rowstride of RGB image data
358 public static void drawRgb32_ImageDithalign(Drawable drawable
, GC gc
, int x
, int y
, int width
, int height
, GdkRgbDither dith
, char* buf
, int rowstride
, int xdith
, int ydith
)
360 // void gdk_draw_rgb_32_image_dithalign (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride, gint xdith, gint ydith);
361 gdk_draw_rgb_32_image_dithalign((drawable
is null) ?
null : drawable
.getDrawableStruct(), (gc
is null) ?
null : gc
.getGCStruct(), x
, y
, width
, height
, dith
, buf
, rowstride
, xdith
, ydith
);
366 * Creates a new GdkRgbCmap structure. The cmap maps color indexes to
367 * RGB colors. If n_colors is less than 256, then images containing
368 * color values greater than or equal to n_colors will produce undefined
369 * results, including possibly segfaults.
371 * The colors, represented as 0xRRGGBB integer values.
373 * The number of colors in the cmap.
375 * The newly created GdkRgbCmap
377 public static GdkRgbCmap
* rgbCmapNew(uint* colors
, int nColors
)
379 // GdkRgbCmap* gdk_rgb_cmap_new (guint32 *colors, gint n_colors);
380 return gdk_rgb_cmap_new(colors
, nColors
);
384 * Frees the memory associated with a GdkRgbCmap created by gdk_rgb_cmap_new().
386 * The GdkRgbCmap to free.
388 public static void rgbCmapFree(GdkRgbCmap
* cmap
)
390 // void gdk_rgb_cmap_free (GdkRgbCmap *cmap);
391 gdk_rgb_cmap_free(cmap
);
397 * gdk_rgb_gc_set_foreground is deprecated and should not be used in newly-written code.
398 * Sets the foreground color in gc to the specified color (or the
399 * closest approximation, in the case of limited visuals).
401 * The GdkGC to modify.
403 * The color, represented as a 0xRRGGBB integer value.
405 public static void rgbGcSetForeground(GC gc
, uint rgb
)
407 // void gdk_rgb_gc_set_foreground (GdkGC *gc, guint32 rgb);
408 gdk_rgb_gc_set_foreground((gc
is null) ?
null : gc
.getGCStruct(), rgb
);
413 * gdk_rgb_gc_set_background is deprecated and should not be used in newly-written code.
414 * Sets the background color in gc to the specified color (or the
415 * closest approximation, in the case of limited visuals).
417 * The GdkGC to modify.
419 * The color, represented as a 0xRRGGBB integer value.
421 public static void rgbGcSetBackground(GC gc
, uint rgb
)
423 // void gdk_rgb_gc_set_background (GdkGC *gc, guint32 rgb);
424 gdk_rgb_gc_set_background((gc
is null) ?
null : gc
.getGCStruct(), rgb
);
429 * gdk_rgb_xpixel_from_rgb is deprecated and should not be used in newly-written code.
430 * Finds the X pixel closest in color to the rgb color specified. This
431 * value may be used to set the pixel field of
434 * The color, represented as a 0xRRGGBB integer value.
438 public static uint rgbXpixelFromRgb(uint rgb
)
440 // gulong gdk_rgb_xpixel_from_rgb (guint32 rgb);
441 return gdk_rgb_xpixel_from_rgb(rgb
);
445 * colormap should be the colormap for the graphics context and
446 * drawable you're using to draw. If you're drawing to a GtkWidget,
447 * call gtk_widget_get_colormap().
448 * color should have its red, green, and blue fields initialized;
449 * gdk_rgb_find_color() will fill in the pixel field with the best
450 * matching pixel from a color cube. The color is then ready to be
451 * used for drawing, e.g. you can call gdk_gc_set_foreground() which
452 * expects pixel to be initialized.
453 * In many cases, you can avoid this whole issue by calling
454 * gdk_gc_set_rgb_fg_color() or gdk_gc_set_rgb_bg_color(), which
455 * do not expect pixel to be initialized in advance. If you use those
456 * functions, there's no need for gdk_rgb_find_color().
462 public static void rgbFindColor(Colormap colormap
, Color color
)
464 // void gdk_rgb_find_color (GdkColormap *colormap, GdkColor *color);
465 gdk_rgb_find_color((colormap
is null) ?
null : colormap
.getColormapStruct(), (color
is null) ?
null : color
.getColorStruct());
469 * If install is TRUE, directs GdkRGB to always install a new "private"
470 * colormap rather than trying to find a best fit with the colors already
471 * allocated. Ordinarily, GdkRGB will install a colormap only if a
472 * sufficient cube cannot be allocated.
473 * A private colormap has more colors, leading to better quality display,
474 * but also leads to the dreaded "colormap flashing" effect.
476 * TRUE to set install mode.
478 public static void rgbSetInstall(int install
)
480 // void gdk_rgb_set_install (gboolean install);
481 gdk_rgb_set_install(install
);
485 * Sets the minimum number of colors for the color cube. Generally,
486 * GdkRGB tries to allocate the largest color cube it can. If it can't
487 * allocate a color cube at least as large as min_colors, it installs a
490 * The minimum number of colors accepted.
492 public static void rgbSetMinColors(int minColors
)
494 // void gdk_rgb_set_min_colors (gint min_colors);
495 gdk_rgb_set_min_colors(minColors
);
499 * Gets a "preferred visual" chosen by GdkRGB for rendering image data
500 * on the default screen. In previous versions of GDK, this was the
501 * only visual GdkRGB could use for rendering. In current versions,
502 * it's simply the visual GdkRGB would have chosen as the optimal one
503 * in those previous versions. GdkRGB can now render to drawables with
506 * The GdkVisual chosen by GdkRGB.
508 public static Visual
rgbGetVisual()
510 // GdkVisual* gdk_rgb_get_visual (void);
511 return new Visual( gdk_rgb_get_visual() );
515 * Get the preferred colormap for rendering image data. Not a
516 * very useful function; historically, GDK could only render RGB image
517 * data to one colormap and visual, but in the current version it can
518 * render to any colormap and visual. So there's no need to call this
521 * the preferred colormap
523 public static Colormap
rgbGetColormap()
525 // GdkColormap* gdk_rgb_get_colormap (void);
526 return new Colormap( gdk_rgb_get_colormap() );
531 * Determines whether the preferred visual is ditherable. This function may be
532 * useful for presenting a user interface choice to the user about which
533 * dither mode is desired; if the display is not ditherable, it may make
534 * sense to gray out or hide the corresponding UI widget.
536 * TRUE if the preferred visual is ditherable.
538 public static int rgbDitherable()
540 // gboolean gdk_rgb_ditherable (void);
541 return gdk_rgb_ditherable();
545 * Determines whether the visual associated with cmap is ditherable. This
546 * function may be useful for presenting a user interface choice to the user
547 * about which dither mode is desired; if the display is not ditherable, it may
548 * make sense to gray out or hide the corresponding UI widget.
552 * TRUE if the visual associated with cmap is ditherable.
554 public static int rgbColormapDitherable(Colormap cmap
)
556 // gboolean gdk_rgb_colormap_ditherable (GdkColormap *cmap);
557 return gdk_rgb_colormap_ditherable((cmap
is null) ?
null : cmap
.getColormapStruct());
561 * Sets the "verbose" flag. This is generally only useful for debugging.
563 * TRUE if verbose messages are desired.
566 * The underlying GDK mechanism for allocating
568 * GdkPixbuf and gdk_pixbuf_render_to_drawable()
569 * Higher-level image handling.
571 public static void rgbSetVerbose(int verbose
)
573 // void gdk_rgb_set_verbose (gboolean verbose);
574 gdk_rgb_set_verbose(verbose
);