From 8cfac64aac10a24710e0c4dcc078349987d7c4cf Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 26 Oct 2000 22:02:44 +0000 Subject: [PATCH] avoid modulo operation on negative values. 2000-10-26 Sven Neumann * app/channel_ops.c (offset_ok_callback): avoid modulo operation on negative values. * app/channel_ops.c * app/crop.c * app/file_new_dialog.c * app/layers_dialog.c * app/preferences_dialog.c * app/rotate_tool.c * app/scale_tool.c: use RINT() when assigning the result of gimp_size_entry_get_refval() to an integer. --- ChangeLog | 14 ++++++++++++++ app/channel_ops.c | 10 ++++++++-- app/core/gimpdrawable-offset.c | 10 ++++++++-- app/core/gimpimage-duplicate.c | 10 ++++++++-- app/crop.c | 9 ++++++--- app/dialogs/image-new-dialog.c | 21 ++++++++++++--------- app/dialogs/preferences-dialog.c | 17 ++++++++++------- app/file_new_dialog.c | 21 ++++++++++++--------- app/gimpdrawable-offset.c | 10 ++++++++-- app/gimpimage-duplicate.c | 10 ++++++++-- app/gui/file-new-dialog.c | 21 ++++++++++++--------- app/gui/layers-dialog.c | 11 +++++++---- app/gui/preferences-dialog.c | 17 ++++++++++------- app/layers_dialog.c | 11 +++++++---- app/preferences_dialog.c | 17 ++++++++++------- app/rotate_tool.c | 6 ++---- app/scale_tool.c | 12 +++++++----- app/tools/crop.c | 9 ++++++--- app/tools/gimpcroptool.c | 9 ++++++--- app/tools/gimprotatetool.c | 6 ++---- app/tools/gimpscaletool.c | 12 +++++++----- app/tools/rotate_tool.c | 6 ++---- app/tools/scale_tool.c | 12 +++++++----- 23 files changed, 179 insertions(+), 102 deletions(-) diff --git a/ChangeLog b/ChangeLog index 383df3490e..7b1219a541 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2000-10-26 Sven Neumann + + * app/channel_ops.c (offset_ok_callback): avoid modulo operation on + negative values. + + * app/channel_ops.c + * app/crop.c + * app/file_new_dialog.c + * app/layers_dialog.c + * app/preferences_dialog.c + * app/rotate_tool.c + * app/scale_tool.c: use RINT() when assigning the result of + gimp_size_entry_get_refval() to an integer. + Thu Oct 26 10:58:23 PDT 2000 Manish Singh * INSTALL: clear up use of --prefix diff --git a/app/channel_ops.c b/app/channel_ops.c index 20de415ced..ba9fe676a2 100644 --- a/app/channel_ops.c +++ b/app/channel_ops.c @@ -228,6 +228,12 @@ offset (GimpImage *gimage, if (wrap_around) { + /* avoid modulo operation on negative values */ + while (offset_x < 0) + offset_x += width; + while (offset_y < 0) + offset_y += height; + offset_x %= width; offset_y %= height; } @@ -464,9 +470,9 @@ offset_ok_callback (GtkWidget *widget, drawable = gimage_active_drawable (gimage); offset_x = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0)); offset_y = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1)); offset (gimage, drawable, off_d->wrap_around, off_d->fill_type, offset_x, offset_y); diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c index 20de415ced..ba9fe676a2 100644 --- a/app/core/gimpdrawable-offset.c +++ b/app/core/gimpdrawable-offset.c @@ -228,6 +228,12 @@ offset (GimpImage *gimage, if (wrap_around) { + /* avoid modulo operation on negative values */ + while (offset_x < 0) + offset_x += width; + while (offset_y < 0) + offset_y += height; + offset_x %= width; offset_y %= height; } @@ -464,9 +470,9 @@ offset_ok_callback (GtkWidget *widget, drawable = gimage_active_drawable (gimage); offset_x = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0)); offset_y = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1)); offset (gimage, drawable, off_d->wrap_around, off_d->fill_type, offset_x, offset_y); diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index 20de415ced..ba9fe676a2 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -228,6 +228,12 @@ offset (GimpImage *gimage, if (wrap_around) { + /* avoid modulo operation on negative values */ + while (offset_x < 0) + offset_x += width; + while (offset_y < 0) + offset_y += height; + offset_x %= width; offset_y %= height; } @@ -464,9 +470,9 @@ offset_ok_callback (GtkWidget *widget, drawable = gimage_active_drawable (gimage); offset_x = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0)); offset_y = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1)); offset (gimage, drawable, off_d->wrap_around, off_d->fill_type, offset_x, offset_y); diff --git a/app/crop.c b/app/crop.c index e83ec0c117..6a63742335 100644 --- a/app/crop.c +++ b/app/crop.c @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include @@ -32,8 +35,8 @@ #include "info_dialog.h" #include "undo.h" -#include "config.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #define STATUSBAR_SIZE 128 @@ -1512,8 +1515,8 @@ crop_orig_changed (GtkWidget *widget, { gdisp = (GDisplay *) tool->gdisp_ptr; crop = (Crop *) tool->private; - ox = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0); - oy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1); + ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((ox != crop->tx1) || (oy != crop->ty1)) diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c index 7acc8b33d3..0a0486de74 100644 --- a/app/dialogs/image-new-dialog.c +++ b/app/dialogs/image-new-dialog.c @@ -15,13 +15,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include "file_new_dialog.h" #include "gimprc.h" #include "gimpui.h" #include "gdisplay.h" -#include "config.h" #include "libgimp/gimpchainbutton.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimplimits.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" @@ -65,10 +68,10 @@ file_new_ok_callback (GtkWidget *widget, values = info->values; /* get the image size in pixels */ - values->width = (int) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - values->height = (int) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); + values->width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0)); + values->height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1)); /* get the resolution in dpi */ values->xresolution = @@ -279,10 +282,10 @@ file_new_image_size_callback (GtkWidget *widget, info = (NewImageInfo*) data; - info->values->width = (gdouble) (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - info->values->height = (gdouble) (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); + info->values->width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0)); + info->values->height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1)); info->size = image_new_calculate_size (info->values); diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 8c7fb7a44d..60826f41d0 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1069,9 +1069,9 @@ prefs_default_size_callback (GtkWidget *widget, gpointer data) { default_width = - (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); default_height = - (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); default_units = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); } @@ -1117,13 +1117,16 @@ prefs_default_resolution_callback (GtkWidget *widget, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1, yres, FALSE); - default_width = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0) + 0.5); - default_height = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1) + 0.5); + default_width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0)); + default_height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1)); + default_xresolution = xres; default_yresolution = yres; - default_resolution_units = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); + + default_resolution_units = + gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); } static void diff --git a/app/file_new_dialog.c b/app/file_new_dialog.c index 7acc8b33d3..0a0486de74 100644 --- a/app/file_new_dialog.c +++ b/app/file_new_dialog.c @@ -15,13 +15,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include "file_new_dialog.h" #include "gimprc.h" #include "gimpui.h" #include "gdisplay.h" -#include "config.h" #include "libgimp/gimpchainbutton.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimplimits.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" @@ -65,10 +68,10 @@ file_new_ok_callback (GtkWidget *widget, values = info->values; /* get the image size in pixels */ - values->width = (int) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - values->height = (int) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); + values->width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0)); + values->height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1)); /* get the resolution in dpi */ values->xresolution = @@ -279,10 +282,10 @@ file_new_image_size_callback (GtkWidget *widget, info = (NewImageInfo*) data; - info->values->width = (gdouble) (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - info->values->height = (gdouble) (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); + info->values->width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0)); + info->values->height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1)); info->size = image_new_calculate_size (info->values); diff --git a/app/gimpdrawable-offset.c b/app/gimpdrawable-offset.c index 20de415ced..ba9fe676a2 100644 --- a/app/gimpdrawable-offset.c +++ b/app/gimpdrawable-offset.c @@ -228,6 +228,12 @@ offset (GimpImage *gimage, if (wrap_around) { + /* avoid modulo operation on negative values */ + while (offset_x < 0) + offset_x += width; + while (offset_y < 0) + offset_y += height; + offset_x %= width; offset_y %= height; } @@ -464,9 +470,9 @@ offset_ok_callback (GtkWidget *widget, drawable = gimage_active_drawable (gimage); offset_x = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0)); offset_y = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1)); offset (gimage, drawable, off_d->wrap_around, off_d->fill_type, offset_x, offset_y); diff --git a/app/gimpimage-duplicate.c b/app/gimpimage-duplicate.c index 20de415ced..ba9fe676a2 100644 --- a/app/gimpimage-duplicate.c +++ b/app/gimpimage-duplicate.c @@ -228,6 +228,12 @@ offset (GimpImage *gimage, if (wrap_around) { + /* avoid modulo operation on negative values */ + while (offset_x < 0) + offset_x += width; + while (offset_y < 0) + offset_y += height; + offset_x %= width; offset_y %= height; } @@ -464,9 +470,9 @@ offset_ok_callback (GtkWidget *widget, drawable = gimage_active_drawable (gimage); offset_x = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 0)); offset_y = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (off_d->off_se), 1)); offset (gimage, drawable, off_d->wrap_around, off_d->fill_type, offset_x, offset_y); diff --git a/app/gui/file-new-dialog.c b/app/gui/file-new-dialog.c index 7acc8b33d3..0a0486de74 100644 --- a/app/gui/file-new-dialog.c +++ b/app/gui/file-new-dialog.c @@ -15,13 +15,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include "file_new_dialog.h" #include "gimprc.h" #include "gimpui.h" #include "gdisplay.h" -#include "config.h" #include "libgimp/gimpchainbutton.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimplimits.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" @@ -65,10 +68,10 @@ file_new_ok_callback (GtkWidget *widget, values = info->values; /* get the image size in pixels */ - values->width = (int) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - values->height = (int) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); + values->width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0)); + values->height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1)); /* get the resolution in dpi */ values->xresolution = @@ -279,10 +282,10 @@ file_new_image_size_callback (GtkWidget *widget, info = (NewImageInfo*) data; - info->values->width = (gdouble) (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - info->values->height = (gdouble) (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); + info->values->width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0)); + info->values->height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1)); info->size = image_new_calculate_size (info->values); diff --git a/app/gui/layers-dialog.c b/app/gui/layers-dialog.c index 851f8fb06b..7d0c123db0 100644 --- a/app/gui/layers-dialog.c +++ b/app/gui/layers-dialog.c @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "config.h" #include @@ -39,6 +40,7 @@ #include "undo.h" #include "libgimp/gimplimits.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" @@ -57,6 +59,7 @@ #include "layer_pvt.h" + #define LAYER_PREVIEW 0 #define MASK_PREVIEW 1 #define FS_PREVIEW 2 @@ -3420,10 +3423,10 @@ new_layer_query_ok_callback (GtkWidget *widget, g_free (layer_name); layer_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry))); - options->xsize = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0) + 0.5); - options->ysize = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1) + 0.5); + options->xsize = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0)); + options->ysize = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1)); fill_type = options->fill_type; diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index 8c7fb7a44d..60826f41d0 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -1069,9 +1069,9 @@ prefs_default_size_callback (GtkWidget *widget, gpointer data) { default_width = - (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); default_height = - (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); default_units = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); } @@ -1117,13 +1117,16 @@ prefs_default_resolution_callback (GtkWidget *widget, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1, yres, FALSE); - default_width = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0) + 0.5); - default_height = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1) + 0.5); + default_width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0)); + default_height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1)); + default_xresolution = xres; default_yresolution = yres; - default_resolution_units = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); + + default_resolution_units = + gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); } static void diff --git a/app/layers_dialog.c b/app/layers_dialog.c index 851f8fb06b..7d0c123db0 100644 --- a/app/layers_dialog.c +++ b/app/layers_dialog.c @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "config.h" #include @@ -39,6 +40,7 @@ #include "undo.h" #include "libgimp/gimplimits.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" @@ -57,6 +59,7 @@ #include "layer_pvt.h" + #define LAYER_PREVIEW 0 #define MASK_PREVIEW 1 #define FS_PREVIEW 2 @@ -3420,10 +3423,10 @@ new_layer_query_ok_callback (GtkWidget *widget, g_free (layer_name); layer_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry))); - options->xsize = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0) + 0.5); - options->ysize = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1) + 0.5); + options->xsize = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0)); + options->ysize = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1)); fill_type = options->fill_type; diff --git a/app/preferences_dialog.c b/app/preferences_dialog.c index 8c7fb7a44d..60826f41d0 100644 --- a/app/preferences_dialog.c +++ b/app/preferences_dialog.c @@ -1069,9 +1069,9 @@ prefs_default_size_callback (GtkWidget *widget, gpointer data) { default_width = - (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); default_height = - (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); default_units = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); } @@ -1117,13 +1117,16 @@ prefs_default_resolution_callback (GtkWidget *widget, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1, yres, FALSE); - default_width = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0) + 0.5); - default_height = (gint) - (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1) + 0.5); + default_width = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0)); + default_height = + RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1)); + default_xresolution = xres; default_yresolution = yres; - default_resolution_units = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); + + default_resolution_units = + gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); } static void diff --git a/app/rotate_tool.c b/app/rotate_tool.c index bff8220e75..b5d0fbdf14 100644 --- a/app/rotate_tool.c +++ b/app/rotate_tool.c @@ -273,10 +273,8 @@ rotate_center_changed (GtkWidget *widget, gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - cx = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); - cy = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + cy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((cx != transform_core->cx) || (cy != transform_core->cy)) diff --git a/app/scale_tool.c b/app/scale_tool.c index 56d07830d4..8b80b35a95 100644 --- a/app/scale_tool.c +++ b/app/scale_tool.c @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include "appenv.h" #include "drawable.h" #include "gdisplay.h" @@ -27,10 +30,11 @@ #include "tile_manager_pvt.h" -#include "config.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimplimits.h" #include "libgimp/gimpintl.h" + /* storage for information dialog fields */ static gchar orig_width_buf[MAX_INFO_BUF]; static gchar orig_height_buf[MAX_INFO_BUF]; @@ -284,10 +288,8 @@ scale_size_changed (GtkWidget *widget, gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - width = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); - height = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((width != (transform_core->trans_info[X1] - transform_core->trans_info[X0])) || diff --git a/app/tools/crop.c b/app/tools/crop.c index e83ec0c117..6a63742335 100644 --- a/app/tools/crop.c +++ b/app/tools/crop.c @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include @@ -32,8 +35,8 @@ #include "info_dialog.h" #include "undo.h" -#include "config.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #define STATUSBAR_SIZE 128 @@ -1512,8 +1515,8 @@ crop_orig_changed (GtkWidget *widget, { gdisp = (GDisplay *) tool->gdisp_ptr; crop = (Crop *) tool->private; - ox = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0); - oy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1); + ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((ox != crop->tx1) || (oy != crop->ty1)) diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index e83ec0c117..6a63742335 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include @@ -32,8 +35,8 @@ #include "info_dialog.h" #include "undo.h" -#include "config.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #define STATUSBAR_SIZE 128 @@ -1512,8 +1515,8 @@ crop_orig_changed (GtkWidget *widget, { gdisp = (GDisplay *) tool->gdisp_ptr; crop = (Crop *) tool->private; - ox = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0); - oy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1); + ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((ox != crop->tx1) || (oy != crop->ty1)) diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index bff8220e75..b5d0fbdf14 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -273,10 +273,8 @@ rotate_center_changed (GtkWidget *widget, gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - cx = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); - cy = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + cy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((cx != transform_core->cx) || (cy != transform_core->cy)) diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index 56d07830d4..8b80b35a95 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include "appenv.h" #include "drawable.h" #include "gdisplay.h" @@ -27,10 +30,11 @@ #include "tile_manager_pvt.h" -#include "config.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimplimits.h" #include "libgimp/gimpintl.h" + /* storage for information dialog fields */ static gchar orig_width_buf[MAX_INFO_BUF]; static gchar orig_height_buf[MAX_INFO_BUF]; @@ -284,10 +288,8 @@ scale_size_changed (GtkWidget *widget, gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - width = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); - height = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((width != (transform_core->trans_info[X1] - transform_core->trans_info[X0])) || diff --git a/app/tools/rotate_tool.c b/app/tools/rotate_tool.c index bff8220e75..b5d0fbdf14 100644 --- a/app/tools/rotate_tool.c +++ b/app/tools/rotate_tool.c @@ -273,10 +273,8 @@ rotate_center_changed (GtkWidget *widget, gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - cx = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); - cy = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + cy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((cx != transform_core->cx) || (cy != transform_core->cy)) diff --git a/app/tools/scale_tool.c b/app/tools/scale_tool.c index 56d07830d4..8b80b35a95 100644 --- a/app/tools/scale_tool.c +++ b/app/tools/scale_tool.c @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include "appenv.h" #include "drawable.h" #include "gdisplay.h" @@ -27,10 +30,11 @@ #include "tile_manager_pvt.h" -#include "config.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimplimits.h" #include "libgimp/gimpintl.h" + /* storage for information dialog fields */ static gchar orig_width_buf[MAX_INFO_BUF]; static gchar orig_height_buf[MAX_INFO_BUF]; @@ -284,10 +288,8 @@ scale_size_changed (GtkWidget *widget, gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - width = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0) + 0.5); - height = - (int) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1) + 0.5); + width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); + height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); if ((width != (transform_core->trans_info[X1] - transform_core->trans_info[X0])) ||