mirror of https://github.com/GNOME/gimp.git
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...
This commit is contained in:
parent
3007193704
commit
e6c1c14a94
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 813 procedures registered total */
|
||||
/* 812 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
**/
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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") ))'
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue