[gegl] operations: give sRGB colors to cairo operations
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: give sRGB colors to cairo operations
- Date: Mon, 7 Oct 2013 02:02:18 +0000 (UTC)
commit ef92a670c17666840c548d0fe3c32051a2df2992
Author: Daniel Sabo <DanielSabo gmail com>
Date: Sun Oct 6 07:24:43 2013 -0700
operations: give sRGB colors to cairo operations
operations/external/path.c | 15 +++++++--------
operations/external/vector-fill.c | 20 ++++++++++----------
operations/external/vector-stroke.c | 17 +++++++++--------
3 files changed, 26 insertions(+), 26 deletions(-)
---
diff --git a/operations/external/path.c b/operations/external/path.c
index f44edf4..12be0a7 100644
--- a/operations/external/path.c
+++ b/operations/external/path.c
@@ -318,7 +318,7 @@ static void
prepare (GeglOperation *operation)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- gegl_operation_set_format (operation, "output", babl_format ("RaGaBaA float"));
+ gegl_operation_set_format (operation, "output", babl_format ("R'aG'aB'aA float"));
if (o->transform && o->transform[0] != '\0')
{
GeglMatrix3 matrix;
@@ -372,14 +372,13 @@ process (GeglOperation *operation,
gegl_buffer_clear (output, result);
}
-
-
if (o->fill_opacity > 0.0001 && o->fill)
{
- gdouble r,g,b,a;
- gegl_color_get_rgba (o->fill, &r,&g,&b,&a);
- a *= o->fill_opacity;
- if (a>0.001)
+ gdouble color[4] = {0, 0, 0, 0};
+ gegl_color_get_pixel (o->fill, babl_format ("R'G'B'A double"), color);
+ color[3] *= o->fill_opacity;
+
+ if (color[3] > 0.001)
{
static GMutex mutex = { 0, };
cairo_t *cr;
@@ -402,7 +401,7 @@ process (GeglOperation *operation,
}
gegl_path_cairo_play (o->d, cr);
- cairo_set_source_rgba (cr, r,g,b,a);
+ cairo_set_source_rgba (cr, color[0], color[1], color[2], color[3]);
cairo_fill (cr);
g_mutex_unlock (&mutex);
diff --git a/operations/external/vector-fill.c b/operations/external/vector-fill.c
index aaf28cc..354a88c 100644
--- a/operations/external/vector-fill.c
+++ b/operations/external/vector-fill.c
@@ -24,7 +24,7 @@
#ifdef GEGL_CHANT_PROPERTIES
-gegl_chant_color (color, _("Color"), "rgba(0.0,0.0,0.0,0.6)",
+gegl_chant_color (color, _("Color"), "rgba(0.0,0.0,0.0,1.0)",
_("Color of paint to use for filling."))
gegl_chant_double (opacity, _("Opacity"), -2.0, 2.0, 1.0,
@@ -76,7 +76,8 @@ static void
prepare (GeglOperation *operation)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- gegl_operation_set_format (operation, "output", babl_format ("RaGaBaA float"));
+ gegl_operation_set_format (operation, "output", babl_format ("R'aG'aB'aA float"));
+
if (o->transform && o->transform[0] != '\0')
{
GeglMatrix3 matrix;
@@ -121,7 +122,7 @@ process (GeglOperation *operation,
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gboolean need_fill = FALSE;
- gdouble r,g,b,a;
+ gdouble color[4] = {0, 0, 0, 0};
if (input)
{
@@ -135,10 +136,10 @@ process (GeglOperation *operation,
if (o->opacity > 0.0001 && o->color)
{
- gegl_color_get_rgba (o->color, &r,&g,&b,&a);
- a *= o->opacity;
- if (a>0.001)
- need_fill=TRUE;
+ gegl_color_get_pixel (o->color, babl_format ("R'G'B'A double"), color);
+ color[3] *= o->opacity;
+ if (color[3] > 0.001)
+ need_fill=TRUE;
}
if (need_fill)
@@ -148,9 +149,8 @@ process (GeglOperation *operation,
cairo_surface_t *surface;
guchar *data;
-
g_mutex_lock (&mutex);
- data = (void*)gegl_buffer_linear_open (output, result, NULL, babl_format ("B'aG'aR'aA u8"));
+ data = (void*)gegl_buffer_linear_open (output, result, NULL, babl_format ("cairo-ARGB32"));
surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
result->width,
@@ -163,7 +163,7 @@ process (GeglOperation *operation,
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
gegl_path_cairo_play (o->d, cr);
- cairo_set_source_rgba (cr, r,g,b,a);
+ cairo_set_source_rgba (cr, color[0], color[1], color[2], color[3]);
cairo_fill (cr);
cairo_destroy (cr);
diff --git a/operations/external/vector-stroke.c b/operations/external/vector-stroke.c
index b400cf2..2d832ea 100644
--- a/operations/external/vector-stroke.c
+++ b/operations/external/vector-stroke.c
@@ -24,7 +24,7 @@
#ifdef GEGL_CHANT_PROPERTIES
-gegl_chant_color (color, _("Color"), "rgba(0.0,0.0,0.0,0.0)",
+gegl_chant_color (color, _("Color"), "rgba(0.0,0.0,0.0,1.0)",
_("Color of paint to use for stroking."))
gegl_chant_double (width, _("Width"), 0.0, 200.0, 2.0,
@@ -75,7 +75,8 @@ static void
prepare (GeglOperation *operation)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- gegl_operation_set_format (operation, "output", babl_format ("RaGaBaA float"));
+ gegl_operation_set_format (operation, "output", babl_format ("R'aG'aB'aA float"));
+
if (o->transform && o->transform[0] != '\0')
{
GeglMatrix3 matrix;
@@ -148,7 +149,7 @@ process (GeglOperation *operation,
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gboolean need_stroke = FALSE;
- gdouble r,g,b,a;
+ gdouble color[4] = {0, 0, 0, 0};
if (input)
{
@@ -161,9 +162,9 @@ process (GeglOperation *operation,
if (o->width > 0.1 && o->opacity > 0.0001)
{
- gegl_color_get_rgba (o->color, &r,&g,&b,&a);
- a *= o->opacity;
- if (a>0.001)
+ gegl_color_get_pixel (o->color, babl_format ("R'G'B'A double"), color);
+ color[3] *= o->opacity;
+ if (color[3] > 0.001)
need_stroke=TRUE;
}
@@ -175,7 +176,7 @@ process (GeglOperation *operation,
guchar *data;
g_mutex_lock (&mutex);
- data = (void*)gegl_buffer_linear_open (output, result, NULL, babl_format ("B'aG'aR'aA u8"));
+ data = (void*)gegl_buffer_linear_open (output, result, NULL, babl_format ("cairo-ARGB32"));
surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
result->width,
@@ -191,7 +192,7 @@ process (GeglOperation *operation,
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
gegl_path_cairo_play (o->d, cr);
- cairo_set_source_rgba (cr, r,g,b,a);
+ cairo_set_source_rgba (cr, color[0], color[1], color[2], color[3]);
cairo_stroke (cr);
cairo_destroy (cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]