[gimp] pdb, libgimp: change the gimp-drawable-invert API again
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb, libgimp: change the gimp-drawable-invert API again
- Date: Sun, 3 Sep 2017 19:30:31 +0000 (UTC)
commit e6c1c14a94b1940688fcfe71acd3e8cf907b78e5
Author: Michael Natterer <mitch gimp org>
Date: Sun Sep 3 21:28:47 2017 +0200
pdb, libgimp: change the gimp-drawable-invert API again
Remove the invert-linear and invert-non-linear variants and simply add
"gboolean linear" to gimp-drawable-invert. This should actually be an
enum but I didn't find a good name right now...
app/pdb/color-cmds.c | 6 +-
app/pdb/drawable-color-cmds.c | 87 ++++++-------------------
app/pdb/internal-procs.c | 2 +-
libgimp/gimp.def | 3 +-
libgimp/gimpcolor_pdb.c | 2 +-
libgimp/gimpcolor_pdb.h | 2 +-
libgimp/gimpdrawablecolor_pdb.c | 47 +++-----------
libgimp/gimpdrawablecolor_pdb.h | 4 +-
plug-ins/pygimp/plug-ins/shadow_bevel.py | 2 +-
plug-ins/script-fu/scripts/carve-it.scm | 2 +-
plug-ins/script-fu/scripts/chrome-it.scm | 4 +-
plug-ins/script-fu/scripts/fuzzyborder.scm | 2 +-
plug-ins/script-fu/scripts/script-fu-util.scm | 4 +-
tools/pdbgen/pdb/color.pdb | 2 +-
tools/pdbgen/pdb/drawable_color.pdb | 55 ++++------------
15 files changed, 59 insertions(+), 165 deletions(-)
---
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index a9e548c..bd47641 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -1054,12 +1054,12 @@ register_color_procs (GimpPDB *pdb)
"gimp-invert");
gimp_procedure_set_static_strings (procedure,
"gimp-invert",
- "Deprecated: Use 'gimp-drawable-invert-non-linear' instead.",
- "Deprecated: Use 'gimp-drawable-invert-non-linear' instead.",
+ "Deprecated: Use 'gimp-drawable-invert' instead.",
+ "Deprecated: Use 'gimp-drawable-invert' instead.",
"",
"",
"",
- "gimp-drawable-invert-non-linear");
+ "gimp-drawable-invert");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
diff --git a/app/pdb/drawable-color-cmds.c b/app/pdb/drawable-color-cmds.c
index d87a9e6..d91a15c 100644
--- a/app/pdb/drawable-color-cmds.c
+++ b/app/pdb/drawable-color-cmds.c
@@ -518,49 +518,19 @@ drawable_hue_saturation_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
-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)
+drawable_invert_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
+ gboolean linear;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
+ linear = g_value_get_boolean (gimp_value_array_index (args, 1));
if (success)
{
@@ -570,6 +540,8 @@ drawable_invert_non_linear_invoker (GimpProcedure *procedure,
{
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Invert"),
+ linear ?
+ "gegl:invert-linear" :
"gegl:invert-gamma",
NULL);
}
@@ -1166,15 +1138,15 @@ register_drawable_color_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
- * gimp-drawable-invert-linear
+ * gimp-drawable-invert
*/
- procedure = gimp_procedure_new (drawable_invert_linear_invoker);
+ procedure = gimp_procedure_new (drawable_invert_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-drawable-invert-linear");
+ "gimp-drawable-invert");
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.",
+ "gimp-drawable-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). If
'linear' is TRUE, the drawable is inverted in linear space.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@@ -1185,29 +1157,12 @@ register_drawable_color_procs (GimpPDB *pdb)
"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_non_linear_invoker);
- gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-drawable-invert-non-linear");
- gimp_procedure_set_static_strings (procedure,
- "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",
- "1995-1996",
- NULL);
gimp_procedure_add_argument (procedure,
- gimp_param_spec_drawable_id ("drawable",
- "drawable",
- "The drawable",
- pdb->gimp, FALSE,
- GIMP_PARAM_READWRITE));
+ g_param_spec_boolean ("linear",
+ "linear",
+ "Whether to invert in linear space",
+ FALSE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 40ca864..9083d52 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 813 procedures registered total */
+/* 812 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 34418b7..3c3ddc7 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -229,8 +229,7 @@ EXPORTS
gimp_drawable_height
gimp_drawable_histogram
gimp_drawable_hue_saturation
- gimp_drawable_invert_linear
- gimp_drawable_invert_non_linear
+ gimp_drawable_invert
gimp_drawable_is_channel
gimp_drawable_is_gray
gimp_drawable_is_indexed
diff --git a/libgimp/gimpcolor_pdb.c b/libgimp/gimpcolor_pdb.c
index 76e22fc..0da6f52 100644
--- a/libgimp/gimpcolor_pdb.c
+++ b/libgimp/gimpcolor_pdb.c
@@ -289,7 +289,7 @@ gimp_equalize (gint32 drawable_ID,
* gimp_invert:
* @drawable_ID: The drawable.
*
- * Deprecated: Use gimp_drawable_invert_non_linear() instead.
+ * Deprecated: Use gimp_drawable_invert() instead.
*
* Returns: TRUE on success.
**/
diff --git a/libgimp/gimpcolor_pdb.h b/libgimp/gimpcolor_pdb.h
index 1b7130f..f939272 100644
--- a/libgimp/gimpcolor_pdb.h
+++ b/libgimp/gimpcolor_pdb.h
@@ -59,7 +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)
+GIMP_DEPRECATED_FOR(gimp_drawable_invert)
gboolean gimp_invert (gint32 drawable_ID);
GIMP_DEPRECATED_FOR(gimp_drawable_curves_spline)
gboolean gimp_curves_spline (gint32 drawable_ID,
diff --git a/libgimp/gimpdrawablecolor_pdb.c b/libgimp/gimpdrawablecolor_pdb.c
index c66901c..dc57970 100644
--- a/libgimp/gimpdrawablecolor_pdb.c
+++ b/libgimp/gimpdrawablecolor_pdb.c
@@ -472,62 +472,33 @@ gimp_drawable_hue_saturation (gint32 drawable_ID,
}
/**
- * gimp_drawable_invert_linear:
+ * gimp_drawable_invert:
* @drawable_ID: The drawable.
+ * @linear: Whether to invert in linear space.
*
- * 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.
+ * 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).
+ * is given as inten' = (255 - inten). If 'linear' is TRUE, the
+ * drawable is inverted in linear space.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
-gimp_drawable_invert_non_linear (gint32 drawable_ID)
+gimp_drawable_invert (gint32 drawable_ID,
+ gboolean linear)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
- return_vals = gimp_run_procedure ("gimp-drawable-invert-non-linear",
+ return_vals = gimp_run_procedure ("gimp-drawable-invert",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
+ GIMP_PDB_INT32, linear,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
diff --git a/libgimp/gimpdrawablecolor_pdb.h b/libgimp/gimpdrawablecolor_pdb.h
index 519a993..6e289f9 100644
--- a/libgimp/gimpdrawablecolor_pdb.h
+++ b/libgimp/gimpdrawablecolor_pdb.h
@@ -73,8 +73,8 @@ gboolean gimp_drawable_hue_saturation (gint32 drawable_ID,
gdouble lightness,
gdouble saturation,
gdouble overlap);
-gboolean gimp_drawable_invert_linear (gint32 drawable_ID);
-gboolean gimp_drawable_invert_non_linear (gint32 drawable_ID);
+gboolean gimp_drawable_invert (gint32 drawable_ID,
+ gboolean linear);
gboolean gimp_drawable_levels (gint32 drawable_ID,
GimpHistogramChannel channel,
gdouble low_input,
diff --git a/plug-ins/pygimp/plug-ins/shadow_bevel.py b/plug-ins/pygimp/plug-ins/shadow_bevel.py
index 4667896..475fc98 100755
--- a/plug-ins/pygimp/plug-ins/shadow_bevel.py
+++ b/plug-ins/pygimp/plug-ins/shadow_bevel.py
@@ -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_drawable_invert_non_linear(shadow)
+ pdb.gimp_drawable_invert(shadow, False)
# translate the drop shadow
shadow.translate(drop_x, drop_y)
diff --git a/plug-ins/script-fu/scripts/carve-it.scm b/plug-ins/script-fu/scripts/carve-it.scm
index d5d5193..5aa5fa9 100644
--- a/plug-ins/script-fu/scripts/carve-it.scm
+++ b/plug-ins/script-fu/scripts/carve-it.scm
@@ -95,7 +95,7 @@
(set! mask-fs (car (gimp-edit-paste mask FALSE)))
(gimp-floating-sel-anchor mask-fs)
(if (= carve-white FALSE)
- (gimp-drawable-invert-non-linear mask))
+ (gimp-drawable-invert mask FALSE))
(set! mask-fat (car (gimp-channel-copy mask)))
(gimp-image-insert-channel img mask-fat -1 0)
diff --git a/plug-ins/script-fu/scripts/chrome-it.scm b/plug-ins/script-fu/scripts/chrome-it.scm
index 96bc3b5..527f5c2 100644
--- a/plug-ins/script-fu/scripts/chrome-it.scm
+++ b/plug-ins/script-fu/scripts/chrome-it.scm
@@ -124,7 +124,7 @@
(set! mask-fs (car (gimp-edit-paste mask FALSE)))
(gimp-floating-sel-anchor mask-fs)
(if (= carve-white FALSE)
- (gimp-drawable-invert-non-linear mask)
+ (gimp-drawable-invert mask FALSE)
)
(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-drawable-invert-non-linear layer2)
+ (gimp-drawable-invert layer2 FALSE)
(gimp-image-insert-layer img layer1 0 0)
(copy-layer-chrome-it img layer1 banding-img banding-layer)
diff --git a/plug-ins/script-fu/scripts/fuzzyborder.scm b/plug-ins/script-fu/scripts/fuzzyborder.scm
index bda183c..45a0f23 100644
--- a/plug-ins/script-fu/scripts/fuzzyborder.scm
+++ b/plug-ins/script-fu/scripts/fuzzyborder.scm
@@ -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-drawable-invert-non-linear theLayer)
+ (gimp-drawable-invert theLayer FALSE)
(gimp-layer-resize theLayer
theWidth
theHeight
diff --git a/plug-ins/script-fu/scripts/script-fu-util.scm b/plug-ins/script-fu/scripts/script-fu-util.scm
index 61d610b..6add266 100644
--- a/plug-ins/script-fu/scripts/script-fu-util.scm
+++ b/plug-ins/script-fu/scripts/script-fu-util.scm
@@ -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-drawable-invert-non-linear layer) \
+; gimp -i -b '(with-files "*.png" (gimp-drawable-invert layer FALSE) \
; (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-drawable-invert-non-linear layer) \
+; gimp -i -b '(with-files "*.png" (gimp-drawable-invert layer FALSE) \
; (gimp-file-save 1 image layer \
; (string-append basename ".jpg") \
; (string-append basename ".jpg") ))'
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index d597a5e..2908152 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -294,7 +294,7 @@ CODE
}
sub invert {
- &std_pdb_deprecated ('gimp-drawable-invert-non-linear');
+ &std_pdb_deprecated ('gimp-drawable-invert');
@inargs = (
{ name => 'drawable', type => 'drawable',
diff --git a/tools/pdbgen/pdb/drawable_color.pdb b/tools/pdbgen/pdb/drawable_color.pdb
index 9d710fe..b2d53f4 100644
--- a/tools/pdbgen/pdb/drawable_color.pdb
+++ b/tools/pdbgen/pdb/drawable_color.pdb
@@ -558,12 +558,14 @@ CODE
);
}
-sub drawable_invert_linear {
- $blurb = 'Invert the contents of the specified drawable in linear light.';
+sub drawable_invert {
+ $blurb = 'Invert the contents of the specified drawable.';
$help = <<'HELP';
-This procedure inverts the contents of the specified drawable. Each component
-inverted independently. This procedure works on linear RGB or Gray values.
+This procedure inverts the contents of the specified drawable. Each
+intensity channel is inverted independently. The inverted intensity is
+given as inten' = (255 - inten). If 'linear' is TRUE, the drawable is
+inverted in linear space.
HELP
&std_pdb_misc;
@@ -571,43 +573,9 @@ HELP
@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
-channel is inverted independently. The inverted intensity is given as inten' =
-(255 - inten).
-HELP
-
- &std_pdb_misc;
- $since = '2.10';
-
- @inargs = (
- { name => 'drawable', type => 'drawable',
- desc => 'The drawable' }
+ desc => 'The drawable' },
+ { name => 'linear', type => 'boolean',
+ desc => 'Whether to invert in linear space' }
);
%invoke = (
@@ -619,6 +587,8 @@ HELP
{
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Invert"),
+ linear ?
+ "gegl:invert-linear" :
"gegl:invert-gamma",
NULL);
}
@@ -852,8 +822,7 @@ CODE
drawable_equalize
drawable_histogram
drawable_hue_saturation
- drawable_invert_linear
- drawable_invert_non_linear
+ drawable_invert
drawable_levels
drawable_levels_stretch
drawable_posterize
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]