modules, core, pdb, plug-ins: GeglColor ports

More minor ports from GimpRGB to
GeglColor.
Note that file-mng's GimpRGB code was
already dummied out.
This commit is contained in:
Alx Sa 2024-03-23 04:10:26 +00:00
parent db88383abb
commit 2e0d31b17e
14 changed files with 111 additions and 68 deletions

View File

@ -197,7 +197,6 @@ gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
if (clip_result && (new_x != orig_x || new_y != orig_y))
{
GimpRGB bg;
GeglColor *color = NULL;
gint clip_x, clip_y;
gint clip_width, clip_height;
@ -209,12 +208,16 @@ gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
* channels, and drawables with an alpha channel.
*/
if (GIMP_IS_CHANNEL (drawable) || babl_format_has_alpha (format))
gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
{
color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, 0.0, 0.0, 0.0, 0.0,
gimp_drawable_get_space (drawable));
}
else
color = gegl_color_duplicate (gimp_context_get_background (context));
{
color = gegl_color_duplicate (gimp_context_get_background (context));
}
if (color == NULL)
color = gimp_gegl_color_new (&bg, gimp_drawable_get_space (drawable));
gegl_buffer_set_color (new_buffer, NULL, color);
g_object_unref (color);
@ -453,7 +456,6 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
new_width != orig_width || new_height != orig_height))
{
GimpRGB bg;
GeglColor *color = NULL;
gint clip_x, clip_y;
gint clip_width, clip_height;
@ -469,12 +471,16 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
* channels, and drawables with an alpha channel.
*/
if (GIMP_IS_CHANNEL (drawable) || babl_format_has_alpha (format))
gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
{
color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, 0.0, 0.0, 0.0, 0.0,
gimp_drawable_get_space (drawable));
}
else
color = gegl_color_duplicate (gimp_context_get_background (context));
{
color = gegl_color_duplicate (gimp_context_get_background (context));
}
if (color == NULL)
color = gimp_gegl_color_new (&bg, gimp_drawable_get_space (drawable));
gegl_buffer_set_color (new_buffer, NULL, color);
g_object_unref (color);

View File

@ -21,10 +21,14 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"

View File

@ -21,12 +21,15 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <string.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"

View File

@ -21,11 +21,14 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h"

View File

@ -21,11 +21,14 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbaseenums.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"

View File

@ -21,11 +21,14 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"

View File

@ -21,12 +21,15 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <string.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"

View File

@ -1084,10 +1084,10 @@ plug_in_colortoalpha_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpDrawable *drawable;
GimpRGB color;
GeglColor *color;
drawable = g_value_get_object (gimp_value_array_index (args, 2));
gimp_value_get_rgb (gimp_value_array_index (args, 3), &color);
color = g_value_get_object (gimp_value_array_index (args, 3));
if (success)
{
@ -1095,7 +1095,7 @@ plug_in_colortoalpha_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglColor *gegl_color = gimp_gegl_color_new (&color, NULL);
GeglColor *gegl_color = gegl_color_duplicate (color);
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:color-to-alpha",
@ -1795,17 +1795,14 @@ plug_in_exchange_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpRGB from;
GimpRGB to;
GeglColor *gegl_from;
GeglColor *gegl_to;
GeglColor *gegl_from = gegl_color_new (NULL);
GeglColor *gegl_to = gegl_color_new (NULL);
GeglNode *node;
gimp_rgb_set_uchar (&from, from_red, from_green, from_blue);
gimp_rgb_set_uchar (&to, to_red, to_green, to_blue);
gegl_from = gimp_gegl_color_new (&from, NULL);
gegl_to = gimp_gegl_color_new (&to, NULL);
gegl_color_set_rgba (gegl_from, from_red / 255.0, from_green / 255.0,
from_blue / 255.0, 1.0);
gegl_color_set_rgba (gegl_to, to_red / 255.0, to_green / 255.0,
to_blue / 255.0, 1.0);
node = gegl_node_new_child (NULL,
"operation", "gegl:color-exchange",
@ -2921,7 +2918,7 @@ plug_in_nova_invoker (GimpProcedure *procedure,
GimpDrawable *drawable;
gint xcenter;
gint ycenter;
GimpRGB color;
GeglColor *color;
gint radius;
gint nspoke;
gint randomhue;
@ -2929,7 +2926,7 @@ plug_in_nova_invoker (GimpProcedure *procedure,
drawable = g_value_get_object (gimp_value_array_index (args, 2));
xcenter = g_value_get_int (gimp_value_array_index (args, 3));
ycenter = g_value_get_int (gimp_value_array_index (args, 4));
gimp_value_get_rgb (gimp_value_array_index (args, 5), &color);
color = g_value_get_object (gimp_value_array_index (args, 5));
radius = g_value_get_int (gimp_value_array_index (args, 6));
nspoke = g_value_get_int (gimp_value_array_index (args, 7));
randomhue = g_value_get_int (gimp_value_array_index (args, 8));
@ -2940,11 +2937,13 @@ plug_in_nova_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglColor *gegl_color;
GeglNode *node;
GeglColor *gegl_color = gimp_gegl_color_new (&color, NULL);
gdouble center_x = (gdouble) xcenter / (gdouble) gimp_item_get_width (GIMP_ITEM (drawable));
gdouble center_y = (gdouble) ycenter / (gdouble) gimp_item_get_height (GIMP_ITEM (drawable));
gegl_color = gegl_color_duplicate (color);
node = gegl_node_new_child (NULL,
"operation", "gegl:supernova",
"center-x", center_x,
@ -5618,12 +5617,11 @@ register_plug_in_compat_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_rgb ("color",
"color",
"Color to remove",
FALSE,
NULL,
GIMP_PARAM_READWRITE));
gegl_param_spec_color ("color",
"color",
"Color to remove",
NULL,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -7663,12 +7661,11 @@ register_plug_in_compat_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_rgb ("color",
"color",
"Color of supernova",
FALSE,
NULL,
GIMP_PARAM_READWRITE));
gegl_param_spec_color ("color",
"color",
"Color of supernova",
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("radius",
"radius",

View File

@ -21,6 +21,7 @@
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <pango/pango.h>
#include <gegl.h>
@ -28,6 +29,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"

View File

@ -808,6 +808,9 @@ paint_ring (GimpColorWheel *wheel,
{
GtkWidget *widget = GTK_WIDGET (wheel);
GimpColorWheelPrivate *priv = gimp_color_wheel_get_instance_private (wheel);
GeglColor *color = gegl_color_new (NULL);
const Babl *render_space;
gdouble luminance[1];
gint width, height;
gint xx, yy;
gdouble dx, dy, dist;
@ -825,6 +828,8 @@ paint_ring (GimpColorWheel *wheel,
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
render_space = gimp_widget_get_render_space (widget, priv->config);
center_x = width / 2.0;
center_y = height / 2.0;
@ -891,7 +896,9 @@ paint_ring (GimpColorWheel *wheel,
b = 1.0;
hsv_to_rgb (&r, &g, &b);
if (GIMP_RGB_LUMINANCE (r, g, b) > 0.5)
gegl_color_set_rgba_with_space (color, r, g, b, 1.0, render_space);
gegl_color_get_pixel (color, babl_format ("Y' double"), luminance);
if (luminance[0] > 0.5)
cairo_set_source_rgb (source_cr, 0.0, 0.0, 0.0);
else
cairo_set_source_rgb (source_cr, 1.0, 1.0, 1.0);
@ -920,6 +927,7 @@ paint_ring (GimpColorWheel *wheel,
cairo_restore (cr);
g_object_unref (color);
g_free (buf);
}
@ -958,6 +966,9 @@ paint_triangle (GimpColorWheel *wheel,
{
GtkWidget *widget = GTK_WIDGET (wheel);
GimpColorWheelPrivate *priv = gimp_color_wheel_get_instance_private (wheel);
GeglColor *color = gegl_color_new (NULL);
const Babl *render_space;
gdouble luminance[1];
gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
gint x1, y1, r1, g1, b1; /* First vertex in scanline order */
gint x2, y2, r2, g2, b2; /* Second vertex */
@ -977,6 +988,8 @@ paint_triangle (GimpColorWheel *wheel,
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
render_space = gimp_widget_get_render_space (widget, priv->config);
/* Compute triangle's vertices */
compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
@ -1127,7 +1140,9 @@ paint_triangle (GimpColorWheel *wheel,
gtk_style_context_save (context);
if (GIMP_RGB_LUMINANCE (r, g, b) > 0.5)
gegl_color_set_rgba_with_space (color, r, g, b, 1.0, render_space);
gegl_color_get_pixel (color, babl_format ("Y' double"), luminance);
if (luminance[0] > 0.5)
{
gtk_style_context_add_class (context, "light-area-focus");
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
@ -1137,6 +1152,7 @@ paint_triangle (GimpColorWheel *wheel,
gtk_style_context_add_class (context, "dark-area-focus");
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
}
g_object_unref (color);
#define RADIUS 4
#define FOCUS_RADIUS 6

View File

@ -787,7 +787,7 @@ HELP
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'color', type => 'color',
{ name => 'color', type => 'geglcolor',
desc => 'Color to remove' }
);
@ -798,7 +798,7 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglColor *gegl_color = gimp_gegl_color_new (&color, NULL);
GeglColor *gegl_color = gegl_color_duplicate (color);
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:color-to-alpha",
@ -1575,17 +1575,14 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpRGB from;
GimpRGB to;
GeglColor *gegl_from;
GeglColor *gegl_to;
GeglColor *gegl_from = gegl_color_new (NULL);
GeglColor *gegl_to = gegl_color_new (NULL);
GeglNode *node;
gimp_rgb_set_uchar (&from, from_red, from_green, from_blue);
gimp_rgb_set_uchar (&to, to_red, to_green, to_blue);
gegl_from = gimp_gegl_color_new (&from, NULL);
gegl_to = gimp_gegl_color_new (&to, NULL);
gegl_color_set_rgba (gegl_from, from_red / 255.0, from_green / 255.0,
from_blue / 255.0, 1.0);
gegl_color_set_rgba (gegl_to, to_red / 255.0, to_green / 255.0,
to_blue / 255.0, 1.0);
node = gegl_node_new_child (NULL,
"operation", "gegl:color-exchange",
@ -2881,8 +2878,8 @@ HELP
desc => 'X coordinates of the center of supernova' },
{ name => 'ycenter', type => 'int32',
desc => 'Y coordinates of the center of supernova' },
{ name => 'color', type => 'color',
desc => 'Color of supernova' },
{ name => 'color', type => 'geglcolor',
desc => 'Color of supernova' },
{ name => 'radius', type => '1 <= int32 <= 3000',
desc => 'Radius of supernova' },
{ name => 'nspoke', type => '1 <= int32 <= 1024',
@ -2898,11 +2895,13 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglColor *gegl_color;
GeglNode *node;
GeglColor *gegl_color = gimp_gegl_color_new (&color, NULL);
gdouble center_x = (gdouble) xcenter / (gdouble) gimp_item_get_width (GIMP_ITEM (drawable));
gdouble center_y = (gdouble) ycenter / (gdouble) gimp_item_get_height (GIMP_ITEM (drawable));
gegl_color = gegl_color_duplicate (color);
node = gegl_node_new_child (NULL,
"operation", "gegl:supernova",
"center-x", center_x,

View File

@ -283,7 +283,8 @@ package Gimp::CodeGen::pdb;
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = g_value_dup_object (gimp_value_array_index ($value))',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_take_object ($value, $var)' },
take_value_func => 'g_value_take_object ($value, $var)',
headers => [ qw(<cairo.h> "libgimpcolor/gimpcolor.h") ] },
display => { name => 'DISPLAY',
gtype => 'GIMP_TYPE_DISPLAY',

View File

@ -453,7 +453,6 @@ dialog_update_preview (GtkWidget *widget,
GBytes *cache;
const guchar *cache_start;
GeglColor *color;
GimpRGB background;
guchar bg[4];
gint width;
gint height;
@ -477,18 +476,19 @@ dialog_update_preview (GtkWidget *widget,
if (bg_trans)
gimp_color_set_alpha (color, 0.0);
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &background);
g_object_unref (color);
if (gimp_drawable_is_gray (drawable))
{
bg[0] = gimp_rgb_luminance_uchar (&background);
gimp_rgba_get_uchar (&background, NULL, NULL, NULL, bg + 3);
guchar luminance[2];
gegl_color_get_pixel (color, babl_format ("Y'A u8"), luminance);
bg[0] = luminance[0];
bg[3] = luminance[1];
}
else
{
gimp_rgba_get_uchar (&background, bg, bg + 1, bg + 2, bg + 3);
gegl_color_get_pixel (color, babl_format ("R'G'B'A u8"), bg);
}
g_object_unref (color);
buffer = g_new (guchar, width * height * bpp);

View File

@ -947,13 +947,16 @@ mng_save_image (GFile *file,
/* how do we get this to work? */
if (config_bkgd)
{
GimpRGB bgcolor;
guchar red, green, blue;
GeglColor *background;
guchar rgb[3];
guchar luminance[1];
gimp_context_get_background (&bgcolor);
gimp_rgb_get_uchar (&bgcolor, &red, &green, &blue);
background = gimp_context_get_background ();
gegl_color_get_pixel (background, babl_format ("R'G'B' u8"), rgb);
gegl_color_get_pixel (background, babl_format ("Y' u8"), luminance);
g_object_unref (background);
if (mng_putchunk_back (handle, red, green, blue,
if (mng_putchunk_back (handle, rgb[0], rgb[1], rgb[2],
MNG_BACKGROUNDCOLOR_MANDATORY,
0, MNG_BACKGROUNDIMAGE_NOTILE) != MNG_NOERROR)
{
@ -962,8 +965,8 @@ mng_save_image (GFile *file,
}
if (mng_putchunk_bkgd (handle, MNG_FALSE, 2, 0,
gimp_rgb_luminance_uchar (&bgcolor),
red, green, blue) != MNG_NOERROR)
luminance,
rgb[0], rgb[1], rgb[2])) != MNG_NOERROR)
{
g_warning ("Unable to mng_putchunk_bkgd() in mng_save_image()");
goto err3;