libgimp, pdb: port gimp_drawable_curves_explicit,spline() to double

and deprecate gimp_curves_explicit,spline().
This commit is contained in:
Michael Natterer 2014-06-17 22:37:46 +02:00
parent 847606d177
commit 98f97a9580
8 changed files with 94 additions and 131 deletions

View File

@ -1063,12 +1063,12 @@ register_color_procs (GimpPDB *pdb)
"gimp-curves-spline");
gimp_procedure_set_static_strings (procedure,
"gimp-curves-spline",
"Modifies the intensity curve(s) for specified drawable.",
"Modifies the intensity mapping for one channel in the specified drawable. The drawable must be either grayscale or RGB, and the channel can be either an intensity component, or the value. The 'control_pts' parameter is an array of integers which define a set of control points which describe a Catmull Rom spline which yields the final intensity curve. Use the 'gimp-curves-explicit' function to explicitly modify intensity levels.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-drawable-curves-spline' instead.",
"Deprecated: Use 'gimp-drawable-curves-spline' instead.",
"",
"",
"",
"gimp-drawable-curves-spline");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
@ -1104,12 +1104,12 @@ register_color_procs (GimpPDB *pdb)
"gimp-curves-explicit");
gimp_procedure_set_static_strings (procedure,
"gimp-curves-explicit",
"Modifies the intensity curve(s) for specified drawable.",
"Modifies the intensity mapping for one channel in the specified drawable. The drawable must be either grayscale or RGB, and the channel can be either an intensity component, or the value. The 'curve' parameter is an array of bytes which explicitly defines how each pixel value in the drawable will be modified. Use the 'gimp-curves-spline' function to modify intensity levels with Catmull Rom splines.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-drawable-curves-explicit' instead.",
"Deprecated: Use 'gimp-drawable-curves-explicit' instead.",
"",
"",
"",
"gimp-drawable-curves-explicit");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",

View File

@ -210,27 +210,28 @@ drawable_curves_explicit_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 channel;
gint32 num_bytes;
const guint8 *curve;
gint32 num_values;
const gdouble *values;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
channel = g_value_get_enum (gimp_value_array_index (args, 1));
num_bytes = g_value_get_int (gimp_value_array_index (args, 2));
curve = gimp_value_get_int8array (gimp_value_array_index (args, 3));
num_values = g_value_get_int (gimp_value_array_index (args, 2));
values = gimp_value_get_floatarray (gimp_value_array_index (args, 3));
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
(num_bytes == 256) &&
(num_values >= 256) &&
(num_values <= 4096) &&
(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_explicit_cruft (channel,
curve,
num_bytes);
GObject *config = gimp_curves_config_new_explicit (channel,
values,
num_values);
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Curves"),
@ -258,12 +259,12 @@ drawable_curves_spline_invoker (GimpProcedure *procedure,
GimpDrawable *drawable;
gint32 channel;
gint32 num_points;
const guint8 *control_pts;
const gdouble *points;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
channel = g_value_get_enum (gimp_value_array_index (args, 1));
num_points = g_value_get_int (gimp_value_array_index (args, 2));
control_pts = gimp_value_get_int8array (gimp_value_array_index (args, 3));
points = gimp_value_get_floatarray (gimp_value_array_index (args, 3));
if (success)
{
@ -275,9 +276,9 @@ drawable_curves_spline_invoker (GimpProcedure *procedure,
(! gimp_drawable_is_gray (drawable) ||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
{
GObject *config = gimp_curves_config_new_spline_cruft (channel,
control_pts,
num_points / 2);
GObject *config = gimp_curves_config_new_spline (channel,
points,
num_points / 2);
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Curves"),
@ -855,7 +856,7 @@ register_drawable_color_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-curves-explicit",
"Modifies the intensity curve(s) for specified drawable.",
"Modifies the intensity mapping for one channel in the specified drawable. The drawable must be either grayscale or RGB, and the channel can be either an intensity component, or the value. The 'curve' parameter is an array of bytes which explicitly defines how each pixel value in the drawable will be modified. Use the 'gimp-curves-spline' function to modify intensity levels with Catmull Rom splines.",
"Modifies the intensity mapping for one channel in the specified drawable. The channel can be either an intensity component, or the value. The 'values' parameter is an array of doubles which explicitly defines how each pixel value in the drawable will be modified. Use the 'gimp-curves-spline' function to modify intensity levels with Catmull Rom splines.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -874,16 +875,16 @@ register_drawable_color_procs (GimpPDB *pdb)
GIMP_HISTOGRAM_VALUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("num-bytes",
"num bytes",
"The number of bytes in the new curve (always 256)",
0, G_MAXINT32, 0,
gimp_param_spec_int32 ("num-values",
"num values",
"The number of values in the new curve",
256, 2096, 256,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8_array ("curve",
"curve",
"The explicit curve",
GIMP_PARAM_READWRITE));
gimp_param_spec_float_array ("values",
"values",
"The explicit curve",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -896,7 +897,7 @@ register_drawable_color_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-curves-spline",
"Modifies the intensity curve(s) for specified drawable.",
"Modifies the intensity mapping for one channel in the specified drawable. The drawable must be either grayscale or RGB, and the channel can be either an intensity component, or the value. The 'control_pts' parameter is an array of integers which define a set of control points which describe a Catmull Rom spline which yields the final intensity curve. Use the 'gimp-curves-explicit' function to explicitly modify intensity levels.",
"Modifies the intensity mapping for one channel in the specified drawable. The channel can be either an intensity component, or the value. The 'points' parameter is an array of doubles which define a set of control points which describe a Catmull Rom spline which yields the final intensity curve. Use the 'gimp-curves-explicit' function to explicitly modify intensity levels.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -918,13 +919,13 @@ register_drawable_color_procs (GimpPDB *pdb)
gimp_param_spec_int32 ("num-points",
"num points",
"The number of values in the control point array",
4, 34, 4,
4, 2048, 4,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8_array ("control-pts",
"control pts",
"The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }",
GIMP_PARAM_READWRITE));
gimp_param_spec_float_array ("points",
"points",
"The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@ -323,15 +323,7 @@ gimp_invert (gint32 drawable_ID)
* @num_points: The number of values in the control point array.
* @control_pts: The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }.
*
* Modifies the intensity curve(s) for specified drawable.
*
* Modifies the intensity mapping for one channel in the specified
* drawable. The drawable must be either grayscale or RGB, and the
* channel can be either an intensity component, or the value. The
* 'control_pts' parameter is an array of integers which define a set
* of control points which describe a Catmull Rom spline which yields
* the final intensity curve. Use the gimp_curves_explicit() function
* to explicitly modify intensity levels.
* Deprecated: Use gimp_drawable_curves_spline() instead.
*
* Returns: TRUE on success.
**/
@ -367,15 +359,7 @@ gimp_curves_spline (gint32 drawable_ID,
* @num_bytes: The number of bytes in the new curve (always 256).
* @curve: The explicit curve.
*
* Modifies the intensity curve(s) for specified drawable.
*
* Modifies the intensity mapping for one channel in the specified
* drawable. The drawable must be either grayscale or RGB, and the
* channel can be either an intensity component, or the value. The
* 'curve' parameter is an array of bytes which explicitly defines how
* each pixel value in the drawable will be modified. Use the
* gimp_curves_spline() function to modify intensity levels with
* Catmull Rom splines.
* Deprecated: Use gimp_drawable_curves_explicit() instead.
*
* Returns: TRUE on success.
**/

View File

@ -60,10 +60,12 @@ GIMP_DEPRECATED_FOR(gimp_drawable_equalize)
gboolean gimp_equalize (gint32 drawable_ID,
gboolean mask_only);
gboolean gimp_invert (gint32 drawable_ID);
GIMP_DEPRECATED_FOR(gimp_drawable_curves_spline)
gboolean gimp_curves_spline (gint32 drawable_ID,
GimpHistogramChannel channel,
gint num_points,
const guint8 *control_pts);
GIMP_DEPRECATED_FOR(gimp_drawable_curves_explicit)
gboolean gimp_curves_explicit (gint32 drawable_ID,
GimpHistogramChannel channel,
gint num_bytes,

View File

@ -174,18 +174,17 @@ gimp_drawable_colorize_hsl (gint32 drawable_ID,
* gimp_drawable_curves_explicit:
* @drawable_ID: The drawable.
* @channel: The channel to modify.
* @num_bytes: The number of bytes in the new curve (always 256).
* @curve: The explicit curve.
* @num_values: The number of values in the new curve.
* @values: The explicit curve.
*
* Modifies the intensity curve(s) for specified drawable.
*
* Modifies the intensity mapping for one channel in the specified
* drawable. The drawable must be either grayscale or RGB, and the
* channel can be either an intensity component, or the value. The
* 'curve' parameter is an array of bytes which explicitly defines how
* each pixel value in the drawable will be modified. Use the
* gimp_curves_spline() function to modify intensity levels with
* Catmull Rom splines.
* drawable. The channel can be either an intensity component, or the
* value. The 'values' parameter is an array of doubles which
* explicitly defines how each pixel value in the drawable will be
* modified. Use the gimp_curves_spline() function to modify intensity
* levels with Catmull Rom splines.
*
* Returns: TRUE on success.
*
@ -194,8 +193,8 @@ gimp_drawable_colorize_hsl (gint32 drawable_ID,
gboolean
gimp_drawable_curves_explicit (gint32 drawable_ID,
GimpHistogramChannel channel,
gint num_bytes,
const guint8 *curve)
gint num_values,
const gdouble *values)
{
GimpParam *return_vals;
gint nreturn_vals;
@ -205,8 +204,8 @@ gimp_drawable_curves_explicit (gint32 drawable_ID,
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_INT32, channel,
GIMP_PDB_INT32, num_bytes,
GIMP_PDB_INT8ARRAY, curve,
GIMP_PDB_INT32, num_values,
GIMP_PDB_FLOATARRAY, values,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
@ -221,17 +220,16 @@ gimp_drawable_curves_explicit (gint32 drawable_ID,
* @drawable_ID: The drawable.
* @channel: The channel to modify.
* @num_points: The number of values in the control point array.
* @control_pts: The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }.
* @points: The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }.
*
* Modifies the intensity curve(s) for specified drawable.
*
* Modifies the intensity mapping for one channel in the specified
* drawable. The drawable must be either grayscale or RGB, and the
* channel can be either an intensity component, or the value. The
* 'control_pts' parameter is an array of integers which define a set
* of control points which describe a Catmull Rom spline which yields
* the final intensity curve. Use the gimp_curves_explicit() function
* to explicitly modify intensity levels.
* drawable. The channel can be either an intensity component, or the
* value. The 'points' parameter is an array of doubles which define a
* set of control points which describe a Catmull Rom spline which
* yields the final intensity curve. Use the gimp_curves_explicit()
* function to explicitly modify intensity levels.
*
* Returns: TRUE on success.
*
@ -241,7 +239,7 @@ gboolean
gimp_drawable_curves_spline (gint32 drawable_ID,
GimpHistogramChannel channel,
gint num_points,
const guint8 *control_pts)
const gdouble *points)
{
GimpParam *return_vals;
gint nreturn_vals;
@ -252,7 +250,7 @@ gimp_drawable_curves_spline (gint32 drawable_ID,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_INT32, channel,
GIMP_PDB_INT32, num_points,
GIMP_PDB_INT8ARRAY, control_pts,
GIMP_PDB_FLOATARRAY, points,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

View File

@ -47,12 +47,12 @@ gboolean gimp_drawable_colorize_hsl (gint32 drawable_ID,
gdouble lightness);
gboolean gimp_drawable_curves_explicit (gint32 drawable_ID,
GimpHistogramChannel channel,
gint num_bytes,
const guint8 *curve);
gint num_values,
const gdouble *values);
gboolean gimp_drawable_curves_spline (gint32 drawable_ID,
GimpHistogramChannel channel,
gint num_points,
const guint8 *control_pts);
const gdouble *points);
gboolean gimp_drawable_desaturate (gint32 drawable_ID,
GimpDesaturateMode desaturate_mode);
gboolean gimp_drawable_equalize (gint32 drawable_ID,

View File

@ -328,18 +328,7 @@ CODE
}
sub curves_spline {
$blurb = 'Modifies the intensity curve(s) for specified drawable.';
$help = <<'HELP';
Modifies the intensity mapping for one channel in the specified drawable. The
drawable must be either grayscale or RGB, and the channel can be either an
intensity component, or the value. The 'control_pts' parameter is an array of
integers which define a set of control points which describe a Catmull Rom
spline which yields the final intensity curve. Use the gimp_curves_explicit()
function to explicitly modify intensity levels.
HELP
&std_pdb_misc;
&std_pdb_deprecated ('gimp-drawable-curves-spline');
@inargs = (
{ name => 'drawable', type => 'drawable',
@ -384,18 +373,7 @@ CODE
}
sub curves_explicit {
$blurb = 'Modifies the intensity curve(s) for specified drawable.';
$help = <<'HELP';
Modifies the intensity mapping for one channel in the specified drawable. The
drawable must be either grayscale or RGB, and the channel can be either an
intensity component, or the value. The 'curve' parameter is an array of bytes
which explicitly defines how each pixel value in the drawable will be modified.
Use the gimp_curves_spline() function to modify intensity levels with Catmull
Rom splines.
HELP
&std_pdb_misc;
&std_pdb_deprecated ('gimp-drawable-curves-explicit');
@inargs = (
{ name => 'drawable', type => 'drawable',

View File

@ -181,12 +181,12 @@ sub drawable_curves_explicit {
$blurb = 'Modifies the intensity curve(s) for specified drawable.';
$help = <<'HELP';
Modifies the intensity mapping for one channel in the specified drawable. The
drawable must be either grayscale or RGB, and the channel can be either an
intensity component, or the value. The 'curve' parameter is an array of bytes
which explicitly defines how each pixel value in the drawable will be modified.
Use the gimp_curves_spline() function to modify intensity levels with Catmull
Rom splines.
Modifies the intensity mapping for one channel in the specified
drawable. The channel can be either an intensity component, or the
value. The 'values' parameter is an array of doubles which explicitly
defines how each pixel value in the drawable will be modified. Use
the gimp_curves_spline() function to modify intensity levels with
Catmull Rom splines.
HELP
&std_pdb_misc;
@ -197,11 +197,10 @@ HELP
desc => 'The drawable' },
{ name => 'channel', type => 'enum GimpHistogramChannel',
desc => 'The channel to modify' },
{ name => 'curve', type => 'int8array',
{ name => 'values', type => 'floatarray',
desc => 'The explicit curve',
array => { name => 'num_bytes',
desc => 'The number of bytes in the new curve (always
256)' } }
array => { name => 'num_values', type => '256 <= int32 <= 2096',
desc => 'The number of values in the new curve' } }
);
%invoke = (
@ -211,14 +210,15 @@ HELP
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
(num_bytes == 256) &&
(num_values >= 256) &&
(num_values <= 4096) &&
(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_explicit_cruft (channel,
curve,
num_bytes);
GObject *config = gimp_curves_config_new_explicit (channel,
values,
num_values);
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Curves"),
@ -237,12 +237,12 @@ sub drawable_curves_spline {
$blurb = 'Modifies the intensity curve(s) for specified drawable.';
$help = <<'HELP';
Modifies the intensity mapping for one channel in the specified drawable. The
drawable must be either grayscale or RGB, and the channel can be either an
intensity component, or the value. The 'control_pts' parameter is an array of
integers which define a set of control points which describe a Catmull Rom
spline which yields the final intensity curve. Use the gimp_curves_explicit()
function to explicitly modify intensity levels.
Modifies the intensity mapping for one channel in the specified
drawable. The channel can be either an intensity component, or the
value. The 'points' parameter is an array of doubles which define a
set of control points which describe a Catmull Rom spline which yields
the final intensity curve. Use the gimp_curves_explicit() function to
explicitly modify intensity levels.
HELP
&std_pdb_misc;
@ -253,10 +253,10 @@ HELP
desc => 'The drawable' },
{ name => 'channel', type => 'enum GimpHistogramChannel',
desc => 'The channel to modify' },
{ name => 'control_pts', type => 'int8array',
{ name => 'points', type => 'floatarray',
desc => 'The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y,
... }',
array => { name => 'num_points', type => '4 <= int32 <= 34',
array => { name => 'num_points', type => '4 <= int32 <= 2048',
desc => 'The number of values in the control point array' }
}
);
@ -273,9 +273,9 @@ HELP
(! gimp_drawable_is_gray (drawable) ||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
{
GObject *config = gimp_curves_config_new_spline_cruft (channel,
control_pts,
num_points / 2);
GObject *config = gimp_curves_config_new_spline (channel,
points,
num_points / 2);
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Curves"),