## GimpCairo-utils GimpCairo-utils — Utility functions for cairo |

## Synopsis

    void                gimp_cairo_set_source_rgb           (cairo_t *cr,
                                                             const GimpRGB *color);
    void                gimp_cairo_set_source_rgba          (cairo_t *cr,
                                                             const GimpRGB *color);
    gboolean            gimp_cairo_set_focus_line_pattern   (cairo_t *cr,
                                                             GtkWidget *widget);
    cairo_pattern_t *   gimp_cairo_checkerboard_create      (cairo_t *cr,
                                                             gint size,
                                                             const GimpRGB *light,
                                                             const GimpRGB *dark);
    cairo_surface_t *   gimp_cairo_surface_create_from_pixbuf
                                                            (GdkPixbuf *pixbuf);
    #define             GIMP_CAIRO_RGB24_SET_PIXEL          (d,
                                                             r,
                                                             g,
                                                             b)
    #define             GIMP_CAIRO_RGB24_GET_PIXEL          (s,
                                                             r,
                                                             g,
                                                             b)
    #define             GIMP_CAIRO_ARGB32_SET_PIXEL         (d,
                                                             r,
                                                             g,
                                                             b,
                                                             a)
    #define             GIMP_CAIRO_ARGB32_GET_PIXEL         (s,
                                                             r,
                                                             g,
                                                             b,
                                                             a)

## Description

Utility functions that make cairo easier to use with common GIMP data types.

## Details

### gimp_cairo_set_source_rgb ()

    void                gimp_cairo_set_source_rgb           (cairo_t *cr,
                                                             const GimpRGB *color);

Sets the source pattern within `cr` to the solid opaque color described by `color`.

This function calls `cairo_set_source_rgb()` for you.

`cr` : | Cairo context
`color` : | GimpRGB color

Since GIMP 2.6

### gimp_cairo_set_source_rgba ()

    void                gimp_cairo_set_source_rgba          (cairo_t *cr,
                                                             const GimpRGB *color);

Sets the source pattern within `cr` to the solid translucent color described by `color`.

This function calls `cairo_set_source_rgba()` for you.

`cr` : | Cairo context
`color` : | GimpRGB color

Since GIMP 2.6

### gimp_cairo_set_focus_line_pattern ()

    gboolean            gimp_cairo_set_focus_line_pattern   (cairo_t *cr,
                                                             GtkWidget *widget);

Sets color and dash pattern for stroking a focus line on the given `cr`. The line pattern is taken from `widget`.

`cr` : | Cairo context
`widget` : | widget to draw the focus indicator on
Returns : | `TRUE` if the widget style has a focus line pattern, `FALSE` otherwise

Since GIMP 2.6

### gimp_cairo_checkerboard_create ()

    cairo_pattern_t *   gimp_cairo_checkerboard_create      (cairo_t *cr,
                                                             gint size,
                                                             const GimpRGB *light,
                                                             const GimpRGB *dark);

Create a repeating checkerboard pattern.

`cr` : | Cairo context
`size` : | check size
`light` : | light check color or `NULL` to use the default light gray
`dark` : | dark check color or `NULL` to use the default dark gray
Returns : | a new Cairo pattern that can be used as a source on `cr`.

Since GIMP 2.6

### gimp_cairo_surface_create_from_pixbuf ()

    cairo_surface_t *   gimp_cairo_surface_create_from_pixbuf
                                                            (GdkPixbuf *pixbuf);

Create a Cairo image surface from a GdkPixbuf.

You should avoid calling this function as there are probably more efficient ways of achieving the result you are looking for.

`pixbuf` : | a GdkPixbuf
Returns : | a cairo_surface_t.

Since GIMP 2.6

### GIMP_CAIRO_RGB24_SET_PIXEL()

    #define             GIMP_CAIRO_RGB24_SET_PIXEL(d, r, g, b)

Sets a single pixel in an Cairo image surface in `CAIRO_FORMAT_RGB24`.

`d` : | pointer to the destination buffer
`r` : | red component
`g` : | green component
`b` : | blue component

Since GIMP 2.6

### GIMP_CAIRO_RGB24_GET_PIXEL()

    #define             GIMP_CAIRO_RGB24_GET_PIXEL(s, r, g, b)

Gets a single pixel from a Cairo image surface in `CAIRO_FORMAT_RGB24`.

`s` : | pointer to the source buffer
`r` : | red component
`g` : | green component
`b` : | blue component

Since GIMP 2.8

### GIMP_CAIRO_ARGB32_SET_PIXEL()

    #define             GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a)

Sets a single pixel in an Cairo image surface in `CAIRO_FORMAT_ARGB32`.

`d` : | pointer to the destination buffer
`r` : | red component, not pre-multiplied
`g` : | green component, not pre-multiplied
`b` : | blue component, not pre-multiplied
`a` : | alpha component

Since GIMP 2.6

### GIMP_CAIRO_ARGB32_GET_PIXEL()

    #define             GIMP_CAIRO_ARGB32_GET_PIXEL(s, r, g, b, a)

Gets a single pixel from a Cairo image surface in `CAIRO_FORMAT_ARGB32`.

`s` : | pointer to the source buffer
`r` : | red component, not pre-multiplied
`g` : | green component, not pre-multiplied
`b` : | blue component, not pre-multiplied
`a` : | alpha component

Since GIMP 2.8