mirror of https://github.com/GNOME/gimp.git
app: remove the legacy curves cruft
and move PDB parameter collection into GimpCurvesConfig convenience constructors.
This commit is contained in:
parent
3bb973f24b
commit
a34b19774b
|
@ -26,8 +26,6 @@ libappbase_a_SOURCES = \
|
|||
color-balance.h \
|
||||
cpercep.c \
|
||||
cpercep.h \
|
||||
curves.c \
|
||||
curves.h \
|
||||
gimphistogram.c \
|
||||
gimphistogram.h \
|
||||
gimplut.c \
|
||||
|
|
|
@ -51,7 +51,6 @@ typedef struct _GimpHistogram GimpHistogram;
|
|||
typedef struct _GimpLut GimpLut;
|
||||
|
||||
typedef struct _ColorBalance ColorBalance;
|
||||
typedef struct _Curves Curves;
|
||||
typedef struct _HueSaturation HueSaturation;
|
||||
typedef struct _Levels Levels;
|
||||
typedef struct _Threshold Threshold;
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "base-types.h"
|
||||
|
||||
#include "curves.h"
|
||||
#include "gimplut.h"
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
curves_init (Curves *curves)
|
||||
{
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
g_return_if_fail (curves != NULL);
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
{
|
||||
gint j;
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
curves->curve[channel][j] = j;
|
||||
}
|
||||
}
|
||||
|
||||
gfloat
|
||||
curves_lut_func (Curves *curves,
|
||||
gint n_channels,
|
||||
gint channel,
|
||||
gfloat value)
|
||||
{
|
||||
gfloat f;
|
||||
gint index;
|
||||
gdouble inten;
|
||||
gint j;
|
||||
|
||||
if (n_channels <= 2)
|
||||
j = channel;
|
||||
else
|
||||
j = channel + 1;
|
||||
|
||||
inten = value;
|
||||
|
||||
/* For RGB and RGBA images this runs through the loop with j = channel + 1
|
||||
* the first time and j = 0 the second time
|
||||
*
|
||||
* For GRAY images this runs through the loop with j = 0 the first and
|
||||
* only time
|
||||
*/
|
||||
for (; j >= 0; j -= (channel + 1))
|
||||
{
|
||||
/* don't apply the overall curve to the alpha channel */
|
||||
if (j == 0 && (n_channels == 2 || n_channels == 4) &&
|
||||
channel == n_channels - 1)
|
||||
return inten;
|
||||
|
||||
if (inten < 0.0)
|
||||
{
|
||||
inten = curves->curve[j][0]/255.0;
|
||||
}
|
||||
else if (inten >= 1.0)
|
||||
{
|
||||
inten = curves->curve[j][255]/255.0;
|
||||
}
|
||||
else /* interpolate the curve */
|
||||
{
|
||||
index = floor (inten * 255.0);
|
||||
f = inten * 255.0 - index;
|
||||
inten = ((1.0 - f) * curves->curve[j][index ] +
|
||||
f * curves->curve[j][index + 1] ) / 255.0;
|
||||
}
|
||||
}
|
||||
|
||||
return inten;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CURVES_H__
|
||||
#define __CURVES_H__
|
||||
|
||||
|
||||
struct _Curves
|
||||
{
|
||||
guchar curve[5][256];
|
||||
};
|
||||
|
||||
|
||||
void curves_init (Curves *curves);
|
||||
gfloat curves_lut_func (Curves *curves,
|
||||
gint nchannels,
|
||||
gint channel,
|
||||
gfloat value);
|
||||
|
||||
|
||||
#endif /* __CURVES_H__ */
|
|
@ -132,8 +132,6 @@ libappcore_a_sources = \
|
|||
gimpdrawable-combine.h \
|
||||
gimpdrawable-convert.c \
|
||||
gimpdrawable-convert.h \
|
||||
gimpdrawable-curves.c \
|
||||
gimpdrawable-curves.h \
|
||||
gimpdrawable-equalize.c \
|
||||
gimpdrawable-equalize.h \
|
||||
gimpdrawable-foreground-extract.c \
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "base/curves.h"
|
||||
#include "base/gimplut.h"
|
||||
|
||||
#include "gegl/gimpcurvesconfig.h"
|
||||
|
||||
/* temp */
|
||||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
|
||||
#include "gimpcurve.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-curves.h"
|
||||
#include "gimpdrawable-operation.h"
|
||||
#include "gimpdrawable-process.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_drawable_curves (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
GimpCurvesConfig *config);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_drawable_curves_spline (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points)
|
||||
{
|
||||
GimpCurvesConfig *config;
|
||||
GimpCurve *curve;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
||||
g_return_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
||||
channel <= GIMP_HISTOGRAM_ALPHA);
|
||||
|
||||
if (channel == GIMP_HISTOGRAM_ALPHA)
|
||||
g_return_if_fail (gimp_drawable_has_alpha (drawable));
|
||||
|
||||
if (gimp_drawable_is_gray (drawable))
|
||||
g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE ||
|
||||
channel == GIMP_HISTOGRAM_ALPHA);
|
||||
|
||||
config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
|
||||
|
||||
curve = config->curve[channel];
|
||||
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
/* FIXME: create a curves object with the right number of points */
|
||||
/* unset the last point */
|
||||
gimp_curve_set_point (curve, curve->n_points - 1, -1, -1);
|
||||
|
||||
n_points = MIN (n_points / 2, curve->n_points);
|
||||
|
||||
for (i = 0; i < n_points; i++)
|
||||
gimp_curve_set_point (curve, i,
|
||||
(gdouble) points[i * 2] / 255.0,
|
||||
(gdouble) points[i * 2 + 1] / 255.0);
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
gimp_drawable_curves (drawable, progress, config);
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_curves_explicit (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points)
|
||||
{
|
||||
GimpCurvesConfig *config;
|
||||
GimpCurve *curve;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
||||
g_return_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
||||
channel <= GIMP_HISTOGRAM_ALPHA);
|
||||
|
||||
if (channel == GIMP_HISTOGRAM_ALPHA)
|
||||
g_return_if_fail (gimp_drawable_has_alpha (drawable));
|
||||
|
||||
if (gimp_drawable_is_gray (drawable))
|
||||
g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE ||
|
||||
channel == GIMP_HISTOGRAM_ALPHA);
|
||||
|
||||
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);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
gimp_curve_set_curve (curve,
|
||||
(gdouble) i / 255.0,
|
||||
(gdouble) points[i] / 255.0);
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
gimp_drawable_curves (drawable, progress, config);
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_drawable_curves (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
GimpCurvesConfig *config)
|
||||
{
|
||||
if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
|
||||
{
|
||||
GeglNode *node;
|
||||
|
||||
node = g_object_new (GEGL_TYPE_NODE,
|
||||
"operation", "gimp:curves",
|
||||
NULL);
|
||||
gegl_node_set (node,
|
||||
"config", config,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation (drawable, progress, C_("undo-type", "Curves"),
|
||||
node, TRUE);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpLut *lut = gimp_lut_new ();
|
||||
Curves cruft;
|
||||
|
||||
gimp_curves_config_to_cruft (config, &cruft,
|
||||
gimp_drawable_is_rgb (drawable));
|
||||
|
||||
gimp_lut_setup (lut,
|
||||
(GimpLutFunc) curves_lut_func,
|
||||
&cruft,
|
||||
gimp_drawable_bytes (drawable));
|
||||
|
||||
gimp_drawable_process_lut (drawable, progress, C_("undo-type", "Curves"), lut);
|
||||
gimp_lut_free (lut);
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_DRAWABLE_CURVES_H__
|
||||
#define __GIMP_DRAWABLE_CURVES_H__
|
||||
|
||||
|
||||
void gimp_drawable_curves_spline (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points);
|
||||
void gimp_drawable_curves_explicit (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_CURVES_H__ */
|
|
@ -34,9 +34,6 @@
|
|||
|
||||
#include "base/gimphistogram.h"
|
||||
|
||||
/* temp cruft */
|
||||
#include "base/curves.h"
|
||||
|
||||
#include "core/gimpcurve.h"
|
||||
|
||||
#include "gimpcurvesconfig.h"
|
||||
|
@ -354,6 +351,70 @@ gimp_curves_config_curve_dirty (GimpCurve *curve,
|
|||
|
||||
/* public functions */
|
||||
|
||||
GObject *
|
||||
gimp_curves_config_new_spline (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points)
|
||||
{
|
||||
GimpCurvesConfig *config;
|
||||
GimpCurve *curve;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
||||
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
||||
|
||||
config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
|
||||
|
||||
curve = config->curve[channel];
|
||||
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
/* FIXME: create a curves object with the right number of points */
|
||||
/* unset the last point */
|
||||
gimp_curve_set_point (curve, curve->n_points - 1, -1, -1);
|
||||
|
||||
n_points = MIN (n_points / 2, curve->n_points);
|
||||
|
||||
for (i = 0; i < n_points; i++)
|
||||
gimp_curve_set_point (curve, i,
|
||||
(gdouble) points[i * 2] / 255.0,
|
||||
(gdouble) points[i * 2 + 1] / 255.0);
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
return G_OBJECT (config);
|
||||
}
|
||||
|
||||
GObject *
|
||||
gimp_curves_config_new_explicit (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points)
|
||||
{
|
||||
GimpCurvesConfig *config;
|
||||
GimpCurve *curve;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
||||
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
||||
|
||||
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);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
gimp_curve_set_curve (curve,
|
||||
(gdouble) i / 255.0,
|
||||
(gdouble) points[i] / 255.0);
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
return G_OBJECT (config);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_curves_config_reset_channel (GimpCurvesConfig *config)
|
||||
{
|
||||
|
@ -506,33 +567,3 @@ gimp_curves_config_save_cruft (GimpCurvesConfig *config,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* temp cruft */
|
||||
|
||||
void
|
||||
gimp_curves_config_to_cruft (GimpCurvesConfig *config,
|
||||
Curves *cruft,
|
||||
gboolean is_color)
|
||||
{
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
|
||||
g_return_if_fail (cruft != NULL);
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
{
|
||||
gimp_curve_get_uchar (config->curve[channel],
|
||||
sizeof (cruft->curve[channel]),
|
||||
cruft->curve[channel]);
|
||||
}
|
||||
|
||||
if (! is_color)
|
||||
{
|
||||
gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_ALPHA],
|
||||
sizeof (cruft->curve[1]),
|
||||
cruft->curve[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,13 @@ struct _GimpCurvesConfigClass
|
|||
|
||||
GType gimp_curves_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GObject * gimp_curves_config_new_spline (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points);
|
||||
GObject * gimp_curves_config_new_explicit (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points);
|
||||
|
||||
void gimp_curves_config_reset_channel (GimpCurvesConfig *config);
|
||||
|
||||
gboolean gimp_curves_config_load_cruft (GimpCurvesConfig *config,
|
||||
|
@ -62,10 +69,4 @@ gboolean gimp_curves_config_save_cruft (GimpCurvesConfig *config,
|
|||
GError **error);
|
||||
|
||||
|
||||
/* temp cruft */
|
||||
void gimp_curves_config_to_cruft (GimpCurvesConfig *config,
|
||||
Curves *cruft,
|
||||
gboolean is_color);
|
||||
|
||||
|
||||
#endif /* __GIMP_CURVES_CONFIG_H__ */
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "base/gimphistogram.h"
|
||||
#include "core/gimpdrawable-color-balance.h"
|
||||
#include "core/gimpdrawable-curves.h"
|
||||
#include "core/gimpdrawable-equalize.h"
|
||||
#include "core/gimpdrawable-histogram.h"
|
||||
#include "core/gimpdrawable-hue-saturation.h"
|
||||
|
@ -35,6 +34,7 @@
|
|||
#include "core/gimpparamspecs.h"
|
||||
#include "gegl/gimpbrightnesscontrastconfig.h"
|
||||
#include "gegl/gimpcolorizeconfig.h"
|
||||
#include "gegl/gimpcurvesconfig.h"
|
||||
#include "gegl/gimpdesaturateconfig.h"
|
||||
#include "gegl/gimpposterizeconfig.h"
|
||||
#include "gegl/gimpthresholdconfig.h"
|
||||
|
@ -393,18 +393,26 @@ curves_spline_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (success)
|
||||
{
|
||||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
|
||||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
|
||||
gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
|
||||
(! gimp_drawable_has_alpha (drawable) &&
|
||||
channel == GIMP_HISTOGRAM_ALPHA) ||
|
||||
(gimp_drawable_is_gray (drawable) &&
|
||||
channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
|
||||
success = FALSE;
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
|
||||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
! (num_points & 1) &&
|
||||
(gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
|
||||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
control_pts,
|
||||
num_points);
|
||||
|
||||
if (success)
|
||||
gimp_drawable_curves_spline (drawable, progress,
|
||||
channel, control_pts, num_points);
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
"gimp:curves",
|
||||
config, TRUE);
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
|
@ -432,18 +440,26 @@ curves_explicit_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (success)
|
||||
{
|
||||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
|
||||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
|
||||
gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
|
||||
(! gimp_drawable_has_alpha (drawable) &&
|
||||
channel == GIMP_HISTOGRAM_ALPHA) ||
|
||||
(gimp_drawable_is_gray (drawable) &&
|
||||
channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
|
||||
success = FALSE;
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
|
||||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
(num_bytes == 256) &&
|
||||
(gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
|
||||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
curve,
|
||||
num_bytes);
|
||||
|
||||
if (success)
|
||||
gimp_drawable_curves_explicit (drawable, progress,
|
||||
channel, curve, num_bytes);
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
"gimp:curves",
|
||||
config, TRUE);
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "base/curves.h"
|
||||
#include "base/gimphistogram.h"
|
||||
#include "base/gimplut.h"
|
||||
|
||||
#include "gegl/gimpcurvesconfig.h"
|
||||
#include "gegl/gimpoperationcurves.h"
|
||||
|
@ -65,8 +63,6 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_curves_tool_finalize (GObject *object);
|
||||
|
||||
static gboolean gimp_curves_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *display,
|
||||
GError **error);
|
||||
|
@ -92,7 +88,6 @@ static void gimp_curves_tool_color_picked (GimpColorTool *color_t
|
|||
gint color_index);
|
||||
static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
|
||||
GObject **config);
|
||||
static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool);
|
||||
static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
|
||||
static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
|
||||
static gboolean gimp_curves_tool_settings_import(GimpImageMapTool *image_map_tool,
|
||||
|
@ -161,13 +156,10 @@ gimp_curves_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_curves_tool_finalize;
|
||||
|
||||
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;
|
||||
|
@ -181,7 +173,6 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
|
|||
im_tool_class->export_dialog_title = _("Export Curves");
|
||||
|
||||
im_tool_class->get_operation = gimp_curves_tool_get_operation;
|
||||
im_tool_class->map = gimp_curves_tool_map;
|
||||
im_tool_class->dialog = gimp_curves_tool_dialog;
|
||||
im_tool_class->reset = gimp_curves_tool_reset;
|
||||
im_tool_class->settings_import = gimp_curves_tool_settings_import;
|
||||
|
@ -191,26 +182,10 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
|
|||
static void
|
||||
gimp_curves_tool_init (GimpCurvesTool *tool)
|
||||
{
|
||||
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
||||
gint i;
|
||||
|
||||
tool->lut = gimp_lut_new ();
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (tool->picked_color); i++)
|
||||
tool->picked_color[i] = -1.0;
|
||||
|
||||
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
|
||||
im_tool->apply_data = tool->lut;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_curves_tool_finalize (GObject *object)
|
||||
{
|
||||
GimpCurvesTool *tool = GIMP_CURVES_TOOL (object);
|
||||
|
||||
gimp_lut_free (tool->lut);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -226,13 +201,6 @@ gimp_curves_tool_initialize (GimpTool *tool,
|
|||
if (! drawable)
|
||||
return FALSE;
|
||||
|
||||
if (gimp_drawable_is_indexed (drawable))
|
||||
{
|
||||
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
||||
_("Curves does not operate on indexed layers."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gimp_config_reset (GIMP_CONFIG (c_tool->config));
|
||||
|
||||
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
|
||||
|
@ -408,22 +376,6 @@ gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
|
|||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
|
||||
GimpDrawable *drawable = image_map_tool->drawable;
|
||||
Curves curves;
|
||||
|
||||
gimp_curves_config_to_cruft (tool->config, &curves,
|
||||
gimp_drawable_is_rgb (drawable));
|
||||
|
||||
gimp_lut_setup (tool->lut,
|
||||
(GimpLutFunc) curves_lut_func,
|
||||
&curves,
|
||||
gimp_drawable_bytes (drawable));
|
||||
}
|
||||
|
||||
|
||||
/*******************/
|
||||
/* Curves dialog */
|
||||
|
|
|
@ -37,7 +37,6 @@ struct _GimpCurvesTool
|
|||
GimpImageMapTool parent_instance;
|
||||
|
||||
GimpCurvesConfig *config;
|
||||
GimpLut *lut;
|
||||
|
||||
/* dialog */
|
||||
gdouble picked_color[5];
|
||||
|
|
|
@ -415,21 +415,29 @@ HELP
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("core/gimpdrawable-curves.h") ],
|
||||
headers => [ qw("gegl/gimpcurvesconfig.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
|
||||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
|
||||
gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
|
||||
(! gimp_drawable_has_alpha (drawable) &&
|
||||
channel == GIMP_HISTOGRAM_ALPHA) ||
|
||||
(gimp_drawable_is_gray (drawable) &&
|
||||
channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
|
||||
success = FALSE;
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
|
||||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
! (num_points & 1) &&
|
||||
(gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
|
||||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
control_pts,
|
||||
num_points);
|
||||
|
||||
if (success)
|
||||
gimp_drawable_curves_spline (drawable, progress,
|
||||
channel, control_pts, num_points);
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
"gimp:curves",
|
||||
config, TRUE);
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
@ -462,21 +470,29 @@ HELP
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("core/gimpdrawable-curves.h") ],
|
||||
headers => [ qw("gegl/gimpcurvesconfig.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
|
||||
! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
|
||||
gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
|
||||
(! gimp_drawable_has_alpha (drawable) &&
|
||||
channel == GIMP_HISTOGRAM_ALPHA) ||
|
||||
(gimp_drawable_is_gray (drawable) &&
|
||||
channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
|
||||
success = FALSE;
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
|
||||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
(num_bytes == 256) &&
|
||||
(gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
|
||||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
curve,
|
||||
num_bytes);
|
||||
|
||||
if (success)
|
||||
gimp_drawable_curves_explicit (drawable, progress,
|
||||
channel, curve, num_bytes);
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
"gimp:curves",
|
||||
config, TRUE);
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue