2008-01-23 09:28:16 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpcurvesconfig.c
|
|
|
|
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-01-23 09:28:16 +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
|
2008-01-23 09:28:16 +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/>.
|
2008-01-23 09:28:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-04-28 15:50:39 +02:00
|
|
|
#include <cairo.h>
|
2008-01-23 09:28:16 +00:00
|
|
|
#include <gegl.h>
|
2012-05-03 03:36:22 +02:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2014-07-02 23:40:26 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2008-01-23 09:28:16 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
2008-01-25 13:02:37 +00:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2012-05-10 21:22:44 +02:00
|
|
|
#include "operations-types.h"
|
2008-01-23 09:28:16 +00:00
|
|
|
|
Issue #1682 - Segfault when starting GIMP, due to empty data files
Use gimp_input_data_stream_read_line_always(), instead of
g_input_data_stream_read_line(), in a bunch of places that don't
expect EOF. If we don't do that, the code assumes the GError
parameter is set by the function and returns an error indication,
causing the caller to segfault when it tries to access
error->message. Instead, we now process an empty line when EOF is
reached, which is caught by the normal parsing logic.
Additionally:
- Use gimp_ascii_strto[id]() when loading gradients, generated
brushes, and palettes, to improve error checking for invalid
numeric input.
- Improve gradient-segment endpoint consistency check.
- Allow loading palette files with 0 colors. They can be created
during the session, so we might as well successfully load them.
2018-06-20 14:47:15 -04:00
|
|
|
#include "core/gimp-utils.h"
|
2008-02-01 12:45:32 +00:00
|
|
|
#include "core/gimpcurve.h"
|
2012-03-24 22:29:53 +01:00
|
|
|
#include "core/gimphistogram.h"
|
2008-02-01 12:45:32 +00:00
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
#include "gimpcurvesconfig.h"
|
|
|
|
|
2008-01-25 13:02:37 +00:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
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
|
|
|
PROP_TRC,
|
2018-01-05 22:37:18 +01:00
|
|
|
PROP_LINEAR,
|
2008-01-23 09:28:16 +00:00
|
|
|
PROP_CHANNEL,
|
|
|
|
PROP_CURVE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
static void gimp_curves_config_iface_init (GimpConfigInterface *iface);
|
2008-01-27 17:39:01 +00:00
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
static void gimp_curves_config_finalize (GObject *object);
|
|
|
|
static void gimp_curves_config_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_curves_config_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2008-05-18 19:13:28 +00:00
|
|
|
static gboolean gimp_curves_config_serialize (GimpConfig *config,
|
|
|
|
GimpConfigWriter *writer,
|
|
|
|
gpointer data);
|
|
|
|
static gboolean gimp_curves_config_deserialize (GimpConfig *config,
|
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level,
|
|
|
|
gpointer data);
|
2008-02-01 12:45:32 +00:00
|
|
|
static gboolean gimp_curves_config_equal (GimpConfig *a,
|
|
|
|
GimpConfig *b);
|
|
|
|
static void gimp_curves_config_reset (GimpConfig *config);
|
|
|
|
static gboolean gimp_curves_config_copy (GimpConfig *src,
|
|
|
|
GimpConfig *dest,
|
|
|
|
GParamFlags flags);
|
2008-01-30 15:48:23 +00:00
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
static void gimp_curves_config_curve_dirty (GimpCurve *curve,
|
|
|
|
GimpCurvesConfig *config);
|
2008-01-27 17:39:01 +00:00
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
|
2008-01-27 17:39:01 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpCurvesConfig, gimp_curves_config,
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
GIMP_TYPE_OPERATION_SETTINGS,
|
2008-01-27 17:39:01 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
|
|
|
gimp_curves_config_iface_init))
|
2008-01-23 09:28:16 +00:00
|
|
|
|
|
|
|
#define parent_class gimp_curves_config_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-01-28 18:57:11 +00:00
|
|
|
gimp_curves_config_class_init (GimpCurvesConfigClass *klass)
|
2008-01-23 09:28:16 +00:00
|
|
|
{
|
2008-02-01 12:45:32 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
|
2014-05-07 01:01:56 +02:00
|
|
|
object_class->finalize = gimp_curves_config_finalize;
|
|
|
|
object_class->set_property = gimp_curves_config_set_property;
|
|
|
|
object_class->get_property = gimp_curves_config_get_property;
|
2008-02-01 12:45:32 +00:00
|
|
|
|
2014-05-07 01:01:56 +02:00
|
|
|
viewable_class->default_icon_name = "gimp-tool-curves";
|
2008-02-01 12:45:32 +00:00
|
|
|
|
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
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_TRC,
|
|
|
|
"trc",
|
2025-07-03 02:45:38 +02:00
|
|
|
_("Tone Reproduction Curve"),
|
|
|
|
_("Work on linear or perceptual RGB, or following the image's TRC"),
|
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
|
|
|
GIMP_TYPE_TRC_TYPE,
|
|
|
|
GIMP_TRC_NON_LINEAR, 0);
|
|
|
|
|
|
|
|
/* compat */
|
2018-01-05 22:37:18 +01:00
|
|
|
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_LINEAR,
|
|
|
|
"linear",
|
|
|
|
_("Linear"),
|
|
|
|
_("Work on linear RGB"),
|
|
|
|
FALSE, 0);
|
|
|
|
|
2016-02-11 23:44:07 +01:00
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CHANNEL,
|
|
|
|
"channel",
|
|
|
|
_("Channel"),
|
|
|
|
_("The affected channel"),
|
|
|
|
GIMP_TYPE_HISTOGRAM_CHANNEL,
|
|
|
|
GIMP_HISTOGRAM_VALUE, 0);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_OBJECT (object_class, PROP_CURVE,
|
|
|
|
"curve",
|
|
|
|
_("Curve"),
|
|
|
|
_("Curve"),
|
|
|
|
GIMP_TYPE_CURVE,
|
|
|
|
GIMP_CONFIG_PARAM_AGGREGATE);
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 17:39:01 +00:00
|
|
|
static void
|
|
|
|
gimp_curves_config_iface_init (GimpConfigInterface *iface)
|
|
|
|
{
|
2008-05-18 19:13:28 +00:00
|
|
|
iface->serialize = gimp_curves_config_serialize;
|
|
|
|
iface->deserialize = gimp_curves_config_deserialize;
|
|
|
|
iface->equal = gimp_curves_config_equal;
|
|
|
|
iface->reset = gimp_curves_config_reset;
|
|
|
|
iface->copy = gimp_curves_config_copy;
|
2008-01-27 17:39:01 +00:00
|
|
|
}
|
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
static void
|
|
|
|
gimp_curves_config_init (GimpCurvesConfig *self)
|
|
|
|
{
|
|
|
|
GimpHistogramChannel channel;
|
|
|
|
|
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
|
|
|
self->curve[channel] = GIMP_CURVE (gimp_curve_new ("curves config"));
|
2008-01-30 15:48:23 +00:00
|
|
|
|
|
|
|
g_signal_connect_object (self->curve[channel], "dirty",
|
|
|
|
G_CALLBACK (gimp_curves_config_curve_dirty),
|
|
|
|
self, 0);
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 17:39:01 +00:00
|
|
|
gimp_config_reset (GIMP_CONFIG (self));
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_curves_config_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object);
|
|
|
|
GimpHistogramChannel channel;
|
|
|
|
|
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
2008-02-01 12:45:32 +00:00
|
|
|
g_object_unref (self->curve[channel]);
|
|
|
|
self->curve[channel] = NULL;
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_curves_config_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
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
|
|
|
case PROP_TRC:
|
|
|
|
g_value_set_enum (value, self->trc);
|
|
|
|
break;
|
|
|
|
|
2018-01-05 22:37:18 +01:00
|
|
|
case PROP_LINEAR:
|
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
|
|
|
g_value_set_boolean (value, self->trc == GIMP_TRC_LINEAR ? TRUE : FALSE);
|
2018-01-05 22:37:18 +01:00
|
|
|
break;
|
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
case PROP_CHANNEL:
|
|
|
|
g_value_set_enum (value, self->channel);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_CURVE:
|
|
|
|
g_value_set_object (value, self->curve[self->channel]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_curves_config_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
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
|
|
|
case PROP_TRC:
|
|
|
|
self->trc = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
2018-01-05 22:37:18 +01:00
|
|
|
case PROP_LINEAR:
|
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
|
|
|
self->trc = g_value_get_boolean (value) ?
|
|
|
|
GIMP_TRC_LINEAR : GIMP_TRC_NON_LINEAR;
|
|
|
|
g_object_notify (object, "trc");
|
2018-01-05 22:37:18 +01:00
|
|
|
break;
|
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
case PROP_CHANNEL:
|
|
|
|
self->channel = g_value_get_enum (value);
|
2008-01-30 15:48:23 +00:00
|
|
|
g_object_notify (object, "curve");
|
2008-01-23 09:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_CURVE:
|
2008-02-01 12:45:32 +00:00
|
|
|
{
|
|
|
|
GimpCurve *src_curve = g_value_get_object (value);
|
|
|
|
GimpCurve *dest_curve = self->curve[self->channel];
|
|
|
|
|
|
|
|
if (src_curve && dest_curve)
|
|
|
|
{
|
2008-09-29 12:33:58 +00:00
|
|
|
gimp_config_copy (GIMP_CONFIG (src_curve),
|
|
|
|
GIMP_CONFIG (dest_curve), 0);
|
2008-02-01 12:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-23 09:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-18 19:13:28 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_curves_config_serialize (GimpConfig *config,
|
|
|
|
GimpConfigWriter *writer,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
|
|
|
|
GimpHistogramChannel channel;
|
|
|
|
GimpHistogramChannel old_channel;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
if (! gimp_operation_settings_config_serialize_base (config, writer, data) ||
|
|
|
|
! gimp_config_serialize_property_by_name (config, "trc", writer))
|
2012-04-02 11:49:22 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2008-05-18 19:13:28 +00:00
|
|
|
old_channel = c_config->channel;
|
|
|
|
|
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
|
|
|
c_config->channel = channel;
|
|
|
|
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
/* serialize the channel properties manually (not using
|
2013-05-19 21:42:50 +02:00
|
|
|
* gimp_config_serialize_properties()), so the parent class'
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
* properties don't end up in the config file one per channel.
|
|
|
|
* See bug #700653.
|
2013-05-19 21:42:50 +02:00
|
|
|
*/
|
|
|
|
success =
|
|
|
|
(gimp_config_serialize_property_by_name (config, "channel", writer) &&
|
|
|
|
gimp_config_serialize_property_by_name (config, "curve", writer));
|
2008-05-18 19:13:28 +00:00
|
|
|
|
|
|
|
if (! success)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
c_config->channel = old_channel;
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_curves_config_deserialize (GimpConfig *config,
|
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
|
|
|
|
GimpHistogramChannel old_channel;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
old_channel = c_config->channel;
|
|
|
|
|
|
|
|
success = gimp_config_deserialize_properties (config, scanner, nest_level);
|
|
|
|
|
|
|
|
g_object_set (config, "channel", old_channel, NULL);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_curves_config_equal (GimpConfig *a,
|
|
|
|
GimpConfig *b)
|
|
|
|
{
|
2008-05-26 18:25:04 +00:00
|
|
|
GimpCurvesConfig *config_a = GIMP_CURVES_CONFIG (a);
|
|
|
|
GimpCurvesConfig *config_b = GIMP_CURVES_CONFIG (b);
|
2008-02-01 12:45:32 +00:00
|
|
|
GimpHistogramChannel channel;
|
|
|
|
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
if (! gimp_operation_settings_config_equal_base (a, b) ||
|
|
|
|
config_a->trc != config_b->trc)
|
2018-01-05 22:37:18 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
2008-05-26 18:25:04 +00:00
|
|
|
GimpCurve *curve_a = config_a->curve[channel];
|
|
|
|
GimpCurve *curve_b = config_b->curve[channel];
|
2008-02-01 12:45:32 +00:00
|
|
|
|
2008-05-26 18:25:04 +00:00
|
|
|
if (curve_a && curve_b)
|
2008-02-01 12:45:32 +00:00
|
|
|
{
|
2008-05-26 18:25:04 +00:00
|
|
|
if (! gimp_config_is_equal_to (GIMP_CONFIG (curve_a),
|
|
|
|
GIMP_CONFIG (curve_b)))
|
2008-02-01 12:45:32 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-26 18:25:04 +00:00
|
|
|
else if (curve_a || curve_b)
|
2008-02-01 12:45:32 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't compare "channel" */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-01-27 17:39:01 +00:00
|
|
|
static void
|
|
|
|
gimp_curves_config_reset (GimpConfig *config)
|
2008-01-23 09:28:16 +00:00
|
|
|
{
|
2008-01-27 17:39:01 +00:00
|
|
|
GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
|
|
|
|
GimpHistogramChannel channel;
|
2008-01-23 09:28:16 +00:00
|
|
|
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
gimp_operation_settings_config_reset_base (config);
|
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
2008-01-27 17:39:01 +00:00
|
|
|
c_config->channel = channel;
|
|
|
|
gimp_curves_config_reset_channel (c_config);
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
2008-01-27 17:39:01 +00:00
|
|
|
|
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
|
|
|
gimp_config_reset_property (G_OBJECT (config), "trc");
|
2008-01-27 17:39:01 +00:00
|
|
|
gimp_config_reset_property (G_OBJECT (config), "channel");
|
2008-02-01 12:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_curves_config_copy (GimpConfig *src,
|
|
|
|
GimpConfig *dest,
|
|
|
|
GParamFlags flags)
|
|
|
|
{
|
|
|
|
GimpCurvesConfig *src_config = GIMP_CURVES_CONFIG (src);
|
|
|
|
GimpCurvesConfig *dest_config = GIMP_CURVES_CONFIG (dest);
|
|
|
|
GimpHistogramChannel channel;
|
|
|
|
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 01:37:19 +03:00
|
|
|
if (! gimp_operation_settings_config_copy_base (src, dest, flags))
|
|
|
|
return FALSE;
|
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
2008-05-18 14:25:54 +00:00
|
|
|
gimp_config_copy (GIMP_CONFIG (src_config->curve[channel]),
|
|
|
|
GIMP_CONFIG (dest_config->curve[channel]),
|
|
|
|
flags);
|
2008-02-01 12:45:32 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
dest_config->trc = src_config->trc;
|
2008-02-01 12:45:32 +00:00
|
|
|
dest_config->channel = src_config->channel;
|
|
|
|
|
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
|
|
|
g_object_notify (G_OBJECT (dest), "trc");
|
2008-02-01 12:45:32 +00:00
|
|
|
g_object_notify (G_OBJECT (dest), "channel");
|
2008-01-27 17:39:01 +00:00
|
|
|
|
2008-02-01 12:45:32 +00:00
|
|
|
return TRUE;
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
2008-01-30 15:48:23 +00:00
|
|
|
static void
|
|
|
|
gimp_curves_config_curve_dirty (GimpCurve *curve,
|
|
|
|
GimpCurvesConfig *config)
|
|
|
|
{
|
|
|
|
g_object_notify (G_OBJECT (config), "curve");
|
|
|
|
}
|
|
|
|
|
2008-01-27 17:39:01 +00:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2012-03-23 09:55:35 +01:00
|
|
|
GObject *
|
2014-06-17 22:23:41 +02:00
|
|
|
gimp_curves_config_new_spline (gint32 channel,
|
|
|
|
const gdouble *points,
|
|
|
|
gint n_points)
|
2012-03-23 09:55:35 +01:00
|
|
|
{
|
|
|
|
GimpCurvesConfig *config;
|
|
|
|
GimpCurve *curve;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
2014-06-17 21:10:33 +02:00
|
|
|
g_return_val_if_fail (points != NULL, NULL);
|
|
|
|
g_return_val_if_fail (n_points >= 2 && n_points <= 1024, NULL);
|
2012-03-23 09:55:35 +01:00
|
|
|
|
|
|
|
config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
|
|
|
|
|
|
|
|
curve = config->curve[channel];
|
|
|
|
|
|
|
|
gimp_data_freeze (GIMP_DATA (curve));
|
|
|
|
|
2014-06-17 21:10:33 +02:00
|
|
|
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
2019-04-19 04:24:24 -04:00
|
|
|
gimp_curve_clear_points (curve);
|
2012-03-23 09:55:35 +01:00
|
|
|
|
|
|
|
for (i = 0; i < n_points; i++)
|
2019-04-19 04:24:24 -04:00
|
|
|
gimp_curve_add_point (curve,
|
2014-06-17 22:23:41 +02:00
|
|
|
(gdouble) points[i * 2],
|
|
|
|
(gdouble) points[i * 2 + 1]);
|
2012-03-23 09:55:35 +01:00
|
|
|
|
|
|
|
gimp_data_thaw (GIMP_DATA (curve));
|
|
|
|
|
|
|
|
return G_OBJECT (config);
|
|
|
|
}
|
|
|
|
|
|
|
|
GObject *
|
2014-06-17 22:23:41 +02:00
|
|
|
gimp_curves_config_new_explicit (gint32 channel,
|
|
|
|
const gdouble *samples,
|
|
|
|
gint n_samples)
|
2012-03-23 09:55:35 +01:00
|
|
|
{
|
|
|
|
GimpCurvesConfig *config;
|
|
|
|
GimpCurve *curve;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
2014-06-17 21:10:33 +02:00
|
|
|
g_return_val_if_fail (samples != NULL, NULL);
|
|
|
|
g_return_val_if_fail (n_samples >= 2 && n_samples <= 4096, NULL);
|
2012-03-23 09:55:35 +01:00
|
|
|
|
|
|
|
config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
|
|
|
|
|
|
|
|
curve = config->curve[channel];
|
|
|
|
|
|
|
|
gimp_data_freeze (GIMP_DATA (curve));
|
|
|
|
|
|
|
|
gimp_curve_set_curve_type (curve, GIMP_CURVE_FREE);
|
2014-06-17 21:10:33 +02:00
|
|
|
gimp_curve_set_n_samples (curve, n_samples);
|
2012-03-23 09:55:35 +01:00
|
|
|
|
2014-06-17 21:10:33 +02:00
|
|
|
for (i = 0; i < n_samples; i++)
|
2012-03-23 09:55:35 +01:00
|
|
|
gimp_curve_set_curve (curve,
|
2014-06-17 22:23:41 +02:00
|
|
|
(gdouble) i / (gdouble) (n_samples - 1),
|
|
|
|
(gdouble) samples[i]);
|
2012-03-23 09:55:35 +01:00
|
|
|
|
|
|
|
gimp_data_thaw (GIMP_DATA (curve));
|
|
|
|
|
|
|
|
return G_OBJECT (config);
|
|
|
|
}
|
|
|
|
|
2014-06-17 22:23:41 +02:00
|
|
|
GObject *
|
|
|
|
gimp_curves_config_new_spline_cruft (gint32 channel,
|
|
|
|
const guint8 *points,
|
|
|
|
gint n_points)
|
|
|
|
{
|
|
|
|
GObject *config;
|
|
|
|
gdouble *d_points;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
|
|
|
g_return_val_if_fail (points != NULL, NULL);
|
|
|
|
g_return_val_if_fail (n_points >= 2 && n_points <= 1024, NULL);
|
|
|
|
|
|
|
|
d_points = g_new (gdouble, 2 * n_points);
|
|
|
|
|
|
|
|
for (i = 0; i < n_points; i++)
|
|
|
|
{
|
|
|
|
d_points[i * 2] = (gdouble) points[i * 2] / 255.0;
|
|
|
|
d_points[i * 2 + 1] = (gdouble) points[i * 2 + 1] / 255.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
config = gimp_curves_config_new_spline (channel, d_points, n_points);
|
|
|
|
|
|
|
|
g_free (d_points);
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
GObject *
|
|
|
|
gimp_curves_config_new_explicit_cruft (gint32 channel,
|
|
|
|
const guint8 *samples,
|
|
|
|
gint n_samples)
|
|
|
|
{
|
|
|
|
GObject *config;
|
|
|
|
gdouble *d_samples;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
|
|
|
g_return_val_if_fail (samples != NULL, NULL);
|
|
|
|
g_return_val_if_fail (n_samples >= 2 && n_samples <= 4096, NULL);
|
|
|
|
|
|
|
|
d_samples = g_new (gdouble, n_samples);
|
|
|
|
|
|
|
|
for (i = 0; i < n_samples; i++)
|
|
|
|
{
|
|
|
|
d_samples[i] = (gdouble) samples[i] / 255.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
config = gimp_curves_config_new_explicit (channel, d_samples, n_samples);
|
|
|
|
|
|
|
|
g_free (d_samples);
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2008-01-23 09:28:16 +00:00
|
|
|
void
|
2008-01-27 17:39:01 +00:00
|
|
|
gimp_curves_config_reset_channel (GimpCurvesConfig *config)
|
2008-01-23 09:28:16 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
|
|
|
|
|
2008-05-18 14:25:54 +00:00
|
|
|
gimp_config_reset (GIMP_CONFIG (config->curve[config->channel]));
|
2008-01-23 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 12:34:46 +00:00
|
|
|
#define GIMP_CURVE_N_CRUFT_POINTS 17
|
|
|
|
|
2008-01-25 13:02:37 +00:00
|
|
|
gboolean
|
|
|
|
gimp_curves_config_load_cruft (GimpCurvesConfig *config,
|
2014-07-04 13:18:01 +02:00
|
|
|
GInputStream *input,
|
2008-01-25 13:02:37 +00:00
|
|
|
GError **error)
|
|
|
|
{
|
2014-07-04 13:18:01 +02:00
|
|
|
GDataInputStream *data_input;
|
|
|
|
gint index[5][GIMP_CURVE_N_CRUFT_POINTS];
|
|
|
|
gint value[5][GIMP_CURVE_N_CRUFT_POINTS];
|
|
|
|
gchar *line;
|
|
|
|
gsize line_len;
|
|
|
|
gint i, j;
|
2008-01-25 13:02:37 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CURVES_CONFIG (config), FALSE);
|
2014-07-04 13:18:01 +02:00
|
|
|
g_return_val_if_fail (G_IS_INPUT_STREAM (input), FALSE);
|
2008-01-25 13:02:37 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
2014-07-04 13:18:01 +02:00
|
|
|
data_input = g_data_input_stream_new (input);
|
|
|
|
|
|
|
|
line_len = 64;
|
Issue #1682 - Segfault when starting GIMP, due to empty data files
Use gimp_input_data_stream_read_line_always(), instead of
g_input_data_stream_read_line(), in a bunch of places that don't
expect EOF. If we don't do that, the code assumes the GError
parameter is set by the function and returns an error indication,
causing the caller to segfault when it tries to access
error->message. Instead, we now process an empty line when EOF is
reached, which is caught by the normal parsing logic.
Additionally:
- Use gimp_ascii_strto[id]() when loading gradients, generated
brushes, and palettes, to improve error checking for invalid
numeric input.
- Improve gradient-segment endpoint consistency check.
- Allow loading palette files with 0 colors. They can be created
during the session, so we might as well successfully load them.
2018-06-20 14:47:15 -04:00
|
|
|
line = gimp_data_input_stream_read_line_always (data_input, &line_len,
|
|
|
|
NULL, error);
|
2014-07-04 13:18:01 +02:00
|
|
|
if (! line)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strcmp (line, "# GIMP Curves File") != 0)
|
2008-01-25 13:02:37 +00:00
|
|
|
{
|
2014-07-04 13:18:01 +02:00
|
|
|
g_set_error_literal (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
|
2016-12-21 04:05:32 +01:00
|
|
|
_("not a GIMP Curves file"));
|
2014-07-04 13:18:01 +02:00
|
|
|
g_object_unref (data_input);
|
|
|
|
g_free (line);
|
2008-01-25 13:02:37 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
2008-02-28 12:34:46 +00:00
|
|
|
for (j = 0; j < GIMP_CURVE_N_CRUFT_POINTS; j++)
|
2008-01-25 13:02:37 +00:00
|
|
|
{
|
2014-07-04 13:18:01 +02:00
|
|
|
gchar *x_str = NULL;
|
|
|
|
gchar *y_str = NULL;
|
|
|
|
|
|
|
|
if (! (x_str = g_data_input_stream_read_upto (data_input, " ", -1,
|
|
|
|
NULL, NULL, error)) ||
|
|
|
|
! g_data_input_stream_read_byte (data_input, NULL, error) ||
|
|
|
|
! (y_str = g_data_input_stream_read_upto (data_input, " ", -1,
|
|
|
|
NULL, NULL, error)) ||
|
|
|
|
! g_data_input_stream_read_byte (data_input, NULL, error))
|
|
|
|
{
|
|
|
|
g_free (x_str);
|
|
|
|
g_free (y_str);
|
|
|
|
g_object_unref (data_input);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf (x_str, "%d", &index[i][j]) != 1 ||
|
|
|
|
sscanf (y_str, "%d", &value[i][j]) != 1)
|
2008-01-25 13:02:37 +00:00
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
g_set_error_literal (error,
|
2016-12-21 04:05:32 +01:00
|
|
|
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
|
|
|
|
_("Parse error, didn't find 2 integers"));
|
2014-07-04 13:18:01 +02:00
|
|
|
g_free (x_str);
|
|
|
|
g_free (y_str);
|
|
|
|
g_object_unref (data_input);
|
2008-01-25 13:02:37 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-07-04 13:18:01 +02:00
|
|
|
|
|
|
|
g_free (x_str);
|
|
|
|
g_free (y_str);
|
2008-01-25 13:02:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-04 13:18:01 +02:00
|
|
|
g_object_unref (data_input);
|
|
|
|
|
2008-01-30 15:48:23 +00:00
|
|
|
g_object_freeze_notify (G_OBJECT (config));
|
|
|
|
|
2008-01-25 13:02:37 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
GimpCurve *curve = config->curve[i];
|
|
|
|
|
|
|
|
gimp_data_freeze (GIMP_DATA (curve));
|
|
|
|
|
|
|
|
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
2019-04-19 04:24:24 -04:00
|
|
|
gimp_curve_clear_points (curve);
|
2008-10-09 09:44:08 +00:00
|
|
|
|
2008-02-28 12:34:46 +00:00
|
|
|
for (j = 0; j < GIMP_CURVE_N_CRUFT_POINTS; j++)
|
2008-06-25 08:13:57 +00:00
|
|
|
{
|
2019-04-19 04:24:24 -04:00
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
|
|
|
|
x = (gdouble) index[i][j] / 255.0;
|
|
|
|
y = (gdouble) value[i][j] / 255.0;
|
|
|
|
|
|
|
|
if (x >= 0.0)
|
|
|
|
gimp_curve_add_point (curve, x, y);
|
2008-06-25 08:13:57 +00:00
|
|
|
}
|
2008-01-25 13:02:37 +00:00
|
|
|
|
|
|
|
gimp_data_thaw (GIMP_DATA (curve));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
config->trc = GIMP_TRC_NON_LINEAR;
|
2018-01-05 22:37:18 +01:00
|
|
|
|
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
|
|
|
g_object_notify (G_OBJECT (config), "trc");
|
2018-01-05 22:37:18 +01:00
|
|
|
|
2008-01-30 15:48:23 +00:00
|
|
|
g_object_thaw_notify (G_OBJECT (config));
|
|
|
|
|
2008-01-25 13:02:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2008-05-19 18:22:01 +00:00
|
|
|
gimp_curves_config_save_cruft (GimpCurvesConfig *config,
|
2014-07-04 18:19:45 +02:00
|
|
|
GOutputStream *output,
|
2008-05-19 18:22:01 +00:00
|
|
|
GError **error)
|
2008-01-25 13:02:37 +00:00
|
|
|
{
|
2014-07-04 18:19:45 +02:00
|
|
|
GString *string;
|
|
|
|
gint i;
|
2008-01-25 13:02:37 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CURVES_CONFIG (config), FALSE);
|
2014-07-04 18:19:45 +02:00
|
|
|
g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), FALSE);
|
2008-05-19 18:22:01 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2008-01-25 13:02:37 +00:00
|
|
|
|
2014-07-02 23:40:26 +02:00
|
|
|
string = g_string_new ("# GIMP Curves File\n");
|
2008-01-25 13:02:37 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
GimpCurve *curve = config->curve[i];
|
2008-02-09 10:01:51 +00:00
|
|
|
gint j;
|
2008-01-25 13:02:37 +00:00
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
if (curve->curve_type == GIMP_CURVE_SMOOTH)
|
2008-01-25 13:02:37 +00:00
|
|
|
{
|
2019-04-19 04:24:24 -04:00
|
|
|
g_object_ref (curve);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
curve = GIMP_CURVE (gimp_data_duplicate (GIMP_DATA (curve)));
|
2008-01-25 13:02:37 +00:00
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
2008-01-25 13:02:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
for (j = 0; j < GIMP_CURVE_N_CRUFT_POINTS; j++)
|
2008-02-11 10:22:59 +00:00
|
|
|
{
|
2019-04-19 04:24:24 -04:00
|
|
|
gint x = -1;
|
|
|
|
gint y = -1;
|
2008-02-11 10:22:59 +00:00
|
|
|
|
2019-04-19 04:24:24 -04:00
|
|
|
if (j < gimp_curve_get_n_points (curve))
|
2008-02-28 12:34:46 +00:00
|
|
|
{
|
2019-04-19 04:24:24 -04:00
|
|
|
gdouble point_x;
|
|
|
|
gdouble point_y;
|
|
|
|
|
|
|
|
gimp_curve_get_point (curve, j, &point_x, &point_y);
|
|
|
|
|
|
|
|
x = floor (point_x * 255.999);
|
|
|
|
y = floor (point_y * 255.999);
|
2008-02-28 12:34:46 +00:00
|
|
|
}
|
2019-04-19 04:24:24 -04:00
|
|
|
|
|
|
|
g_string_append_printf (string, "%d %d ", x, y);
|
2008-02-11 10:22:59 +00:00
|
|
|
}
|
2008-01-25 13:02:37 +00:00
|
|
|
|
2014-07-02 23:40:26 +02:00
|
|
|
g_string_append_printf (string, "\n");
|
2019-04-19 15:27:30 -04:00
|
|
|
|
|
|
|
g_object_unref (curve);
|
2008-01-25 13:02:37 +00:00
|
|
|
}
|
|
|
|
|
2014-07-02 23:40:26 +02:00
|
|
|
if (! g_output_stream_write_all (output, string->str, string->len,
|
2014-09-07 20:30:14 +02:00
|
|
|
NULL, NULL, error))
|
2014-07-02 23:40:26 +02:00
|
|
|
{
|
2014-07-04 18:19:45 +02:00
|
|
|
g_prefix_error (error, _("Writing curves file failed: "));
|
2014-07-02 23:40:26 +02:00
|
|
|
g_string_free (string, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_string_free (string, TRUE);
|
|
|
|
|
2008-01-25 13:02:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2025-04-09 13:09:41 +00:00
|
|
|
|
|
|
|
#define PS_CURVE_N_MAX_POINTS 19
|
|
|
|
|
|
|
|
/* Loads Photoshop .acv Curves preset */
|
|
|
|
gboolean
|
|
|
|
gimp_curves_config_load_acv (GimpCurvesConfig *config,
|
|
|
|
GInputStream *input,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GDataInputStream *data_input;
|
|
|
|
guint16 version = 0;
|
|
|
|
guint16 count = 0;
|
|
|
|
gint in[5][PS_CURVE_N_MAX_POINTS];
|
|
|
|
gint out[5][PS_CURVE_N_MAX_POINTS];
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CURVES_CONFIG (config), FALSE);
|
|
|
|
g_return_val_if_fail (G_IS_INPUT_STREAM (input), FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
data_input = g_data_input_stream_new (input);
|
|
|
|
|
|
|
|
g_data_input_stream_set_byte_order (data_input,
|
|
|
|
G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN);
|
|
|
|
|
|
|
|
version = g_data_input_stream_read_uint16 (data_input, NULL, error);
|
|
|
|
if (! version)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
count = g_data_input_stream_read_uint16 (data_input, NULL, error);
|
|
|
|
if (! count)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
count = CLAMP (count, 1, 5);
|
|
|
|
for (gint i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
guint16 points = 0;
|
|
|
|
|
|
|
|
points = g_data_input_stream_read_uint16 (data_input, NULL, error);
|
|
|
|
if (! points || points > PS_CURVE_N_MAX_POINTS)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (gint j = 0; j < points; j++)
|
|
|
|
{
|
|
|
|
/* Curves can start at 0, 0, so we'll check for an error instead */
|
|
|
|
out[i][j] = g_data_input_stream_read_uint16 (data_input, NULL, error);
|
|
|
|
if (error && *error)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
in[i][j] = g_data_input_stream_read_uint16 (data_input, NULL, error);
|
|
|
|
if (error && *error)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (points < PS_CURVE_N_MAX_POINTS)
|
|
|
|
{
|
|
|
|
in[i][points] = -1;
|
|
|
|
out[i][points] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (data_input);
|
|
|
|
g_object_freeze_notify (G_OBJECT (config));
|
|
|
|
|
|
|
|
for (gint i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
GimpCurve *curve = config->curve[i];
|
|
|
|
|
|
|
|
gimp_data_freeze (GIMP_DATA (curve));
|
|
|
|
|
|
|
|
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
|
|
|
gimp_curve_clear_points (curve);
|
|
|
|
|
|
|
|
for (gint j = 0; j < PS_CURVE_N_MAX_POINTS; j++)
|
|
|
|
{
|
|
|
|
if (in[i][j] > -1 && out[i][j] > -1)
|
|
|
|
gimp_curve_add_point (curve, in[i][j] / 255.0, out[i][j] / 255.0);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gimp_data_thaw (GIMP_DATA (curve));
|
|
|
|
}
|
|
|
|
|
|
|
|
config->trc = GIMP_TRC_NON_LINEAR;
|
|
|
|
g_object_notify (G_OBJECT (config), "trc");
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (config));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
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: "));
|
|
|
|
g_object_unref (data_input);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|