app/actions/image-commands.c app/actions/select-commands.c

2007-12-26  Michael Natterer  <mitch@gimp.org>

	* app/actions/image-commands.c
	* app/actions/select-commands.c
	* app/core/gimp-edit.c
	* app/core/gimpdrawable-stroke.c
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage-preview.c
	* app/core/gimpimage-rotate.c
	* app/core/gimpimageundo.c
	* app/core/gimpitem-preview.c
	* app/dialogs/grid-dialog.c
	* app/dialogs/layer-options-dialog.c
	* app/dialogs/offset-dialog.c
	* app/dialogs/stroke-dialog.c
	* app/display/gimpdisplayshell-scale.c
	* app/display/gimpdisplayshell-title.c
	* app/display/gimpdisplayshell.c
	* app/display/gimpstatusbar.c
	* app/paint/gimppaintoptions.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimppainttool.c
	* app/tools/gimprectangletool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpscaletool.c
	* app/tools/gimptexttool.c
	* app/vectors/gimpvectors-export.c
	* app/vectors/gimpvectors-import.c
	* app/widgets/gimpcursorview.c
	* app/widgets/gimpimagepropview.c
	* app/widgets/gimptoolbox-dnd.c
	* app/widgets/gimpviewrendererdrawable.c
	* app/widgets/gimpviewrendererimage.c
	* app/xcf/xcf-load.c
	* app/xcf/xcf-save.c: use gimp_image_get/set_resolution() instead
	of accessing the GimpImage members directly.


svn path=/trunk/; revision=24436
This commit is contained in:
Michael Natterer 2007-12-26 17:33:41 +00:00 committed by Michael Natterer
parent 44b3ae548f
commit 1e8371361e
35 changed files with 410 additions and 229 deletions

View File

@ -1,3 +1,41 @@
2007-12-26 Michael Natterer <mitch@gimp.org>
* app/actions/image-commands.c
* app/actions/select-commands.c
* app/core/gimp-edit.c
* app/core/gimpdrawable-stroke.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-preview.c
* app/core/gimpimage-rotate.c
* app/core/gimpimageundo.c
* app/core/gimpitem-preview.c
* app/dialogs/grid-dialog.c
* app/dialogs/layer-options-dialog.c
* app/dialogs/offset-dialog.c
* app/dialogs/stroke-dialog.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-title.c
* app/display/gimpdisplayshell.c
* app/display/gimpstatusbar.c
* app/paint/gimppaintoptions.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimppainttool.c
* app/tools/gimprectangletool.c
* app/tools/gimprotatetool.c
* app/tools/gimpscaletool.c
* app/tools/gimptexttool.c
* app/vectors/gimpvectors-export.c
* app/vectors/gimpvectors-import.c
* app/widgets/gimpcursorview.c
* app/widgets/gimpimagepropview.c
* app/widgets/gimptoolbox-dnd.c
* app/widgets/gimpviewrendererdrawable.c
* app/widgets/gimpviewrendererimage.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c: use gimp_image_get/set_resolution() instead
of accessing the GimpImage members directly.
2007-12-26 Sven Neumann <sven@gimp.org>
* app/paint/gimpbrushcore.c: sprinkled with const qualifiers.

View File

@ -610,10 +610,15 @@ image_print_size_callback (GtkWidget *dialog,
GimpUnit resolution_unit,
gpointer data)
{
gdouble xres;
gdouble yres;
gtk_widget_destroy (dialog);
if (xresolution == image->xresolution &&
yresolution == image->yresolution &&
gimp_image_get_resolution (image, &xres, &yres);
if (xresolution == xres &&
yresolution == yres &&
resolution_unit == gimp_image_get_unit (image))
return;
@ -641,16 +646,20 @@ image_scale_callback (GtkWidget *dialog,
gpointer user_data)
{
GimpImage *image = GIMP_IMAGE (viewable);
gdouble xres;
gdouble yres;
image_scale_unit = unit;
image_scale_interp = interpolation;
gimp_image_get_resolution (image, &xres, &yres);
if (width > 0 && height > 0)
{
if (width == gimp_image_get_width (image) &&
height == gimp_image_get_height (image) &&
xresolution == image->xresolution &&
yresolution == image->yresolution &&
xresolution == xres &&
yresolution == yres &&
resolution_unit == gimp_image_get_unit (image))
return;

View File

@ -144,8 +144,12 @@ select_feather_cmd_callback (GtkAction *action,
{
GimpDisplay *display;
GtkWidget *dialog;
gdouble xres;
gdouble yres;
return_if_no_display (display, data);
gimp_image_get_resolution (display->image, &xres, &yres);
dialog = gimp_query_size_box (_("Feather Selection"),
display->shell,
gimp_standard_help_func,
@ -153,8 +157,7 @@ select_feather_cmd_callback (GtkAction *action,
_("Feather selection by"),
select_feather_radius, 0, 32767, 3,
GIMP_DISPLAY_SHELL (display->shell)->unit,
MIN (display->image->xresolution,
display->image->yresolution),
MIN (xres, yres),
FALSE,
G_OBJECT (display->image), "disconnect",
select_feather_callback, display->image);
@ -179,8 +182,12 @@ select_shrink_cmd_callback (GtkAction *action,
GimpDisplay *display;
GtkWidget *dialog;
GtkWidget *button;
gdouble xres;
gdouble yres;
return_if_no_display (display, data);
gimp_image_get_resolution (display->image, &xres, &yres);
dialog = gimp_query_size_box (_("Shrink Selection"),
display->shell,
gimp_standard_help_func,
@ -188,8 +195,7 @@ select_shrink_cmd_callback (GtkAction *action,
_("Shrink selection by"),
select_shrink_pixels, 1, 32767, 0,
GIMP_DISPLAY_SHELL (display->shell)->unit,
MIN (display->image->xresolution,
display->image->yresolution),
MIN (xres, yres),
FALSE,
G_OBJECT (display->image), "disconnect",
select_shrink_callback, display->image);
@ -213,8 +219,12 @@ select_grow_cmd_callback (GtkAction *action,
{
GimpDisplay *display;
GtkWidget *dialog;
gdouble xres;
gdouble yres;
return_if_no_display (display, data);
gimp_image_get_resolution (display->image, &xres, &yres);
dialog = gimp_query_size_box (_("Grow Selection"),
display->shell,
gimp_standard_help_func,
@ -222,8 +232,7 @@ select_grow_cmd_callback (GtkAction *action,
_("Grow selection by"),
select_grow_pixels, 1, 32767, 0,
GIMP_DISPLAY_SHELL (display->shell)->unit,
MIN (display->image->xresolution,
display->image->yresolution),
MIN (xres, yres),
FALSE,
G_OBJECT (display->image), "disconnect",
select_grow_callback, display->image);
@ -237,8 +246,12 @@ select_border_cmd_callback (GtkAction *action,
GimpDisplay *display;
GtkWidget *dialog;
GtkWidget *button;
gdouble xres;
gdouble yres;
return_if_no_display (display, data);
gimp_image_get_resolution (display->image, &xres, &yres);
dialog = gimp_query_size_box (_("Border Selection"),
display->shell,
gimp_standard_help_func,
@ -246,8 +259,7 @@ select_border_cmd_callback (GtkAction *action,
_("Border selection by"),
select_border_radius, 1, 32767, 0,
GIMP_DISPLAY_SHELL (display->shell)->unit,
MIN (display->image->xresolution,
display->image->yresolution),
MIN (xres, yres),
FALSE,
G_OBJECT (display->image), "disconnect",
select_border_callback, display->image);
@ -390,12 +402,16 @@ select_feather_callback (GtkWidget *widget,
if (unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gdouble factor;
factor = (MAX (image->xresolution, image->yresolution) /
MIN (image->xresolution, image->yresolution));
gimp_image_get_resolution (image, &xres, &yres);
if (image->xresolution == MIN (image->xresolution, image->yresolution))
factor = (MAX (xres, yres) /
MIN (xres, yres));
if (xres == MIN (xres, yres))
radius_y *= factor;
else
radius_x *= factor;
@ -429,12 +445,16 @@ select_border_callback (GtkWidget *widget,
if (unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gdouble factor;
factor = (MAX (image->xresolution, image->yresolution) /
MIN (image->xresolution, image->yresolution));
gimp_image_get_resolution (image, &xres, &yres);
if (image->xresolution == MIN (image->xresolution, image->yresolution))
factor = (MAX (xres, yres) /
MIN (xres, yres));
if (xres == MIN (xres, yres))
radius_y *= factor;
else
radius_x *= factor;
@ -459,12 +479,16 @@ select_grow_callback (GtkWidget *widget,
if (unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gdouble factor;
factor = (MAX (image->xresolution, image->yresolution) /
MIN (image->xresolution, image->yresolution));
gimp_image_get_resolution (image, &xres, &yres);
if (image->xresolution == MIN (image->xresolution, image->yresolution))
factor = (MAX (xres, yres) /
MIN (xres, yres));
if (xres == MIN (xres, yres))
radius_y *= factor;
else
radius_x *= factor;
@ -492,12 +516,16 @@ select_shrink_callback (GtkWidget *widget,
if (unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gdouble factor;
factor = (MAX (image->xresolution, image->yresolution) /
MIN (image->xresolution, image->yresolution));
gimp_image_get_resolution (image, &xres, &yres);
if (image->xresolution == MIN (image->xresolution, image->yresolution))
factor = (MAX (xres, yres) /
MIN (xres, yres));
if (xres == MIN (xres, yres))
radius_y *= factor;
else
radius_x *= factor;

View File

@ -314,10 +314,12 @@ gimp_edit_paste_as_new (Gimp *gimp,
if (invoke)
{
gimp_image_set_resolution (image,
invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (image,
gimp_image_get_unit (invoke));
gdouble xres;
gdouble yres;
gimp_image_get_resolution (invoke, &xres, &yres);
gimp_image_set_resolution (image, xres, yres);
gimp_image_set_unit (image, gimp_image_get_unit (invoke));
}
layer = gimp_layer_new_from_tiles (paste->tiles, image, type,

View File

@ -214,9 +214,11 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
TileManager *mask;
gint x, y, w, h;
gint bytes;
gint off_x, off_y;
gint off_x;
gint off_y;
guchar bg[1] = { 0, };
PixelRegion maskPR, basePR;
PixelRegion maskPR;
PixelRegion basePR;
image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -228,7 +230,7 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
{
x = 0;
y = 0;
w = gimp_item_width (GIMP_ITEM (drawable));
w = gimp_item_width (GIMP_ITEM (drawable));
h = gimp_item_height (GIMP_ITEM (drawable));
}
else if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
@ -242,12 +244,14 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
if (options->unit != GIMP_UNIT_PIXEL)
{
gimp_scan_convert_set_pixel_ratio (scan_convert,
image->yresolution /
image->xresolution);
gdouble xres;
gdouble yres;
width *= (image->yresolution /
_gimp_unit_get_factor (image->gimp, options->unit));
gimp_image_get_resolution (image, &xres, &yres);
gimp_scan_convert_set_pixel_ratio (scan_convert, yres / xres);
width *= (yres / _gimp_unit_get_factor (image->gimp, options->unit));
}
gimp_scan_convert_stroke (scan_convert, width,

View File

@ -56,6 +56,8 @@ gimp_image_duplicate (GimpImage *image)
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
gchar *filename;
gdouble xres;
gdouble yres;
gint count;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
@ -88,9 +90,9 @@ gimp_image_duplicate (GimpImage *image)
FALSE);
/* Copy resolution information */
new_image->xresolution = image->xresolution;
new_image->yresolution = image->yresolution;
new_image->resolution_unit = gimp_image_get_unit (image);
gimp_image_get_resolution (image, &xres, &yres);
gimp_image_set_resolution (new_image, xres, yres);
gimp_image_set_unit (new_image, gimp_image_get_unit (image));
/* Copy floating layer */
floating_layer = gimp_image_floating_sel (image);

View File

@ -39,14 +39,18 @@ gimp_image_get_preview_size (GimpViewable *viewable,
gint *height)
{
GimpImage *image = GIMP_IMAGE (viewable);
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
gimp_viewable_calc_preview_size (gimp_image_get_width (image),
gimp_image_get_height (image),
size,
size,
dot_for_dot,
image->xresolution,
image->yresolution,
xres,
yres,
width,
height,
NULL);

View File

@ -183,6 +183,9 @@ gimp_image_rotate (GimpImage *image,
/* Resize the image (if needed) */
if (size_changed)
{
gdouble xres;
gdouble yres;
gimp_image_undo_push_image_size (image, NULL);
g_object_set (image,
@ -190,16 +193,10 @@ gimp_image_rotate (GimpImage *image,
"height", new_image_height,
NULL);
if (image->xresolution != image->yresolution)
{
gdouble tmp;
gimp_image_get_resolution (image, &xres, &yres);
gimp_image_undo_push_image_resolution (image, NULL);
tmp = image->xresolution;
image->yresolution = image->xresolution;
image->xresolution = tmp;
}
if (xres != yres)
gimp_image_set_resolution (image, yres, xres);
}
gimp_image_undo_group_end (image);

View File

@ -135,8 +135,9 @@ gimp_image_undo_constructor (GType type,
break;
case GIMP_UNDO_IMAGE_RESOLUTION:
image_undo->xresolution = image->xresolution;
image_undo->yresolution = image->yresolution;
gimp_image_get_resolution (image,
&image_undo->xresolution,
&image_undo->yresolution);
image_undo->resolution_unit = gimp_image_get_unit (image);
break;
@ -288,23 +289,24 @@ gimp_image_undo_pop (GimpUndo *undo,
break;
case GIMP_UNDO_IMAGE_RESOLUTION:
if (ABS (image_undo->xresolution - image->xresolution) >= 1e-5 ||
ABS (image_undo->yresolution - image->yresolution) >= 1e-5)
{
gdouble xres;
gdouble yres;
{
gdouble xres;
gdouble yres;
xres = image->xresolution;
yres = image->yresolution;
gimp_image_get_resolution (image, &xres, &yres);
image->xresolution = image_undo->xresolution;
image->yresolution = image_undo->yresolution;
if (ABS (image_undo->xresolution - xres) >= 1e-5 ||
ABS (image_undo->yresolution - yres) >= 1e-5)
{
image->xresolution = image_undo->xresolution;
image->yresolution = image_undo->yresolution;
image_undo->xresolution = xres;
image_undo->yresolution = yres;
image_undo->xresolution = xres;
image_undo->yresolution = yres;
accum->resolution_changed = TRUE;
}
accum->resolution_changed = TRUE;
}
}
if (image_undo->resolution_unit != gimp_image_get_unit (image))
{

View File

@ -56,13 +56,18 @@ gimp_item_get_preview_size (GimpViewable *viewable,
if (image && ! is_popup)
{
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
gimp_viewable_calc_preview_size (gimp_image_get_width (image),
gimp_image_get_height (image),
size,
size,
dot_for_dot,
image->xresolution,
image->yresolution,
xres,
yres,
width,
height,
NULL);
@ -98,14 +103,19 @@ gimp_item_get_popup_size (GimpViewable *viewable,
gimp_item_height (item) > height)
{
gboolean scaling_up;
gdouble xres = 1.0;
gdouble yres = 1.0;
if (image)
gimp_image_get_resolution (image, &xres, &yres);
gimp_viewable_calc_preview_size (gimp_item_width (item),
gimp_item_height (item),
width * 2,
height * 2,
dot_for_dot,
image ? image->xresolution : 1.0,
image ? image->yresolution : 1.0,
xres,
yres,
popup_width,
popup_height,
&scaling_up);

View File

@ -69,11 +69,15 @@ grid_dialog_new (GimpImage *image,
GimpGrid *grid_backup;
GtkWidget *dialog;
GtkWidget *editor;
gdouble xres;
gdouble yres;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
gimp_image_get_resolution (image, &xres, &yres);
grid = gimp_image_get_grid (GIMP_IMAGE (image));
grid_backup = gimp_config_duplicate (GIMP_CONFIG (grid));
@ -102,8 +106,7 @@ grid_dialog_new (GimpImage *image,
G_CALLBACK (grid_dialog_response),
dialog);
editor = gimp_grid_editor_new (grid, context,
image->xresolution, image->yresolution);
editor = gimp_grid_editor_new (grid, context, xres, yres);
gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
editor);

View File

@ -130,6 +130,11 @@ layer_options_dialog_new (GimpImage *image,
if (! layer)
{
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
/* The size labels */
label = gtk_label_new (_("Width:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
@ -169,9 +174,9 @@ layer_options_dialog_new (GimpImage *image,
GIMP_UNIT_PIXEL);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0,
image->xresolution, FALSE);
xres, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 1,
image->yresolution, FALSE);
yres, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 0,
GIMP_MIN_IMAGE_SIZE,

View File

@ -87,6 +87,8 @@ offset_dialog_new (GimpDrawable *drawable,
GtkWidget *frame;
GtkWidget *radio_button;
GtkObject *adjustment;
gdouble xres;
gdouble yres;
const gchar *title = NULL;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
@ -100,6 +102,8 @@ offset_dialog_new (GimpDrawable *drawable,
item = GIMP_ITEM (drawable);
dialog->image = gimp_item_get_image (item);
gimp_image_get_resolution (dialog->image, &xres, &yres);
if (GIMP_IS_LAYER (drawable))
title = _("Offset Layer");
else if (GIMP_IS_LAYER_MASK (drawable))
@ -187,9 +191,9 @@ offset_dialog_new (GimpDrawable *drawable,
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (dialog->off_se), GIMP_UNIT_PIXEL);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (dialog->off_se), 0,
dialog->image->xresolution, FALSE);
xres, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (dialog->off_se), 1,
dialog->image->yresolution, FALSE);
yres, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (dialog->off_se), 0,
- gimp_item_width (item),

View File

@ -173,9 +173,12 @@ stroke_dialog_new (GimpItem *item,
{
GtkWidget *stroke_editor;
gdouble xres;
gdouble yres;
stroke_editor = gimp_stroke_editor_new (desc->stroke_options,
image->yresolution);
gimp_image_get_resolution (image, &xres, &yres);
stroke_editor = gimp_stroke_editor_new (desc->stroke_options, yres);
gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
gtk_widget_show (stroke_editor);

View File

@ -394,6 +394,8 @@ gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
GimpImage *image;
gint image_width;
gint image_height;
gdouble xres;
gdouble yres;
gdouble zoom_factor;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@ -403,12 +405,12 @@ gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
image_width = gimp_image_get_width (image);
image_height = gimp_image_get_height (image);
gimp_image_get_resolution (image, &xres, &yres);
if (! shell->dot_for_dot)
{
image_width = ROUND (image_width *
shell->monitor_xres / image->xresolution);
image_height = ROUND (image_height *
shell->monitor_yres / image->yresolution);
image_width = ROUND (image_width * shell->monitor_xres / xres);
image_height = ROUND (image_height * shell->monitor_yres / yres);
}
zoom_factor = MIN ((gdouble) shell->disp_width / (gdouble) image_width,
@ -430,6 +432,8 @@ gimp_display_shell_scale_fill (GimpDisplayShell *shell)
GimpImage *image;
gint image_width;
gint image_height;
gdouble xres;
gdouble yres;
gdouble zoom_factor;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@ -439,12 +443,12 @@ gimp_display_shell_scale_fill (GimpDisplayShell *shell)
image_width = gimp_image_get_width (image);
image_height = gimp_image_get_height (image);
gimp_image_get_resolution (image, &xres, &yres);
if (! shell->dot_for_dot)
{
image_width = ROUND (image_width *
shell->monitor_xres / image->xresolution);
image_height = ROUND (image_height *
shell->monitor_yres / image->yresolution);
image_width = ROUND (image_width * shell->monitor_xres / xres);
image_height = ROUND (image_height * shell->monitor_yres / yres);
}
zoom_factor = MAX ((gdouble) shell->disp_width / (gdouble) image_width,
@ -798,15 +802,19 @@ img2real (GimpDisplayShell *shell,
gdouble len)
{
GimpImage *image = shell->display->image;
gdouble xres;
gdouble yres;
gdouble res;
if (shell->unit == GIMP_UNIT_PIXEL)
return len;
gimp_image_get_resolution (image, &xres, &yres);
if (xdir)
res = image->xresolution;
res = xres;
else
res = image->yresolution;
res = yres;
return len * _gimp_unit_get_factor (image->gimp, shell->unit) / res;
}

View File

@ -346,14 +346,18 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
case 'W': /* width in real-world units */
if (shell->unit != GIMP_UNIT_PIXEL)
{
gchar unit_format[8];
gdouble xres;
gdouble yres;
gchar unit_format[8];
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
_gimp_unit_get_digits (gimp, shell->unit) + 1);
i += print (title, title_len, i, unit_format,
(gimp_image_get_width (image) *
_gimp_unit_get_factor (gimp, shell->unit) /
image->xresolution));
xres));
break;
}
/* else fallthru */
@ -365,14 +369,18 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
case 'H': /* height in real-world units */
if (shell->unit != GIMP_UNIT_PIXEL)
{
gchar unit_format[8];
gdouble xres;
gdouble yres;
gchar unit_format[8];
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
_gimp_unit_get_digits (gimp, shell->unit) + 1);
i += print (title, title_len, i, unit_format,
(gimp_image_get_height (image) *
_gimp_unit_get_factor (gimp, shell->unit) /
image->yresolution));
yres));
break;
}
/* else fallthru */

View File

@ -1163,16 +1163,20 @@ void
gimp_display_shell_scale_changed (GimpDisplayShell *shell)
{
GimpImage *image;
gdouble xres;
gdouble yres;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
image = shell->display->image;
gimp_image_get_resolution (image, &xres, &yres);
shell->scale_x = (gimp_zoom_model_get_factor (shell->zoom) *
SCREEN_XRES (shell) / image->xresolution);
SCREEN_XRES (shell) / xres);
shell->scale_y = (gimp_zoom_model_get_factor (shell->zoom) *
SCREEN_YRES (shell) / image->yresolution);
SCREEN_YRES (shell) / yres);
shell->x_dest_inc = gimp_image_get_width (image);
shell->y_dest_inc = gimp_image_get_height (image);

View File

@ -609,10 +609,9 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
g_return_if_fail (title != NULL);
g_return_if_fail (separator != NULL);
if (help == NULL)
{
help = "";
}
help = "";
shell = statusbar->shell;
@ -629,15 +628,19 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
else /* show real world units */
{
GimpImage *image = shell->display->image;
gdouble xres;
gdouble yres;
gdouble unit_factor = _gimp_unit_get_factor (image->gimp,
shell->unit);
gimp_image_get_resolution (image, &xres, &yres);
gimp_statusbar_push (statusbar, context,
statusbar->cursor_format_str,
title,
x * unit_factor / image->xresolution,
x * unit_factor / xres,
separator,
y * unit_factor / image->yresolution,
y * unit_factor / yres,
help);
}
}
@ -654,10 +657,9 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
g_return_if_fail (title != NULL);
if (help == NULL)
{
help = "";
}
help = "";
shell = statusbar->shell;
@ -672,18 +674,22 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
else /* show real world units */
{
GimpImage *image = shell->display->image;
gdouble xres;
gdouble yres;
gdouble resolution;
gdouble unit_factor = _gimp_unit_get_factor (image->gimp,
shell->unit);
gimp_image_get_resolution (image, &xres, &yres);
switch (axis)
{
case GIMP_ORIENTATION_HORIZONTAL:
resolution = image->xresolution;
resolution = xres;
break;
case GIMP_ORIENTATION_VERTICAL:
resolution = image->yresolution;
resolution = yres;
break;
default:
@ -1037,6 +1043,8 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
GimpImage *image = shell->display->image;
GtkTreeModel *model;
const gchar *text;
gdouble xres;
gdouble yres;
gint width;
gint diff;
@ -1048,8 +1056,8 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
gimp_statusbar_scale_changed, statusbar);
model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo));
gimp_unit_store_set_resolutions (GIMP_UNIT_STORE (model),
image->xresolution, image->yresolution);
gimp_image_get_resolution (image, &xres, &yres);
gimp_unit_store_set_resolutions (GIMP_UNIT_STORE (model), xres, yres);
g_signal_handlers_block_by_func (statusbar->unit_combo,
gimp_statusbar_unit_changed, statusbar);

View File

@ -580,10 +580,16 @@ gimp_paint_options_get_fade (GimpPaintOptions *paint_options,
fade_options->fade_length / 100);
break;
default:
unit_factor = gimp_unit_get_factor (fade_options->fade_unit);
fade_out = (fade_options->fade_length *
MAX (image->xresolution,
image->yresolution) / unit_factor);
{
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
unit_factor = gimp_unit_get_factor (fade_options->fade_unit);
fade_out = (fade_options->fade_length *
MAX (xres, yres) / unit_factor);
}
break;
}
@ -664,10 +670,16 @@ gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options,
gradient_options->gradient_length / 100);
break;
default:
unit_factor = gimp_unit_get_factor (gradient_options->gradient_unit);
gradient_length = (gradient_options->gradient_length *
MAX (image->xresolution,
image->yresolution) / unit_factor);
{
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
unit_factor = gimp_unit_get_factor (gradient_options->gradient_unit);
gradient_length = (gradient_options->gradient_length *
MAX (xres, yres) / unit_factor);
}
break;
}

View File

@ -222,8 +222,12 @@ gimp_magnify_tool_button_release (GimpTool *tool,
if (new_scale != current_scale)
{
gint offset_x = 0;
gint offset_y = 0;
gdouble xres;
gdouble yres;
gint offset_x = 0;
gint offset_y = 0;
gimp_image_get_resolution (display->image, &xres, &yres);
switch (options->zoom_type)
{
@ -238,13 +242,11 @@ gimp_magnify_tool_button_release (GimpTool *tool,
* offset
*/
offset_x = RINT (new_scale * ((x1 + x2) / 2.0) *
SCREEN_XRES (shell) / display->image->xresolution
-
SCREEN_XRES (shell) / xres -
(shell->disp_width / 2.0));
offset_y = RINT (new_scale * ((y1 + y2) / 2.0) *
SCREEN_YRES (shell) / display->image->yresolution
-
SCREEN_YRES (shell) / yres -
(shell->disp_height / 2.0));
break;
@ -261,16 +263,14 @@ gimp_magnify_tool_button_release (GimpTool *tool,
offset_x = RINT (new_scale * UNSCALEX (shell,
shell->offset_x +
shell->disp_width / 2.0) *
SCREEN_XRES (shell) / display->image->xresolution
-
SCREEN_XRES (shell) / xres -
(SCALEX (shell, (x1 + x2) / 2.0) -
shell->offset_x));
offset_y = RINT (new_scale * UNSCALEY (shell,
shell->offset_y +
shell->disp_height / 2.0) *
SCREEN_YRES (shell) / display->image->yresolution
-
SCREEN_YRES (shell) / yres -
(SCALEY (shell, (y1 + y2) / 2.0) -
shell->offset_y));
break;

View File

@ -809,6 +809,8 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
gdouble theta1, theta2;
gdouble pixel_angle;
gdouble unit_angle;
gdouble xres;
gdouble yres;
gchar format[128];
/* calculate distance and angle */
@ -829,15 +831,17 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
pixel_width = ABS (ax - bx);
pixel_height = ABS (ay - by);
gimp_image_get_resolution (image, &xres, &yres);
unit_width = (_gimp_unit_get_factor (image->gimp, shell->unit) *
pixel_width / image->xresolution);
pixel_width / xres);
unit_height = (_gimp_unit_get_factor (image->gimp, shell->unit) *
pixel_height / image->yresolution);
pixel_height / yres);
pixel_distance = sqrt (SQR (ax - bx) + SQR (ay - by));
unit_distance = (_gimp_unit_get_factor (image->gimp, shell->unit) *
sqrt (SQR ((gdouble)(ax - bx) / image->xresolution) +
SQR ((gdouble)(ay - by) / image->yresolution)));
sqrt (SQR ((gdouble)(ax - bx) / xres) +
SQR ((gdouble)(ay - by) / yres)));
if (measure->num_points != 3)
bx = ax > 0 ? 1 : -1;
@ -849,10 +853,8 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
if (pixel_angle > 180.0)
pixel_angle = fabs (360.0 - pixel_angle);
theta1 = gimp_measure_tool_get_angle (ax, ay,
image->xresolution, image->yresolution);
theta2 = gimp_measure_tool_get_angle (bx, by,
image->xresolution, image->yresolution);
theta1 = gimp_measure_tool_get_angle (ax, ay, xres, yres);
theta2 = gimp_measure_tool_get_angle (bx, by, xres, yres);
measure->angle1 = theta1;
measure->angle2 = theta2;

View File

@ -606,15 +606,19 @@ gimp_paint_tool_oper_update (GimpTool *tool,
else
{
GimpImage *image = display->image;
gdouble xres;
gdouble yres;
gchar format_str[64];
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (format_str, sizeof (format_str), "%%.%df %s. %%s",
_gimp_unit_get_digits (image->gimp, shell->unit),
_gimp_unit_get_symbol (image->gimp, shell->unit));
dist = (_gimp_unit_get_factor (image->gimp, shell->unit) *
sqrt (SQR (dx / image->xresolution) +
SQR (dy / image->yresolution)));
sqrt (SQR (dx / xres) +
SQR (dy / yres)));
gimp_tool_push_status (tool, display, format_str,
dist, status_help);

View File

@ -1909,6 +1909,8 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
GimpTool *tool = GIMP_TOOL (rect_tool);
GimpRectangleOptionsPrivate *options_private;
GimpRectangleToolPrivate *private;
gdouble xres;
gdouble yres;
options_private =
GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (gimp_tool_get_options (tool));
@ -1930,10 +1932,12 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->display);
gimp_image_get_resolution (display->image, &xres, &yres);
if (options_private->fixed_width_entry)
{
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options_private->fixed_width_entry),
0, display->image->xresolution, FALSE);
0, xres, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options_private->fixed_width_entry),
0, 0, gimp_image_get_width (display->image));
}
@ -1941,7 +1945,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
if (options_private->fixed_height_entry)
{
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options_private->fixed_height_entry),
0, display->image->yresolution, FALSE);
0, yres, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options_private->fixed_height_entry),
0, 0, gimp_image_get_height (display->image));
}
@ -1949,7 +1953,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
if (options_private->x_entry)
{
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options_private->x_entry),
0, display->image->xresolution, FALSE);
0, xres, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options_private->x_entry),
0, 0, gimp_image_get_width (display->image));
}
@ -1957,7 +1961,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
if (options_private->y_entry)
{
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options_private->y_entry),
0, display->image->yresolution, FALSE);
0, yres, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options_private->y_entry),
0, 0, gimp_image_get_height (display->image));
}
@ -1965,7 +1969,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
if (options_private->width_entry)
{
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options_private->width_entry),
0, display->image->xresolution, FALSE);
0, xres, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options_private->width_entry),
0, 0, gimp_image_get_width (display->image));
}
@ -1973,7 +1977,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
if (options_private->height_entry)
{
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options_private->height_entry),
0, display->image->yresolution, FALSE);
0, yres, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options_private->height_entry),
0, 0, gimp_image_get_height (display->image));
}

View File

@ -198,12 +198,16 @@ gimp_rotate_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *display)
{
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
gdouble xres;
gdouble yres;
tr_tool->trans_info[ANGLE] = 0.0;
tr_tool->trans_info[REAL_ANGLE] = 0.0;
tr_tool->trans_info[CENTER_X] = tr_tool->cx;
tr_tool->trans_info[CENTER_Y] = tr_tool->cy;
gimp_image_get_resolution (display->image, &xres, &yres);
g_signal_handlers_block_by_func (rotate->sizeentry,
rotate_center_changed,
tr_tool);
@ -212,9 +216,9 @@ gimp_rotate_tool_prepare (GimpTransformTool *tr_tool,
GIMP_DISPLAY_SHELL (display->shell)->unit);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
display->image->xresolution, FALSE);
xres, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
display->image->yresolution, FALSE);
yres, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
-65536,

View File

@ -138,12 +138,16 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool,
{
GimpScaleTool *scale = GIMP_SCALE_TOOL (tr_tool);
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
gdouble xres;
gdouble yres;
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y2;
gimp_image_get_resolution (display->image, &xres, &yres);
if (scale->box)
{
g_signal_handlers_disconnect_by_func (scale->box,
@ -161,8 +165,8 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool,
"height", tr_tool->y2 - tr_tool->y1,
"keep-aspect", options->constrain,
"unit", GIMP_DISPLAY_SHELL (display->shell)->unit,
"xresolution", display->image->xresolution,
"yresolution", display->image->yresolution,
"xresolution", xres,
"yresolution", yres,
NULL);
gtk_container_set_border_width (GTK_CONTAINER (scale->box), 6);

View File

@ -943,6 +943,10 @@ gimp_text_tool_set_image (GimpTextTool *text_tool,
if (image)
{
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
text_tool->image = image;
g_object_add_weak_pointer (G_OBJECT (text_tool->image),
@ -952,8 +956,8 @@ gimp_text_tool_set_image (GimpTextTool *text_tool,
G_CALLBACK (gimp_text_tool_layer_changed),
text_tool, 0);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_entry),
0, image->yresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_entry), 0,
yres, FALSE);
}
}

View File

@ -167,10 +167,14 @@ gimp_vectors_export_image_size (const GimpImage *image,
const gchar *abbrev;
gchar wbuf[G_ASCII_DTOSTR_BUF_SIZE];
gchar hbuf[G_ASCII_DTOSTR_BUF_SIZE];
gdouble xres;
gdouble yres;
gdouble w, h;
w = (gdouble) gimp_image_get_width (image) / image->xresolution;
h = (gdouble) gimp_image_get_height (image) / image->yresolution;
gimp_image_get_resolution (image, &xres, &yres);
w = (gdouble) gimp_image_get_width (image) / xres;
h = (gdouble) gimp_image_get_height (image) / yres;
/* FIXME: should probably use the display unit here */
unit = gimp_image_get_unit (image);

View File

@ -474,36 +474,36 @@ svg_handler_svg_start (SvgHandler *handler,
gdouble y = 0;
gdouble w = handler->width;
gdouble h = handler->height;
gdouble xres;
gdouble yres;
matrix = g_slice_new (GimpMatrix3);
gimp_matrix3_identity (matrix);
gimp_image_get_resolution (parser->image, &xres, &yres);
while (*names)
{
switch (*names[0])
{
case 'x':
if (strcmp (*names, "x") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution, &x);
parse_svg_length (*values, handler->width, xres, &x);
break;
case 'y':
if (strcmp (*names, "y") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution, &y);
parse_svg_length (*values, handler->height, yres, &y);
break;
case 'w':
if (strcmp (*names, "width") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution, &w);
parse_svg_length (*values, handler->width, xres, &w);
break;
case 'h':
if (strcmp (*names, "height") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution, &h);
parse_svg_length (*values, handler->height, yres, &h);
break;
case 'v':
@ -637,13 +637,17 @@ svg_handler_rect_start (SvgHandler *handler,
const gchar **values,
SvgParser *parser)
{
SvgPath *path = g_slice_new0 (SvgPath);
gdouble x = 0.0;
gdouble y = 0.0;
gdouble width = 0.0;
gdouble height = 0.0;
gdouble rx = 0.0;
gdouble ry = 0.0;
SvgPath *path = g_slice_new0 (SvgPath);
gdouble x = 0.0;
gdouble y = 0.0;
gdouble width = 0.0;
gdouble height = 0.0;
gdouble rx = 0.0;
gdouble ry = 0.0;
gdouble xres;
gdouble yres;
gimp_image_get_resolution (parser->image, &xres, &yres);
while (*names)
{
@ -656,41 +660,29 @@ svg_handler_rect_start (SvgHandler *handler,
case 'x':
if (strcmp (*names, "x") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&x);
parse_svg_length (*values, handler->width, xres, &x);
break;
case 'y':
if (strcmp (*names, "y") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&y);
parse_svg_length (*values, handler->height, yres, &y);
break;
case 'w':
if (strcmp (*names, "width") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&width);
parse_svg_length (*values, handler->width, xres, &width);
break;
case 'h':
if (strcmp (*names, "height") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&height);
parse_svg_length (*values, handler->height, yres, &height);
break;
case 'r':
if (strcmp (*names, "rx") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&rx);
parse_svg_length (*values, handler->width, xres, &rx);
else if (strcmp (*names, "ry") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&ry);
parse_svg_length (*values, handler->height, yres, &ry);
break;
case 't':
@ -798,6 +790,10 @@ svg_handler_ellipse_start (SvgHandler *handler,
GimpCoords center = { 0.0, 0.0, 1.0, 0.5, 0.5, 0.5 };
gdouble rx = 0.0;
gdouble ry = 0.0;
gdouble xres;
gdouble yres;
gimp_image_get_resolution (parser->image, &xres, &yres);
while (*names)
{
@ -810,36 +806,24 @@ svg_handler_ellipse_start (SvgHandler *handler,
case 'c':
if (strcmp (*names, "cx") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&center.x);
parse_svg_length (*values, handler->width, xres, &center.x);
else if (strcmp (*names, "cy") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&center.y);
parse_svg_length (*values, handler->height, yres, &center.y);
break;
case 'r':
if (strcmp (*names, "r") == 0)
{
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&rx);
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&ry);
parse_svg_length (*values, handler->width, xres, &rx);
parse_svg_length (*values, handler->height, yres, &ry);
}
else if (strcmp (*names, "rx") == 0)
{
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&rx);
parse_svg_length (*values, handler->width, xres, &rx);
}
else if (strcmp (*names, "ry") == 0)
{
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&ry);
parse_svg_length (*values, handler->height, yres, &ry);
}
break;
@ -879,6 +863,10 @@ svg_handler_line_start (SvgHandler *handler,
GimpCoords start = { 0.0, 0.0, 1.0, 0.5, 0.5, 0.5 };
GimpCoords end = { 0.0, 0.0, 1.0, 0.5, 0.5, 0.5 };
GimpStroke *stroke;
gdouble xres;
gdouble yres;
gimp_image_get_resolution (parser->image, &xres, &yres);
while (*names)
{
@ -891,24 +879,16 @@ svg_handler_line_start (SvgHandler *handler,
case 'x':
if (strcmp (*names, "x1") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&start.x);
parse_svg_length (*values, handler->width, xres, &start.x);
else if (strcmp (*names, "x2") == 0)
parse_svg_length (*values,
handler->width, parser->image->xresolution,
&end.x);
parse_svg_length (*values, handler->width, xres, &end.x);
break;
case 'y':
if (strcmp (*names, "y1") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&start.y);
parse_svg_length (*values, handler->height, yres, &start.y);
else if (strcmp (*names, "y2") == 0)
parse_svg_length (*values,
handler->height, parser->image->yresolution,
&end.y);
parse_svg_length (*values, handler->height, yres, &end.y);
break;
case 't':

View File

@ -383,6 +383,8 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
GimpImageType sample_type;
GimpRGB color;
gint color_index;
gdouble xres;
gdouble yres;
g_return_if_fail (GIMP_IS_CURSOR_VIEW (view));
g_return_if_fail (GIMP_IS_IMAGE (image));
@ -390,6 +392,8 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
if (unit == GIMP_UNIT_PIXEL)
unit = gimp_image_get_unit (image);
gimp_image_get_resolution (image, &xres, &yres);
in_image = (x >= 0.0 && x < gimp_image_get_width (image) &&
y >= 0.0 && y < gimp_image_get_height (image));
@ -408,12 +412,10 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
g_snprintf (format_buf, sizeof (format_buf),
FORMAT_STRING ("%%.%df %s"), unit_digits, unit_str);
g_snprintf (buf, sizeof (buf), format_buf,
x * unit_factor / image->xresolution);
g_snprintf (buf, sizeof (buf), format_buf, x * unit_factor / xres);
gtk_label_set_text (GTK_LABEL (view->unit_x_label), buf);
g_snprintf (buf, sizeof (buf), format_buf,
y * unit_factor / image->yresolution);
g_snprintf (buf, sizeof (buf), format_buf, y * unit_factor / yres);
gtk_label_set_text (GTK_LABEL (view->unit_y_label), buf);
if (gimp_image_pick_color (image, NULL,

View File

@ -437,6 +437,10 @@ gimp_image_prop_view_update (GimpImagePropView *view)
const gchar *desc;
gchar format_buf[32];
gchar buf[256];
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
/* pixel size */
g_snprintf (buf, sizeof (buf), ngettext ("%d × %d pixel",
@ -456,8 +460,8 @@ gimp_image_prop_view_update (GimpImagePropView *view)
unit_digits + 1, unit_digits + 1,
_gimp_unit_get_plural (image->gimp, unit));
g_snprintf (buf, sizeof (buf), format_buf,
gimp_image_get_width (image) * unit_factor / image->xresolution,
gimp_image_get_height (image) * unit_factor / image->yresolution);
gimp_image_get_width (image) * unit_factor / xres,
gimp_image_get_height (image) * unit_factor / yres);
gtk_label_set_text (GTK_LABEL (view->print_size_label), buf);
/* resolution */
@ -467,8 +471,8 @@ gimp_image_prop_view_update (GimpImagePropView *view)
g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
_gimp_unit_get_abbreviation (image->gimp, unit));
g_snprintf (buf, sizeof (buf), _("%g × %g %s"),
image->xresolution / unit_factor,
image->yresolution / unit_factor,
xres / unit_factor,
yres / unit_factor,
unit == GIMP_UNIT_INCH ? _("ppi") : format_buf);
gtk_label_set_text (GTK_LABEL (view->resolution_label), buf);

View File

@ -182,6 +182,8 @@ gimp_toolbox_drop_drawable (GtkWidget *widget,
gint off_x, off_y;
gint bytes;
GimpImageBaseType type;
gdouble xres;
gdouble yres;
if (context->gimp->busy)
return;
@ -201,7 +203,8 @@ gimp_toolbox_drop_drawable (GtkWidget *widget,
gimp_image_get_colormap_size (image),
FALSE);
gimp_image_set_resolution (new_image, image->xresolution, image->yresolution);
gimp_image_get_resolution (image, &xres, &yres);
gimp_image_set_resolution (new_image, xres, yres);
gimp_image_set_unit (new_image, gimp_image_get_unit (image));
if (GIMP_IS_LAYER (drawable))
@ -281,6 +284,8 @@ gimp_toolbox_drop_component (GtkWidget *widget,
GimpImage *new_image;
GimpLayer *new_layer;
const gchar *desc;
gdouble xres;
gdouble yres;
if (context->gimp->busy)
return;
@ -292,7 +297,8 @@ gimp_toolbox_drop_component (GtkWidget *widget,
gimp_image_undo_disable (new_image);
gimp_image_set_resolution (new_image, image->xresolution, image->yresolution);
gimp_image_get_resolution (image, &xres, &yres);
gimp_image_set_resolution (new_image, xres, yres);
gimp_image_set_unit (new_image, gimp_image_get_unit (image));
channel = gimp_channel_new_from_component (image, component, NULL, NULL);

View File

@ -71,6 +71,8 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
gint height;
gint view_width;
gint view_height;
gdouble xres = 1.0;
gdouble yres = 1.0;
gboolean scaling_up;
TempBuf *render_buf = NULL;
@ -81,6 +83,9 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
width = renderer->width;
height = renderer->height;
if (image)
gimp_image_get_resolution (image, &xres, &yres);
if (image && ! renderer->is_popup)
{
width = MAX (1, ROUND ((((gdouble) width /
@ -95,8 +100,8 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
width,
height,
renderer->dot_for_dot,
image->xresolution,
image->yresolution,
xres,
yres,
&view_width,
&view_height,
&scaling_up);
@ -108,8 +113,8 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
width,
height,
renderer->dot_for_dot,
image ? image->xresolution : 1.0,
image ? image->yresolution : 1.0,
xres,
yres,
&view_width,
&view_height,
&scaling_up);

View File

@ -77,16 +77,20 @@ gimp_view_renderer_image_render (GimpViewRenderer *renderer,
{
gint view_width;
gint view_height;
gdouble xres;
gdouble yres;
gboolean scaling_up;
TempBuf *render_buf = NULL;
gimp_image_get_resolution (image, &xres, &yres);
gimp_viewable_calc_preview_size (gimp_image_get_width (image),
gimp_image_get_height (image),
renderer->width,
renderer->height,
renderer->dot_for_dot,
image->xresolution,
image->yresolution,
xres,
yres,
&view_width,
&view_height,
&scaling_up);

View File

@ -447,8 +447,7 @@ xcf_load_image_props (XcfInfo *info,
yres = image->gimp->config->default_image->yresolution;
}
image->xresolution = xres;
image->yresolution = yres;
gimp_image_set_resolution (image, xres, yres);
}
break;

View File

@ -392,6 +392,10 @@ xcf_save_image_props (XcfInfo *info,
{
GimpParasite *parasite = NULL;
GimpUnit unit = gimp_image_get_unit (image);
gdouble xres;
gdouble yres;
gimp_image_get_resolution (image, &xres, &yres);
/* check and see if we should save the colormap property */
if (gimp_image_get_colormap (image))
@ -412,7 +416,7 @@ xcf_save_image_props (XcfInfo *info,
gimp_image_get_sample_points (image)));
xcf_check_error (xcf_save_prop (info, image, PROP_RESOLUTION, error,
image->xresolution, image->yresolution));
xres, yres));
xcf_check_error (xcf_save_prop (info, image, PROP_TATTOO, error,
gimp_image_get_tattoo_state (image)));