2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 22:05:25 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 22:05:25 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-05-19 18:22:01 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <glib/gstdio.h>
|
2007-12-30 17:54:51 +00:00
|
|
|
#include <gegl.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2008-05-19 18:22:01 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2003-06-05 20:29:03 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2024-11-02 00:09:39 +01:00
|
|
|
#include "libgimpcolor/gimpcolor-private.h"
|
2008-01-27 17:39:01 +00:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 23:56:18 +00:00
|
|
|
|
2002-05-03 12:45:22 +00:00
|
|
|
#include "tools-types.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2012-05-10 21:22:44 +02:00
|
|
|
#include "operations/gimpcurvesconfig.h"
|
|
|
|
#include "operations/gimpoperationcurves.h"
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2003-12-11 23:35:17 +00:00
|
|
|
#include "core/gimp.h"
|
2007-11-02 12:18:50 +00:00
|
|
|
#include "core/gimpcurve.h"
|
2008-05-11 14:56:57 +00:00
|
|
|
#include "core/gimpcurve-map.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
#include "core/gimpdrawable.h"
|
2003-12-11 23:35:17 +00:00
|
|
|
#include "core/gimpdrawable-histogram.h"
|
2008-11-12 10:56:06 +00:00
|
|
|
#include "core/gimperror.h"
|
2012-03-24 22:29:53 +01:00
|
|
|
#include "core/gimphistogram.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2004-02-19 19:56:04 +00:00
|
|
|
#include "widgets/gimpcolorbar.h"
|
2007-11-04 13:09:10 +00:00
|
|
|
#include "widgets/gimpcurveview.h"
|
2018-01-06 03:12:23 +01:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
#include "widgets/gimppropwidgets.h"
|
2011-10-06 21:59:07 +02:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
#include "gimpcurvestool.h"
|
2003-12-12 00:17:04 +00:00
|
|
|
#include "gimphistogramoptions.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2007-11-02 16:51:18 +00:00
|
|
|
#define GRAPH_SIZE 256
|
|
|
|
#define BAR_SIZE 12
|
|
|
|
#define RADIUS 4
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
static gboolean gimp_curves_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error);
|
|
|
|
static void gimp_curves_tool_button_release (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static gboolean gimp_curves_tool_key_press (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_curves_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static gchar * gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
|
2017-07-09 18:58:00 +02:00
|
|
|
gchar **description);
|
2023-12-22 01:17:02 +09:00
|
|
|
static void gimp_curves_tool_dialog (GimpFilterTool *filter_tool);
|
|
|
|
static void gimp_curves_tool_reset (GimpFilterTool *filter_tool);
|
|
|
|
static void gimp_curves_tool_config_notify (GimpFilterTool *filter_tool,
|
|
|
|
GimpConfig *config,
|
|
|
|
const GParamSpec *pspec);
|
|
|
|
static gboolean gimp_curves_tool_settings_import (GimpFilterTool *filter_tool,
|
|
|
|
GInputStream *input,
|
|
|
|
GError **error);
|
|
|
|
static gboolean gimp_curves_tool_settings_export (GimpFilterTool *filter_tool,
|
|
|
|
GOutputStream *output,
|
|
|
|
GError **error);
|
|
|
|
static void gimp_curves_tool_color_picked (GimpFilterTool *filter_tool,
|
|
|
|
gpointer identifier,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
const Babl *sample_format,
|
2023-12-23 23:11:43 +09:00
|
|
|
GeglColor *color);
|
2023-12-22 01:17:02 +09:00
|
|
|
|
|
|
|
static void gimp_curves_tool_export_setup (GimpSettingsBox *settings_box,
|
|
|
|
GtkFileChooserDialog *dialog,
|
|
|
|
gboolean export,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
static void gimp_curves_tool_update_channel (GimpCurvesTool *tool);
|
|
|
|
static void gimp_curves_tool_update_point (GimpCurvesTool *tool);
|
|
|
|
|
|
|
|
static void curves_curve_dirty_callback (GimpCurve *curve,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
|
|
|
|
static void curves_channel_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
static void curves_channel_reset_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
|
|
|
|
static gboolean curves_menu_sensitivity (gint value,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void curves_graph_selection_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
|
|
|
|
static void curves_point_coords_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
static void curves_point_type_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
|
|
|
|
static void curves_curve_type_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool);
|
|
|
|
|
|
|
|
static GeglColor * curves_get_channel_color (GtkWidget *widget,
|
|
|
|
GimpHistogramChannel channel);
|
2016-05-10 00:08:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpCurvesTool, gimp_curves_tool, GIMP_TYPE_FILTER_TOOL)
|
2005-12-13 09:13:50 +00:00
|
|
|
|
|
|
|
#define parent_class gimp_curves_tool_parent_class
|
2001-11-20 23:00:47 +00:00
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
/* public functions */
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_curves_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_CURVES_TOOL,
|
2003-12-12 00:17:04 +00:00
|
|
|
GIMP_TYPE_HISTOGRAM_OPTIONS,
|
2003-12-12 10:53:41 +00:00
|
|
|
gimp_color_options_gui,
|
2003-06-28 11:20:37 +00:00
|
|
|
0,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-curves-tool",
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Curves"),
|
2018-01-14 15:42:29 +01:00
|
|
|
_("Adjust color curves"),
|
2004-04-29 13:19:28 +00:00
|
|
|
N_("_Curves..."), NULL,
|
2003-08-22 01:42:57 +00:00
|
|
|
NULL, GIMP_HELP_TOOL_CURVES,
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_TOOL_CURVES,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
|
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpFilterToolClass *filter_tool_class = GIMP_FILTER_TOOL_CLASS (klass);
|
2005-12-13 09:13:50 +00:00
|
|
|
|
2017-03-25 11:32:17 +01:00
|
|
|
tool_class->initialize = gimp_curves_tool_initialize;
|
|
|
|
tool_class->button_release = gimp_curves_tool_button_release;
|
|
|
|
tool_class->key_press = gimp_curves_tool_key_press;
|
|
|
|
tool_class->oper_update = gimp_curves_tool_oper_update;
|
2005-12-13 09:13:50 +00:00
|
|
|
|
2017-03-25 11:32:17 +01:00
|
|
|
filter_tool_class->get_operation = gimp_curves_tool_get_operation;
|
|
|
|
filter_tool_class->dialog = gimp_curves_tool_dialog;
|
|
|
|
filter_tool_class->reset = gimp_curves_tool_reset;
|
2017-07-03 00:15:09 +02:00
|
|
|
filter_tool_class->config_notify = gimp_curves_tool_config_notify;
|
2017-03-25 11:32:17 +01:00
|
|
|
filter_tool_class->settings_import = gimp_curves_tool_settings_import;
|
|
|
|
filter_tool_class->settings_export = gimp_curves_tool_settings_export;
|
2017-05-30 17:12:22 -04:00
|
|
|
filter_tool_class->color_picked = gimp_curves_tool_color_picked;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-02-21 12:25:09 +00:00
|
|
|
gimp_curves_tool_init (GimpCurvesTool *tool)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2012-03-23 09:55:35 +01:00
|
|
|
gint i;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2008-02-09 10:56:25 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (tool->picked_color); i++)
|
|
|
|
tool->picked_color[i] = -1.0;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static gboolean
|
2006-09-26 20:55:40 +00:00
|
|
|
gimp_curves_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2019-04-19 07:30:39 -04:00
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2020-05-25 11:30:31 +02:00
|
|
|
GList *drawables;
|
|
|
|
GimpDrawable *drawable;
|
2019-04-19 07:30:39 -04:00
|
|
|
GimpCurvesConfig *config;
|
|
|
|
GimpHistogram *histogram;
|
|
|
|
GimpHistogramChannel channel;
|
2003-11-13 11:23:01 +00:00
|
|
|
|
2009-08-20 17:05:23 +02:00
|
|
|
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2020-05-25 11:30:31 +02:00
|
|
|
drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
if (g_list_length (drawables) != 1)
|
|
|
|
{
|
|
|
|
if (g_list_length (drawables) > 1)
|
|
|
|
gimp_tool_message_literal (tool, display,
|
|
|
|
_("Cannot modify multiple drawables. Select only one."));
|
|
|
|
else
|
|
|
|
gimp_tool_message_literal (tool, display, _("No selected drawables."));
|
|
|
|
|
|
|
|
g_list_free (drawables);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
drawable = drawables->data;
|
|
|
|
g_list_free (drawables);
|
|
|
|
|
2018-01-05 22:37:18 +01:00
|
|
|
config = GIMP_CURVES_CONFIG (filter_tool->config);
|
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 14:23:01 +02:00
|
|
|
histogram = gimp_histogram_new (config->trc);
|
|
|
|
g_object_unref (gimp_drawable_calculate_histogram_async (drawable, histogram,
|
|
|
|
FALSE));
|
2007-11-15 10:33:51 +00:00
|
|
|
gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph),
|
2008-02-04 21:41:57 +00:00
|
|
|
histogram);
|
2013-06-11 21:23:32 +02:00
|
|
|
g_object_unref (histogram);
|
2004-02-21 12:25:09 +00:00
|
|
|
|
2013-06-23 16:51:24 +02:00
|
|
|
if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8)
|
2013-06-13 00:23:49 +02:00
|
|
|
{
|
2019-04-19 11:09:51 -04:00
|
|
|
c_tool->scale = 255.0;
|
|
|
|
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_input), 0);
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_output), 0);
|
2019-04-19 11:33:04 -04:00
|
|
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (c_tool->point_input), 3);
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (c_tool->point_output), 3);
|
2013-06-13 00:23:49 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-19 11:09:51 -04:00
|
|
|
c_tool->scale = 100.0;
|
|
|
|
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_input), 2);
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_output), 2);
|
2019-04-19 11:33:04 -04:00
|
|
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (c_tool->point_input), 6);
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (c_tool->point_output), 6);
|
2013-06-13 00:23:49 +02:00
|
|
|
}
|
|
|
|
|
2019-04-19 11:09:51 -04:00
|
|
|
gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (c_tool->graph),
|
|
|
|
0, c_tool->scale);
|
|
|
|
gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph),
|
|
|
|
0, c_tool->scale);
|
|
|
|
|
|
|
|
gtk_spin_button_set_range (GTK_SPIN_BUTTON (c_tool->point_output),
|
|
|
|
0, c_tool->scale);
|
|
|
|
|
2019-04-19 07:30:39 -04:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
|
|
|
g_signal_connect (config->curve[channel], "dirty",
|
|
|
|
G_CALLBACK (curves_curve_dirty_callback),
|
|
|
|
tool);
|
|
|
|
}
|
|
|
|
|
2019-04-19 11:09:51 -04:00
|
|
|
gimp_curves_tool_update_point (c_tool);
|
|
|
|
|
2017-05-30 17:12:22 -04:00
|
|
|
/* always pick colors */
|
|
|
|
gimp_filter_tool_enable_color_picking (filter_tool, NULL, FALSE);
|
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
return TRUE;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-27 18:55:12 +00:00
|
|
|
gimp_curves_tool_button_release (GimpTool *tool,
|
2008-11-01 15:17:36 +00:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 18:55:12 +00:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
|
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2015-10-17 15:31:08 +02:00
|
|
|
if (state & gimp_get_extend_selection_mask ())
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2008-01-25 10:02:11 +00:00
|
|
|
GimpCurve *curve = config->curve[config->channel];
|
2008-02-09 10:56:25 +00:00
|
|
|
gdouble value = c_tool->picked_color[config->channel];
|
2019-04-19 04:24:24 -04:00
|
|
|
gint point;
|
2007-11-02 12:18:50 +00:00
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
point = gimp_curve_get_point_at (curve, value);
|
2007-11-02 12:18:50 +00:00
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
if (point < 0)
|
|
|
|
{
|
2019-04-19 10:09:08 -04:00
|
|
|
GimpCurvePointType type = GIMP_CURVE_POINT_SMOOTH;
|
|
|
|
|
|
|
|
point = gimp_curve_view_get_selected (
|
|
|
|
GIMP_CURVE_VIEW (c_tool->graph));
|
|
|
|
|
|
|
|
if (point >= 0)
|
|
|
|
type = gimp_curve_get_point_type (curve, point);
|
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
point = gimp_curve_add_point (
|
|
|
|
curve,
|
|
|
|
value, gimp_curve_map_value (curve, value));
|
2019-04-19 10:09:08 -04:00
|
|
|
|
|
|
|
gimp_curve_set_point_type (curve, point, type);
|
2019-04-19 04:24:24 -04:00
|
|
|
}
|
2007-11-02 16:51:18 +00:00
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
gimp_curve_view_set_selected (GIMP_CURVE_VIEW (c_tool->graph), point);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
2011-10-06 21:59:07 +02:00
|
|
|
else if (state & gimp_get_toggle_behavior_mask ())
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2015-12-28 02:04:46 +01:00
|
|
|
GimpHistogramChannel channel;
|
2019-04-19 10:09:08 -04:00
|
|
|
GimpCurvePointType type = GIMP_CURVE_POINT_SMOOTH;
|
|
|
|
gint point;
|
|
|
|
|
|
|
|
point = gimp_curve_view_get_selected (GIMP_CURVE_VIEW (c_tool->graph));
|
|
|
|
|
|
|
|
if (point >= 0)
|
|
|
|
{
|
|
|
|
type = gimp_curve_get_point_type (config->curve[config->channel],
|
|
|
|
point);
|
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2015-12-28 02:04:46 +01:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
2002-08-28 19:47:07 +00:00
|
|
|
{
|
2015-12-28 02:04:46 +01:00
|
|
|
GimpCurve *curve = config->curve[channel];
|
|
|
|
gdouble value = c_tool->picked_color[channel];
|
2007-11-02 12:18:50 +00:00
|
|
|
|
2015-12-28 02:04:46 +01:00
|
|
|
if (value != -1)
|
|
|
|
{
|
2019-04-19 04:24:24 -04:00
|
|
|
point = gimp_curve_get_point_at (curve, value);
|
|
|
|
|
|
|
|
if (point < 0)
|
|
|
|
{
|
|
|
|
point = gimp_curve_add_point (
|
|
|
|
curve,
|
|
|
|
value, gimp_curve_map_value (curve, value));
|
2019-04-19 10:09:08 -04:00
|
|
|
|
|
|
|
gimp_curve_set_point_type (curve, point, type);
|
2019-04-19 04:24:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (channel == config->channel)
|
|
|
|
{
|
|
|
|
gimp_curve_view_set_selected (GIMP_CURVE_VIEW (c_tool->graph),
|
|
|
|
point);
|
|
|
|
}
|
2015-12-28 02:04:46 +01:00
|
|
|
}
|
2002-08-28 19:47:07 +00:00
|
|
|
}
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2003-06-05 20:29:03 +00:00
|
|
|
/* chain up to halt the tool */
|
2007-02-27 18:55:12 +00:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,
|
|
|
|
release_type, display);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2008-03-28 23:18:19 +00:00
|
|
|
static gboolean
|
2005-10-19 15:42:29 +00:00
|
|
|
gimp_curves_tool_key_press (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpDisplay *display)
|
2005-10-19 15:42:29 +00:00
|
|
|
{
|
2007-11-05 08:59:09 +00:00
|
|
|
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
|
|
|
|
|
2013-04-26 00:11:51 +02:00
|
|
|
if (tool->display && c_tool->graph)
|
|
|
|
{
|
|
|
|
if (gtk_widget_event (c_tool->graph, (GdkEvent *) kevent))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-02-08 20:28:41 +00:00
|
|
|
|
|
|
|
return GIMP_TOOL_CLASS (parent_class)->key_press (tool, kevent, display);
|
2005-10-19 15:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 15:17:36 +00:00
|
|
|
gimp_curves_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
2005-10-19 15:42:29 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
if (gimp_filter_tool_on_guide (GIMP_FILTER_TOOL (tool),
|
|
|
|
coords, display))
|
2005-10-19 15:42:29 +00:00
|
|
|
{
|
2016-04-14 19:25:59 +01:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
|
|
|
|
display);
|
2005-10-19 15:42:29 +00:00
|
|
|
}
|
2009-05-24 18:19:19 +02:00
|
|
|
else
|
|
|
|
{
|
2018-07-15 14:32:53 +02:00
|
|
|
GimpColorPickTarget target;
|
|
|
|
gchar *status = NULL;
|
|
|
|
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
2005-10-19 15:42:29 +00:00
|
|
|
|
2016-04-14 19:25:59 +01:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2005-10-19 15:42:29 +00:00
|
|
|
|
2016-04-14 19:25:59 +01:00
|
|
|
if (state & extend_mask)
|
|
|
|
{
|
2018-07-15 14:32:53 +02:00
|
|
|
target = GIMP_COLOR_PICK_TARGET_PALETTE;
|
2016-04-14 19:25:59 +01:00
|
|
|
status = g_strdup (_("Click to add a control point"));
|
|
|
|
}
|
|
|
|
else if (state & toggle_mask)
|
|
|
|
{
|
2018-07-15 14:32:53 +02:00
|
|
|
target = GIMP_COLOR_PICK_TARGET_PALETTE;
|
2016-04-14 19:25:59 +01:00
|
|
|
status = g_strdup (_("Click to add control points to all channels"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 14:32:53 +02:00
|
|
|
target = GIMP_COLOR_PICK_TARGET_NONE;
|
2016-04-14 19:25:59 +01:00
|
|
|
status = gimp_suggest_modifiers (_("Click to locate on curve"),
|
|
|
|
(extend_mask | toggle_mask) & ~state,
|
|
|
|
_("%s: add control point"),
|
|
|
|
_("%s: add control points to all channels"),
|
|
|
|
NULL);
|
|
|
|
}
|
2015-10-17 15:31:08 +02:00
|
|
|
|
2018-07-15 14:32:53 +02:00
|
|
|
GIMP_COLOR_TOOL (tool)->pick_target = target;
|
2016-04-14 19:25:59 +01:00
|
|
|
|
|
|
|
if (proximity)
|
|
|
|
gimp_tool_push_status (tool, display, "%s", status);
|
|
|
|
|
|
|
|
g_free (status);
|
|
|
|
}
|
2005-10-19 15:42:29 +00:00
|
|
|
}
|
|
|
|
|
2016-01-22 21:22:36 +01:00
|
|
|
static gchar *
|
2016-05-10 00:08:36 +02:00
|
|
|
gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
|
2017-07-09 18:58:00 +02:00
|
|
|
gchar **description)
|
2008-01-23 09:28:16 +00:00
|
|
|
{
|
2017-07-09 18:58:00 +02:00
|
|
|
*description = g_strdup (_("Adjust Color Curves"));
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2016-01-22 21:22:36 +01:00
|
|
|
return g_strdup ("gimp:curves");
|
1999-05-13 22:53:40 +00:00
|
|
|
}
|
1999-04-07 22:02:26 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
|
1999-07-02 17:40:10 +00:00
|
|
|
/*******************/
|
|
|
|
/* Curves dialog */
|
|
|
|
/*******************/
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
static void
|
2016-05-10 00:08:36 +02:00
|
|
|
gimp_curves_tool_dialog (GimpFilterTool *filter_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpCurvesTool *tool = GIMP_CURVES_TOOL (filter_tool);
|
|
|
|
GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (filter_tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2008-02-01 18:18:16 +00:00
|
|
|
GtkListStore *store;
|
2008-06-03 10:51:04 +00:00
|
|
|
GtkWidget *main_vbox;
|
2016-01-24 21:41:03 +01:00
|
|
|
GtkWidget *frame_vbox;
|
2008-02-01 18:18:16 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *hbox2;
|
|
|
|
GtkWidget *label;
|
2016-01-24 21:41:03 +01:00
|
|
|
GtkWidget *main_frame;
|
2008-02-01 18:18:16 +00:00
|
|
|
GtkWidget *frame;
|
2018-05-03 01:27:00 +02:00
|
|
|
GtkWidget *grid;
|
2008-02-01 18:18:16 +00:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *bar;
|
2008-05-22 08:39:30 +00:00
|
|
|
GtkWidget *combo;
|
2000-01-20 12:22:54 +00:00
|
|
|
|
2016-05-10 00:08:36 +02:00
|
|
|
g_signal_connect (filter_tool->settings_box, "file-dialog-setup",
|
2008-10-09 15:25:59 +00:00
|
|
|
G_CALLBACK (gimp_curves_tool_export_setup),
|
2016-05-10 00:08:36 +02:00
|
|
|
filter_tool);
|
2008-10-09 15:25:59 +00:00
|
|
|
|
2016-05-10 00:08:36 +02:00
|
|
|
main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2008-02-01 18:18:16 +00:00
|
|
|
/* The combo box for selecting channels */
|
2016-01-24 21:41:03 +01:00
|
|
|
main_frame = gimp_frame_new (NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), main_frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (main_frame);
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2016-01-24 21:41:03 +01:00
|
|
|
gtk_frame_set_label_widget (GTK_FRAME (main_frame), hbox);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2005-03-08 12:37:30 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Cha_nnel:"));
|
2016-01-24 21:41:03 +01:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
-1);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-02-28 23:27:12 +00:00
|
|
|
store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL,
|
|
|
|
GIMP_HISTOGRAM_VALUE,
|
|
|
|
GIMP_HISTOGRAM_ALPHA);
|
2023-05-22 18:13:44 +02:00
|
|
|
g_set_weak_pointer (&tool->channel_menu,
|
|
|
|
gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store)));
|
2005-02-28 23:27:12 +00:00
|
|
|
g_object_unref (store);
|
|
|
|
|
2008-02-01 18:18:16 +00:00
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
|
|
|
|
config->channel);
|
2014-05-07 21:30:06 +02:00
|
|
|
gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (tool->channel_menu),
|
|
|
|
"gimp-channel");
|
2017-01-29 14:07:06 +01:00
|
|
|
gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (tool->channel_menu),
|
|
|
|
curves_menu_sensitivity, filter_tool, NULL);
|
2008-02-01 18:18:16 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), tool->channel_menu, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tool->channel_menu);
|
2003-03-24 18:04:11 +00:00
|
|
|
|
2008-02-01 18:18:16 +00:00
|
|
|
g_signal_connect (tool->channel_menu, "changed",
|
|
|
|
G_CALLBACK (curves_channel_callback),
|
|
|
|
tool);
|
2001-11-23 23:04:49 +00:00
|
|
|
|
2008-02-01 18:18:16 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->channel_menu);
|
2005-03-08 12:37:30 +00:00
|
|
|
|
2005-08-23 00:18:08 +00:00
|
|
|
button = gtk_button_new_with_mnemonic (_("R_eset Channel"));
|
2004-03-05 01:31:33 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_widget_show (button);
|
1999-09-27 17:58:10 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-08-26 11:35:56 +00:00
|
|
|
G_CALLBACK (curves_channel_reset_callback),
|
2004-02-21 12:25:09 +00:00
|
|
|
tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2008-02-01 18:18:16 +00:00
|
|
|
/* The histogram scale radio buttons */
|
2014-05-07 21:30:06 +02:00
|
|
|
hbox2 = gimp_prop_enum_icon_box_new (G_OBJECT (tool_options),
|
|
|
|
"histogram-scale", "gimp-histogram",
|
|
|
|
0, 0);
|
2008-02-01 18:18:16 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
2002-10-14 13:39:35 +00:00
|
|
|
|
2018-01-06 03:12:23 +01:00
|
|
|
/* The linear/perceptual radio buttons */
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 14:23:01 +02:00
|
|
|
hbox2 = gimp_prop_enum_icon_box_new (G_OBJECT (config), "trc",
|
|
|
|
"gimp-color-space",
|
|
|
|
-1, -1);
|
2018-01-06 03:12:23 +01:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
2018-01-05 22:37:18 +01:00
|
|
|
|
2016-01-24 21:41:03 +01:00
|
|
|
frame_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (main_frame), frame_vbox);
|
|
|
|
gtk_widget_show (frame_vbox);
|
|
|
|
|
2018-05-03 01:27:00 +02:00
|
|
|
/* The grid for the color bars and the graph */
|
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (frame_vbox), grid, TRUE, TRUE, 0);
|
2004-02-21 12:25:09 +00:00
|
|
|
|
|
|
|
/* The left color bar */
|
2011-09-30 11:29:11 +02:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2018-05-03 01:27:00 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), vbox, 0, 0, 1, 1);
|
2008-06-03 10:51:04 +00:00
|
|
|
gtk_widget_show (vbox);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2008-06-03 10:51:04 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, RADIUS);
|
1997-11-24 22:05:25 +00:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2004-02-21 12:25:09 +00:00
|
|
|
tool->yrange = gimp_color_bar_new (GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_widget_set_size_request (tool->yrange, BAR_SIZE, -1);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), tool->yrange);
|
|
|
|
gtk_widget_show (tool->yrange);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* The curves graph */
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2018-05-03 02:40:28 +02:00
|
|
|
gtk_widget_set_hexpand (frame, TRUE);
|
|
|
|
gtk_widget_set_vexpand (frame, TRUE);
|
2018-05-03 01:27:00 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), frame, 1, 0, 1, 1);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_widget_show (frame);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2023-05-22 18:13:44 +02:00
|
|
|
g_set_weak_pointer (&tool->graph, gimp_curve_view_new ());
|
2018-01-29 21:00:25 +01:00
|
|
|
|
2010-02-23 11:39:35 +01:00
|
|
|
gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (tool->graph), 0, 255);
|
|
|
|
gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (tool->graph), 0, 255);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_widget_set_size_request (tool->graph,
|
|
|
|
GRAPH_SIZE + RADIUS * 2,
|
|
|
|
GRAPH_SIZE + RADIUS * 2);
|
|
|
|
g_object_set (tool->graph,
|
2003-12-11 23:35:17 +00:00
|
|
|
"border-width", RADIUS,
|
|
|
|
"subdivisions", 1,
|
|
|
|
NULL);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), tool->graph);
|
|
|
|
gtk_widget_show (tool->graph);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2016-05-13 22:00:25 +02:00
|
|
|
g_object_bind_property (G_OBJECT (tool_options), "histogram-scale",
|
|
|
|
G_OBJECT (tool->graph), "histogram-scale",
|
|
|
|
G_BINDING_SYNC_CREATE |
|
|
|
|
G_BINDING_BIDIRECTIONAL);
|
2004-02-21 12:25:09 +00:00
|
|
|
|
2019-04-19 07:30:39 -04:00
|
|
|
g_signal_connect (tool->graph, "selection-changed",
|
|
|
|
G_CALLBACK (curves_graph_selection_callback),
|
|
|
|
tool);
|
|
|
|
|
2004-02-21 12:25:09 +00:00
|
|
|
/* The bottom color bar */
|
2011-09-30 11:29:11 +02:00
|
|
|
hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2018-05-03 01:27:00 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), hbox2, 1, 1, 1, 1);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_widget_show (hbox2);
|
2003-12-12 00:17:04 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), frame, TRUE, TRUE, RADIUS);
|
1997-11-24 22:05:25 +00:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
|
2008-06-03 10:51:04 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
2004-02-19 19:56:04 +00:00
|
|
|
|
2004-02-21 12:25:09 +00:00
|
|
|
tool->xrange = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_widget_set_size_request (tool->xrange, -1, BAR_SIZE / 2);
|
2008-06-03 10:51:04 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), tool->xrange, TRUE, TRUE, 0);
|
2004-02-21 12:25:09 +00:00
|
|
|
gtk_widget_show (tool->xrange);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2004-02-19 19:56:04 +00:00
|
|
|
bar = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL);
|
2008-06-03 10:51:04 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), bar, TRUE, TRUE, 0);
|
2004-02-19 19:56:04 +00:00
|
|
|
gtk_widget_show (bar);
|
|
|
|
|
2018-05-03 01:27:00 +02:00
|
|
|
gtk_widget_show (grid);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-04-19 11:09:51 -04:00
|
|
|
/* The point properties box */
|
2019-04-19 07:30:39 -04:00
|
|
|
tool->point_box = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tool->point_box);
|
|
|
|
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Input:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2019-04-19 11:22:57 -04:00
|
|
|
tool->point_input = gimp_spin_button_new_with_range (0.0, 0.0, 1.0);
|
2019-04-19 07:30:39 -04:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), tool->point_input, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tool->point_input);
|
|
|
|
|
|
|
|
g_signal_connect (tool->point_input, "value-changed",
|
|
|
|
G_CALLBACK (curves_point_coords_callback),
|
|
|
|
tool);
|
|
|
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->point_input);
|
|
|
|
|
|
|
|
label = gtk_label_new_with_mnemonic (_("O_utput:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2019-04-19 11:22:57 -04:00
|
|
|
tool->point_output = gimp_spin_button_new_with_range (0.0, 0.0, 1.0);
|
2019-04-19 07:30:39 -04:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), tool->point_output, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tool->point_output);
|
|
|
|
|
|
|
|
g_signal_connect (tool->point_output, "value-changed",
|
|
|
|
G_CALLBACK (curves_point_coords_callback),
|
|
|
|
tool);
|
|
|
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->point_output);
|
|
|
|
|
2019-04-19 10:09:08 -04:00
|
|
|
label = gtk_label_new_with_mnemonic (_("T_ype:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
hbox2 = gimp_enum_icon_box_new (GIMP_TYPE_CURVE_POINT_TYPE,
|
|
|
|
"gimp-curve-point",
|
|
|
|
GTK_ICON_SIZE_MENU,
|
|
|
|
G_CALLBACK (curves_point_type_callback),
|
2019-08-08 00:01:10 +02:00
|
|
|
tool, NULL,
|
2019-04-19 10:09:08 -04:00
|
|
|
&tool->point_type);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox2);
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2019-04-19 07:30:39 -04:00
|
|
|
gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, FALSE, FALSE, 0);
|
2003-03-14 23:24:37 +00:00
|
|
|
gtk_widget_show (hbox);
|
2003-07-10 12:13:21 +00:00
|
|
|
|
2019-04-19 10:09:08 -04:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->point_type);
|
|
|
|
|
2008-05-22 08:39:30 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Curve _type:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
2003-03-14 23:24:37 +00:00
|
|
|
|
2019-04-19 11:09:51 -04:00
|
|
|
/* The curve-type combo */
|
2008-05-22 08:39:30 +00:00
|
|
|
tool->curve_type = combo = gimp_enum_combo_box_new (GIMP_TYPE_CURVE_TYPE);
|
2014-05-07 21:30:06 +02:00
|
|
|
gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo),
|
|
|
|
"gimp-curve");
|
2008-05-22 08:39:30 +00:00
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), 0,
|
|
|
|
G_CALLBACK (curves_curve_type_callback),
|
2019-08-08 00:22:15 +02:00
|
|
|
tool, NULL);
|
2008-05-22 08:39:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (combo);
|
2008-05-22 09:05:30 +00:00
|
|
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
2015-06-15 00:11:13 +02:00
|
|
|
|
|
|
|
gimp_curves_tool_update_channel (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-10-17 11:33:43 +00:00
|
|
|
static void
|
2016-05-10 00:08:36 +02:00
|
|
|
gimp_curves_tool_reset (GimpFilterTool *filter_tool)
|
2001-10-17 11:33:43 +00:00
|
|
|
{
|
2020-04-14 17:53:21 +03:00
|
|
|
GimpHistogramChannel channel;
|
2008-09-30 13:46:08 +00:00
|
|
|
|
2020-04-14 17:53:21 +03:00
|
|
|
g_object_get (filter_tool->config,
|
|
|
|
"channel", &channel,
|
|
|
|
NULL);
|
2008-09-30 13:46:08 +00:00
|
|
|
|
2020-04-14 17:53:21 +03:00
|
|
|
GIMP_FILTER_TOOL_CLASS (parent_class)->reset (filter_tool);
|
2018-01-05 22:37:18 +01:00
|
|
|
|
2020-04-14 17:53:21 +03:00
|
|
|
g_object_set (filter_tool->config,
|
|
|
|
"channel", channel,
|
|
|
|
NULL);
|
2001-10-17 11:33:43 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 00:15:09 +02:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_config_notify (GimpFilterTool *filter_tool,
|
|
|
|
GimpConfig *config,
|
|
|
|
const GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpCurvesTool *curves_tool = GIMP_CURVES_TOOL (filter_tool);
|
|
|
|
GimpCurvesConfig *curves_config = GIMP_CURVES_CONFIG (config);
|
|
|
|
GimpCurve *curve = curves_config->curve[curves_config->channel];
|
|
|
|
|
|
|
|
GIMP_FILTER_TOOL_CLASS (parent_class)->config_notify (filter_tool,
|
|
|
|
config, pspec);
|
|
|
|
|
2018-01-20 16:01:20 +01:00
|
|
|
if (! curves_tool->channel_menu ||
|
|
|
|
! curves_tool->graph)
|
2017-07-03 00:15:09 +02:00
|
|
|
return;
|
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 14:23:01 +02:00
|
|
|
if (! strcmp (pspec->name, "trc"))
|
2018-01-05 22:37:18 +01:00
|
|
|
{
|
|
|
|
GimpHistogram *histogram;
|
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 14:23:01 +02:00
|
|
|
histogram = gimp_histogram_new (curves_config->trc);
|
|
|
|
g_object_unref (gimp_drawable_calculate_histogram_async
|
2020-05-25 11:30:31 +02:00
|
|
|
(GIMP_TOOL (filter_tool)->drawables->data, histogram, FALSE));
|
2018-01-05 22:37:18 +01:00
|
|
|
gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (curves_tool->graph),
|
|
|
|
histogram);
|
|
|
|
g_object_unref (histogram);
|
|
|
|
}
|
|
|
|
else if (! strcmp (pspec->name, "channel"))
|
2017-07-03 00:15:09 +02:00
|
|
|
{
|
|
|
|
gimp_curves_tool_update_channel (GIMP_CURVES_TOOL (filter_tool));
|
|
|
|
}
|
|
|
|
else if (! strcmp (pspec->name, "curve"))
|
|
|
|
{
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (curves_tool->curve_type),
|
|
|
|
curve->curve_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
static gboolean
|
2016-05-10 00:08:36 +02:00
|
|
|
gimp_curves_tool_settings_import (GimpFilterTool *filter_tool,
|
|
|
|
GInputStream *input,
|
|
|
|
GError **error)
|
2004-02-25 10:23:43 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2016-01-22 21:22:36 +01:00
|
|
|
gchar header[64];
|
|
|
|
gsize bytes_read;
|
2008-05-19 18:22:01 +00:00
|
|
|
|
2014-07-04 13:18:01 +02:00
|
|
|
if (! g_input_stream_read_all (input, header, sizeof (header),
|
|
|
|
&bytes_read, NULL, error) ||
|
|
|
|
bytes_read != sizeof (header))
|
2008-06-25 08:16:48 +00:00
|
|
|
{
|
2025-04-09 13:09:41 +00:00
|
|
|
/* A Photoshop .acv curves preset file might be smaller than
|
|
|
|
* 64 bytes, so we'll check if that's the case */
|
|
|
|
if (bytes_read > 2 && header[0] == 0 &&
|
|
|
|
(header[1] == 1 || header[1] == 4))
|
|
|
|
{
|
|
|
|
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL);
|
|
|
|
|
|
|
|
return gimp_curves_config_load_acv (config, input, error);
|
|
|
|
}
|
|
|
|
|
2025-04-07 18:57:31 +00:00
|
|
|
if (error && *error)
|
|
|
|
g_prefix_error (error, _("Could not read header: "));
|
|
|
|
else
|
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
|
|
|
_("Could not read header: "));
|
2008-06-25 08:16:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-07-04 18:19:45 +02:00
|
|
|
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL);
|
2008-06-25 08:16:48 +00:00
|
|
|
|
2014-07-04 18:19:45 +02:00
|
|
|
if (g_str_has_prefix (header, "# GIMP Curves File\n"))
|
2016-01-22 21:22:36 +01:00
|
|
|
return gimp_curves_config_load_cruft (config, input, error);
|
2004-02-25 13:55:45 +00:00
|
|
|
|
2025-04-09 13:09:41 +00:00
|
|
|
if (bytes_read > 2 && header[0] == 0 &&
|
|
|
|
(header[1] == 1 || header[1] == 4))
|
|
|
|
return gimp_curves_config_load_acv (config, input, error);
|
|
|
|
|
2016-05-10 00:08:36 +02:00
|
|
|
return GIMP_FILTER_TOOL_CLASS (parent_class)->settings_import (filter_tool,
|
|
|
|
input,
|
|
|
|
error);
|
2004-02-25 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-05-10 00:08:36 +02:00
|
|
|
gimp_curves_tool_settings_export (GimpFilterTool *filter_tool,
|
|
|
|
GOutputStream *output,
|
|
|
|
GError **error)
|
2004-02-25 10:23:43 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpCurvesTool *tool = GIMP_CURVES_TOOL (filter_tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2008-05-19 18:22:01 +00:00
|
|
|
|
2008-10-09 15:25:59 +00:00
|
|
|
if (tool->export_old_format)
|
2016-01-22 21:22:36 +01:00
|
|
|
return gimp_curves_config_save_cruft (config, output, error);
|
2008-05-19 18:22:01 +00:00
|
|
|
|
2016-05-10 00:08:36 +02:00
|
|
|
return GIMP_FILTER_TOOL_CLASS (parent_class)->settings_export (filter_tool,
|
|
|
|
output,
|
|
|
|
error);
|
2008-10-09 15:25:59 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:40:59 -04:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_color_picked (GimpFilterTool *filter_tool,
|
|
|
|
gpointer identifier,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
const Babl *sample_format,
|
2023-12-23 23:11:43 +09:00
|
|
|
GeglColor *color)
|
2017-05-31 08:40:59 -04:00
|
|
|
{
|
2017-07-10 23:28:49 +02:00
|
|
|
GimpCurvesTool *tool = GIMP_CURVES_TOOL (filter_tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2020-05-25 11:30:31 +02:00
|
|
|
GimpDrawable *drawable = GIMP_TOOL (tool)->drawables->data;
|
2023-12-23 23:11:43 +09:00
|
|
|
gdouble rgb[4];
|
2018-01-05 22:37:18 +01:00
|
|
|
|
2023-12-23 23:11:43 +09:00
|
|
|
/* TODO: double-check this code. What RGB values do we want exactly? Right
|
|
|
|
* now, we use sRGB space values.
|
|
|
|
*/
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 14:23:01 +02:00
|
|
|
if (config->trc == GIMP_TRC_LINEAR)
|
2023-12-23 23:11:43 +09:00
|
|
|
gegl_color_get_pixel (color, babl_format ("RGBA double"), rgb);
|
|
|
|
else
|
|
|
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
2017-05-31 08:40:59 -04:00
|
|
|
|
2023-12-23 23:11:43 +09:00
|
|
|
tool->picked_color[GIMP_HISTOGRAM_RED] = rgb[0];
|
|
|
|
tool->picked_color[GIMP_HISTOGRAM_GREEN] = rgb[1];
|
|
|
|
tool->picked_color[GIMP_HISTOGRAM_BLUE] = rgb[2];
|
2017-05-31 08:40:59 -04:00
|
|
|
|
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2023-12-23 23:11:43 +09:00
|
|
|
tool->picked_color[GIMP_HISTOGRAM_ALPHA] = rgb[3];
|
2017-05-31 08:40:59 -04:00
|
|
|
else
|
|
|
|
tool->picked_color[GIMP_HISTOGRAM_ALPHA] = -1;
|
|
|
|
|
2023-12-23 23:11:43 +09:00
|
|
|
tool->picked_color[GIMP_HISTOGRAM_VALUE] = MAX (MAX (rgb[0], rgb[1]), rgb[2]);
|
2017-05-31 08:40:59 -04:00
|
|
|
|
|
|
|
gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
|
|
|
|
tool->picked_color[config->channel]);
|
|
|
|
}
|
|
|
|
|
2008-10-09 15:25:59 +00:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_export_setup (GimpSettingsBox *settings_box,
|
|
|
|
GtkFileChooserDialog *dialog,
|
|
|
|
gboolean export,
|
|
|
|
GimpCurvesTool *tool)
|
|
|
|
{
|
|
|
|
GtkWidget *button;
|
2008-05-19 18:22:01 +00:00
|
|
|
|
2008-10-09 15:25:59 +00:00
|
|
|
if (! export)
|
|
|
|
return;
|
|
|
|
|
|
|
|
button = gtk_check_button_new_with_mnemonic (_("Use _old curves file format"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
|
|
|
tool->export_old_format);
|
|
|
|
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), button);
|
|
|
|
gtk_widget_show (button);
|
2004-02-25 13:55:45 +00:00
|
|
|
|
2008-10-09 15:25:59 +00:00
|
|
|
g_signal_connect (button, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&tool->export_old_format);
|
2004-02-25 10:23:43 +00:00
|
|
|
}
|
1999-09-03 21:58:41 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2015-06-15 00:11:13 +02:00
|
|
|
gimp_curves_tool_update_channel (GimpCurvesTool *tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
|
|
|
GimpCurve *curve = config->curve[config->channel];
|
2015-06-15 00:11:13 +02:00
|
|
|
GimpHistogramChannel channel;
|
2008-01-25 10:02:11 +00:00
|
|
|
|
2015-06-15 00:11:13 +02:00
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
|
|
|
|
config->channel);
|
2007-11-05 08:59:09 +00:00
|
|
|
|
2015-06-15 00:11:13 +02:00
|
|
|
switch (config->channel)
|
2002-05-03 11:31:08 +00:00
|
|
|
{
|
2015-06-15 00:11:13 +02:00
|
|
|
guchar r[256];
|
|
|
|
guchar g[256];
|
|
|
|
guchar b[256];
|
|
|
|
|
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
|
|
|
case GIMP_HISTOGRAM_RGB:
|
2015-11-02 08:53:50 +01:00
|
|
|
case GIMP_HISTOGRAM_LUMINANCE:
|
2015-06-15 00:11:13 +02:00
|
|
|
gimp_curve_get_uchar (curve, sizeof (r), r);
|
|
|
|
|
|
|
|
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
|
|
|
|
r, r, r);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
|
|
|
gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_RED],
|
|
|
|
sizeof (r), r);
|
|
|
|
gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_GREEN],
|
|
|
|
sizeof (g), g);
|
|
|
|
gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_BLUE],
|
|
|
|
sizeof (b), b);
|
|
|
|
|
|
|
|
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
|
|
|
|
r, g, b);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
|
|
|
|
config->channel);
|
|
|
|
gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
|
|
|
|
tool->picked_color[config->channel]);
|
|
|
|
|
|
|
|
gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange),
|
|
|
|
config->channel);
|
2010-02-20 20:32:19 +01:00
|
|
|
|
2015-06-15 00:11:13 +02:00
|
|
|
gimp_curve_view_remove_all_backgrounds (GIMP_CURVE_VIEW (tool->graph));
|
2008-02-01 18:18:16 +00:00
|
|
|
|
2015-06-15 00:11:13 +02:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
2023-12-22 01:17:02 +09:00
|
|
|
GeglColor *curve_color;
|
2017-02-09 22:41:05 +01:00
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
curve_color = curves_get_channel_color (tool->graph, channel);
|
2017-02-09 22:41:05 +01:00
|
|
|
|
2015-06-15 00:11:13 +02:00
|
|
|
if (channel == config->channel)
|
2023-12-22 01:17:02 +09:00
|
|
|
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve, curve_color);
|
2015-06-15 00:11:13 +02:00
|
|
|
else
|
2023-12-22 01:17:02 +09:00
|
|
|
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
|
|
|
|
config->curve[channel], curve_color);
|
|
|
|
|
|
|
|
g_clear_object (&curve_color);
|
2015-06-15 00:11:13 +02:00
|
|
|
}
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2015-06-15 00:11:13 +02:00
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->curve_type),
|
|
|
|
curve->curve_type);
|
2019-04-19 07:30:39 -04:00
|
|
|
|
|
|
|
gimp_curves_tool_update_point (tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_curves_tool_update_point (GimpCurvesTool *tool)
|
|
|
|
{
|
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
|
|
|
GimpCurve *curve = config->curve[config->channel];
|
|
|
|
gint point;
|
|
|
|
|
|
|
|
point = gimp_curve_view_get_selected (GIMP_CURVE_VIEW (tool->graph));
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (tool->point_box, point >= 0);
|
|
|
|
|
|
|
|
if (point >= 0)
|
|
|
|
{
|
|
|
|
gdouble min = 0.0;
|
|
|
|
gdouble max = 1.0;
|
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
|
|
|
|
if (point > 0)
|
|
|
|
gimp_curve_get_point (curve, point - 1, &min, NULL);
|
|
|
|
|
|
|
|
if (point < gimp_curve_get_n_points (curve) - 1)
|
|
|
|
gimp_curve_get_point (curve, point + 1, &max, NULL);
|
|
|
|
|
|
|
|
gimp_curve_get_point (curve, point, &x, &y);
|
|
|
|
|
2019-04-19 11:09:51 -04:00
|
|
|
x *= tool->scale;
|
|
|
|
y *= tool->scale;
|
|
|
|
min *= tool->scale;
|
|
|
|
max *= tool->scale;
|
2019-04-19 07:30:39 -04:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (tool->point_input,
|
|
|
|
curves_point_coords_callback,
|
|
|
|
tool);
|
|
|
|
g_signal_handlers_block_by_func (tool->point_output,
|
|
|
|
curves_point_coords_callback,
|
|
|
|
tool);
|
|
|
|
|
|
|
|
gtk_spin_button_set_range (GTK_SPIN_BUTTON (tool->point_input), min, max);
|
|
|
|
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (tool->point_input), x);
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (tool->point_output), y);
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (tool->point_input,
|
|
|
|
curves_point_coords_callback,
|
|
|
|
tool);
|
|
|
|
g_signal_handlers_unblock_by_func (tool->point_output,
|
|
|
|
curves_point_coords_callback,
|
|
|
|
tool);
|
2019-04-19 10:09:08 -04:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (tool->point_type,
|
|
|
|
curves_point_type_callback,
|
|
|
|
tool);
|
|
|
|
|
|
|
|
gimp_int_radio_group_set_active (
|
|
|
|
GTK_RADIO_BUTTON (tool->point_type),
|
|
|
|
gimp_curve_get_point_type (curve, point));
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (tool->point_type,
|
|
|
|
curves_point_type_callback,
|
|
|
|
tool);
|
2019-04-19 07:30:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
curves_curve_dirty_callback (GimpCurve *curve,
|
|
|
|
GimpCurvesTool *tool)
|
|
|
|
{
|
|
|
|
if (tool->graph &&
|
|
|
|
gimp_curve_view_get_curve (GIMP_CURVE_VIEW (tool->graph)) == curve)
|
|
|
|
{
|
|
|
|
gimp_curves_tool_update_point (tool);
|
|
|
|
}
|
2015-06-15 00:11:13 +02:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2008-01-30 18:31:43 +00:00
|
|
|
static void
|
|
|
|
curves_channel_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool)
|
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2008-01-30 18:31:43 +00:00
|
|
|
gint value;
|
|
|
|
|
|
|
|
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
|
|
|
|
config->channel != value)
|
|
|
|
{
|
|
|
|
g_object_set (config,
|
|
|
|
"channel", value,
|
|
|
|
NULL);
|
2007-04-12 14:48:04 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 15:57:25 +00:00
|
|
|
curves_channel_reset_callback (GtkWidget *widget,
|
2004-02-21 12:25:09 +00:00
|
|
|
GimpCurvesTool *tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
2016-01-22 21:22:36 +01:00
|
|
|
|
|
|
|
gimp_curve_reset (config->curve[config->channel], FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2002-03-17 16:35:05 +00:00
|
|
|
static gboolean
|
2005-02-28 23:27:12 +00:00
|
|
|
curves_menu_sensitivity (gint value,
|
|
|
|
gpointer data)
|
2002-03-17 16:35:05 +00:00
|
|
|
{
|
2020-05-25 11:30:31 +02:00
|
|
|
GimpDrawable *drawable = GIMP_TOOL (data)->drawables->data;
|
2008-02-03 23:53:00 +00:00
|
|
|
GimpHistogramChannel channel = value;
|
2004-04-18 22:38:45 +00:00
|
|
|
|
2017-01-29 14:07:06 +01:00
|
|
|
if (!drawable)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-03-17 16:35:05 +00:00
|
|
|
switch (channel)
|
|
|
|
{
|
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
return TRUE;
|
2004-01-24 18:35:49 +00:00
|
|
|
|
2002-03-17 16:35:05 +00:00
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
2008-02-03 23:53:00 +00:00
|
|
|
return gimp_drawable_is_rgb (drawable);
|
2004-01-24 18:35:49 +00:00
|
|
|
|
2002-03-17 16:35:05 +00:00
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
2008-02-03 23:53:00 +00:00
|
|
|
return gimp_drawable_has_alpha (drawable);
|
2004-07-06 16:33:30 +00:00
|
|
|
|
|
|
|
case GIMP_HISTOGRAM_RGB:
|
|
|
|
return FALSE;
|
2015-11-02 08:53:50 +01:00
|
|
|
|
|
|
|
case GIMP_HISTOGRAM_LUMINANCE:
|
|
|
|
return FALSE;
|
2002-03-17 16:35:05 +00:00
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2002-03-17 16:35:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-19 07:30:39 -04:00
|
|
|
static void
|
|
|
|
curves_graph_selection_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool)
|
|
|
|
{
|
|
|
|
gimp_curves_tool_update_point (tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
curves_point_coords_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool)
|
|
|
|
{
|
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
|
|
|
GimpCurve *curve = config->curve[config->channel];
|
|
|
|
gint point;
|
|
|
|
|
|
|
|
point = gimp_curve_view_get_selected (GIMP_CURVE_VIEW (tool->graph));
|
|
|
|
|
|
|
|
if (point >= 0)
|
|
|
|
{
|
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
|
|
|
|
x = gtk_spin_button_get_value (GTK_SPIN_BUTTON (tool->point_input));
|
|
|
|
y = gtk_spin_button_get_value (GTK_SPIN_BUTTON (tool->point_output));
|
|
|
|
|
2019-04-19 11:09:51 -04:00
|
|
|
x /= tool->scale;
|
|
|
|
y /= tool->scale;
|
2019-04-19 07:30:39 -04:00
|
|
|
|
|
|
|
gimp_curve_set_point (curve, point, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-19 10:09:08 -04:00
|
|
|
static void
|
|
|
|
curves_point_type_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *tool)
|
|
|
|
{
|
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
|
|
|
GimpCurve *curve = config->curve[config->channel];
|
|
|
|
gint point;
|
|
|
|
|
|
|
|
point = gimp_curve_view_get_selected (GIMP_CURVE_VIEW (tool->graph));
|
|
|
|
|
|
|
|
if (point >= 0 && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
{
|
|
|
|
GimpCurvePointType type;
|
|
|
|
|
|
|
|
type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
|
|
|
"gimp-item-data"));
|
|
|
|
|
|
|
|
gimp_curve_set_point_type (curve, point, type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2003-03-14 23:24:37 +00:00
|
|
|
curves_curve_type_callback (GtkWidget *widget,
|
2004-12-17 13:11:29 +00:00
|
|
|
GimpCurvesTool *tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2008-05-22 08:39:30 +00:00
|
|
|
gint value;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2008-05-22 08:39:30 +00:00
|
|
|
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
|
|
|
|
{
|
2016-05-10 00:08:36 +02:00
|
|
|
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
|
|
|
|
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (filter_tool->config);
|
|
|
|
GimpCurveType curve_type = value;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2008-02-01 18:18:16 +00:00
|
|
|
if (config->curve[config->channel]->curve_type != curve_type)
|
2008-05-22 08:39:30 +00:00
|
|
|
gimp_curve_set_curve_type (config->curve[config->channel], curve_type);
|
2000-05-09 05:43:29 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2014-09-21 12:29:35 +02:00
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
static GeglColor *
|
2017-02-09 22:41:05 +01:00
|
|
|
curves_get_channel_color (GtkWidget *widget,
|
2023-12-22 01:17:02 +09:00
|
|
|
GimpHistogramChannel channel)
|
2014-09-21 12:29:35 +02:00
|
|
|
{
|
2023-12-22 01:17:02 +09:00
|
|
|
static const gdouble channel_colors[GIMP_HISTOGRAM_RGB][4] =
|
2014-09-21 12:29:35 +02:00
|
|
|
{
|
|
|
|
{ 0.0, 0.0, 0.0, 1.0 },
|
|
|
|
{ 1.0, 0.0, 0.0, 1.0 },
|
|
|
|
{ 0.0, 1.0, 0.0, 1.0 },
|
|
|
|
{ 0.0, 0.0, 1.0, 1.0 },
|
|
|
|
{ 0.5, 0.5, 0.5, 1.0 }
|
|
|
|
};
|
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
GeglColor *color;
|
|
|
|
GdkRGBA rgba;
|
2018-05-08 23:32:48 +02:00
|
|
|
|
2014-09-21 12:29:35 +02:00
|
|
|
if (channel == GIMP_HISTOGRAM_VALUE)
|
2023-12-22 01:17:02 +09:00
|
|
|
return NULL;
|
2017-02-09 22:41:05 +01:00
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
color = gegl_color_new (NULL);
|
2017-02-09 22:41:05 +01:00
|
|
|
if (channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
{
|
2018-05-08 23:32:48 +02:00
|
|
|
GtkStyleContext *style = gtk_widget_get_style_context (widget);
|
|
|
|
gdouble lum;
|
2023-12-22 01:17:02 +09:00
|
|
|
gdouble rgb[4];
|
2018-05-08 23:32:48 +02:00
|
|
|
|
|
|
|
gtk_style_context_get_color (style, gtk_style_context_get_state (style),
|
|
|
|
&rgba);
|
|
|
|
|
|
|
|
lum = GIMP_RGB_LUMINANCE (rgba.red, rgba.green, rgba.blue);
|
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
rgb[3] = 1.0;
|
2018-05-08 23:32:48 +02:00
|
|
|
if (lum > 0.5)
|
2023-12-22 01:17:02 +09:00
|
|
|
rgb[0] = rgb[1] = rgb[2] = lum - 0.3;
|
2018-05-08 23:32:48 +02:00
|
|
|
else
|
2023-12-22 01:17:02 +09:00
|
|
|
rgb[0] = rgb[1] = rgb[2] = lum + 0.3;
|
2014-09-21 12:29:35 +02:00
|
|
|
|
2024-02-12 18:28:50 +01:00
|
|
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
2023-12-22 01:17:02 +09:00
|
|
|
|
|
|
|
return color;
|
2017-02-09 22:41:05 +01:00
|
|
|
}
|
|
|
|
|
2024-02-12 18:28:50 +01:00
|
|
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), channel_colors[channel]);
|
2018-05-08 23:32:48 +02:00
|
|
|
|
2023-12-22 01:17:02 +09:00
|
|
|
return color;
|
2014-09-21 12:29:35 +02:00
|
|
|
}
|