plugins: add compatibility wrappers to motion-blur

and remove the old plugin.
This commit is contained in:
Téo Mazars 2013-07-04 23:02:55 +02:00
parent 8a7d5c9d16
commit ec6720c897
9 changed files with 466 additions and 1185 deletions

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 690 procedures registered total */
/* 692 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -259,6 +259,164 @@ plug_in_cubism_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_mblur_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 type;
gdouble length;
gdouble angle;
gdouble center_x;
gdouble center_y;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
type = g_value_get_int (gimp_value_array_index (args, 3));
length = g_value_get_double (gimp_value_array_index (args, 4));
angle = g_value_get_double (gimp_value_array_index (args, 5));
center_x = g_value_get_double (gimp_value_array_index (args, 6));
center_y = g_value_get_double (gimp_value_array_index (args, 7));
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))
{
GeglNode *node = NULL;
if (type == 0)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-linear",
"length", length,
"angle", angle,
NULL);
}
else if (type == 1)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-circular",
"center-x", center_x,
"center-y", center_y,
"angle", angle,
NULL);
}
else if (type == 2)
{
gdouble factor = CLAMP (length / 256.0, 0.0, 1.0);
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-zoom",
"center-x", center_x,
"center-y", center_y,
"factor", factor,
NULL);
}
if (node != NULL)
{
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Motion Blur"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_mblur_inward_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 type;
gdouble length;
gdouble angle;
gdouble center_x;
gdouble center_y;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
type = g_value_get_int (gimp_value_array_index (args, 3));
length = g_value_get_double (gimp_value_array_index (args, 4));
angle = g_value_get_double (gimp_value_array_index (args, 5));
center_x = g_value_get_double (gimp_value_array_index (args, 6));
center_y = g_value_get_double (gimp_value_array_index (args, 7));
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))
{
GeglNode *node = NULL;
if (type == 0)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-linear",
"length", length,
"angle", angle,
NULL);
}
else if (type == 1)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-circular",
"center-x", center_x,
"center-y", center_y,
"angle", angle,
NULL);
}
else if (type == 2)
{
gdouble factor = CLAMP (-length / (256.0 - length), -10.0, 0.0);
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-zoom",
"center-x", center_x,
"center-y", center_y,
"factor", factor,
NULL);
}
if (node != NULL)
{
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Motion Blur"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_pixelize_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1100,6 +1258,138 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-mblur
*/
procedure = gimp_procedure_new (plug_in_mblur_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-mblur");
gimp_procedure_set_static_strings (procedure,
"plug-in-mblur",
"Simulate movement using directional blur",
"This plug-in simulates the effect seen when photographing a moving object at a slow shutter speed. Done by adding multiple displaced copies.",
"Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom, -cirular' for credits.",
"Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom, -cirular' for credits.",
"2013",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("type",
"type",
"Type of motion blur { LINEAR (0), RADIAL (1), ZOOM (2) }",
0, 2, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("length",
"length",
"Length",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("angle",
"angle",
"Angle",
0, 360, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("center-x",
"center x",
"Center X",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("center-y",
"center y",
"Center Y",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-mblur-inward
*/
procedure = gimp_procedure_new (plug_in_mblur_inward_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-mblur-inward");
gimp_procedure_set_static_strings (procedure,
"plug-in-mblur-inward",
"Simulate movement using directional blur",
"This procedure is equivalent to plug-in-mblur but performs the zoom blur inward instead of outward.",
"Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom, -cirular' for credits.",
"Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom, -cirular' for credits.",
"2013",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("type",
"type",
"Type of motion blur { LINEAR (0), RADIAL (1), ZOOM (2) }",
0, 2, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("length",
"length",
"Length",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("angle",
"angle",
"Angle",
0, 360, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("center-x",
"center x",
"Center X",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("center-y",
"center y",
"Center Y",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-pixelize
*/

View File

@ -22,8 +22,6 @@
/blur-gauss.exe
/blur-gauss-selective
/blur-gauss-selective.exe
/blur-motion
/blur-motion.exe
/border-average
/border-average.exe
/bump-map

View File

@ -54,7 +54,6 @@ libexec_PROGRAMS = \
blur \
blur-gauss \
blur-gauss-selective \
blur-motion \
border-average \
bump-map \
cartoon \
@ -377,23 +376,6 @@ blur_gauss_selective_LDADD = \
$(INTLLIBS) \
$(blur_gauss_selective_RC)
blur_motion_SOURCES = \
blur-motion.c
blur_motion_LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpmodule) \
$(libgimp) \
$(libgimpmath) \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(blur_motion_RC)
border_average_SOURCES = \
border-average.c
@ -722,7 +704,6 @@ decompose_LDADD = \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(GEGL_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(decompose_RC)

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@ blinds_RC = blinds.rc.o
blur_RC = blur.rc.o
blur_gauss_RC = blur-gauss.rc.o
blur_gauss_selective_RC = blur-gauss-selective.rc.o
blur_motion_RC = blur-motion.rc.o
border_average_RC = border-average.rc.o
bump_map_RC = bump-map.rc.o
cartoon_RC = cartoon.rc.o

View File

@ -9,7 +9,6 @@
'blur' => {},
'blur-gauss' => { ui => 1 },
'blur-gauss-selective' => { ui => 1, cflags => 'MMX_EXTRA_CFLAGS' },
'blur-motion' => { ui => 1 },
'border-average' => { ui => 1 },
'bump-map' => { ui => 1 },
'cartoon' => { ui => 1 },

View File

@ -16,7 +16,6 @@ plug-ins/common/blinds.c
plug-ins/common/blur.c
plug-ins/common/blur-gauss.c
plug-ins/common/blur-gauss-selective.c
plug-ins/common/blur-motion.c
plug-ins/common/border-average.c
plug-ins/common/bump-map.c
plug-ins/common/cartoon.c

View File

@ -245,6 +245,179 @@ CODE
);
}
sub plug_in_mblur {
$blurb = 'Simulate movement using directional blur';
$help = <<'HELP';
This plug-in simulates the effect seen when
photographing a moving object at a slow shutter
speed. Done by adding multiple displaced copies.
HELP
&std_pdb_compat('gegl:motion-blur-linear, -zoom, -cirular');
$date = '2013';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'type', type => '0 <= int32 <= 2',
desc => 'Type of motion blur { LINEAR (0), RADIAL (1), ZOOM (2) }' },
{ name => 'length', type => 'float',
desc => 'Length' },
{ name => 'angle', type => '0 <= float <= 360',
desc => 'Angle' },
{ name => 'center_x', type => 'float',
desc => 'Center X' },
{ name => 'center_y', type => 'float',
desc => 'Center Y' }
);
%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))
{
GeglNode *node = NULL;
if (type == 0)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-linear",
"length", length,
"angle", angle,
NULL);
}
else if (type == 1)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-circular",
"center-x", center_x,
"center-y", center_y,
"angle", angle,
NULL);
}
else if (type == 2)
{
gdouble factor = CLAMP (length / 256.0, 0.0, 1.0);
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-zoom",
"center-x", center_x,
"center-y", center_y,
"factor", factor,
NULL);
}
if (node != NULL)
{
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Motion Blur"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_mblur_inward {
$blurb = 'Simulate movement using directional blur';
$help = <<'HELP';
This procedure is equivalent to plug-in-mblur but
performs the zoom blur inward instead of outward.
HELP
&std_pdb_compat('gegl:motion-blur-linear, -zoom, -cirular');
$date = '2013';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'type', type => '0 <= int32 <= 2',
desc => 'Type of motion blur { LINEAR (0), RADIAL (1), ZOOM (2) }' },
{ name => 'length', type => 'float',
desc => 'Length' },
{ name => 'angle', type => '0 <= float <= 360',
desc => 'Angle' },
{ name => 'center_x', type => 'float',
desc => 'Center X' },
{ name => 'center_y', type => 'float',
desc => 'Center Y' }
);
%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))
{
GeglNode *node = NULL;
if (type == 0)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-linear",
"length", length,
"angle", angle,
NULL);
}
else if (type == 1)
{
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-circular",
"center-x", center_x,
"center-y", center_y,
"angle", angle,
NULL);
}
else if (type == 2)
{
gdouble factor = CLAMP (-length / (256.0 - length), -10.0, 0.0);
node = gegl_node_new_child (NULL,
"operation", "gegl:motion-blur-zoom",
"center-x", center_x,
"center-y", center_y,
"factor", factor,
NULL);
}
if (node != NULL)
{
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Motion Blur"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_pixelize {
$blurb = 'Simplify image into an array of solid-colored squares';
@ -1040,6 +1213,8 @@ CODE
plug_in_autocrop_layer
plug_in_colortoalpha
plug_in_cubism
plug_in_mblur
plug_in_mblur_inward
plug_in_pixelize
plug_in_pixelize2
plug_in_polar_coords