mirror of https://github.com/GNOME/gimp.git
plug-ins, libgimpbase, text: Port border-average...
...to fully use and return GeglColor. Also, fix gimptext-parasite sending a GimpRGB to create a GimpText instead of the now required GeglColor, and update documentation in gimp_checks_get_colors to reference GeglColor instead of GimpRGB.
This commit is contained in:
parent
32c9a9a6cc
commit
9bee3bed2a
|
@ -231,7 +231,7 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
|||
guint32 parasite_data_size;
|
||||
gboolean antialias;
|
||||
gdouble spacing;
|
||||
GimpRGB rgb;
|
||||
GeglColor *rgb = gegl_color_new ("none");
|
||||
glong color;
|
||||
gint i;
|
||||
|
||||
|
@ -277,14 +277,15 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
|||
spacing = g_strtod (params[LINE_SPACING], NULL);
|
||||
|
||||
color = strtol (params[COLOR], NULL, 16);
|
||||
gimp_rgba_set_uchar (&rgb, color >> 16, color >> 8, color, 255);
|
||||
gegl_color_set_rgba (rgb, (color >> 16) / 255.0f, (color >> 8) / 255.0f,
|
||||
color / 255.0f, 1.0);
|
||||
|
||||
retval = g_object_new (GIMP_TYPE_TEXT,
|
||||
"text", text,
|
||||
"antialias", antialias,
|
||||
"justify", justify,
|
||||
"line-spacing", spacing,
|
||||
"color", &rgb,
|
||||
"color", rgb,
|
||||
NULL);
|
||||
|
||||
gimp_text_set_font_from_xlfd (GIMP_TEXT (retval), params[XLFD]);
|
||||
|
@ -293,6 +294,7 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
|||
g_free (str);
|
||||
g_free (text);
|
||||
g_strfreev (params);
|
||||
g_object_unref (rgb);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@
|
|||
*
|
||||
* To obtain the user-set colors in Preferences, just call:
|
||||
* |[<!-- language="C" -->
|
||||
* GimpRGB color1 = *(gimp_check_custom_color1 ());
|
||||
* GimpRGB color2 = *(gimp_check_custom_color2 ());
|
||||
* GeglColor *color1 = gimp_check_custom_color1 ();
|
||||
* GeglColor *color2 = gimp_check_custom_color2 ();
|
||||
* gimp_checks_get_colors (gimp_check_type (), &color1, &color2);
|
||||
* ]|
|
||||
*
|
||||
|
|
|
@ -66,7 +66,7 @@ static GimpValueArray * border_average_run (GimpProcedure
|
|||
static void borderaverage (GObject *config,
|
||||
GeglBuffer *buffer,
|
||||
GimpDrawable *drawable,
|
||||
GimpRGB *result);
|
||||
GeglColor *result);
|
||||
|
||||
static gboolean borderaverage_dialog (GimpProcedure *procedure,
|
||||
GObject *config,
|
||||
|
@ -149,7 +149,7 @@ border_average_create_procedure (GimpPlugIn *plug_in,
|
|||
0, G_MAXINT, 4,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_VAL_RGB (procedure, "borderaverage",
|
||||
GIMP_PROC_VAL_COLOR (procedure, "borderaverage",
|
||||
_("The average color of the specified border."),
|
||||
_("The average color of the specified border."),
|
||||
TRUE, NULL,
|
||||
|
@ -172,7 +172,7 @@ border_average_run (GimpProcedure *procedure,
|
|||
GimpDrawable *drawable;
|
||||
GimpValueArray *return_vals = NULL;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
GimpRGB result_color = { 0.0, };
|
||||
GeglColor *result_color;
|
||||
GeglBuffer *buffer;
|
||||
|
||||
gegl_init (NULL, NULL);
|
||||
|
@ -194,11 +194,15 @@ border_average_run (GimpProcedure *procedure,
|
|||
drawable = drawables[0];
|
||||
}
|
||||
|
||||
result_color = gegl_color_new ("transparent");
|
||||
buffer = gimp_drawable_get_buffer (drawable);
|
||||
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE &&
|
||||
! borderaverage_dialog (procedure, G_OBJECT (config), image, drawable))
|
||||
{
|
||||
g_object_unref (result_color);
|
||||
return gimp_procedure_new_return_values (procedure, GIMP_PDB_CANCEL, NULL);
|
||||
}
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
|
@ -206,16 +210,10 @@ border_average_run (GimpProcedure *procedure,
|
|||
if (gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
gimp_progress_init ( _("Border Average"));
|
||||
borderaverage (G_OBJECT (config), buffer, drawable, &result_color);
|
||||
borderaverage (G_OBJECT (config), buffer, drawable, result_color);
|
||||
|
||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, result_color.r, result_color.g, result_color.b, result_color.a, NULL);
|
||||
gimp_context_set_foreground (color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
gimp_context_set_foreground (result_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -228,7 +226,7 @@ border_average_run (GimpProcedure *procedure,
|
|||
return_vals = gimp_procedure_new_return_values (procedure, status, NULL);
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
GIMP_VALUES_SET_RGB (return_vals, 1, &result_color);
|
||||
GIMP_VALUES_SET_COLOR (return_vals, 1, result_color);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -238,7 +236,7 @@ static void
|
|||
borderaverage (GObject *config,
|
||||
GeglBuffer *buffer,
|
||||
GimpDrawable *drawable,
|
||||
GimpRGB *result)
|
||||
GeglColor *result)
|
||||
{
|
||||
gint x, y, width, height;
|
||||
gint max;
|
||||
|
@ -257,7 +255,7 @@ borderaverage (GObject *config,
|
|||
|
||||
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
||||
{
|
||||
gimp_rgba_set_uchar (result, 0, 0, 0, 255);
|
||||
gegl_color_set_rgba (result, 0.0, 0.0, 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -352,7 +350,7 @@ borderaverage (GObject *config,
|
|||
}
|
||||
|
||||
/* return the color */
|
||||
gimp_rgba_set_uchar (result, r, g, b, 255);
|
||||
gegl_color_set_rgba (result, r / 255.0, g / 255.0, b / 255.0, 1.0);
|
||||
|
||||
g_free (cube);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue