Next: , Previous: Package_Gdk.Pixmap, Up: Top



Package Gdk.Rgb

This package implements a client-side pixmap. As opposed to the pixmaps found in Gdk.Pixmap, this one simply implements a local buffer, which can be manipulated at the pixel level easily. This buffer then needs to be sent to the server. The major efficiency difference is that the same amount of data needs to be sent to the server no matter how much things were modified. Gdk.Pixmaps requires one communication with the server per drawing function. Some X servers are also optimized so that the buffers in this package can be implemented in shared memory with the server, which of course makes it much faster to transfer the data. This package is basically an implementation of XImage (on X-Window), which means that it handles transparently different depths, byte ordering,... It also provides some color dithering functions.

See the commands Get_Visual and Get_Cmap below on how to use the colormaps and visual with this package

Dithering simulates a higher number of colors than what is available on the current visual (only for 8-bit and 16-bit displays).

Types

type Gdk_Rgb_Cmap is new Gdk.C_Proxy;

This is the full colormap, ie a set of 256 Rgb items. You can extract values using the functions Get or Set below.



type Gdk_Rgb_Dither is
(Dither_None, Dither_Normal, Dither_Max);

The three kinds of dithering that are implemented in this package: - Dither_None: No dithering will be done - Dither_Normal: Specifies dithering on 8 bit displays, but not 16-bit. Usually the best choice. - Dither_Max: Specifies dithering on every kind of display for Gdk_Rgb_Dither'Size use Glib.Gint'Size;



type Rgb_Buffer is array (Natural) of Glib.Guchar;





type Rgb_Buffer_Access is access all Rgb_Buffer;





type Rgb_Cmap_Index is new Natural range 0 .. 255;





subtype Rgb_Item is Glib.Guint32;

This represents the coding for a rbg value. The exact encoding depends on the visual used and its depth (pseudo-color, true-color, ...)


Subprograms
function Get_Visual return Gdk.Visual.Gdk_Visual;
See Get_Cmap.

function Get_Cmap return Gdk.Color.Gdk_Colormap;
Return the visual and the color map used internally in this package.
Note that these are not the same as returned by Gtk.Widget or Gdk.Window, and you should use these if you are using this package.

The drawable you intend to copy the RGB buffer to must use this visual and this colormap. Therefore, before creating the widget, you need to do the following:

  • Gtk.Widget.Push_Visual (Gdk.Rgb.Get_Visual);
  • Gtk.Widget.Push_Colormap (Gdk.Rgb.Get_Cmap);
  • Gtk_New (....)
  • Gtk.Widget.Pop_Visual;
  • Gtk.Widget.Pop_Colormap;

Color manipulation


function Xpixel_From_Rgb (Value : in Rgb_Item) return Glib.Gulong;
Convert the Rgb representation to the usual one found in Gdk.Color.
pragma Deprecated (Xpixel_From_Rgb);

procedure GC_Set_Foreground (GC : Gdk.GC.Gdk_GC; Value : Rgb_Item);
See GC_Set_Background.
pragma Deprecated (GC_Set_Foreground);

procedure GC_Set_Background (GC : Gdk.GC.Gdk_GC; Value : Rgb_Item);
Modify the foreground and the background of a graphic context with a
value. These are exactly the same functions has found in Gdk.Gc, but do not use the same parameters. pragma Deprecated (GC_Set_Background);

Colormap manipulation


function Get (Cmap : Gdk_Rgb_Cmap; Index : Rgb_Cmap_Index) return Rgb_Item;
Access an item in a colormap.

procedure Set (Cmap : Gdk_Rgb_Cmap; Index : Rgb_Cmap_Index; Value : Rgb_Item);
Set an item in Cmap.

procedure Gdk_New (Cmap : out Gdk_Rgb_Cmap; Colors : Glib.Guint32_Array);
Create a colormap.

procedure Free (Cmap : Gdk_Rgb_Cmap);
Free a colormap.

Drawing Images


procedure Draw_Rgb_Image (Drawable : Gdk.Drawable.Gdk_Drawable; GC : Gdk.GC.Gdk_GC; X, Y : Glib.Gint; Width, Height : Glib.Gint; Dith : Gdk_Rgb_Dither; Rgb_Buf : Rgb_Buffer; Rowstride : Glib.Gint);
Render a Gdk buffer with 24 bit Data.
Such a buffer is a one dimensional array of bytes, where every byte triplet makes up a pixel (byte 0 is red, byte 1 is green and byte 2 is blue).
  • Width: Number of pixels (byte triplets) per row of the image.
  • Height: Number of rows in the image.
  • RowStride: Number of bytes between rows... (row n+1 will start at byte row n + Rowstride). Gdk.Rgb is faster if both the source pointer and the rowstride are aligned to a 4 byte boundary.
  • (X, Y, Width, Height): Define a region in the target to copy the buffer to.

procedure Draw_Rgb_Image_Dithalign (Drawable : Gdk.Drawable.Gdk_Drawable; GC : Gdk.GC.Gdk_GC; X, Y : Glib.Gint; Width, Height : Glib.Gint; Dith : Gdk_Rgb_Dither; Rgb_Buf : Rgb_Buffer; Rowstride : Glib.Gint; Xdith, Ydith : Glib.Gint);
Same kind of function as above, but for different buffer types (???).

procedure Draw_Rgb_32_Image (Drawable : Gdk.Drawable.Gdk_Drawable; GC : Gdk.GC.Gdk_GC; X, Y : Glib.Gint; Width, Height : Glib.Gint; Dith : Gdk_Rgb_Dither; Rgb_Buf : Rgb_Buffer; Rowstride : Glib.Gint);
Same kind of function as above, but for different buffer types (???).

procedure Draw_Rgb_32_Image_Dithalign (Drawable : Gdk.Drawable.Gdk_Drawable; GC : Gdk.GC.Gdk_GC; X, Y : Glib.Gint; Width, Height : Glib.Gint; Dith : Gdk_Rgb_Dither; Rgb_Buf : Rgb_Buffer; Rowstride : Glib.Gint; Xdith, Ydith : Glib.Gint);
Same kind of function as above, but for different buffer types (???).

procedure Draw_Gray_Image (Drawable : Gdk.Drawable.Gdk_Drawable; GC : Gdk.GC.Gdk_GC; X, Y : Glib.Gint; Width, Height : Glib.Gint; Dith : Gdk_Rgb_Dither; Rgb_Buf : Rgb_Buffer; Rowstride : Glib.Gint);
Same kind of function as above, but for different buffer types (???).

procedure Draw_Indexed_Image (Drawable : Gdk.Drawable.Gdk_Drawable; GC : Gdk.GC.Gdk_GC; X, Y : Glib.Gint; Width, Height : Glib.Gint; Dith : Gdk_Rgb_Dither; Rgb_Buf : Rgb_Buffer; Rowstride : Glib.Gint; Cmap : Gdk_Rgb_Cmap);
Same kind of function as above, but for different buffer types (???).