Commit 2e6c39ed authored by Michael Natterer's avatar Michael Natterer 😴

pdb, libgimp: rename gimp_drawable_invert() to _invert_non_linear()

and add gimp_drawable_invert_linear(). Also, finally deprecate
gimp_invert() and port all its uses in plug-ins and scripts to
gimp_drawable_invert_non_linear() so the result is the same.
parent 188a8255
......@@ -1054,12 +1054,12 @@ register_color_procs (GimpPDB *pdb)
"gimp-invert");
gimp_procedure_set_static_strings (procedure,
"gimp-invert",
"Invert the contents of the specified drawable.",
"This procedure inverts the contents of the specified drawable. Each intensity channel is inverted independently. The inverted intensity is given as inten' = (255 - inten).",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-drawable-invert-non-linear' instead.",
"Deprecated: Use 'gimp-drawable-invert-non-linear' instead.",
"",
"",
"",
"gimp-drawable-invert-non-linear");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
......
......@@ -518,12 +518,44 @@ drawable_hue_saturation_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
drawable_invert_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
drawable_invert_linear_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
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))
{
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Invert"),
"gegl:invert-linear",
NULL);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
drawable_invert_non_linear_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
......@@ -1134,14 +1166,37 @@ register_drawable_color_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
* gimp-drawable-invert
* gimp-drawable-invert-linear
*/
procedure = gimp_procedure_new (drawable_invert_linear_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-invert-linear");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-invert-linear",
"Invert the contents of the specified drawable in linear light.",
"This procedure inverts the contents of the specified drawable. Each component inverted independently. This procedure works on linear RGB or Gray values.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-invert-non-linear
*/
procedure = gimp_procedure_new (drawable_invert_invoker);
procedure = gimp_procedure_new (drawable_invert_non_linear_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-invert");
"gimp-drawable-invert-non-linear");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-invert",
"Invert the contents of the specified drawable.",
"gimp-drawable-invert-non-linear",
"Invert the contents of the specified drawable in perceptual space.",
"This procedure inverts the contents of the specified drawable. Each intensity channel is inverted independently. The inverted intensity is given as inten' = (255 - inten).",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 812 procedures registered total */
/* 813 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -229,7 +229,8 @@ EXPORTS
gimp_drawable_height
gimp_drawable_histogram
gimp_drawable_hue_saturation
gimp_drawable_invert
gimp_drawable_invert_linear
gimp_drawable_invert_non_linear
gimp_drawable_is_channel
gimp_drawable_is_gray
gimp_drawable_is_indexed
......
......@@ -289,11 +289,7 @@ gimp_equalize (gint32 drawable_ID,
* gimp_invert:
* @drawable_ID: The drawable.
*
* Invert the contents of the specified drawable.
*
* This procedure inverts the contents of the specified drawable. Each
* intensity channel is inverted independently. The inverted intensity
* is given as inten' = (255 - inten).
* Deprecated: Use gimp_drawable_invert_non_linear() instead.
*
* Returns: TRUE on success.
**/
......
......@@ -59,6 +59,7 @@ gboolean gimp_desaturate_full (gint32 drawable_ID,
GIMP_DEPRECATED_FOR(gimp_drawable_equalize)
gboolean gimp_equalize (gint32 drawable_ID,
gboolean mask_only);
GIMP_DEPRECATED_FOR(gimp_drawable_invert_non_linear)
gboolean gimp_invert (gint32 drawable_ID);
GIMP_DEPRECATED_FOR(gimp_drawable_curves_spline)
gboolean gimp_curves_spline (gint32 drawable_ID,
......
......@@ -472,10 +472,43 @@ gimp_drawable_hue_saturation (gint32 drawable_ID,
}
/**
* gimp_drawable_invert:
* gimp_drawable_invert_linear:
* @drawable_ID: The drawable.
*
* Invert the contents of the specified drawable.
* Invert the contents of the specified drawable in linear light.
*
* This procedure inverts the contents of the specified drawable. Each
* component inverted independently. This procedure works on linear RGB
* or Gray values.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_drawable_invert_linear (gint32 drawable_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-drawable-invert-linear",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_drawable_invert_non_linear:
* @drawable_ID: The drawable.
*
* Invert the contents of the specified drawable in perceptual space.
*
* This procedure inverts the contents of the specified drawable. Each
* intensity channel is inverted independently. The inverted intensity
......@@ -486,13 +519,13 @@ gimp_drawable_hue_saturation (gint32 drawable_ID,
* Since: 2.10
**/
gboolean
gimp_drawable_invert (gint32 drawable_ID)
gimp_drawable_invert_non_linear (gint32 drawable_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-drawable-invert",
return_vals = gimp_run_procedure ("gimp-drawable-invert-non-linear",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_END);
......
......@@ -73,7 +73,8 @@ gboolean gimp_drawable_hue_saturation (gint32 drawable_ID,
gdouble lightness,
gdouble saturation,
gdouble overlap);
gboolean gimp_drawable_invert (gint32 drawable_ID);
gboolean gimp_drawable_invert_linear (gint32 drawable_ID);
gboolean gimp_drawable_invert_non_linear (gint32 drawable_ID);
gboolean gimp_drawable_levels (gint32 drawable_ID,
GimpHistogramChannel channel,
gdouble low_input,
......
......@@ -42,7 +42,7 @@ def shadow_bevel(img, drawable, blur, bevel, do_shadow, drop_x, drop_y):
0, 0, 0, 0, True, False, 0)
# make the shadow layer black now ...
pdb.gimp_invert(shadow)
pdb.gimp_drawable_invert_non_linear(shadow)
# translate the drop shadow
shadow.translate(drop_x, drop_y)
......
......@@ -95,7 +95,7 @@
(set! mask-fs (car (gimp-edit-paste mask FALSE)))
(gimp-floating-sel-anchor mask-fs)
(if (= carve-white FALSE)
(gimp-invert mask))
(gimp-drawable-invert-non-linear mask))
(set! mask-fat (car (gimp-channel-copy mask)))
(gimp-image-insert-channel img mask-fat -1 0)
......
......@@ -124,7 +124,7 @@
(set! mask-fs (car (gimp-edit-paste mask FALSE)))
(gimp-floating-sel-anchor mask-fs)
(if (= carve-white FALSE)
(gimp-invert mask)
(gimp-drawable-invert-non-linear mask)
)
(gimp-context-set-background '(255 255 255))
......@@ -145,7 +145,7 @@
(gimp-edit-fill layer3 FILL-BACKGROUND)
(gimp-selection-none img)
(set! layer2 (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
(gimp-invert layer2)
(gimp-drawable-invert-non-linear layer2)
(gimp-image-insert-layer img layer1 0 0)
(copy-layer-chrome-it img layer1 banding-img banding-layer)
......
......@@ -112,7 +112,7 @@
(- theWidth inSize) (- theHeight inSize) TRUE)
(gimp-drawable-desaturate theLayer DESATURATE-LIGHTNESS)
(gimp-drawable-brightness-contrast theLayer 0.5 0.5)
(gimp-invert theLayer)
(gimp-drawable-invert-non-linear theLayer)
(gimp-layer-resize theLayer
theWidth
theHeight
......
......@@ -60,12 +60,12 @@
; For example, to invert the colors of all of the PNG files in the
; start directory:
;
; gimp -i -b '(with-files "*.png" (gimp-invert layer) \
; gimp -i -b '(with-files "*.png" (gimp-drawable-invert-non-linear layer) \
; (gimp-file-save 1 image layer filename filename ))'
;
; To do the same thing, but saving them as jpeg instead:
;
; gimp -i -b '(with-files "*.png" (gimp-invert layer) \
; gimp -i -b '(with-files "*.png" (gimp-drawable-invert-non-linear layer) \
; (gimp-file-save 1 image layer \
; (string-append basename ".jpg") \
; (string-append basename ".jpg") ))'
......
......@@ -294,15 +294,7 @@ CODE
}
sub invert {
$blurb = 'Invert the contents of the specified drawable.';
$help = <<'HELP';
This procedure inverts the contents of the specified drawable. Each intensity
channel is inverted independently. The inverted intensity is given as inten' =
(255 - inten).
HELP
&std_pdb_misc;
&std_pdb_deprecated ('gimp-drawable-invert-non-linear');
@inargs = (
{ name => 'drawable', type => 'drawable',
......
......@@ -558,8 +558,43 @@ CODE
);
}
sub drawable_invert {
$blurb = 'Invert the contents of the specified drawable.';
sub drawable_invert_linear {
$blurb = 'Invert the contents of the specified drawable in linear light.';
$help = <<'HELP';
This procedure inverts the contents of the specified drawable. Each component
inverted independently. This procedure works on linear RGB or Gray values.
HELP
&std_pdb_misc;
$since = '2.10';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
%invoke = (
code => <<'CODE'
{
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))
{
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Invert"),
"gegl:invert-linear",
NULL);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_invert_non_linear {
$blurb = 'Invert the contents of the specified drawable in perceptual space.';
$help = <<'HELP';
This procedure inverts the contents of the specified drawable. Each intensity
......@@ -811,13 +846,16 @@ CODE
@procs = qw(drawable_brightness_contrast
drawable_color_balance
drawable_colorize_hsl
drawable_curves_explicit drawable_curves_spline
drawable_curves_explicit
drawable_curves_spline
drawable_desaturate
drawable_equalize
drawable_histogram
drawable_hue_saturation
drawable_invert
drawable_levels drawable_levels_stretch
drawable_invert_linear
drawable_invert_non_linear
drawable_levels
drawable_levels_stretch
drawable_posterize
drawable_threshold);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment