Commit 0c3ff3b0 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

fixed offset calculation for 90 and 270 degree rotations.

2003-06-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-rotate.c (gimp_image_rotate_item_offset):
	fixed offset calculation for 90 and 270 degree rotations.

	* app/core/gimpimage-flip.c
	* app/core/gimpimage-rotate.c
	* app/core/gimpimage-scale.c: increase the progress also when
	transforming the selection. Makes the progress appear more
	continuous. Also clened up and simplified the progress code
	in all files.

	* app/core/gimpimage-resize.[ch]: added a progress like in the
	files above.

	* app/gui/image-commands.c (image_resize_callback): changed
	accordingly.

	(image_scale_implement): clened up and simplified a lot.

	* tools/pdbgen/pdb/image.pdb: changed accordingly.

	* app/pdb/image_cmds.c: regenerated.
parent cac290d0
2003-06-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-rotate.c (gimp_image_rotate_item_offset):
fixed offset calculation for 90 and 270 degree rotations.
* app/core/gimpimage-flip.c
* app/core/gimpimage-rotate.c
* app/core/gimpimage-scale.c: increase the progress also when
transforming the selection. Makes the progress appear more
continuous. Also clened up and simplified the progress code
in all files.
* app/core/gimpimage-resize.[ch]: added a progress like in the
files above.
* app/gui/image-commands.c (image_resize_callback): changed
accordingly.
(image_scale_implement): clened up and simplified a lot.
* tools/pdbgen/pdb/image.pdb: changed accordingly.
* app/pdb/image_cmds.c: regenerated.
2003-06-03 Adam D. Moss <adam@gimp.org>
* plug-ins/common/gifload.c: When initializing the LZW state,
......@@ -38,7 +62,7 @@
(layer_dissolve_mode): pass the mask to dissolve_pixels(). No need
to call add_alpha_pixels() since we overwrite the dest buffer
entirely in disolve_pixels().
entirely in dissolve_pixels().
* app/paint-funcs.c (initial_sub_region, combine_sub_region):
allocate the buffer large enough for DISSOLVE (which always needs
......@@ -417,11 +417,21 @@ image_resize_callback (GtkWidget *widget,
if (image_resize->resize->width > 0 &&
image_resize->resize->height > 0)
{
GimpProgress *progress;
progress = gimp_progress_start (image_resize->gdisp,
_("Resizing..."),
TRUE, NULL, NULL);
gimp_image_resize (image_resize->gimage,
image_resize->resize->width,
image_resize->resize->height,
image_resize->resize->offset_x,
image_resize->resize->offset_y);
image_resize->resize->offset_y,
gimp_progress_update_and_flush, progress);
gimp_progress_end (progress);
gimp_image_flush (image_resize->gimage);
}
else
......@@ -481,10 +491,8 @@ image_scale_warn_callback (GtkWidget *widget,
gpointer data)
{
ImageResize *image_scale;
GimpImage *gimage;
image_scale = (ImageResize *) data;
gimage = image_scale->gimage;
if (do_scale) /* User doesn't mind losing layers... */
{
......@@ -501,41 +509,28 @@ image_scale_warn_callback (GtkWidget *widget,
static void
image_scale_implement (ImageResize *image_scale)
{
GimpImage *gimage = NULL;
gboolean display_flush = FALSE; /* this is a bit ugly:
we hijack the flush variable
to check if an undo_group was
already started */
GimpImage *gimage;
g_assert (image_scale != NULL);
g_assert (image_scale->gimage != NULL);
gimage = image_scale->gimage;
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
if (image_scale->resize->resolution_x == gimage->xresolution &&
image_scale->resize->resolution_y == gimage->yresolution &&
image_scale->resize->unit == gimage->unit &&
image_scale->resize->width == gimage->width &&
image_scale->resize->height == gimage->height)
return;
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Scale Image"));
gimp_image_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
display_flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
if (! display_flush)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Scale Image"));
gimp_image_set_unit (gimage, image_scale->resize->unit);
display_flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
......@@ -544,10 +539,6 @@ image_scale_implement (ImageResize *image_scale)
{
GimpProgress *progress;
if (! display_flush)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Scale Image"));
progress = gimp_progress_start (image_scale->gdisp,
_("Scaling..."),
TRUE, NULL, NULL);
......@@ -559,8 +550,6 @@ image_scale_implement (ImageResize *image_scale)
gimp_progress_update_and_flush, progress);
gimp_progress_end (progress);
display_flush = TRUE;
}
else
{
......@@ -570,9 +559,7 @@ image_scale_implement (ImageResize *image_scale)
}
}
if (display_flush)
{
gimp_image_undo_group_end (gimage);
gimp_image_flush (gimage);
}
}
......@@ -45,9 +45,7 @@ gimp_image_flip (GimpImage *gimage,
GimpItem *item;
GList *list;
gdouble axis;
gint num_channels;
gint num_layers;
gint num_vectors;
gint progress_max;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
......@@ -69,9 +67,10 @@ gimp_image_flip (GimpImage *gimage,
return;
}
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
num_vectors = gimage->vectors->num_children;
progress_max = (gimage->channels->num_children +
gimage->layers->num_children +
gimage->vectors->num_children +
1 /* selection */);
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -92,9 +91,7 @@ gimp_image_flip (GimpImage *gimage,
gimp_item_flip (item, flip_type, axis, TRUE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Flip all vectors */
......@@ -107,15 +104,16 @@ gimp_image_flip (GimpImage *gimage,
gimp_item_flip (item, flip_type, axis, FALSE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Don't forget the selection mask! */
gimp_item_flip (GIMP_ITEM (gimage->selection_mask), flip_type, axis, TRUE);
gimp_image_mask_invalidate (gimage);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
/* Flip all layers */
for (list = GIMP_LIST (gimage->layers)->list;
list;
......@@ -126,9 +124,7 @@ gimp_image_flip (GimpImage *gimage,
gimp_item_flip (item, flip_type, axis, FALSE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Flip all Guides */
......
......@@ -42,16 +42,25 @@ gimp_image_resize (GimpImage *gimage,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y)
gint offset_y,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpLayer *floating_layer;
GList *list;
gint progress_max;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
progress_max = (gimage->channels->num_children +
gimage->layers->num_children +
gimage->vectors->num_children +
1 /* selection */);
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -77,6 +86,9 @@ gimp_image_resize (GimpImage *gimage,
GimpItem *item = list->data;
gimp_item_resize (item, new_width, new_height, offset_x, offset_y);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Resize all vectors */
......@@ -87,6 +99,9 @@ gimp_image_resize (GimpImage *gimage,
GimpItem *item = list->data;
gimp_item_resize (item, new_width, new_height, offset_x, offset_y);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Don't forget the selection mask! */
......@@ -94,6 +109,9 @@ gimp_image_resize (GimpImage *gimage,
new_width, new_height, offset_x, offset_y);
gimp_image_mask_invalidate (gimage);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
/* Reposition all layers */
for (list = GIMP_LIST (gimage->layers)->list;
list;
......@@ -102,6 +120,9 @@ gimp_image_resize (GimpImage *gimage,
GimpItem *item = list->data;
gimp_item_translate (item, offset_x, offset_y, TRUE);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Reposition or remove all guides */
......
......@@ -24,7 +24,9 @@ void gimp_image_resize (GimpImage *gimage,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y);
gint offset_y,
GimpProgressFunc progress_func,
gpointer progress_data);
#endif /* __GIMP_IMAGE_RESIZE_H__ */
......@@ -55,9 +55,7 @@ gimp_image_rotate (GimpImage *gimage,
GList *list;
gdouble center_x;
gdouble center_y;
gint num_channels;
gint num_layers;
gint num_vectors;
gint progress_max;
gint progress_current = 1;
gint new_image_width;
gint new_image_height;
......@@ -70,9 +68,10 @@ gimp_image_rotate (GimpImage *gimage,
center_x = (gdouble) gimage->width / 2.0;
center_y = (gdouble) gimage->height / 2.0;
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
num_vectors = gimage->vectors->num_children;
progress_max = (gimage->channels->num_children +
gimage->layers->num_children +
gimage->vectors->num_children +
1 /* selection */);
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -117,9 +116,7 @@ gimp_image_rotate (GimpImage *gimage,
item->offset_y = 0;
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Rotate all vectors */
......@@ -142,9 +139,7 @@ gimp_image_rotate (GimpImage *gimage,
FALSE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Don't forget the selection mask! */
......@@ -156,6 +151,9 @@ gimp_image_rotate (GimpImage *gimage,
gimp_image_mask_invalidate (gimage);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
/* Rotate all layers */
for (list = GIMP_LIST (gimage->layers)->list;
list;
......@@ -172,9 +170,7 @@ gimp_image_rotate (GimpImage *gimage,
gimp_image_rotate_item_offset (gimage, rotate_type, item, off_x, off_y);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Rotate all Guides */
......@@ -225,14 +221,19 @@ gimp_image_rotate_item_offset (GimpImage *gimage,
gint off_x,
gint off_y)
{
gint x, y;
gint x = 0;
gint y = 0;
switch (rotate_type)
{
case GIMP_ROTATE_270:
case GIMP_ROTATE_90:
x = gimage->height - off_y - gimp_item_width (item) - off_x;
y = gimage->width - off_x - gimp_item_height (item) - off_y;
x = gimage->height - off_y - gimp_item_width (item);
y = off_x;
break;
case GIMP_ROTATE_270:
x = off_y;
y = gimage->width - off_x - gimp_item_height (item);
break;
case GIMP_ROTATE_180:
......
......@@ -52,9 +52,7 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint num_vectors;
gint progress_max;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
......@@ -62,9 +60,10 @@ gimp_image_scale (GimpImage *gimage,
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
num_vectors = gimage->vectors->num_children;
progress_max = (gimage->channels->num_children +
gimage->layers->num_children +
gimage->vectors->num_children +
1 /* selection */);
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -98,9 +97,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_item_scale (item, new_width, new_height, 0, 0, interpolation_type);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Scale all vectors */
......@@ -113,9 +110,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_item_scale (item, new_width, new_height, 0, 0, interpolation_type);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* Don't forget the selection mask! */
......@@ -123,6 +118,9 @@ gimp_image_scale (GimpImage *gimage,
0, 0, interpolation_type);
gimp_image_mask_invalidate (gimage);
if (progress_func)
(* progress_func) (0, progress_max, progress_current++, progress_data);
/* Scale all layers */
for (list = GIMP_LIST (gimage->layers)->list;
list;
......@@ -142,9 +140,7 @@ gimp_image_scale (GimpImage *gimage,
}
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
(* progress_func) (0, progress_max, progress_current++, progress_data);
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -417,11 +417,21 @@ image_resize_callback (GtkWidget *widget,
if (image_resize->resize->width > 0 &&
image_resize->resize->height > 0)
{
GimpProgress *progress;
progress = gimp_progress_start (image_resize->gdisp,
_("Resizing..."),
TRUE, NULL, NULL);
gimp_image_resize (image_resize->gimage,
image_resize->resize->width,
image_resize->resize->height,
image_resize->resize->offset_x,
image_resize->resize->offset_y);
image_resize->resize->offset_y,
gimp_progress_update_and_flush, progress);
gimp_progress_end (progress);
gimp_image_flush (image_resize->gimage);
}
else
......@@ -481,10 +491,8 @@ image_scale_warn_callback (GtkWidget *widget,
gpointer data)
{
ImageResize *image_scale;
GimpImage *gimage;
image_scale = (ImageResize *) data;
gimage = image_scale->gimage;
if (do_scale) /* User doesn't mind losing layers... */
{
......@@ -501,41 +509,28 @@ image_scale_warn_callback (GtkWidget *widget,
static void
image_scale_implement (ImageResize *image_scale)
{
GimpImage *gimage = NULL;
gboolean display_flush = FALSE; /* this is a bit ugly:
we hijack the flush variable
to check if an undo_group was
already started */
GimpImage *gimage;
g_assert (image_scale != NULL);
g_assert (image_scale->gimage != NULL);
gimage = image_scale->gimage;
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
if (image_scale->resize->resolution_x == gimage->xresolution &&
image_scale->resize->resolution_y == gimage->yresolution &&
image_scale->resize->unit == gimage->unit &&
image_scale->resize->width == gimage->width &&
image_scale->resize->height == gimage->height)
return;
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Scale Image"));
gimp_image_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
display_flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
if (! display_flush)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Scale Image"));
gimp_image_set_unit (gimage, image_scale->resize->unit);
display_flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
......@@ -544,10 +539,6 @@ image_scale_implement (ImageResize *image_scale)
{
GimpProgress *progress;
if (! display_flush)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Scale Image"));
progress = gimp_progress_start (image_scale->gdisp,
_("Scaling..."),
TRUE, NULL, NULL);
......@@ -559,8 +550,6 @@ image_scale_implement (ImageResize *image_scale)
gimp_progress_update_and_flush, progress);
gimp_progress_end (progress);
display_flush = TRUE;
}
else
{
......@@ -570,9 +559,7 @@ image_scale_implement (ImageResize *image_scale)
}
}
if (display_flush)
{
gimp_image_undo_group_end (gimage);
gimp_image_flush (gimage);
}
}
......@@ -479,7 +479,7 @@ image_resize_invoker (Gimp *gimp,
if (success)
{
gimp_image_resize (gimage, new_width, new_height, offx, offy);
gimp_image_resize (gimage, new_width, new_height, offx, offy, NULL, NULL);
}
return procedural_db_return_args (&image_resize_proc, success);
......
......@@ -295,7 +295,7 @@ HELP
headers => [ qw("core/gimpimage-resize.h") ],
code => <<'CODE'
{
gimp_image_resize (gimage, new_width, new_height, offx, offy);
gimp_image_resize (gimage, new_width, new_height, offx, offy, NULL, NULL);
}
CODE
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment