GDK Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# Color Contexts

## Name

Color Contexts -- routines for allocating colors (deprecated).

## Synopsis

    #include <gdk/gdk.h>

    struct      GdkColorContext;
    struct      GdkColorContextDither;
    enum        GdkColorContextMode;
    GdkColorContext* gdk_color_context_new      (GdkVisual *visual,
                                                 GdkColormap *colormap);
    GdkColorContext* gdk_color_context_new_mono (GdkVisual *visual,
                                                 GdkColormap *colormap);
    void        gdk_color_context_free          (GdkColorContext *cc);
    gulong      gdk_color_context_get_pixel     (GdkColorContext *cc,
                                                 gushort red,
                                                 gushort green,
                                                 gushort blue,
                                                 gint *failed);
    void        gdk_color_context_get_pixels    (GdkColorContext *cc,
                                                 gushort *reds,
                                                 gushort *greens,
                                                 gushort *blues,
                                                 gint ncolors,
                                                 gulong *colors,
                                                 gint *nallocated);
    void        gdk_color_context_get_pixels_incremental
                                                (GdkColorContext *cc,
                                                 gushort *reds,
                                                 gushort *greens,
                                                 gushort *blues,
                                                 gint ncolors,
                                                 gint *used,
                                                 gulong *colors,
                                                 gint *nallocated);
    gint        gdk_color_context_query_color   (GdkColorContext *cc,
                                                 GdkColor *color);
    gint        gdk_color_context_query_colors  (GdkColorContext *cc,
                                                 GdkColor *colors,
                                                 gint num_colors);
    gint        gdk_color_context_add_palette   (GdkColorContext *cc,
                                                 GdkColor *palette,
                                                 gint num_palette);
    void        gdk_color_context_init_dither   (GdkColorContext *cc);
    void        gdk_color_context_free_dither   (GdkColorContext *cc);
    gulong      gdk_color_context_get_pixel_from_palette
                                                (GdkColorContext *cc,
                                                 gushort *red,
                                                 gushort *green,
                                                 gushort *blue,
                                                 gint *failed);
    guchar      gdk_color_context_get_index_from_palette
                                                (GdkColorContext *cc,
                                                 gint *red,
                                                 gint *green,
                                                 gint *blue,
                                                 gint *failed);

## Description

The GdkColorContext type is used for allocating groups of colors.

It is now deprecated in favor of the gdk_colormap_*() functions described in the Colormaps and Colors section.

## Details

### struct GdkColorContext

    struct GdkColorContext
    {
      GdkVisual *visual;
      GdkColormap *colormap;

      gint num_colors;		/* available no. of colors in colormap */
      gint max_colors;		/* maximum no. of colors */
      gint num_allocated;		/* no. of allocated colors */

      GdkColorContextMode mode;
      gint need_to_free_colormap;
      GdkAtom std_cmap_atom;

      gulong *clut;			/* color look-up table */
      GdkColor *cmap;		/* colormap */

      GHashTable *color_hash;	/* hash table of allocated colors */
      GdkColor *palette;		/* preallocated palette */
      gint num_palette;		/* size of palette */

      GdkColorContextDither *fast_dither;	/* fast dither matrix */

      struct
      {
        gint red;
        gint green;
        gint blue;
      } shifts;

### struct GdkColorContextDither

    struct GdkColorContextDither
    {
      gint fast_rgb[32][32][32]; /* quick look-up table for faster rendering */
      gint fast_err[32][32][32]; /* internal RGB error information */
      gint fast_erg[32][32][32];
      gint fast_erb[32][32][32];
    };

### enum GdkColorContextMode

    typedef enum
    {
      GDK_CC_MODE_UNDEFINED,
      GDK_CC_MODE_BW,
      GDK_CC_MODE_STD_CMAP,
      GDK_CC_MODE_TRUE,
      GDK_CC_MODE_MY_GRAY,
      GDK_CC_MODE_PALETTE
    } GdkColorContextMode;

### gdk_color_context_new ()

    GdkColorContext* gdk_color_context_new      (GdkVisual *visual,
                                                 GdkColormap *colormap);

`visual` : |
`colormap` : |
Returns : |

### gdk_color_context_new_mono ()

    GdkColorContext* gdk_color_context_new_mono (GdkVisual *visual,
                                                 GdkColormap *colormap);

`visual` : |
`colormap` : |
Returns : |

### gdk_color_context_free ()

    void        gdk_color_context_free          (GdkColorContext *cc);

`cc` : |

### gdk_color_context_get_pixel ()

    gulong      gdk_color_context_get_pixel     (GdkColorContext *cc,
                                                 gushort red,
                                                 gushort green,
                                                 gushort blue,
                                                 gint *failed);

`cc` : |
`red` : |
`green` : |
`blue` : |
`failed` : |
Returns : |

### gdk_color_context_get_pixels ()

    void        gdk_color_context_get_pixels    (GdkColorContext *cc,
                                                 gushort *reds,
                                                 gushort *greens,
                                                 gushort *blues,
                                                 gint ncolors,
                                                 gulong *colors,
                                                 gint *nallocated);

`cc` : |
`reds` : |
`greens` : |
`blues` : |
`ncolors` : |
`colors` : |
`nallocated` : |

### gdk_color_context_get_pixels_incremental ()

    void        gdk_color_context_get_pixels_incremental
                                                (GdkColorContext *cc,
                                                 gushort *reds,
                                                 gushort *greens,
                                                 gushort *blues,
                                                 gint ncolors,
                                                 gint *used,
                                                 gulong *colors,
                                                 gint *nallocated);

`cc` : |
`reds` : |
`greens` : |
`blues` : |
`ncolors` : |
`used` : |
`colors` : |
`nallocated` : |

### gdk_color_context_query_color ()

    gint        gdk_color_context_query_color   (GdkColorContext *cc,
                                                 GdkColor *color);

`cc` : |
`color` : |
Returns : |

### gdk_color_context_query_colors ()

    gint        gdk_color_context_query_colors  (GdkColorContext *cc,
                                                 GdkColor *colors,
                                                 gint num_colors);

`cc` : |
`colors` : |
`num_colors` : |
Returns : |

### gdk_color_context_add_palette ()

    gint        gdk_color_context_add_palette   (GdkColorContext *cc,
                                                 GdkColor *palette,
                                                 gint num_palette);

`cc` : |
`palette` : |
`num_palette` : |
Returns : |

### gdk_color_context_init_dither ()

    void        gdk_color_context_init_dither   (GdkColorContext *cc);

`cc` : |

### gdk_color_context_free_dither ()

    void        gdk_color_context_free_dither   (GdkColorContext *cc);

`cc` : |

### gdk_color_context_get_pixel_from_palette ()

    gulong      gdk_color_context_get_pixel_from_palette
                                                (GdkColorContext *cc,
                                                 gushort *red,
                                                 gushort *green,
                                                 gushort *blue,
                                                 gint *failed);

`cc` : |
`red` : |
`green` : |
`blue` : |
`failed` : |
Returns : |

### gdk_color_context_get_index_from_palette ()

    guchar      gdk_color_context_get_index_from_palette
                                                (GdkColorContext *cc,
                                                 gint *red,
                                                 gint *green,
                                                 gint *blue,
                                                 gint *failed);

`cc` : |
`red` : |
`green` : |
`blue` : |
`failed` : |
Returns : |

<<< Previous Page | Home | Up | Next Page >>>
Colormaps and Colors | Visuals