2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-28 10:39:58 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-12-11 03:33:25 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-05-09 22:34:59 +00:00
|
|
|
#include "core-types.h"
|
|
|
|
|
2001-07-04 19:31:35 +00:00
|
|
|
#include "gimp.h"
|
2008-11-02 20:46:57 +00:00
|
|
|
#include "gimpcontainer.h"
|
2007-06-09 17:17:30 +00:00
|
|
|
#include "gimpchannel.h"
|
2004-04-14 23:37:34 +00:00
|
|
|
#include "gimpcontext.h"
|
2006-06-06 22:48:57 +00:00
|
|
|
#include "gimpguide.h"
|
2000-12-29 15:22:01 +00:00
|
|
|
#include "gimpimage.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-28 17:51:06 +00:00
|
|
|
#include "gimpimage-guides.h"
|
2006-05-21 11:32:41 +00:00
|
|
|
#include "gimpimage-item-list.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-28 17:51:06 +00:00
|
|
|
#include "gimpimage-resize.h"
|
2005-08-07 21:05:09 +00:00
|
|
|
#include "gimpimage-sample-points.h"
|
2003-02-13 11:23:50 +00:00
|
|
|
#include "gimpimage-undo.h"
|
2003-02-14 14:14:29 +00:00
|
|
|
#include "gimpimage-undo-push.h"
|
2001-02-01 18:44:22 +00:00
|
|
|
#include "gimplayer.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "gimpprogress.h"
|
2007-01-30 10:34:59 +00:00
|
|
|
#include "gimpsamplepoint.h"
|
2001-07-04 19:31:35 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2003-02-13 11:23:50 +00:00
|
|
|
|
2000-12-28 16:19:55 +00:00
|
|
|
|
1998-06-28 10:39:58 +00:00
|
|
|
void
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_resize (GimpImage *image,
|
2004-08-10 18:47:21 +00:00
|
|
|
GimpContext *context,
|
2004-09-04 22:08:43 +00:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
2004-08-10 18:47:21 +00:00
|
|
|
GimpProgress *progress)
|
2005-02-24 16:39:12 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_resize_with_layers (image, context,
|
2005-02-24 16:39:12 +00:00
|
|
|
new_width, new_height, offset_x, offset_y,
|
2006-05-19 14:50:46 +00:00
|
|
|
GIMP_ITEM_SET_NONE,
|
2005-02-24 16:39:12 +00:00
|
|
|
progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-05-19 14:50:46 +00:00
|
|
|
gimp_image_resize_with_layers (GimpImage *image,
|
|
|
|
GimpContext *context,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
GimpItemSet layer_set,
|
|
|
|
GimpProgress *progress)
|
1998-06-28 10:39:58 +00:00
|
|
|
{
|
2004-08-10 18:47:21 +00:00
|
|
|
GList *list;
|
2006-05-21 11:32:41 +00:00
|
|
|
GList *resize_layers;
|
2004-08-10 18:47:21 +00:00
|
|
|
gdouble progress_max;
|
|
|
|
gdouble progress_current = 1.0;
|
2005-02-24 16:39:12 +00:00
|
|
|
gint old_width, old_height;
|
1998-06-28 10:39:58 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
2004-04-14 23:37:34 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2001-08-11 14:39:19 +00:00
|
|
|
g_return_if_fail (new_width > 0 && new_height > 0);
|
2004-08-10 18:47:21 +00:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
1999-01-10 23:36:29 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_set_busy (image->gimp);
|
1998-06-28 10:39:58 +00:00
|
|
|
|
2008-11-02 20:46:57 +00:00
|
|
|
progress_max = (gimp_container_num_children (image->channels) +
|
|
|
|
gimp_container_num_children (image->layers) +
|
|
|
|
gimp_container_num_children (image->vectors) +
|
2003-06-03 16:42:46 +00:00
|
|
|
1 /* selection */);
|
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
g_object_freeze_notify (G_OBJECT (image));
|
2004-07-14 12:12:50 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_RESIZE,
|
2003-02-13 11:23:50 +00:00
|
|
|
_("Resize Image"));
|
1998-06-28 10:39:58 +00:00
|
|
|
|
2006-05-21 11:32:41 +00:00
|
|
|
resize_layers = gimp_image_item_list_get_list (image, NULL,
|
|
|
|
GIMP_ITEM_TYPE_LAYERS,
|
|
|
|
layer_set);
|
|
|
|
|
2007-12-25 16:21:40 +00:00
|
|
|
old_width = gimp_image_get_width (image);
|
|
|
|
old_height = gimp_image_get_height (image);
|
2005-02-24 16:39:12 +00:00
|
|
|
|
1998-06-28 10:39:58 +00:00
|
|
|
/* Push the image size to the stack */
|
2008-08-28 19:12:03 +00:00
|
|
|
gimp_image_undo_push_image_size (image,
|
|
|
|
NULL,
|
|
|
|
-offset_x,
|
|
|
|
-offset_y,
|
|
|
|
new_width,
|
|
|
|
new_height);
|
1998-06-28 10:39:58 +00:00
|
|
|
|
|
|
|
/* Set the new width and height */
|
2006-03-28 17:08:36 +00:00
|
|
|
g_object_set (image,
|
2004-07-14 12:12:50 +00:00
|
|
|
"width", new_width,
|
|
|
|
"height", new_height,
|
|
|
|
NULL);
|
1998-06-28 10:39:58 +00:00
|
|
|
|
|
|
|
/* Resize all channels */
|
2008-11-02 20:46:57 +00:00
|
|
|
for (list = gimp_image_get_channel_iter (image);
|
2003-05-09 11:27:21 +00:00
|
|
|
list;
|
2001-02-19 13:06:09 +00:00
|
|
|
list = g_list_next (list))
|
1998-06-28 10:39:58 +00:00
|
|
|
{
|
2003-05-07 13:01:17 +00:00
|
|
|
GimpItem *item = list->data;
|
1999-07-09 18:15:39 +00:00
|
|
|
|
2004-04-14 23:37:34 +00:00
|
|
|
gimp_item_resize (item, context,
|
|
|
|
new_width, new_height, offset_x, offset_y);
|
2003-06-03 16:42:46 +00:00
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
1999-07-09 18:15:39 +00:00
|
|
|
}
|
|
|
|
|
2003-05-09 00:38:51 +00:00
|
|
|
/* Resize all vectors */
|
2008-11-02 20:46:57 +00:00
|
|
|
for (list = gimp_image_get_vectors_iter (image);
|
2003-05-09 11:27:21 +00:00
|
|
|
list;
|
2003-05-09 00:38:51 +00:00
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
|
|
|
|
2004-04-14 23:37:34 +00:00
|
|
|
gimp_item_resize (item, context,
|
|
|
|
new_width, new_height, offset_x, offset_y);
|
2003-06-03 16:42:46 +00:00
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
2003-05-09 00:38:51 +00:00
|
|
|
}
|
|
|
|
|
2003-05-09 11:27:21 +00:00
|
|
|
/* Don't forget the selection mask! */
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_item_resize (GIMP_ITEM (gimp_image_get_mask (image)), context,
|
2003-05-09 11:27:21 +00:00
|
|
|
new_width, new_height, offset_x, offset_y);
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
2003-06-03 16:42:46 +00:00
|
|
|
|
2003-05-09 11:27:21 +00:00
|
|
|
/* Reposition all layers */
|
2008-11-02 20:46:57 +00:00
|
|
|
for (list = gimp_image_get_layer_iter (image);
|
2003-05-09 11:27:21 +00:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
2005-02-24 16:39:12 +00:00
|
|
|
gint old_offset_x;
|
|
|
|
gint old_offset_y;
|
|
|
|
|
|
|
|
gimp_item_offsets (item, &old_offset_x, &old_offset_y);
|
2003-05-09 11:27:21 +00:00
|
|
|
|
|
|
|
gimp_item_translate (item, offset_x, offset_y, TRUE);
|
2003-06-03 16:42:46 +00:00
|
|
|
|
2006-05-21 11:32:41 +00:00
|
|
|
if (g_list_find (resize_layers, item))
|
2005-03-01 20:19:53 +00:00
|
|
|
gimp_item_resize (item, context,
|
|
|
|
new_width, new_height,
|
|
|
|
offset_x + old_offset_x, offset_y + old_offset_y);
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
2003-05-09 11:27:21 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 11:32:41 +00:00
|
|
|
g_list_free (resize_layers);
|
|
|
|
|
2003-05-09 11:27:21 +00:00
|
|
|
/* Reposition or remove all guides */
|
2007-12-25 17:09:04 +00:00
|
|
|
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
|
1999-07-09 18:15:39 +00:00
|
|
|
{
|
2003-03-30 16:11:51 +00:00
|
|
|
GimpGuide *guide = list->data;
|
|
|
|
gboolean remove_guide = FALSE;
|
2006-06-07 15:49:59 +00:00
|
|
|
gint new_position = gimp_guide_get_position (guide);
|
1999-07-09 18:15:39 +00:00
|
|
|
|
2006-06-07 15:49:59 +00:00
|
|
|
switch (gimp_guide_get_orientation (guide))
|
2004-09-04 22:08:43 +00:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2003-05-09 11:27:21 +00:00
|
|
|
new_position += offset_y;
|
2004-09-04 22:08:43 +00:00
|
|
|
if (new_position < 0 || new_position > new_height)
|
2003-03-30 16:11:51 +00:00
|
|
|
remove_guide = TRUE;
|
2004-09-04 22:08:43 +00:00
|
|
|
break;
|
2000-12-27 18:15:37 +00:00
|
|
|
|
2004-09-04 22:08:43 +00:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2003-05-09 11:27:21 +00:00
|
|
|
new_position += offset_x;
|
2004-09-04 22:08:43 +00:00
|
|
|
if (new_position < 0 || new_position > new_width)
|
2003-03-30 16:11:51 +00:00
|
|
|
remove_guide = TRUE;
|
2004-09-04 22:08:43 +00:00
|
|
|
break;
|
2000-12-27 18:15:37 +00:00
|
|
|
|
2004-09-04 22:08:43 +00:00
|
|
|
default:
|
2003-05-09 11:27:21 +00:00
|
|
|
break;
|
2004-09-04 22:08:43 +00:00
|
|
|
}
|
2003-03-30 16:11:51 +00:00
|
|
|
|
|
|
|
if (remove_guide)
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_remove_guide (image, guide, TRUE);
|
2006-06-07 15:49:59 +00:00
|
|
|
else if (new_position != gimp_guide_get_position (guide))
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_move_guide (image, guide, new_position, TRUE);
|
1998-06-28 10:39:58 +00:00
|
|
|
}
|
|
|
|
|
2005-08-07 21:05:09 +00:00
|
|
|
/* Reposition or remove sample points */
|
2007-12-25 17:09:04 +00:00
|
|
|
for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
|
2005-08-07 21:05:09 +00:00
|
|
|
{
|
|
|
|
GimpSamplePoint *sample_point = list->data;
|
|
|
|
gboolean remove_sample_point = FALSE;
|
|
|
|
gint new_x = sample_point->x;
|
|
|
|
gint new_y = sample_point->y;
|
|
|
|
|
|
|
|
new_y += offset_y;
|
|
|
|
if ((sample_point->y < 0) || (sample_point->y > new_height))
|
|
|
|
remove_sample_point = TRUE;
|
|
|
|
|
|
|
|
new_x += offset_x;
|
|
|
|
if ((sample_point->x < 0) || (sample_point->x > new_width))
|
|
|
|
remove_sample_point = TRUE;
|
|
|
|
|
|
|
|
if (remove_sample_point)
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_remove_sample_point (image, sample_point, TRUE);
|
2005-08-07 21:05:09 +00:00
|
|
|
else if (new_x != sample_point->x || new_y != sample_point->y)
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_move_sample_point (image, sample_point,
|
2005-08-07 21:05:09 +00:00
|
|
|
new_x, new_y, TRUE);
|
|
|
|
}
|
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_end (image);
|
2001-05-06 17:56:10 +00:00
|
|
|
|
2008-08-28 19:12:03 +00:00
|
|
|
gimp_image_size_changed_detailed (image,
|
|
|
|
offset_x,
|
|
|
|
offset_y,
|
|
|
|
old_width,
|
|
|
|
old_height);
|
2008-08-03 11:35:53 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
g_object_thaw_notify (G_OBJECT (image));
|
1999-01-10 23:36:29 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_unset_busy (image->gimp);
|
1998-06-28 10:39:58 +00:00
|
|
|
}
|
2004-09-04 22:08:43 +00:00
|
|
|
|
|
|
|
void
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_resize_to_layers (GimpImage *image,
|
2004-09-04 22:08:43 +00:00
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress)
|
|
|
|
{
|
2008-11-02 20:46:57 +00:00
|
|
|
GList *list = gimp_image_get_layer_iter (image);
|
2004-09-04 22:08:43 +00:00
|
|
|
GimpItem *item;
|
2007-02-28 08:57:17 +00:00
|
|
|
gint min_x, max_x;
|
|
|
|
gint min_y, max_y;
|
2005-02-24 16:39:12 +00:00
|
|
|
|
2004-09-04 22:08:43 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* figure out starting values */
|
|
|
|
item = list->data;
|
|
|
|
min_x = item->offset_x;
|
|
|
|
min_y = item->offset_y;
|
2007-12-23 16:58:41 +00:00
|
|
|
max_x = item->offset_x + gimp_item_width (item);
|
|
|
|
max_y = item->offset_y + gimp_item_height (item);
|
2004-09-04 22:08:43 +00:00
|
|
|
|
|
|
|
/* Respect all layers */
|
|
|
|
for (list = g_list_next (list);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
item = list->data;
|
|
|
|
|
|
|
|
min_x = MIN (min_x, item->offset_x);
|
|
|
|
min_y = MIN (min_y, item->offset_y);
|
2007-12-23 16:58:41 +00:00
|
|
|
max_x = MAX (max_x, item->offset_x + gimp_item_width (item));
|
|
|
|
max_y = MAX (max_y, item->offset_y + gimp_item_height (item));
|
2004-09-04 22:08:43 +00:00
|
|
|
}
|
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_resize (image, context,
|
2004-09-04 22:08:43 +00:00
|
|
|
max_x - min_x, max_y - min_y,
|
|
|
|
- min_x, - min_y,
|
|
|
|
progress);
|
|
|
|
}
|
|
|
|
|
2007-06-09 17:17:30 +00:00
|
|
|
void
|
|
|
|
gimp_image_resize_to_selection (GimpImage *image,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpChannel *selection = gimp_image_get_mask (image);
|
|
|
|
gint x1, y1;
|
|
|
|
gint x2, y2;
|
|
|
|
|
|
|
|
if (gimp_channel_is_empty (selection))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp_channel_bounds (selection, &x1, &y1, &x2, &y2);
|
|
|
|
|
|
|
|
gimp_image_resize (image, context,
|
|
|
|
x2 - x1, y2 - y1,
|
|
|
|
- x1, - y1,
|
|
|
|
progress);
|
|
|
|
}
|