Kaydet (Commit) 29991e23 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i123438# Corrected crop for clipboard bitmap data preparations

(cherry picked from commit 2104f864)

Change-Id: I3376d72317f27bfe7898e515ce1d2788761d1422
üst 33450a25
...@@ -757,23 +757,25 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo ...@@ -757,23 +757,25 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo
if( aMapGraph == MAP_PIXEL ) if( aMapGraph == MAP_PIXEL )
{ {
aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetLeftCrop(), // crops are in 1/100th mm -> to aMapGraph -> to MAP_PIXEL
rAttr.GetTopCrop() ), aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel(
aMap100 ); Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()),
aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetRightCrop(), aMap100);
rAttr.GetBottomCrop() ), aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel(
aMap100 ); Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()),
aMap100);
} }
else else
{ {
aCropLeftTop = OutputDevice::LogicToLogic( Size( rAttr.GetLeftCrop(), // crops are in GraphicObject units -> to aMapGraph
rAttr.GetTopCrop() ), aCropLeftTop = OutputDevice::LogicToLogic(
aMap100, Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()),
aMapGraph ); aMap100,
aCropRightBottom = OutputDevice::LogicToLogic( Size( rAttr.GetRightCrop(), aMapGraph);
rAttr.GetBottomCrop() ), aCropRightBottom = OutputDevice::LogicToLogic(
aMap100, Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()),
aMapGraph ); aMap100,
aMapGraph);
} }
// #104115# If the metafile is cropped, give it a special // #104115# If the metafile is cropped, give it a special
...@@ -823,15 +825,29 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo ...@@ -823,15 +825,29 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo
BitmapEx aBitmapEx( aTransGraphic.GetBitmapEx() ); BitmapEx aBitmapEx( aTransGraphic.GetBitmapEx() );
Rectangle aCropRect; Rectangle aCropRect;
// convert crops to pixel (crops are always in GraphicObject units) // convert crops to pixel
if(rAttr.IsCropped()) if(rAttr.IsCropped())
{ {
aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( if( aMapGraph == MAP_PIXEL )
Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()), {
aMapGraph); // crops are in 1/100th mm -> to MAP_PIXEL
aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel(
Size(rAttr.GetRightCrop(), rAttr.GetBottomCrop()), Size(rAttr.GetLeftCrop(), rAttr.GetTopCrop()),
aMapGraph); 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 // convert from prefmapmode to pixel
Size aSrcSizePixel( Size aSrcSizePixel(
...@@ -851,8 +867,9 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo ...@@ -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 // 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 // will keep the original Bitmap untouched and thus quality will not change
const double fFactorX(aBitmapEx.GetSizePixel().Width() / aSrcSizePixel.Width()); // caution: convert to double first, else pretty big errors may occurr
const double fFactorY(aBitmapEx.GetSizePixel().Height() / aSrcSizePixel.Height()); 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.Width() = basegfx::fround(aCropLeftTop.Width() * fFactorX);
aCropLeftTop.Height() = basegfx::fround(aCropLeftTop.Height() * fFactorY); aCropLeftTop.Height() = basegfx::fround(aCropLeftTop.Height() * fFactorY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment