summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-10-08 09:16:27 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-10-08 14:31:32 +0200
commitdd4a67084853a030bf4b9f1f85d728620e0604a5 (patch)
tree2fe01d5939ee5e1b4f127243561efc56e792b1d6 /vcl/source
parentef2ec07b4113fdadf863352c832af657b5ae205c (diff)
vcl: avoid downscale && upscale in DrawTransformedBitmapEx()
If we rotate a bitmap and put it to a metafile, we'll create a MetaBmpExScaleAction. But just because we need to store a transformed bitmap for rotation purposes, it doesn't mean we also need to scale it. This helps in case later the metafile is upscaled and the downscaled bitmap would look blurry. Change-Id: I7d64a88af460e80dffde8052186888eddbb440fe Reviewed-on: https://gerrit.libreoffice.org/80426 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/outdev/bitmap.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 7959b13f8f68..2cbdb2fdb2b3 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -1208,7 +1208,7 @@ void OutputDevice::DrawTransformedBitmapEx(
const bool bInvert(RasterOp::Invert == meRasterOp);
const bool bBitmapChangedColor(mnDrawMode & (DrawModeFlags::BlackBitmap | DrawModeFlags::WhiteBitmap | DrawModeFlags::GrayBitmap ));
bool bDone(false);
- const basegfx::B2DHomMatrix aFullTransform(GetViewTransformation() * rTransformation);
+ basegfx::B2DHomMatrix aFullTransform(GetViewTransformation() * rTransformation);
const bool bTryDirectPaint(!bInvert && !bBitmapChangedColor && !bMetafile );
if(bTryDirectPaint)
@@ -1272,6 +1272,19 @@ void OutputDevice::DrawTransformedBitmapEx(
aTransformed = BitmapEx(aContent, aMaskBmp);
}
+ // Remove scaling from aFulltransform: we transform due to shearing or rotation, scaling
+ // will happen according to aDestSize.
+ basegfx::B2DVector aFullScale, aFullTranslate;
+ double fFullRotate, fFullShearX;
+ aFullTransform.decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX);
+ if (aFullScale.getX() != 0 && aFullScale.getY() != 0)
+ {
+ basegfx::B2DHomMatrix aTransform = basegfx::utils::createScaleB2DHomMatrix(
+ rOriginalSizePixel.getWidth() / aFullScale.getX(),
+ rOriginalSizePixel.getHeight() / aFullScale.getY());
+ aFullTransform *= aTransform;
+ }
+
aTransformed = aTransformed.getTransformed(
aFullTransform,
aVisibleRange,