Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument
diff options
context:
space:
mode:
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 */