From efcfec9eb8dc8646c5f5f3fd486b4c195734e243 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 28 Feb 2010 15:42:55 +0100 Subject: [PATCH] app: remove ancient utility function img2real() and use gimp_pixels_to_units() directly. --- app/display/gimpdisplayshell-scale.c | 81 +++++++++++++--------------- 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index 83bea28c37..e3583d5f03 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -82,10 +82,6 @@ static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shel gint *y, GimpZoomFocus zoom_focus); -static gdouble img2real (GimpDisplayShell *shell, - gboolean xdir, - gdouble a); - /* public functions */ @@ -173,6 +169,8 @@ gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) GimpImage *image; gint image_width; gint image_height; + gdouble resolution_x = 1.0; + gdouble resolution_y = 1.0; gdouble horizontal_lower; gdouble horizontal_upper; gdouble horizontal_max_size; @@ -189,6 +187,8 @@ gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) { image_width = gimp_image_get_width (image); image_height = gimp_image_get_height (image); + + gimp_image_get_resolution (image, &resolution_x, &resolution_y); } else { @@ -204,15 +204,23 @@ gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) if (image) { - horizontal_upper = img2real (shell, TRUE, - FUNSCALEX (shell, shell->disp_width)); - horizontal_max_size = img2real (shell, TRUE, - MAX (image_width, image_height)); + horizontal_upper = gimp_pixels_to_units (FUNSCALEX (shell, + shell->disp_width), + shell->unit, + resolution_x); + horizontal_max_size = gimp_pixels_to_units (MAX (image_width, + image_height), + shell->unit, + resolution_x); - vertical_upper = img2real (shell, FALSE, - FUNSCALEY (shell, shell->disp_height)); - vertical_max_size = img2real (shell, FALSE, - MAX (image_width, image_height)); + vertical_upper = gimp_pixels_to_units (FUNSCALEY (shell, + shell->disp_height), + shell->unit, + resolution_y); + vertical_max_size = gimp_pixels_to_units (MAX (image_width, + image_height), + shell->unit, + resolution_y); } else { @@ -228,19 +236,24 @@ gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) if (image) { - horizontal_lower += img2real (shell, TRUE, - FUNSCALEX (shell, - (gdouble) shell->offset_x)); - horizontal_upper += img2real (shell, TRUE, - FUNSCALEX (shell, - (gdouble) shell->offset_x)); + gdouble offset_x; + gdouble offset_y; - vertical_lower += img2real (shell, FALSE, - FUNSCALEY (shell, - (gdouble) shell->offset_y)); - vertical_upper += img2real (shell, FALSE, - FUNSCALEY (shell, - (gdouble) shell->offset_y)); + offset_x = gimp_pixels_to_units (FUNSCALEX (shell, + (gdouble) shell->offset_x), + shell->unit, + resolution_x); + + offset_y = gimp_pixels_to_units (FUNSCALEX (shell, + (gdouble) shell->offset_y), + shell->unit, + resolution_y); + + horizontal_lower += offset_x; + horizontal_upper += offset_x; + + vertical_lower += offset_y; + vertical_upper += offset_y; } /* Finally setup the actual rulers */ @@ -1109,23 +1122,3 @@ gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell, break; } } - -/* scale image coord to realworld units (cm, inches, pixels) - * - * 27/Feb/1999 I tried inlining this, but the result was slightly - * slower (poorer cache locality, probably) -- austin - */ -static gdouble -img2real (GimpDisplayShell *shell, - gboolean xdir, - gdouble len) -{ - gdouble xres; - gdouble yres; - - gimp_image_get_resolution (gimp_display_get_image (shell->display), - &xres, &yres); - - return gimp_pixels_to_units (len, shell->unit, - xdir ? xres : yres); -}