mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 09:53:25 +00:00
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
3 changed files with 25 additions and 25 deletions
|
@ -231,7 +231,7 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
||||||
guint32 parasite_data_size;
|
guint32 parasite_data_size;
|
||||||
gboolean antialias;
|
gboolean antialias;
|
||||||
gdouble spacing;
|
gdouble spacing;
|
||||||
GimpRGB rgb;
|
GeglColor *rgb = gegl_color_new ("none");
|
||||||
glong color;
|
glong color;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
@ -277,14 +277,15 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
||||||
spacing = g_strtod (params[LINE_SPACING], NULL);
|
spacing = g_strtod (params[LINE_SPACING], NULL);
|
||||||
|
|
||||||
color = strtol (params[COLOR], NULL, 16);
|
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,
|
retval = g_object_new (GIMP_TYPE_TEXT,
|
||||||
"text", text,
|
"text", text,
|
||||||
"antialias", antialias,
|
"antialias", antialias,
|
||||||
"justify", justify,
|
"justify", justify,
|
||||||
"line-spacing", spacing,
|
"line-spacing", spacing,
|
||||||
"color", &rgb,
|
"color", rgb,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gimp_text_set_font_from_xlfd (GIMP_TEXT (retval), params[XLFD]);
|
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 (str);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
g_strfreev (params);
|
g_strfreev (params);
|
||||||
|
g_object_unref (rgb);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@
|
||||||
*
|
*
|
||||||
* To obtain the user-set colors in Preferences, just call:
|
* To obtain the user-set colors in Preferences, just call:
|
||||||
* |[<!-- language="C" -->
|
* |[<!-- language="C" -->
|
||||||
* GimpRGB color1 = *(gimp_check_custom_color1 ());
|
* GeglColor *color1 = gimp_check_custom_color1 ();
|
||||||
* GimpRGB color2 = *(gimp_check_custom_color2 ());
|
* GeglColor *color2 = gimp_check_custom_color2 ();
|
||||||
* gimp_checks_get_colors (gimp_check_type (), &color1, &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,
|
static void borderaverage (GObject *config,
|
||||||
GeglBuffer *buffer,
|
GeglBuffer *buffer,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpRGB *result);
|
GeglColor *result);
|
||||||
|
|
||||||
static gboolean borderaverage_dialog (GimpProcedure *procedure,
|
static gboolean borderaverage_dialog (GimpProcedure *procedure,
|
||||||
GObject *config,
|
GObject *config,
|
||||||
|
@ -149,7 +149,7 @@ border_average_create_procedure (GimpPlugIn *plug_in,
|
||||||
0, G_MAXINT, 4,
|
0, G_MAXINT, 4,
|
||||||
G_PARAM_READWRITE);
|
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."),
|
||||||
_("The average color of the specified border."),
|
_("The average color of the specified border."),
|
||||||
TRUE, NULL,
|
TRUE, NULL,
|
||||||
|
@ -172,7 +172,7 @@ border_average_run (GimpProcedure *procedure,
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
GimpValueArray *return_vals = NULL;
|
GimpValueArray *return_vals = NULL;
|
||||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||||
GimpRGB result_color = { 0.0, };
|
GeglColor *result_color;
|
||||||
GeglBuffer *buffer;
|
GeglBuffer *buffer;
|
||||||
|
|
||||||
gegl_init (NULL, NULL);
|
gegl_init (NULL, NULL);
|
||||||
|
@ -194,11 +194,15 @@ border_average_run (GimpProcedure *procedure,
|
||||||
drawable = drawables[0];
|
drawable = drawables[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result_color = gegl_color_new ("transparent");
|
||||||
buffer = gimp_drawable_get_buffer (drawable);
|
buffer = gimp_drawable_get_buffer (drawable);
|
||||||
|
|
||||||
if (run_mode == GIMP_RUN_INTERACTIVE &&
|
if (run_mode == GIMP_RUN_INTERACTIVE &&
|
||||||
! borderaverage_dialog (procedure, G_OBJECT (config), image, drawable))
|
! borderaverage_dialog (procedure, G_OBJECT (config), image, drawable))
|
||||||
|
{
|
||||||
|
g_object_unref (result_color);
|
||||||
return gimp_procedure_new_return_values (procedure, GIMP_PDB_CANCEL, NULL);
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_CANCEL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -206,16 +210,10 @@ border_average_run (GimpProcedure *procedure,
|
||||||
if (gimp_drawable_is_rgb (drawable))
|
if (gimp_drawable_is_rgb (drawable))
|
||||||
{
|
{
|
||||||
gimp_progress_init ( _("Border Average"));
|
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)
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||||
{
|
gimp_context_set_foreground (result_color);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -228,7 +226,7 @@ border_average_run (GimpProcedure *procedure,
|
||||||
return_vals = gimp_procedure_new_return_values (procedure, status, NULL);
|
return_vals = gimp_procedure_new_return_values (procedure, status, NULL);
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
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;
|
return return_vals;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +236,7 @@ static void
|
||||||
borderaverage (GObject *config,
|
borderaverage (GObject *config,
|
||||||
GeglBuffer *buffer,
|
GeglBuffer *buffer,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpRGB *result)
|
GeglColor *result)
|
||||||
{
|
{
|
||||||
gint x, y, width, height;
|
gint x, y, width, height;
|
||||||
gint max;
|
gint max;
|
||||||
|
@ -257,7 +255,7 @@ borderaverage (GObject *config,
|
||||||
|
|
||||||
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +350,7 @@ borderaverage (GObject *config,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the color */
|
/* 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);
|
g_free (cube);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue