applied patch from Philip Lafleur that makes Autocrop register a new

2004-05-29  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/autocrop.c: applied patch from Philip Lafleur
	that makes Autocrop register a new procedure that autocrops a
	single layer as requested in bug #142618.

	* tools/pdbgen/pdb/layer.pdb
	* app/pdb/layer_cmds.c
	* libgimp/gimplayer_pdb.c: fixed documentation for gimp_resize_layer.
	Patch provided by Philip Lafleur (bug #142618).
This commit is contained in:
Sven Neumann
2004-05-29 11:29:37 +00:00
committed by Sven Neumann
parent e56c2fe71f
commit 2626b09043
5 changed files with 73 additions and 27 deletions

View File

@ -1,8 +1,19 @@
2004-05-29 Sven Neumann <sven@gimp.org>
* plug-ins/common/autocrop.c: applied patch from Philip Lafleur
that makes Autocrop register a new procedure that autocrops a
single layer as requested in bug #142618.
* tools/pdbgen/pdb/layer.pdb
* app/pdb/layer_cmds.c
* libgimp/gimplayer_pdb.c: fixed documentation for gimp_resize_layer.
Patch provided by Philip Lafleur (bug #142618).
2004-05-29 Sven Neumann <sven@gimp.org>
* app/widgets/gimptemplateeditor.c
(gimp_template_editor_constructor): add the spinbuttons to the
size entry in the correct order. Fixes bug 143347.
size entry in the correct order. Fixes bug #143347.
2004-05-28 Michael Natterer <mitch@gimp.org>

View File

@ -545,12 +545,12 @@ static ProcArg layer_resize_inargs[] =
{
GIMP_PDB_INT32,
"offx",
"x offset between upper left corner of old and new layers: (new - old)"
"x offset between upper left corner of old and new layers: (old - new)"
},
{
GIMP_PDB_INT32,
"offy",
"y offset between upper left corner of old and new layers: (new - old)"
"y offset between upper left corner of old and new layers: (old - new)"
}
};

View File

@ -234,8 +234,8 @@ gimp_layer_scale (gint32 layer_ID,
* @layer_ID: The layer.
* @new_width: New layer width.
* @new_height: New layer height.
* @offx: x offset between upper left corner of old and new layers: (new - old).
* @offy: y offset between upper left corner of old and new layers: (new - old).
* @offx: x offset between upper left corner of old and new layers: (old - new).
* @offy: y offset between upper left corner of old and new layers: (old - new).
*
* Resize the layer to the specified extents.
*

View File

@ -31,25 +31,26 @@
/* Declare local functions. */
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gboolean colors_equal (const guchar *col1,
const guchar *col2,
gint bytes);
static gint guess_bgcolor (GimpPixelRgn *pr,
gint width,
gint height,
gint bytes,
guchar *color);
static gboolean colors_equal (const guchar *col1,
const guchar *col2,
gint bytes);
static gint guess_bgcolor (GimpPixelRgn *pr,
gint width,
gint height,
gint bytes,
guchar *color);
static void doit (GimpDrawable *drawable,
gint32 image_id,
gboolean show_progress);
static void doit (GimpDrawable *drawable,
gint32 image_id,
gboolean show_progress,
gboolean layer_only);
GimpPlugInInfo PLUG_IN_INFO =
@ -89,6 +90,22 @@ query (void)
gimp_plugin_menu_register ("plug_in_autocrop",
N_("<Image>/Image/Crop"));
gimp_install_procedure ("plug_in_autocrop_layer",
"Automagically crops a layer.",
"",
"Tim Newsome",
"Tim Newsome",
"1997",
N_("_Autocrop"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register ("plug_in_autocrop_layer",
N_("<Image>/Layer/Crop"));
}
static void
@ -133,7 +150,8 @@ run (const gchar *name,
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width() + 1));
doit (drawable, image_id, interactive);
doit (drawable, image_id, interactive,
! strcmp (name, "plug_in_autocrop_layer"));
if (interactive)
gimp_displays_flush ();
@ -151,7 +169,8 @@ run (const gchar *name,
static void
doit (GimpDrawable *drawable,
gint32 image_id,
gboolean show_progress)
gboolean show_progress,
gboolean layer_only)
{
GimpPixelRgn srcPR;
gint width, height;
@ -159,7 +178,8 @@ doit (GimpDrawable *drawable,
gint32 nx, ny, nw, nh;
guchar *buffer;
guchar color[4] = {0, 0, 0, 0};
gint32 layer_id = 0;
width = drawable->width;
height = drawable->height;
bytes = drawable->bpp;
@ -169,6 +189,16 @@ doit (GimpDrawable *drawable,
nw = width;
nh = height;
if (layer_only)
{
layer_id = gimp_image_get_active_layer (image_id);
if (layer_id == -1)
{
gimp_drawable_detach (drawable);
return;
}
}
/* initialize the pixel regions */
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
@ -249,7 +279,12 @@ doit (GimpDrawable *drawable,
gimp_drawable_detach (drawable);
if (nw != width || nh != height)
gimp_image_crop (image_id, nw, nh, nx, ny);
{
if (layer_only)
gimp_layer_resize (layer_id, nw, nh, 0 - nx, 0 - ny);
else
gimp_image_crop (image_id, nw, nh, nx, ny);
}
if (show_progress)
gimp_progress_update (1.00);

View File

@ -323,7 +323,7 @@ sub layer_resize {
foreach (qw(x y)) {
push @args, { name => "off$_", type => 'int32',
desc => "$_ offset between upper left corner of old and
new layers: (new - old)" }
new layers: (old - new)" }
}
&layer_dim_proc('resize', <<'HELP', @args);