2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-05-20 18:36:29 +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
|
2003-05-20 18:36:29 +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
|
2003-05-20 18:36:29 +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/>.
|
2003-05-20 18:36:29 +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>
|
2003-05-20 18:36:29 +08:00
|
|
|
|
|
|
|
#include "core-types.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 "vectors/gimpvectors.h"
|
|
|
|
|
2003-05-20 18:36:29 +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"
|
2003-05-20 18:36:29 +08:00
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpimage-rotate.h"
|
|
|
|
#include "gimpimage-guides.h"
|
2005-03-05 00:34:59 +08:00
|
|
|
#include "gimpimage-sample-points.h"
|
2003-05-20 18:36:29 +08:00
|
|
|
#include "gimpimage-undo.h"
|
|
|
|
#include "gimpimage-undo-push.h"
|
|
|
|
#include "gimpitem.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 "gimplayer.h"
|
|
|
|
#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"
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_image_rotate_item_offset (GimpImage *image,
|
2005-03-05 00:34:59 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
GimpItem *item,
|
|
|
|
gint off_x,
|
|
|
|
gint off_y);
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_image_rotate_guides (GimpImage *image,
|
2005-03-05 00:34:59 +08:00
|
|
|
GimpRotationType rotate_type);
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_image_rotate_sample_points (GimpImage *image,
|
2005-03-05 00:34:59 +08:00
|
|
|
GimpRotationType rotate_type);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate (GimpImage *image,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-20 18:36:29 +08:00
|
|
|
GimpRotationType rotate_type,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2003-05-20 18:36:29 +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;
|
|
|
|
GimpItem *item;
|
|
|
|
GList *list;
|
|
|
|
gdouble center_x;
|
|
|
|
gdouble center_y;
|
|
|
|
gint new_image_width;
|
|
|
|
gint new_image_height;
|
|
|
|
gint previous_image_width;
|
|
|
|
gint previous_image_height;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
gboolean size_changed;
|
2003-05-20 18:36:29 +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));
|
2004-08-11 02:47:21 +08:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2008-08-29 03:12:03 +08:00
|
|
|
previous_image_width = gimp_image_get_width (image);
|
|
|
|
previous_image_height = gimp_image_get_height (image);
|
|
|
|
|
|
|
|
center_x = previous_image_width / 2.0;
|
|
|
|
center_y = previous_image_height / 2.0;
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
/* Resize the image (if needed) */
|
|
|
|
switch (rotate_type)
|
|
|
|
{
|
|
|
|
case GIMP_ROTATE_90:
|
|
|
|
case GIMP_ROTATE_270:
|
2007-12-26 00:21:40 +08:00
|
|
|
new_image_width = gimp_image_get_height (image);
|
|
|
|
new_image_height = gimp_image_get_width (image);
|
2003-05-20 23:26:38 +08:00
|
|
|
size_changed = TRUE;
|
2008-08-03 19:35:53 +08:00
|
|
|
offset_x = (gimp_image_get_width (image) - new_image_width) / 2;
|
|
|
|
offset_y = (gimp_image_get_height (image) - new_image_height) / 2;
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_180:
|
2007-12-26 00:21:40 +08:00
|
|
|
new_image_width = gimp_image_get_width (image);
|
|
|
|
new_image_height = gimp_image_get_height (image);
|
2003-05-20 23:26:38 +08:00
|
|
|
size_changed = FALSE;
|
2008-08-03 19:35:53 +08:00
|
|
|
offset_x = 0;
|
|
|
|
offset_y = 0;
|
|
|
|
break;
|
2003-05-20 23:41:39 +08:00
|
|
|
|
|
|
|
default:
|
2018-01-22 19:33:39 +08:00
|
|
|
g_return_if_reached ();
|
2003-05-20 23:41:39 +08:00
|
|
|
return;
|
2003-05-20 19:55:12 +08:00
|
|
|
}
|
|
|
|
|
2018-01-24 02:50:07 +08:00
|
|
|
gimp_set_busy (image->gimp);
|
|
|
|
|
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);
|
2003-05-20 18:36:29 +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_container (queue, gimp_image_get_layers (image));
|
|
|
|
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));
|
2003-05-20 18:36:29 +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
|
|
|
g_object_freeze_notify (G_OBJECT (image));
|
2007-12-26 00:21:40 +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_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_ROTATE, NULL);
|
2003-06-04 00:42:46 +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
|
|
|
/* Rotate all layers, channels (including selection mask), and vectors */
|
|
|
|
while ((item = gimp_object_queue_pop (queue)))
|
2003-05-20 18:36:29 +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
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (item, &off_x, &off_y);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_rotate (item, context, rotate_type, center_x, center_y, FALSE);
|
2003-05-20 18:36:29 +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
|
|
|
if (GIMP_IS_LAYER (item))
|
|
|
|
{
|
|
|
|
gimp_image_rotate_item_offset (image, rotate_type, item, off_x, off_y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_item_set_offset (item, 0, 0);
|
|
|
|
|
|
|
|
if (GIMP_IS_VECTORS (item))
|
|
|
|
{
|
|
|
|
gimp_item_set_size (item, new_image_width, new_image_height);
|
|
|
|
|
|
|
|
gimp_item_translate (item,
|
|
|
|
(new_image_width - gimp_image_get_width (image)) / 2,
|
|
|
|
(new_image_height - gimp_image_get_height (image)) / 2,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_progress_set_value (progress, 1.0);
|
2003-05-20 18:36:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Rotate all Guides */
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate_guides (image, rotate_type);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2005-03-05 00:34:59 +08:00
|
|
|
/* Rotate all sample points */
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate_sample_points (image, rotate_type);
|
2005-03-05 00:34:59 +08:00
|
|
|
|
2003-05-20 23:26:38 +08:00
|
|
|
/* Resize the image (if needed) */
|
|
|
|
if (size_changed)
|
|
|
|
{
|
2007-12-27 01:33:41 +08:00
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
|
2008-08-29 03:12:03 +08:00
|
|
|
gimp_image_undo_push_image_size (image,
|
|
|
|
NULL,
|
|
|
|
offset_x,
|
|
|
|
offset_y,
|
|
|
|
new_image_width,
|
|
|
|
new_image_height);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_object_set (image,
|
2004-07-14 20:12:50 +08:00
|
|
|
"width", new_image_width,
|
|
|
|
"height", new_image_height,
|
|
|
|
NULL);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2007-12-27 01:33:41 +08:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2007-12-27 01:33:41 +08:00
|
|
|
if (xres != yres)
|
|
|
|
gimp_image_set_resolution (image, yres, xres);
|
2003-05-20 23:26:38 +08:00
|
|
|
}
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2014-05-25 04:41:21 +08:00
|
|
|
/* Notify guide movements */
|
|
|
|
for (list = gimp_image_get_guides (image);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
gimp_image_guide_moved (image, list->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Notify sample point movements */
|
|
|
|
for (list = gimp_image_get_sample_points (image);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
gimp_image_sample_point_moved (image, list->data);
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
2003-05-20 18:36:29 +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
|
|
|
g_object_unref (queue);
|
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
if (size_changed)
|
2008-08-29 03:12:03 +08:00
|
|
|
gimp_image_size_changed_detailed (image,
|
|
|
|
-offset_x,
|
|
|
|
-offset_y,
|
|
|
|
previous_image_width,
|
|
|
|
previous_image_height);
|
2003-05-20 19:55:12 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (image));
|
2004-07-14 20:12:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_unset_busy (image->gimp);
|
2003-05-20 18:36:29 +08:00
|
|
|
}
|
2003-05-20 19:55:12 +08:00
|
|
|
|
2003-05-24 06:50:03 +08:00
|
|
|
|
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate_item_offset (GimpImage *image,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
GimpItem *item,
|
|
|
|
gint off_x,
|
|
|
|
gint off_y)
|
2003-05-24 06:50:03 +08:00
|
|
|
{
|
2003-06-04 00:42:46 +08:00
|
|
|
gint x = 0;
|
|
|
|
gint y = 0;
|
2003-05-24 06:50:03 +08:00
|
|
|
|
|
|
|
switch (rotate_type)
|
|
|
|
{
|
|
|
|
case GIMP_ROTATE_90:
|
2008-11-03 08:09:01 +08:00
|
|
|
x = gimp_image_get_height (image) - off_y - gimp_item_get_width (item);
|
2003-06-04 00:42:46 +08:00
|
|
|
y = off_x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_270:
|
|
|
|
x = off_y;
|
2008-11-03 08:09:01 +08:00
|
|
|
y = gimp_image_get_width (image) - off_x - gimp_item_get_height (item);
|
2003-05-24 06:50:03 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_180:
|
|
|
|
return;
|
2018-01-22 19:33:39 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
2003-05-24 06:50:03 +08:00
|
|
|
}
|
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (item, &off_x, &off_y);
|
2003-05-24 06:50:03 +08:00
|
|
|
|
|
|
|
x -= off_x;
|
|
|
|
y -= off_y;
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-24 06:50:03 +08:00
|
|
|
if (x || y)
|
|
|
|
gimp_item_translate (item, x, y, FALSE);
|
|
|
|
}
|
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate_guides (GimpImage *image,
|
2003-05-20 19:55:12 +08:00
|
|
|
GimpRotationType rotate_type)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
/* Rotate all Guides */
|
2009-08-28 01:31:55 +08:00
|
|
|
for (list = gimp_image_get_guides (image);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
2003-05-20 19:55:12 +08:00
|
|
|
{
|
2006-06-07 23:49:59 +08:00
|
|
|
GimpGuide *guide = list->data;
|
|
|
|
GimpOrientationType orientation = gimp_guide_get_orientation (guide);
|
|
|
|
gint position = gimp_guide_get_position (guide);
|
2003-05-20 19:55:12 +08:00
|
|
|
|
|
|
|
switch (rotate_type)
|
|
|
|
{
|
|
|
|
case GIMP_ROTATE_90:
|
2006-06-07 23:49:59 +08:00
|
|
|
switch (orientation)
|
2003-05-20 19:55:12 +08:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2007-01-30 07:21:41 +08:00
|
|
|
gimp_image_undo_push_guide (image, NULL, guide);
|
2006-06-07 23:49:59 +08:00
|
|
|
gimp_guide_set_orientation (guide, GIMP_ORIENTATION_VERTICAL);
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_guide_set_position (guide,
|
|
|
|
gimp_image_get_height (image) - position);
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2007-01-30 07:21:41 +08:00
|
|
|
gimp_image_undo_push_guide (image, NULL, guide);
|
2006-06-07 23:49:59 +08:00
|
|
|
gimp_guide_set_orientation (guide, GIMP_ORIENTATION_HORIZONTAL);
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_180:
|
2006-06-07 23:49:59 +08:00
|
|
|
switch (orientation)
|
2003-05-20 19:55:12 +08:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_move_guide (image, guide,
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_image_get_height (image) - position,
|
|
|
|
TRUE);
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_move_guide (image, guide,
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_image_get_width (image) - position,
|
|
|
|
TRUE);
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_270:
|
2006-06-07 23:49:59 +08:00
|
|
|
switch (orientation)
|
2003-05-20 19:55:12 +08:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2007-01-30 07:21:41 +08:00
|
|
|
gimp_image_undo_push_guide (image, NULL, guide);
|
2006-06-07 23:49:59 +08:00
|
|
|
gimp_guide_set_orientation (guide, GIMP_ORIENTATION_VERTICAL);
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2007-01-30 07:21:41 +08:00
|
|
|
gimp_image_undo_push_guide (image, NULL, guide);
|
2006-06-07 23:49:59 +08:00
|
|
|
gimp_guide_set_orientation (guide, GIMP_ORIENTATION_HORIZONTAL);
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_guide_set_position (guide,
|
|
|
|
gimp_image_get_width (image) - position);
|
2003-05-20 19:55:12 +08:00
|
|
|
break;
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-20 19:55:12 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2003-05-20 19:55:12 +08:00
|
|
|
}
|
|
|
|
}
|
2005-03-05 00:34:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate_sample_points (GimpImage *image,
|
2005-03-05 00:34:59 +08:00
|
|
|
GimpRotationType rotate_type)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
/* Rotate all sample points */
|
2009-08-28 01:31:55 +08:00
|
|
|
for (list = gimp_image_get_sample_points (image);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
2005-03-05 00:34:59 +08:00
|
|
|
{
|
|
|
|
GimpSamplePoint *sample_point = list->data;
|
|
|
|
gint old_x;
|
|
|
|
gint old_y;
|
|
|
|
|
2007-01-30 18:34:59 +08:00
|
|
|
gimp_image_undo_push_sample_point (image, NULL, sample_point);
|
|
|
|
|
2016-01-05 05:06:27 +08:00
|
|
|
gimp_sample_point_get_position (sample_point, &old_x, &old_y);
|
2005-03-05 00:34:59 +08:00
|
|
|
|
|
|
|
switch (rotate_type)
|
|
|
|
{
|
|
|
|
case GIMP_ROTATE_90:
|
2016-01-05 05:06:27 +08:00
|
|
|
gimp_sample_point_set_position (sample_point,
|
|
|
|
gimp_image_get_height (image) - old_y,
|
|
|
|
old_x);
|
2005-03-05 00:34:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_180:
|
2016-01-05 05:06:27 +08:00
|
|
|
gimp_sample_point_set_position (sample_point,
|
|
|
|
gimp_image_get_width (image) - old_x,
|
|
|
|
gimp_image_get_height (image) - old_y);
|
2005-03-05 00:34:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_270:
|
2016-01-05 05:06:27 +08:00
|
|
|
gimp_sample_point_set_position (sample_point,
|
|
|
|
old_y,
|
|
|
|
gimp_image_get_width (image) - old_x);
|
2005-03-05 00:34:59 +08:00
|
|
|
break;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2005-03-05 00:34:59 +08:00
|
|
|
}
|
|
|
|
}
|