summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-10-13 21:14:28 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-10-14 07:39:11 +0200
commit846711ad526fcc147bb39df26bf2c2ff25a053f3 (patch)
tree6a97ebc40f7c17eac87dc7e34554d63525237a95
parenttdf#150664 Initialize input line correctly (diff)
downloadcore-846711ad526fcc147bb39df26bf2c2ff25a053f3.tar.gz
core-846711ad526fcc147bb39df26bf2c2ff25a053f3.zip
Resolves: tdf#151468 honour tiff resolution fields
Change-Id: I57d996f49c6ae7e60991ff53eae867144b56d89d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141346 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--vcl/source/filter/itiff/itiff.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx
index d8895b8cff31..db30ea2cac3c 100644
--- a/vcl/source/filter/itiff/itiff.cxx
+++ b/vcl/source/filter/itiff/itiff.cxx
@@ -25,6 +25,7 @@
#include <vcl/BitmapTools.hxx>
#include <vcl/animate/Animation.hxx>
#include <bitmap/BitmapWriteAccess.hxx>
+#include <tools/fract.hxx>
#include <tools/stream.hxx>
#include <unotools/configmgr.hxx>
@@ -243,6 +244,25 @@ bool ImportTiffGraphicImport(SvStream& rTIFF, Graphic& rGraphic)
break;
}
+ MapMode aMapMode;
+ uint16_t ResolutionUnit = RESUNIT_NONE;
+ if (TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &ResolutionUnit) == 1 && ResolutionUnit != RESUNIT_NONE)
+ {
+ float xres = 0, yres = 0;
+
+ if (TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) == 1 &&
+ TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) == 1 &&
+ xres != 0 && yres != 0)
+ {
+ if (ResolutionUnit == RESUNIT_INCH)
+ aMapMode = MapMode(MapUnit::MapInch, Point(0,0), Fraction(1/xres), Fraction(1/yres));
+ else if (ResolutionUnit == RESUNIT_CENTIMETER)
+ aMapMode = MapMode(MapUnit::MapCM, Point(0,0), Fraction(1/xres), Fraction(1/yres));
+ }
+ }
+ aBitmapEx.SetPrefMapMode(aMapMode);
+ aBitmapEx.SetPrefSize(Size(w, h));
+
AnimationBitmap aAnimationBitmap(aBitmapEx, Point(0, 0), aBitmapEx.GetSizePixel(),
ANIMATION_TIMEOUT_ON_CLICK, Disposal::Back);
aAnimation.Insert(aAnimationBitmap);