Images

Images — A client-side area for bit-mapped graphics

Synopsis

#include <gdk/gdk.h>

                    GdkImage;
GdkImage*           gdk_image_new                       (GdkImageType type,
                                                         GdkVisual *visual,
                                                         gint width,
                                                         gint height);
enum                GdkImageType;
GdkColormap*        gdk_image_get_colormap              (GdkImage *image);
void                gdk_image_set_colormap              (GdkImage *image,
                                                         GdkColormap *colormap);
guint16             gdk_image_get_bits_per_pixel        (GdkImage *image);
guint16             gdk_image_get_bytes_per_pixel       (GdkImage *image);
guint16             gdk_image_get_bytes_per_line        (GdkImage *image);
GdkByteOrder        gdk_image_get_byte_order            (GdkImage *image);
guint16             gdk_image_get_depth                 (GdkImage *image);
gint                gdk_image_get_height                (GdkImage *image);
GdkImageType        gdk_image_get_image_type            (GdkImage *image);
GdkVisual *         gdk_image_get_visual                (GdkImage *image);
gint                gdk_image_get_width                 (GdkImage *image);

void                gdk_image_put_pixel                 (GdkImage *image,
                                                         gint x,
                                                         gint y,
                                                         guint32 pixel);
guint32             gdk_image_get_pixel                 (GdkImage *image,
                                                         gint x,
                                                         gint y);

Description

The GdkImage 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 GdkImage use gdk_image_new(). To create an image from part of a GdkWindow 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 GdkImage in a GdkWindow or GdkPixmap use gdk_draw_image().

To destroy a GdkImage use g_object_unref().

Details

GdkImage

typedef struct {
  GObject parent_instance;

  
  GdkImageType GSEAL (type); /* read only. */
  GdkVisual    *GSEAL (visual);	    /* read only. visual used to create the image */
  GdkByteOrder GSEAL (byte_order); /* read only. */
  gint		GSEAL (width);  /* read only. */
  gint		GSEAL (height); /* read only. */
  guint16 GSEAL (depth);  /* read only. */
  guint16 GSEAL (bpp);    /* read only. bytes per pixel */
  guint16 GSEAL (bpl);    /* read only. bytes per line */
  guint16       GSEAL (bits_per_pixel); /* read only. bits per pixel */
  gpointer GSEAL (mem);

  GdkColormap  *GSEAL (colormap); /* read only. */
} GdkImage;

The GdkImage struct contains information on the image and the pixel data.

GObject parent_instance;

the parent instance

gdk_image_new ()

GdkImage*           gdk_image_new                       (GdkImageType type,
                                                         GdkVisual *visual,
                                                         gint width,
                                                         gint height);

Creates a new GdkImage.

type :

the type of the GdkImage, 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 GdkVisual to use for the image.

width :

the width of the image in pixels.

height :

the height of the image in pixels.

Returns :

a new GdkImage, or NULL if the image could not be created.

enum GdkImageType

typedef enum
{
  GDK_IMAGE_NORMAL,
  GDK_IMAGE_SHARED,
  GDK_IMAGE_FASTEST
} GdkImageType;

Specifies the type of a GdkImage.

GDK_IMAGE_NORMAL

The original X image type, which is quite slow since the image has to be transferred from the client to the server to display it.

GDK_IMAGE_SHARED

A faster image type, which uses shared memory to transfer the image data between client and server. However this will only be available if client and server are on the same machine and the shared memory extension is supported by the server.

GDK_IMAGE_FASTEST

Specifies that GDK_IMAGE_SHARED should be tried first, and if that fails then GDK_IMAGE_NORMAL will be used.

gdk_image_get_colormap ()

GdkColormap*        gdk_image_get_colormap              (GdkImage *image);

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 GdkImage

Returns :

colormap for the image

gdk_image_set_colormap ()

void                gdk_image_set_colormap              (GdkImage *image,
                                                         GdkColormap *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 GdkImage

colormap :

a GdkColormap

gdk_image_get_bits_per_pixel ()

guint16             gdk_image_get_bits_per_pixel        (GdkImage *image);

Determines the number of bits per pixel of the image.

image :

a GdkImage

Returns :

the bits per pixel

Since 2.22


gdk_image_get_bytes_per_pixel ()

guint16             gdk_image_get_bytes_per_pixel       (GdkImage *image);

Determines the number of bytes per pixel of the image.

image :

a GdkImage

Returns :

the bytes per pixel

Since 2.22


gdk_image_get_bytes_per_line ()

guint16             gdk_image_get_bytes_per_line        (GdkImage *image);

Determines the number of bytes per line of the image.

image :

a GdkImage

Returns :

the bytes per line

Since 2.22


gdk_image_get_byte_order ()

GdkByteOrder        gdk_image_get_byte_order            (GdkImage *image);

Determines the byte order of the image.

image :

a GdkImage

Returns :

a GdkVisual

Since 2.22


gdk_image_get_depth ()

guint16             gdk_image_get_depth                 (GdkImage *image);

Determines the depth of the image.

image :

a GdkImage

Returns :

the depth

Since 2.22


gdk_image_get_height ()

gint                gdk_image_get_height                (GdkImage *image);

Determines the height of the image.

image :

a GdkImage

Returns :

the height

Since 2.22


gdk_image_get_image_type ()

GdkImageType        gdk_image_get_image_type            (GdkImage *image);

Determines the type of a given image.

image :

a GdkImage

Returns :

the GdkImageType of the image

Since 2.22


gdk_image_get_visual ()

GdkVisual *         gdk_image_get_visual                (GdkImage *image);

Determines the visual that was used to create the image.

image :

a GdkImage

Returns :

a GdkVisual

Since 2.22


gdk_image_get_width ()

gint                gdk_image_get_width                 (GdkImage *image);

Determines the width of the image.

image :

a GdkImage

Returns :

the width

Since 2.22


gdk_image_put_pixel ()

void                gdk_image_put_pixel                 (GdkImage *image,
                                                         gint x,
                                                         gint y,
                                                         guint32 pixel);

Sets a pixel in a GdkImage to a given pixel value.

image :

a GdkImage.

x :

the x coordinate of the pixel to set.

y :

the y coordinate of the pixel to set.

pixel :

the pixel value to set.

gdk_image_get_pixel ()

guint32             gdk_image_get_pixel                 (GdkImage *image,
                                                         gint x,
                                                         gint y);

Gets a pixel value at a specified position in a GdkImage.

image :

a GdkImage.

x :

the x coordinate of the pixel to get.

y :

the y coordinate of the pixel to get.

Returns :

the pixel value at the given position.

See Also

Bitmaps and Pixmaps

Graphics which are stored on the X Windows server. Since these are stored on the server they can be drawn very quickly, and all of the Drawing Primitives can be used to draw on them. Their main disadvantage is that manipulating individual pixels can be very slow.

GdkRGB

Built on top of GdkImage, this provides much more functionality, including the dithering of colors to produce better output on low-color displays.