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
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-06-28 10:39:58 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-06-28 10:39:58 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1998-06-28 10:39:58 +00:00
|
|
|
*/
|
2000-12-11 03:33:25 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-10-15 01:58:39 +02:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
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"
|
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"
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
#include "gimpobjectqueue.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
|
|
|
|
2012-09-05 23:26:54 +02:00
|
|
|
#include "text/gimptextlayer.h"
|
|
|
|
|
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
|
|
|
{
|
2016-10-10 00:02:16 +02:00
|
|
|
gimp_image_resize_with_layers (image, context, GIMP_FILL_TRANSPARENT,
|
2005-02-24 16:39:12 +00:00
|
|
|
new_width, new_height, offset_x, offset_y,
|
2012-09-05 23:26:54 +02:00
|
|
|
GIMP_ITEM_SET_NONE, TRUE,
|
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,
|
2016-10-10 00:02:16 +02:00
|
|
|
GimpFillType fill_type,
|
2006-05-19 14:50:46 +00:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
GimpItemSet layer_set,
|
2012-09-05 23:26:54 +02:00
|
|
|
gboolean resize_text_layers,
|
2006-05-19 14:50:46 +00:00
|
|
|
GimpProgress *progress)
|
1998-06-28 10:39:58 +00:00
|
|
|
{
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
GimpObjectQueue *queue;
|
|
|
|
GList *resize_layers;
|
|
|
|
GList *list;
|
|
|
|
GimpItem *item;
|
|
|
|
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
|
|
|
|
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,
|
2010-06-08 14:24:11 +03:00
|
|
|
C_("undo-type", "Resize Image"));
|
1998-06-28 10:39:58 +00:00
|
|
|
|
2018-03-26 04:26:52 -04:00
|
|
|
resize_layers = gimp_image_item_list_get_list (image,
|
|
|
|
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 */
|
2012-09-22 16:34:14 +02: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
|
|
|
|
2003-05-09 11:27:21 +00:00
|
|
|
/* Reposition all layers */
|
2009-08-27 19:31:55 +02:00
|
|
|
for (list = gimp_image_get_layer_iter (image);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
|
|
|
|
|
|
|
gimp_item_translate (item, offset_x, offset_y, TRUE);
|
|
|
|
}
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
queue = gimp_object_queue_new (progress);
|
|
|
|
progress = GIMP_PROGRESS (queue);
|
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
for (list = resize_layers; list; list = g_list_next (list))
|
2003-05-09 11:27:21 +00:00
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
2005-02-24 16:39:12 +00:00
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
/* group layers can't be resized here */
|
2009-08-25 15:46:53 +02:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (item)))
|
|
|
|
continue;
|
|
|
|
|
2012-09-05 23:26:54 +02:00
|
|
|
if (! resize_text_layers && gimp_item_is_text_layer (item))
|
|
|
|
continue;
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
gimp_item_start_move (item, TRUE);
|
2005-03-01 20:19:53 +00:00
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
gimp_object_queue_push (queue, item);
|
2003-05-09 11:27:21 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 11:32:41 +00:00
|
|
|
g_list_free (resize_layers);
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
|
|
|
|
gimp_object_queue_push (queue, gimp_image_get_mask (image));
|
|
|
|
gimp_object_queue_push_container (queue, gimp_image_get_channels (image));
|
|
|
|
gimp_object_queue_push_container (queue, gimp_image_get_vectors (image));
|
|
|
|
|
|
|
|
/* Resize all resize_layers, channels (including selection mask), and
|
|
|
|
* vectors
|
|
|
|
*/
|
|
|
|
while ((item = gimp_object_queue_pop (queue)))
|
|
|
|
{
|
|
|
|
if (GIMP_IS_LAYER (item))
|
|
|
|
{
|
|
|
|
gint old_offset_x;
|
|
|
|
gint old_offset_y;
|
|
|
|
|
|
|
|
gimp_item_get_offset (item, &old_offset_x, &old_offset_y);
|
|
|
|
|
|
|
|
gimp_item_resize (item, context, fill_type,
|
|
|
|
new_width, new_height,
|
|
|
|
old_offset_x, old_offset_y);
|
|
|
|
|
|
|
|
gimp_item_end_move (item, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_item_resize (item, context, GIMP_FILL_TRANSPARENT,
|
|
|
|
new_width, new_height, offset_x, offset_y);
|
|
|
|
}
|
|
|
|
}
|
2006-05-21 11:32:41 +00:00
|
|
|
|
2003-05-09 11:27:21 +00:00
|
|
|
/* Reposition or remove all guides */
|
2014-07-10 00:08:14 +02:00
|
|
|
list = gimp_image_get_guides (image);
|
|
|
|
|
|
|
|
while (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
|
|
|
|
2014-07-10 00:08:14 +02:00
|
|
|
list = g_list_next (list);
|
|
|
|
|
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 */
|
2014-07-10 00:08:14 +02:00
|
|
|
list = gimp_image_get_sample_points (image);
|
|
|
|
|
|
|
|
while (list)
|
2005-08-07 21:05:09 +00:00
|
|
|
{
|
|
|
|
GimpSamplePoint *sample_point = list->data;
|
|
|
|
gboolean remove_sample_point = FALSE;
|
2016-01-04 22:06:27 +01:00
|
|
|
gint old_x;
|
|
|
|
gint old_y;
|
|
|
|
gint new_x;
|
|
|
|
gint new_y;
|
2005-08-07 21:05:09 +00:00
|
|
|
|
2014-07-10 00:08:14 +02:00
|
|
|
list = g_list_next (list);
|
|
|
|
|
2016-01-04 22:06:27 +01:00
|
|
|
gimp_sample_point_get_position (sample_point, &old_x, &old_y);
|
|
|
|
|
|
|
|
new_y = old_y + offset_y;
|
|
|
|
if ((new_y < 0) || (new_y > new_height))
|
2005-08-07 21:05:09 +00:00
|
|
|
remove_sample_point = TRUE;
|
|
|
|
|
2016-01-04 22:06:27 +01:00
|
|
|
new_x = old_x + offset_x;
|
|
|
|
if ((new_x < 0) || (new_x > new_width))
|
2005-08-07 21:05:09 +00:00
|
|
|
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);
|
2016-01-04 22:06:27 +01:00
|
|
|
else if (new_x != old_x || new_y != old_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);
|
|
|
|
}
|
|
|
|
|
app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects. This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.
In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups. This also affects layers
with masks, whose progress is now reported together instead of
individually.
Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 10:18:46 -04:00
|
|
|
g_object_unref (queue);
|
|
|
|
|
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,
|
2012-09-22 16:34:14 +02:00
|
|
|
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)
|
|
|
|
{
|
2009-08-02 17:44:05 +02:00
|
|
|
GList *list;
|
2004-09-04 22:08:43 +00:00
|
|
|
GimpItem *item;
|
2009-08-27 19:31:55 +02:00
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
2005-02-24 16:39:12 +00:00
|
|
|
|
2009-08-02 17:44:05 +02:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
list = gimp_image_get_layer_iter (image);
|
2009-08-02 17:44:05 +02:00
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
if (! list)
|
2004-09-04 22:08:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* figure out starting values */
|
|
|
|
item = list->data;
|
2009-08-02 17:44:05 +02:00
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
x = gimp_item_get_offset_x (item);
|
|
|
|
y = gimp_item_get_offset_y (item);
|
|
|
|
width = gimp_item_get_width (item);
|
|
|
|
height = gimp_item_get_height (item);
|
2004-09-04 22:08:43 +00:00
|
|
|
|
|
|
|
/* Respect all layers */
|
2009-08-02 17:44:05 +02:00
|
|
|
for (list = g_list_next (list); list; list = g_list_next (list))
|
2004-09-04 22:08:43 +00:00
|
|
|
{
|
|
|
|
item = list->data;
|
|
|
|
|
2009-08-27 19:31:55 +02:00
|
|
|
gimp_rectangle_union (x, y,
|
|
|
|
width, height,
|
|
|
|
gimp_item_get_offset_x (item),
|
|
|
|
gimp_item_get_offset_y (item),
|
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item),
|
|
|
|
&x, &y,
|
|
|
|
&width, &height);
|
2004-09-04 22:08:43 +00:00
|
|
|
}
|
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_resize (image, context,
|
2009-08-27 19:31:55 +02:00
|
|
|
width, height, -x, -y,
|
2004-09-04 22:08:43 +00:00
|
|
|
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);
|
2015-07-02 03:04:39 +02:00
|
|
|
gint x, y, w, h;
|
2007-06-09 17:17:30 +00:00
|
|
|
|
2015-07-02 03:04:39 +02:00
|
|
|
if (gimp_item_bounds (GIMP_ITEM (selection), &x, &y, &w, &h))
|
|
|
|
{
|
|
|
|
gimp_image_resize (image, context,
|
|
|
|
w, h, -x, -y,
|
|
|
|
progress);
|
|
|
|
}
|
2007-06-09 17:17:30 +00:00
|
|
|
}
|