gwyrgba

gwyrgba — Bit depth independet RGBA colors.

Synopsis




#define     GWY_TYPE_RGBA
struct      GwyRGBA;
GType       gwy_rgba_get_type               (void);
GwyRGBA*    gwy_rgba_copy                   (const GwyRGBA *rgba);
void        gwy_rgba_free                   (GwyRGBA *rgba);
void        gwy_rgba_to_gdk_color           (GwyRGBA *rgba,
                                             GdkColor *gdkcolor);
guint16     gwy_rgba_to_gdk_alpha           (GwyRGBA *rgba);
void        gwy_rgba_from_gdk_color         (GwyRGBA *rgba,
                                             GdkColor *gdkcolor);
void        gwy_rgba_from_gdk_color_and_alpha
                                            (GwyRGBA *rgba,
                                             GdkColor *gdkcolor,
                                             guint16 gdkalpha);
gboolean    gwy_rgba_get_from_container     (GwyRGBA *rgba,
                                             GwyContainer *container,
                                             const gchar *prefix);
void        gwy_rgba_store_to_container     (GwyRGBA *rgba,
                                             GwyContainer *container,
                                             const gchar *prefix);

Description

Details

GWY_TYPE_RGBA

#define GWY_TYPE_RGBA                         (gwy_rgba_get_type())


struct GwyRGBA

struct GwyRGBA {

    gdouble r;
    gdouble g;
    gdouble b;
    gdouble a;
};

RGB[A] color specification type.

All values are from the range [0,1].

gdouble r The red component.
gdouble g The green component.
gdouble b The blue component.
gdouble a The alpha (opacity) value.

gwy_rgba_get_type ()

GType       gwy_rgba_get_type               (void);

Returns :

gwy_rgba_copy ()

GwyRGBA*    gwy_rgba_copy                   (const GwyRGBA *rgba);

Makes a copy of a rgba structure. The result must be freed using gwy_rgba_free().

XXX: Just kidding, we curently dont' use memchunks.

rgba : A GwyRGBA.
Returns : A copy of rgba.

Since 1.3.


gwy_rgba_free ()

void        gwy_rgba_free                   (GwyRGBA *rgba);

Frees an rgba structure created with gwy_rgba_copy().

rgba : A GwyRGBA.

Since 1.3.


gwy_rgba_to_gdk_color ()

void        gwy_rgba_to_gdk_color           (GwyRGBA *rgba,
                                             GdkColor *gdkcolor);

Converts a rgba to a Gdk color.

Note no allocation is performed, just channel value conversion.

rgba : A GwyRGBA.
gdkcolor : A GdkColor.

Since 1.3.


gwy_rgba_to_gdk_alpha ()

guint16     gwy_rgba_to_gdk_alpha           (GwyRGBA *rgba);

Converts a rgba to a Gdk opacity value.

rgba : A GwyRGBA.
Returns : The opacity value as a 16bit integer.

Since 1.3.


gwy_rgba_from_gdk_color ()

void        gwy_rgba_from_gdk_color         (GwyRGBA *rgba,
                                             GdkColor *gdkcolor);

Converts a Gdk color to a rgba.

The alpha value is unchanged, as GdkColor has no opacity information.

rgba : A GwyRGBA.
gdkcolor : A GdkColor.

Since 1.3.


gwy_rgba_from_gdk_color_and_alpha ()

void        gwy_rgba_from_gdk_color_and_alpha
                                            (GwyRGBA *rgba,
                                             GdkColor *gdkcolor,
                                             guint16 gdkalpha);

Converts a Gdk color plus an opacity value to a rgba.

rgba : A GwyRGBA.
gdkcolor : A GdkColor.
gdkalpha : Gdk 16bit opacity value.

gwy_rgba_get_from_container ()

gboolean    gwy_rgba_get_from_container     (GwyRGBA *rgba,
                                             GwyContainer *container,
                                             const gchar *prefix);

Gets RGBA color components from a container.

rgba : A GwyRGBA.
container : A GwyContainer to get the color components from.
prefix : Prefix in container, e.g. "/0/mask" (it would try to fetch "/0/mask/red", "/0/mask/green", etc. then).
Returns : Whether all rgba components were successfully found and set.

Since 1.3.


gwy_rgba_store_to_container ()

void        gwy_rgba_store_to_container     (GwyRGBA *rgba,
                                             GwyContainer *container,
                                             const gchar *prefix);

Stores RGBA color components to a container.

rgba : A GwyRGBA.
container : A GwyContainer to store the color components to.
prefix : Prefix in container, e.g. "/0/mask" (it would try to store "/0/mask/red", "/0/mask/green", etc. then).

Since 1.3.