[evince] Fix dpi calculation
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] Fix dpi calculation
- Date: Sun, 21 Feb 2010 11:37:39 +0000 (UTC)
commit db8a118298552769e835c67d29dfe1fa41de698a
Author: Juanjo MarÃn <juanj marin juntadeandalucia es>
Date: Sun Feb 21 12:14:25 2010 +0100
Fix dpi calculation
Fixes bug #608586.
shell/ev-utils.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/shell/ev-utils.c b/shell/ev-utils.c
index 8cda889..d77e91f 100644
--- a/shell/ev-utils.c
+++ b/shell/ev-utils.c
@@ -307,14 +307,17 @@ gdouble
get_screen_dpi (GtkWindow *window)
{
GdkScreen *screen;
- gdouble xdpi, ydpi;
+ gdouble dp, di;
screen = gtk_window_get_screen (window);
- xdpi = 25.4 * gdk_screen_get_width (screen) / gdk_screen_get_width_mm (screen);
- ydpi = 25.4 * gdk_screen_get_height (screen) / gdk_screen_get_height_mm (screen);
-
- return (xdpi + ydpi) / 2.0;
+ /*diagonal in pixels*/
+ dp = hypot (gdk_screen_get_width (screen), gdk_screen_get_height (screen));
+
+ /*diagonal in inches*/
+ di = hypot (gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm (screen)) / 25.4;
+
+ return (dp / di);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]