From de3612f2a4b46b555edc50ca344a04bc3a8f7280 Mon Sep 17 00:00:00 2001 From: Matthew S. Wilson Date: Sat, 02 Jul 2005 14:49:23 +0000 Subject: scale the reported height by using the resolution aspect ratio 2005-07-02 Matthew S. Wilson * tiff/tiff-document.c (tiff_document_get_page_size): scale the reported height by using the resolution aspect ratio (tiff_document_render_pixbuf): scale the pixbuf using the resolution aspect ratio --- (limited to 'tiff') diff --git a/tiff/tiff-document.c b/tiff/tiff-document.c index f2ed498..3324e7d 100644 --- a/tiff/tiff-document.c +++ b/tiff/tiff-document.c @@ -90,7 +90,7 @@ tiff_document_load (EvDocument *document, if (tiff) { guint32 w, h; - + /* FIXME: unused data? why bother here */ TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); } @@ -143,6 +143,7 @@ tiff_document_get_page_size (EvDocument *document, double *height) { guint32 w, h; + gfloat x_res, y_res; TiffDocument *tiff_document = TIFF_DOCUMENT (document); g_return_if_fail (TIFF_IS_DOCUMENT (document)); @@ -157,6 +158,9 @@ tiff_document_get_page_size (EvDocument *document, TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x_res); + TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y_res); + h = h * (x_res / y_res); if (tiff_document->orientation == EV_ORIENTATION_PORTRAIT || tiff_document->orientation == EV_ORIENTATION_UPSIDEDOWN) { @@ -210,6 +214,7 @@ tiff_document_render_pixbuf (EvDocument *document, { TiffDocument *tiff_document = TIFF_DOCUMENT (document); int width, height; + float x_res, y_res; gint rowstride, bytes; guchar *pixels = NULL; GdkPixbuf *pixbuf; @@ -238,6 +243,18 @@ tiff_document_render_pixbuf (EvDocument *document, return NULL; } + if (!TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x_res)) + { + pop_handlers (); + return NULL; + } + + if (! TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y_res)) + { + pop_handlers (); + return NULL; + } + pop_handlers (); /* Sanity check the doc */ @@ -268,7 +285,7 @@ tiff_document_render_pixbuf (EvDocument *document, scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, width * rc->scale, - height * rc->scale, + height * rc->scale * (x_res/y_res), GDK_INTERP_BILINEAR); g_object_unref (pixbuf); -- cgit v0.9.1