![]() |
![]() |
Gwyddion Drawing Library Reference Manual | ![]() |
---|
gwyrgbagwyrgba — Bit depth independet RGBA colors. |
#define GWY_TYPE_RGBA 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 (const GwyRGBA *rgba, GdkColor *gdkcolor); guint16 gwy_rgba_to_gdk_alpha (const GwyRGBA *rgba); void gwy_rgba_from_gdk_color (GwyRGBA *rgba, const GdkColor *gdkcolor); void gwy_rgba_from_gdk_color_and_alpha (GwyRGBA *rgba, const GdkColor *gdkcolor, guint16 gdkalpha); void gwy_rgba_interpolate (const GwyRGBA *src1, const GwyRGBA *src2, gdouble x, GwyRGBA *rgba); gboolean gwy_rgba_get_from_container (GwyRGBA *rgba, GwyContainer *container, const gchar *prefix); void gwy_rgba_store_to_container (const GwyRGBA *rgba, GwyContainer *container, const gchar *prefix); void gwy_rgba_set_gdk_gc_fg (const GwyRGBA *rgba, GdkGC *gc); void gwy_rgba_set_gdk_gc_bg (const GwyRGBA *rgba, GdkGC *gc);
GwyRGBA is a bit depth independent representation of an RGB or RGBA color, using floating point values from the [0,1] interval.
GwyRGBA is not an object, but a simple struct that can be allocated on
stack on created with
typedef struct { gdouble r; gdouble g; gdouble b; gdouble a; } GwyRGBA;
RGB[A] color specification type.
All values are from the range [0,1].
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. |
void gwy_rgba_free (GwyRGBA *rgba);
Frees an rgba structure created with gwy_rgba_copy().
rgba : | A GwyRGBA. |
void gwy_rgba_to_gdk_color (const GwyRGBA *rgba, GdkColor *gdkcolor);
Converts a rgba to a Gdk color.
Note no allocation is performed, just channel value conversion.
guint16 gwy_rgba_to_gdk_alpha (const GwyRGBA *rgba);
Converts a rgba to a Gdk opacity value.
rgba : | A GwyRGBA. |
Returns : | The opacity value as a 16bit integer. |
void gwy_rgba_from_gdk_color (GwyRGBA *rgba, const GdkColor *gdkcolor);
Converts a Gdk color to a rgba.
The alpha value is unchanged, as GdkColor has no opacity information.
void gwy_rgba_from_gdk_color_and_alpha (GwyRGBA *rgba, const GdkColor *gdkcolor, guint16 gdkalpha);
Converts a Gdk color plus an opacity value to a rgba.
void gwy_rgba_interpolate (const GwyRGBA *src1, const GwyRGBA *src2, gdouble x, GwyRGBA *rgba);
Linearly interpolates two colors, including alpha blending.
Correct blending of two not fully opaque colors is tricky. Always use this function, not simple independent interpolation of r, g, b, and a.
src1 : | Color at point x = 0.0. |
src2 : | Color at point x = 1.0. |
x : | Point in interval 0..1 to take color from. |
rgba : | A GwyRGBA to store result to. |
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. |
void gwy_rgba_store_to_container (const 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 will store "/0/mask/red", "/0/mask/green", etc. then). |
void gwy_rgba_set_gdk_gc_fg (const GwyRGBA *rgba, GdkGC *gc);
Sets foreground color of a Gdk graphics context from a RGBA color.
This is a convenience wrapper around gdk_gc_set_rgb_fg_color(), see its documentation for details and caveats.
rgba : | A GwyRGBA. Its alpha component is ignored, only RGB is used. |
gc : | A Gdk graphics context to set forgeground color of. |
void gwy_rgba_set_gdk_gc_bg (const GwyRGBA *rgba, GdkGC *gc);
Sets foreground color of a Gdk graphics context from a RGBA color.
This is a convenience wrapper around gdk_gc_set_rgb_bg_color(), see its documentation for details and caveats.
rgba : | A GwyRGBA. Its alpha component is ignored, only RGB is used. |
gc : | A Gdk graphics context to set forgeground color of. |
<< Gwyddion Drawing Library Reference Manual | GwyGradient >> |