Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2010-02-21 11:29:24 (GMT)
committer Carlos Garcia Campos <carlosgc@gnome.org>2010-02-21 11:29:24 (GMT)
commit8ee88d8e916cb126a0a12e4816b9d1043cbd6472 (patch)
tree2232d5b36f4c451f6e18ee72c06b034b2e9c5478 /libdocument
parentdb8a118298552769e835c67d29dfe1fa41de698a (diff)
Move get_screen_dpi to libdocument
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/ev-document-misc.c15
-rw-r--r--libdocument/ev-document-misc.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index 14bc3a3..0a23394 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
+#include <math.h>
#include <gtk/gtk.h>
@@ -363,3 +364,17 @@ ev_document_misc_invert_pixbuf (GdkPixbuf *pixbuf)
}
}
}
+
+gdouble
+ev_document_misc_get_screen_dpi (GdkScreen *screen)
+{
+ gdouble dp, di;
+
+ /*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);
+}
diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h
index 8e92983..61d070d 100644
--- a/libdocument/ev-document-misc.h
+++ b/libdocument/ev-document-misc.h
@@ -54,6 +54,8 @@ cairo_surface_t *ev_document_misc_surface_rotate_and_scale (cairo_surface_t *sur
void ev_document_misc_invert_surface (cairo_surface_t *surface);
void ev_document_misc_invert_pixbuf (GdkPixbuf *pixbuf);
+gdouble ev_document_misc_get_screen_dpi (GdkScreen *screen);
+
G_END_DECLS
#endif /* EV_DOCUMENT_MISC_H */