summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-06-10 22:22:38 +0200
committerJulien Nabet <serval2412@yahoo.fr>2022-06-11 21:35:14 +0200
commit988285410f8883ad49f32c4b804c4f5bd14569d0 (patch)
tree4ce69fd2ad132f072acc9e3f259ec00874b0764d
parent35edeb2d2cef6759435e1a1b68a5a09fe5217178 (diff)
tdf#98743: TIFF export uses 96dpi by default
Create a brand new odg with A4 format with just a rectangle or a smiley on it and export it in tiff. Since we export the whole page, the size is: - in cm: 21x29.7 (definition of A4) - in inches: about 8.2677x11.6929 Taking a look at the value of the generated tiff, we got: ImageWidth: 794 ImageLength: 1123 Notice that 794/8.2677 like 1123/11.6929 is about 96. So resolution isn't 300x300 (like the code suggests) but 96x96. Then let's remove all the useless mechanism to try to find the X and Y resolutions. TIFF Documentation indicates that "XResolution" and "YResolution" tags use "RATIONAL" type which is defined as: "Two LONGs: the first represents the numerator of a fraction; the second, the denominator." Since we got a non floating value, we can use "1" for denominator and "96" for nominator. With this we change TIFFWriter::ImplWriteResolution implementation to put the nominator first which corresponds to the resolution passed by argument to the method and the denominator afterwards. Finally, let's fix the name of the second of ImplWriteResolution, it's the resolution value, not the resolution unit. Next step would be to use the dialog box for compressing options (like for png or jpg). But for this I think we should take benefit of external lib "libtiff" since we now use it now for import. Change-Id: I7dbd04e506e98c344f97e455955cdf2c2f6d83c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135631 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--vcl/source/filter/etiff/etiff.cxx15
1 files changed, 4 insertions, 11 deletions
diff --git a/vcl/source/filter/etiff/etiff.cxx b/vcl/source/filter/etiff/etiff.cxx
index b34accab889b..2bfaea923c23 100644
--- a/vcl/source/filter/etiff/etiff.cxx
+++ b/vcl/source/filter/etiff/etiff.cxx
@@ -191,15 +191,8 @@ bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem const * pF
if ( ImplWriteHeader( aAnimation.Count() > 0 ) )
{
- Size aDestMapSize( 300, 300 );
- const MapMode& aMapMode( aBmp.GetPrefMapMode() );
- if ( aMapMode.GetMapUnit() != MapUnit::MapPixel )
- {
- const Size aPrefSize( rGraphic.GetPrefSize() );
- aDestMapSize = OutputDevice::LogicToLogic(aPrefSize, aMapMode, MapMode(MapUnit::MapInch));
- }
- ImplWriteResolution( mnXResPos, aDestMapSize.Width() );
- ImplWriteResolution( mnYResPos, aDestMapSize.Height() );
+ ImplWriteResolution( mnXResPos, 96 );
+ ImplWriteResolution( mnYResPos, 96 );
if ( mnPalPos )
ImplWritePalette();
ImplWriteBody();
@@ -447,14 +440,14 @@ void TIFFWriter::ImplWriteBody()
}
-void TIFFWriter::ImplWriteResolution( sal_uInt64 nStreamPos, sal_uInt32 nResolutionUnit )
+void TIFFWriter::ImplWriteResolution( sal_uInt64 nStreamPos, sal_uInt32 nResolutionValue )
{
sal_uInt64 nCurrentPos = m_rOStm.Tell();
m_rOStm.Seek( nStreamPos + 8 );
m_rOStm.WriteUInt32( nCurrentPos - mnStreamOfs );
m_rOStm.Seek( nCurrentPos );
+ m_rOStm.WriteUInt32( nResolutionValue );
m_rOStm.WriteUInt32( 1 );
- m_rOStm.WriteUInt32( nResolutionUnit );
}