diff options
author | Armin Le Grand <alg@apache.org> | 2013-10-14 15:01:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-14 20:30:05 +0100 |
commit | 29991e23bc883a3965614269f90cd8bed75a567b (patch) | |
tree | 739f44487644218eb181447cda8a478350f13e5e /svtools/source | |
parent | convert creating document mail merge dialog to .ui (diff) | |
download | core-29991e23bc883a3965614269f90cd8bed75a567b.tar.gz core-29991e23bc883a3965614269f90cd8bed75a567b.zip |
Resolves: #i123438# Corrected crop for clipboard bitmap data preparations
(cherry picked from commit 2104f864ec0cf0989e962c045ee69010e3505f3e)
Change-Id: I3376d72317f27bfe7898e515ce1d2788761d1422
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 85f0d0b84f56..96408bfc33d6 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -757,23 +757,25 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo if( aMapGraph == MAP_PIXEL ) { - aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetLeftCrop(), - rAttr.GetTopCrop() ), - aMap100 ); - aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetRightCrop(), - rAttr.GetBottomCrop() ), - aMap100 ); + // crops are in 1/100th mm -> to aMapGraph -> to MAP_PIXEL + aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( + Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()), + aMap100); + aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( + Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()), + aMap100); } else { - aCropLeftTop = OutputDevice::LogicToLogic( Size( rAttr.GetLeftCrop(), - rAttr.GetTopCrop() ), - aMap100, - aMapGraph ); - aCropRightBottom = OutputDevice::LogicToLogic( Size( rAttr.GetRightCrop(), - rAttr.GetBottomCrop() ), - aMap100, - aMapGraph ); + // crops are in GraphicObject units -> to aMapGraph + aCropLeftTop = OutputDevice::LogicToLogic( + Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()), + aMap100, + aMapGraph); + aCropRightBottom = OutputDevice::LogicToLogic( + Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()), + aMap100, + aMapGraph); } // #104115# If the metafile is cropped, give it a special @@ -823,15 +825,29 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo BitmapEx aBitmapEx( aTransGraphic.GetBitmapEx() ); Rectangle aCropRect; - // convert crops to pixel (crops are always in GraphicObject units) + // convert crops to pixel if(rAttr.IsCropped()) { - aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( - Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()), - aMapGraph); - aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( - Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()), - aMapGraph); + if( aMapGraph == MAP_PIXEL ) + { + // crops are in 1/100th mm -> to MAP_PIXEL + aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( + Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()), + aMap100); + aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( + Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()), + aMap100); + } + else + { + // crops are in GraphicObject units -> to MAP_PIXEL + aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( + Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()), + aMapGraph); + aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( + Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()), + aMapGraph); + } // convert from prefmapmode to pixel Size aSrcSizePixel( @@ -851,8 +867,9 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo // another possibility is to adapt the values created so far with a factor; this // will keep the original Bitmap untouched and thus quality will not change - const double fFactorX(aBitmapEx.GetSizePixel().Width() / aSrcSizePixel.Width()); - const double fFactorY(aBitmapEx.GetSizePixel().Height() / aSrcSizePixel.Height()); + // caution: convert to double first, else pretty big errors may occurr + const double fFactorX((double)aBitmapEx.GetSizePixel().Width() / aSrcSizePixel.Width()); + const double fFactorY((double)aBitmapEx.GetSizePixel().Height() / aSrcSizePixel.Height()); aCropLeftTop.Width() = basegfx::fround(aCropLeftTop.Width() * fFactorX); aCropLeftTop.Height() = basegfx::fround(aCropLeftTop.Height() * fFactorY); |