summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-08-09 14:54:05 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-08-09 18:30:36 +0200
commitf394b313ad9eac459e4765a639410ebd9278351a (patch)
tree6f32d055c17baaef670652f545eb5d9fd65d61b1
parente845507bc22a166ec172a4b4d9da120a16f8a964 (diff)
Resolves: tdf#99286 for jpeg dpi use apis that know about MapUnit::MapPixel
move the code which can do this from sw to vcl Change-Id: I9940fb80ecdbfe8f70afc500c691288ed0993701 Reviewed-on: https://gerrit.libreoffice.org/40925 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/docnode/ndnotxt.cxx18
-rw-r--r--vcl/source/filter/jpeg/jpegc.cxx6
-rw-r--r--vcl/source/gdi/graph.cxx24
3 files changed, 19 insertions, 29 deletions
diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx
index 3d33fda5cd5d..8cf1d1c399ba 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -119,21 +119,9 @@ const tools::PolyPolygon *SwNoTextNode::HasContour() const
{
if ( !bPixelGrf && m_bPixelContour )
{
- const Size aGrfPixelSize( GetGraphic().GetSizePixel() );
- const Size aGrfPrefMapModeSize( GetGraphic().GetPrefSize() );
- if ( aGrfMap.GetMapUnit() == MapUnit::MapInch )
- {
- nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() );
- nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() );
- }
- else
- {
- const Size aGrf1000thInchSize =
- OutputDevice::LogicToLogic( aGrfPrefMapModeSize,
- aGrfMap, MapUnit::Map1000thInch );
- nGrfDPIx = 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
- nGrfDPIy = 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
- }
+ basegfx::B2DSize aDPI = GetGraphic().GetPPI();
+ nGrfDPIx = aDPI.getX();
+ nGrfDPIy = aDPI.getY();
}
}
OSL_ENSURE( !bPixelGrf || aGrfMap == aContourMap,
diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx
index c674c667c788..4305f065ed54 100644
--- a/vcl/source/filter/jpeg/jpegc.cxx
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -279,7 +279,7 @@ void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
}
bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream,
- long nWidth, long nHeight, basegfx::B2DSize const & aPPI, bool bGreys,
+ long nWidth, long nHeight, basegfx::B2DSize const & rPPI, bool bGreys,
long nQualityPercent, long aChromaSubsampling,
css::uno::Reference<css::task::XStatusIndicator> const & status )
{
@@ -315,8 +315,8 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream,
jpeg_set_quality( &cinfo, (int) nQualityPercent, FALSE );
cinfo.density_unit = 1;
- cinfo.X_density = aPPI.getX();
- cinfo.Y_density = aPPI.getY();
+ cinfo.X_density = rPPI.getX();
+ cinfo.Y_density = rPPI.getY();
if ( ( nWidth > 128 ) || ( nHeight > 128 ) )
jpeg_simple_progression( &cinfo );
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 6452e08660fa..9d8833683f34 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <tools/fract.hxx>
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
#include <vcl/graph.hxx>
@@ -402,24 +403,25 @@ void Graphic::SetPrefMapMode( const MapMode& rPrefMapMode )
basegfx::B2DSize Graphic::GetPPI() const
{
- MapMode aMapMode = GetPrefMapMode();
+ double nGrfDPIx;
+ double nGrfDPIy;
- double fWidthInches = ( GetPrefSize().Width() * aMapMode.GetUnitMultiplier() ) / 2540;
- double fHeightInches = ( GetPrefSize().Height() * aMapMode.GetUnitMultiplier() ) / 2540;
- double fPpiX = 0;
- double fPpiY = 0;
-
- if ( fWidthInches > 0 || fHeightInches > 0 ) // we don't want a divide by 0 situation
+ const MapMode aGrfMap(GetPrefMapMode());
+ const Size aGrfPixelSize(GetSizePixel());
+ const Size aGrfPrefMapModeSize(GetPrefSize());
+ if (aGrfMap.GetMapUnit() == MapUnit::MapInch)
{
- fPpiX = GetSizePixel().Width() / fWidthInches;
- fPpiY = GetSizePixel().Height() / fHeightInches;
+ nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() );
+ nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() );
}
else
{
- SAL_WARN("vcl", "PPI X is " << fPpiX << " and PPI Y is " << fPpiY << ": thus we are making this 0 DPI. This is unlikely.");
+ const Size aGrf1000thInchSize = OutputDevice::LogicToLogic(aGrfPrefMapModeSize, aGrfMap, MapUnit::Map1000thInch);
+ nGrfDPIx = 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
+ nGrfDPIy = 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
}
- return basegfx::B2DSize( fPpiX, fPpiY );
+ return basegfx::B2DSize(nGrfDPIx, nGrfDPIy);
}
Size Graphic::GetSizePixel( const OutputDevice* pRefDevice ) const