2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-28 18:39:58 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-06-28 18:39:58 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-06-28 18:39:58 +08: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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-06-28 18:39:58 +08:00
|
|
|
*/
|
2000-12-11 11:33:25 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2009-08-28 01:31:55 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "gimp.h"
|
2008-11-03 04:46:57 +08:00
|
|
|
#include "gimpcontainer.h"
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "gimpcontext.h"
|
2006-06-07 06:48:57 +08:00
|
|
|
#include "gimpguide.h"
|
2000-12-29 23:22:01 +08: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-29 01:51:06 +08:00
|
|
|
#include "gimpimage-guides.h"
|
2006-05-21 19:32:41 +08: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-29 01:51:06 +08:00
|
|
|
#include "gimpimage-resize.h"
|
2005-08-08 05:05:09 +08:00
|
|
|
#include "gimpimage-sample-points.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
#include "gimpimage-undo.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "gimpimage-undo-push.h"
|
2001-02-02 02:44:22 +08: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 22:18:46 +08:00
|
|
|
#include "gimpobjectqueue.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "gimpprogress.h"
|
2007-01-30 18:34:59 +08:00
|
|
|
#include "gimpsamplepoint.h"
|
2001-07-05 03:31:35 +08:00
|
|
|
|
2012-09-06 05:26:54 +08:00
|
|
|
#include "text/gimptextlayer.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
|
2000-12-29 00:19:55 +08:00
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_resize (GimpImage *image,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpContext *context,
|
2004-09-05 06:08:43 +08:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2005-02-25 00:39:12 +08:00
|
|
|
{
|
2016-10-10 06:02:16 +08:00
|
|
|
gimp_image_resize_with_layers (image, context, GIMP_FILL_TRANSPARENT,
|
2005-02-25 00:39:12 +08:00
|
|
|
new_width, new_height, offset_x, offset_y,
|
2012-09-06 05:26:54 +08:00
|
|
|
GIMP_ITEM_SET_NONE, TRUE,
|
2005-02-25 00:39:12 +08:00
|
|
|
progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-05-19 22:50:46 +08:00
|
|
|
gimp_image_resize_with_layers (GimpImage *image,
|
|
|
|
GimpContext *context,
|
2016-10-10 06:02:16 +08:00
|
|
|
GimpFillType fill_type,
|
2006-05-19 22:50:46 +08:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
GimpItemSet layer_set,
|
2012-09-06 05:26:54 +08:00
|
|
|
gboolean resize_text_layers,
|
2006-05-19 22:50:46 +08:00
|
|
|
GimpProgress *progress)
|
1998-06-28 18:39:58 +08: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 22:18:46 +08:00
|
|
|
GimpObjectQueue *queue;
|
|
|
|
GList *resize_layers;
|
|
|
|
GList *list;
|
|
|
|
GimpItem *item;
|
|
|
|
gint old_width, old_height;
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2001-08-11 22:39:19 +08:00
|
|
|
g_return_if_fail (new_width > 0 && new_height > 0);
|
2004-08-11 02:47:21 +08:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_set_busy (image->gimp);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_object_freeze_notify (G_OBJECT (image));
|
2004-07-14 20:12:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_RESIZE,
|
2010-06-08 19:24:11 +08:00
|
|
|
C_("undo-type", "Resize Image"));
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2018-03-26 16:26:52 +08:00
|
|
|
resize_layers = gimp_image_item_list_get_list (image,
|
|
|
|
GIMP_ITEM_TYPE_LAYERS,
|
|
|
|
layer_set);
|
|
|
|
|
2007-12-26 00:21:40 +08:00
|
|
|
old_width = gimp_image_get_width (image);
|
|
|
|
old_height = gimp_image_get_height (image);
|
2005-02-25 00:39:12 +08:00
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
/* Push the image size to the stack */
|
2012-09-22 22:34:14 +08:00
|
|
|
gimp_image_undo_push_image_size (image, NULL,
|
|
|
|
-offset_x, -offset_y,
|
|
|
|
new_width, new_height);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
|
|
|
/* Set the new width and height */
|
2006-03-29 01:08:36 +08:00
|
|
|
g_object_set (image,
|
2004-07-14 20:12:50 +08:00
|
|
|
"width", new_width,
|
|
|
|
"height", new_height,
|
|
|
|
NULL);
|
1998-06-28 18:39:58 +08:00
|
|
|
|
2003-05-09 19:27:21 +08:00
|
|
|
/* Reposition all layers */
|
2009-08-28 01:31:55 +08: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 22:18:46 +08:00
|
|
|
queue = gimp_object_queue_new (progress);
|
|
|
|
progress = GIMP_PROGRESS (queue);
|
|
|
|
|
2009-08-28 01:31:55 +08:00
|
|
|
for (list = resize_layers; list; list = g_list_next (list))
|
2003-05-09 19:27:21 +08:00
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
2005-02-25 00:39:12 +08:00
|
|
|
|
2009-08-28 01:31:55 +08:00
|
|
|
/* group layers can't be resized here */
|
2009-08-25 21:46:53 +08:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (item)))
|
|
|
|
continue;
|
|
|
|
|
2012-09-06 05:26:54 +08:00
|
|
|
if (! resize_text_layers && gimp_item_is_text_layer (item))
|
|
|
|
continue;
|
|
|
|
|
Bug 795410 - Deleting a layer group and then undoing the deletion ...
... raises a CRITICAL
gimp_item_{start,end}_move() currently serves two different
purposes: It is used by GimpLayer to suspend/resume mask resizing
of the layer's ancestors; this is necessary whenever an operation
on a layer might affect the size of its ancestors. It is also used
by GimpGroupLayer to suspend/resume its own mask resizing; this, on
the other hand, is only necessary before applying one of the
transformation functions to the group, so that mask modification is
handled by GimpLayer. In other words, the effects of
gimp_item_{start,end}_move() on group layers are only necessary in
a subset of the cases in which these functions are used.
While in itself this isn't a problem, it does cause issues when
removing a group layer: gimp_image_remove_layer() calls
gimp_item_start_move() before removing the layer, and
gimp_item_end_move() afterwards. While the former function is
called while the layer is still attached to the image, the latter
function is called after the layer is no longer attached. Since
GimpGroupLayer pushes an undo step in response to these calls, only
the call to start_move() results in an undo step, while the call to
end_move() doesn't, resulting in an unbalanced
GIMP_UNDO_GROUP_LAYER_START_MOVE undo step on the stack. This
causes problems when undoing the operation.
Add gimp_item_{start,end}_transform() functions, and corresponding
GimpItem::{start,end}_transform() virtual functions, which are more
specialized versions of gimp_item_{start,end}_move(), which should
be used instead of the former before/after transforming an item; in
other cases, such as when removing ot reordering an item,
gimp_item_{start,end}_move() should still be used. The default
implementation of GimpItem::{start,end}_transform() calls
gimp_item_{start,end}_move(), respectively, so subclasses that
override these functions don't have to do that themselves.
In GimpGroupLayer, override GimpItem::{start,end}_transform(),
instead of GimpItem::{start,end}_move(), for the same purpose of
suspending mask resize. This avoids these functions from being
called when removing a layer group, fixing the bug.
2018-04-22 15:39:40 +08:00
|
|
|
/* note that we call gimp_item_start_move(), and not
|
|
|
|
* gimp_item_start_transform(). see the comment in gimp_item_resize()
|
|
|
|
* for more information.
|
|
|
|
*/
|
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 22:18:46 +08:00
|
|
|
gimp_item_start_move (item, TRUE);
|
2005-03-02 04:19:53 +08: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 22:18:46 +08:00
|
|
|
gimp_object_queue_push (queue, item);
|
2003-05-09 19:27:21 +08:00
|
|
|
}
|
|
|
|
|
2006-05-21 19:32:41 +08: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 22:18:46 +08: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 19:32:41 +08:00
|
|
|
|
2003-05-09 19:27:21 +08:00
|
|
|
/* Reposition or remove all guides */
|
2014-07-10 06:08:14 +08:00
|
|
|
list = gimp_image_get_guides (image);
|
|
|
|
|
|
|
|
while (list)
|
1999-07-10 02:15:39 +08:00
|
|
|
{
|
2003-03-31 00:11:51 +08:00
|
|
|
GimpGuide *guide = list->data;
|
|
|
|
gboolean remove_guide = FALSE;
|
2006-06-07 23:49:59 +08:00
|
|
|
gint new_position = gimp_guide_get_position (guide);
|
1999-07-10 02:15:39 +08:00
|
|
|
|
2014-07-10 06:08:14 +08:00
|
|
|
list = g_list_next (list);
|
|
|
|
|
2006-06-07 23:49:59 +08:00
|
|
|
switch (gimp_guide_get_orientation (guide))
|
2004-09-05 06:08:43 +08:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2003-05-09 19:27:21 +08:00
|
|
|
new_position += offset_y;
|
2004-09-05 06:08:43 +08:00
|
|
|
if (new_position < 0 || new_position > new_height)
|
2003-03-31 00:11:51 +08:00
|
|
|
remove_guide = TRUE;
|
2004-09-05 06:08:43 +08:00
|
|
|
break;
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2004-09-05 06:08:43 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2003-05-09 19:27:21 +08:00
|
|
|
new_position += offset_x;
|
2004-09-05 06:08:43 +08:00
|
|
|
if (new_position < 0 || new_position > new_width)
|
2003-03-31 00:11:51 +08:00
|
|
|
remove_guide = TRUE;
|
2004-09-05 06:08:43 +08:00
|
|
|
break;
|
2000-12-28 02:15:37 +08:00
|
|
|
|
2004-09-05 06:08:43 +08:00
|
|
|
default:
|
2003-05-09 19:27:21 +08:00
|
|
|
break;
|
2004-09-05 06:08:43 +08:00
|
|
|
}
|
2003-03-31 00:11:51 +08:00
|
|
|
|
|
|
|
if (remove_guide)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_remove_guide (image, guide, TRUE);
|
2006-06-07 23:49:59 +08:00
|
|
|
else if (new_position != gimp_guide_get_position (guide))
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_move_guide (image, guide, new_position, TRUE);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
|
|
|
|
2005-08-08 05:05:09 +08:00
|
|
|
/* Reposition or remove sample points */
|
2014-07-10 06:08:14 +08:00
|
|
|
list = gimp_image_get_sample_points (image);
|
|
|
|
|
|
|
|
while (list)
|
2005-08-08 05:05:09 +08:00
|
|
|
{
|
|
|
|
GimpSamplePoint *sample_point = list->data;
|
|
|
|
gboolean remove_sample_point = FALSE;
|
2016-01-05 05:06:27 +08:00
|
|
|
gint old_x;
|
|
|
|
gint old_y;
|
|
|
|
gint new_x;
|
|
|
|
gint new_y;
|
2005-08-08 05:05:09 +08:00
|
|
|
|
2014-07-10 06:08:14 +08:00
|
|
|
list = g_list_next (list);
|
|
|
|
|
2016-01-05 05:06:27 +08:00
|
|
|
gimp_sample_point_get_position (sample_point, &old_x, &old_y);
|
|
|
|
|
|
|
|
new_y = old_y + offset_y;
|
2019-08-10 23:32:45 +08:00
|
|
|
if ((new_y < 0) || (new_y >= new_height))
|
2005-08-08 05:05:09 +08:00
|
|
|
remove_sample_point = TRUE;
|
|
|
|
|
2016-01-05 05:06:27 +08:00
|
|
|
new_x = old_x + offset_x;
|
2019-08-10 23:32:45 +08:00
|
|
|
if ((new_x < 0) || (new_x >= new_width))
|
2005-08-08 05:05:09 +08:00
|
|
|
remove_sample_point = TRUE;
|
|
|
|
|
|
|
|
if (remove_sample_point)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_remove_sample_point (image, sample_point, TRUE);
|
2016-01-05 05:06:27 +08:00
|
|
|
else if (new_x != old_x || new_y != old_y)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_move_sample_point (image, sample_point,
|
2005-08-08 05:05:09 +08: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 22:18:46 +08:00
|
|
|
g_object_unref (queue);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2008-08-29 03:12:03 +08:00
|
|
|
gimp_image_size_changed_detailed (image,
|
2012-09-22 22:34:14 +08:00
|
|
|
offset_x, offset_y,
|
|
|
|
old_width, old_height);
|
2008-08-03 19:35:53 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (image));
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_unset_busy (image->gimp);
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
2004-09-05 06:08:43 +08:00
|
|
|
|
|
|
|
void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_resize_to_layers (GimpImage *image,
|
2004-09-05 06:08:43 +08:00
|
|
|
GimpContext *context,
|
2018-06-06 05:28:57 +08:00
|
|
|
gint *offset_x,
|
|
|
|
gint *offset_y,
|
|
|
|
gint *new_width,
|
|
|
|
gint *new_height,
|
2004-09-05 06:08:43 +08:00
|
|
|
GimpProgress *progress)
|
|
|
|
{
|
2009-08-02 23:44:05 +08:00
|
|
|
GList *list;
|
2004-09-05 06:08:43 +08:00
|
|
|
GimpItem *item;
|
2009-08-28 01:31:55 +08:00
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
2005-02-25 00:39:12 +08:00
|
|
|
|
2009-08-02 23:44:05 +08: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-28 01:31:55 +08:00
|
|
|
list = gimp_image_get_layer_iter (image);
|
2009-08-02 23:44:05 +08:00
|
|
|
|
2009-08-28 01:31:55 +08:00
|
|
|
if (! list)
|
2004-09-05 06:08:43 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* figure out starting values */
|
|
|
|
item = list->data;
|
2009-08-02 23:44:05 +08:00
|
|
|
|
2009-08-28 01:31:55 +08: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-05 06:08:43 +08:00
|
|
|
|
|
|
|
/* Respect all layers */
|
2009-08-02 23:44:05 +08:00
|
|
|
for (list = g_list_next (list); list; list = g_list_next (list))
|
2004-09-05 06:08:43 +08:00
|
|
|
{
|
|
|
|
item = list->data;
|
|
|
|
|
2009-08-28 01:31:55 +08: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-05 06:08:43 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_resize (image, context,
|
2009-08-28 01:31:55 +08:00
|
|
|
width, height, -x, -y,
|
2004-09-05 06:08:43 +08:00
|
|
|
progress);
|
2018-06-06 05:28:57 +08:00
|
|
|
if (offset_x)
|
|
|
|
*offset_x = -x;
|
|
|
|
if (offset_y)
|
|
|
|
*offset_y = -y;
|
|
|
|
if (new_width)
|
|
|
|
*new_width = width;
|
|
|
|
if (new_height)
|
|
|
|
*new_height = height;
|
2004-09-05 06:08:43 +08:00
|
|
|
}
|
|
|
|
|
2007-06-10 01:17:30 +08:00
|
|
|
void
|
|
|
|
gimp_image_resize_to_selection (GimpImage *image,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpChannel *selection = gimp_image_get_mask (image);
|
2015-07-02 09:04:39 +08:00
|
|
|
gint x, y, w, h;
|
2007-06-10 01:17:30 +08:00
|
|
|
|
2015-07-02 09:04:39 +08:00
|
|
|
if (gimp_item_bounds (GIMP_ITEM (selection), &x, &y, &w, &h))
|
|
|
|
{
|
|
|
|
gimp_image_resize (image, context,
|
|
|
|
w, h, -x, -y,
|
|
|
|
progress);
|
|
|
|
}
|
2007-06-10 01:17:30 +08:00
|
|
|
}
|