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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-05-20 18:36:29 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2003-05-20 18:36:29 +08:00
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
|
|
|
#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"
|
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
|
|
|
{
|
2009-08-02 23:44:05 +08:00
|
|
|
GList *all_layers;
|
|
|
|
GList *all_channels;
|
|
|
|
GList *all_vectors;
|
2004-04-13 21:54:54 +08:00
|
|
|
GList *list;
|
|
|
|
gdouble center_x;
|
|
|
|
gdouble center_y;
|
2004-08-11 02:47:21 +08:00
|
|
|
gdouble progress_max;
|
|
|
|
gdouble progress_current = 1.0;
|
2004-04-13 21:54:54 +08:00
|
|
|
gint new_image_width;
|
|
|
|
gint new_image_height;
|
2008-08-29 03:12:03 +08:00
|
|
|
gint previous_image_width;
|
|
|
|
gint previous_image_height;
|
2008-08-03 19:35:53 +08:00
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
2004-04-13 21:54:54 +08:00
|
|
|
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
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_set_busy (image->gimp);
|
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
|
|
|
|
2009-08-02 23:44:05 +08:00
|
|
|
all_layers = gimp_image_get_layer_list (image);
|
|
|
|
all_channels = gimp_image_get_channel_list (image);
|
|
|
|
all_vectors = gimp_image_get_vectors_list (image);
|
|
|
|
|
|
|
|
progress_max = (g_list_length (all_layers) +
|
|
|
|
g_list_length (all_channels) +
|
|
|
|
g_list_length (all_vectors) +
|
2003-06-04 00:42:46 +08:00
|
|
|
1 /* selection */);
|
2003-05-20 18:36:29 +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_ROTATE, NULL);
|
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:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return;
|
2003-05-20 19:55:12 +08:00
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
/* Rotate all channels */
|
2009-08-02 23:44:05 +08:00
|
|
|
for (list = all_channels; list; list = g_list_next (list))
|
2003-05-20 18:36:29 +08:00
|
|
|
{
|
2007-02-28 16:57:17 +08:00
|
|
|
GimpItem *item = list->data;
|
2003-05-20 18:36:29 +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 23:26:38 +08:00
|
|
|
|
2008-11-12 05:14:52 +08:00
|
|
|
gimp_item_set_offset (item, 0, 0);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
2003-05-20 18:36:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Rotate all vectors */
|
2009-08-02 23:44:05 +08:00
|
|
|
for (list = all_vectors; list; list = g_list_next (list))
|
2003-05-20 18:36:29 +08:00
|
|
|
{
|
2007-02-28 16:57:17 +08:00
|
|
|
GimpItem *item = list->data;
|
2003-05-20 18:36:29 +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
|
|
|
|
2008-11-12 05:14:52 +08:00
|
|
|
item->width = new_image_width;
|
|
|
|
item->height = new_image_height;
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (item), "width");
|
|
|
|
g_object_notify (G_OBJECT (item), "height");
|
|
|
|
|
|
|
|
gimp_item_set_offset (item, 0, 0);
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2003-05-24 06:50:03 +08:00
|
|
|
gimp_item_translate (item,
|
2007-12-26 00:21:40 +08:00
|
|
|
(new_image_width - gimp_image_get_width (image)) / 2,
|
|
|
|
(new_image_height - gimp_image_get_height (image)) / 2,
|
2006-04-12 20:49:29 +08:00
|
|
|
FALSE);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
2003-05-20 18:36:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't forget the selection mask! */
|
2007-12-26 00:21:40 +08:00
|
|
|
{
|
|
|
|
GimpChannel *mask = gimp_image_get_mask (image);
|
2003-05-24 06:50:03 +08:00
|
|
|
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_item_rotate (GIMP_ITEM (mask), context,
|
|
|
|
rotate_type, center_x, center_y, FALSE);
|
2003-05-24 06:50:03 +08:00
|
|
|
|
2008-11-12 05:14:52 +08:00
|
|
|
gimp_item_set_offset (GIMP_ITEM (mask), 0, 0);
|
2007-12-26 00:21:40 +08:00
|
|
|
|
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
|
|
|
}
|
2003-06-04 00:42:46 +08:00
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
/* Rotate all layers */
|
2009-08-02 23:44:05 +08:00
|
|
|
for (list = all_layers; list; list = g_list_next (list))
|
2003-05-20 18:36:29 +08:00
|
|
|
{
|
2007-02-28 16:57:17 +08:00
|
|
|
GimpItem *item = list->data;
|
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2009-08-25 21:46:53 +08:00
|
|
|
/* group layers are updated automatically */
|
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (item)))
|
|
|
|
continue;
|
|
|
|
|
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
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_rotate_item_offset (image, rotate_type, item, off_x, off_y);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
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
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
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
|
|
|
|
2009-08-02 23:44:05 +08:00
|
|
|
g_list_free (all_layers);
|
|
|
|
g_list_free (all_channels);
|
|
|
|
g_list_free (all_vectors);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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 */
|
2007-12-26 01:09:04 +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 */
|
2007-12-26 01:09:04 +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);
|
|
|
|
|
2005-03-05 00:34:59 +08:00
|
|
|
old_x = sample_point->x;
|
|
|
|
old_y = sample_point->y;
|
|
|
|
|
|
|
|
switch (rotate_type)
|
|
|
|
{
|
|
|
|
case GIMP_ROTATE_90:
|
|
|
|
sample_point->x = old_y;
|
2007-12-26 00:21:40 +08:00
|
|
|
sample_point->y = gimp_image_get_height (image) - old_x;
|
2005-03-05 00:34:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_180:
|
2007-12-26 00:21:40 +08:00
|
|
|
sample_point->x = gimp_image_get_height (image) - old_x;
|
|
|
|
sample_point->y = gimp_image_get_width (image) - old_y;
|
2005-03-05 00:34:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ROTATE_270:
|
2007-12-26 00:21:40 +08:00
|
|
|
sample_point->x = gimp_image_get_width (image) - old_y;
|
2005-03-05 00:34:59 +08:00
|
|
|
sample_point->y = old_x;
|
|
|
|
break;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2005-03-05 00:34:59 +08:00
|
|
|
}
|
|
|
|
}
|