Next: , Previous: GdkRGB, Up: Top


11 Images

A client-side area for bit-mapped graphics

11.1 Overview

The <gdk-image> type represents an area for drawing graphics. It has now been superceded to a large extent by the much more flexible GdkRGB functions.

To create an empty <gdk-image> use gdk-image-new. To create a <gdk-image> from bitmap data use gdk-image-new-bitmap. To create an image from part of a <gdk-window> use gdk-drawable-get-image.

The image can be manipulated with gdk-image-get-pixel and gdk-image-put-pixel, or alternatively by changing the actual pixel data. Though manipulating the pixel data requires complicated code to cope with the different formats that may be used.

To draw a <gdk-image> in a <gdk-window> or <gdk-pixmap> use gdk-draw-image.

To destroy a <gdk-image> use gdk-image-destroy.

11.2 Usage

— Class: <gdk-image>

Derives from <gobject>.

This class defines no direct slots.

— Function: gdk-image-new (type <gdk-image-type>) (visual <gdk-visual>) (width int) (height int) ⇒  (ret <gdk-image>)

Creates a new <gdk-image>.

type
the type of the <gdk-image>, one of ‘GDK_IMAGE_NORMAL’, ‘GDK_IMAGE_SHARED’ and ‘GDK_IMAGE_FASTEST’. ‘GDK_IMAGE_FASTEST’ is probably the best choice, since it will try creating a ‘GDK_IMAGE_SHARED’ image first and if that fails it will then use ‘GDK_IMAGE_NORMAL’.
visual
the <gdk-visual> to use for the image.
width
the width of the image in pixels.
height
the height of the image in pixels.
ret
a new <gdk-image>, or ‘#f’ if the image could not be created.
— Function: gdk-image-get (drawable <gdk-drawable>) (int) (int) (width int) (height int) ⇒  (ret <gdk-image>)

gdk_image_get’ is deprecated and should not be used in newly-written code.

This is a deprecated wrapper for gdk-drawable-get-image; gdk-drawable-get-image should be used instead. Or even better: in most cases gdk-pixbuf-get-from-drawable is the most convenient choice.

drawable
a <gdk-drawable>
x
x coordinate in window
y
y coordinate in window
width
width of area in window
height
height of area in window
ret
a new <gdk-image> or ‘#f
— Function: gdk-image-get-colormap (self <gdk-image>) ⇒  (ret <gdk-colormap>)
— Method: get-colormap

Retrieves the colormap for a given image, if it exists. An image will have a colormap if the drawable from which it was created has a colormap, or if a colormap was set explicitely with gdk-image-set-colormap.

image
a <gdk-image>
ret
colormap for the image
— Function: gdk-image-set-colormap (self <gdk-image>) (colormap <gdk-colormap>)
— Method: set-colormap

Sets the colormap for the image to the given colormap. Normally there's no need to use this function, images are created with the correct colormap if you get the image from a drawable. If you create the image from scratch, use the colormap of the drawable you intend to render the image to.

image
a <gdk-image>
colormap
a <gdk-colormap>
— Function: gdk-image-put-pixel (self <gdk-image>) (int) (int) (pixel unsigned-int32)
— Method: put-pixel

Sets a pixel in a <gdk-image> to a given pixel value.

image
a <gdk-image>.
x
the x coordinate of the pixel to set.
y
the y coordinate of the pixel to set.
pixel
the pixel value to set.
— Function: gdk-image-get-pixel (self <gdk-image>) (int) (int) ⇒  (ret unsigned-int32)
— Method: get-pixel

Gets a pixel value at a specified position in a <gdk-image>.

image
a <gdk-image>.
x
the x coordinate of the pixel to get.
y
the y coordinate of the pixel to get.
ret
the pixel value at the given position.