From aa451a4230778f9d4e6a931f51a60dba5f7a116a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 13 Oct 2022 21:14:28 +0100 Subject: Resolves: tdf#151468 honour tiff resolution fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I57d996f49c6ae7e60991ff53eae867144b56d89d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141345 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/source/filter/itiff/itiff.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'vcl') diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx index 0edd4e72e83e..c6c102df9464 100644 --- a/vcl/source/filter/itiff/itiff.cxx +++ b/vcl/source/filter/itiff/itiff.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -266,6 +267,25 @@ bool ImportTiffGraphicImport(SvStream& rTIFF, Graphic& rGraphic) } } + 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)); + AnimationFrame aAnimationFrame(aBitmapEx, Point(0, 0), aBitmapEx.GetSizePixel(), ANIMATION_TIMEOUT_ON_CLICK, Disposal::Back); aAnimation.Insert(aAnimationFrame); -- cgit