summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-01-27 20:11:26 +0100
committerJan Holesovsky <kendy@collabora.com>2014-01-27 20:17:01 +0100
commit3cf3700b7a903e88f5296076c40ae854bce91cdc (patch)
tree2196cd24ecbbb2124e0705bf7ed02a68115212a4
parentc0deb50f8f7feecb7adb049e8253c9566232abde (diff)
fdo#74124: Scale the pictures before calling ImplDrawAlpha().
When the source and destination bitmap do not have the same size, ImplDrawAlpha() does not use direct paint, but instead it gets the image from the screen, blends it with the provided bitmap, and again draws it. Unfortunately, the blending uses the most trivial (and ugly) way of scaling; so to produce much better results, let's scale to the destination size before even calling ImplDrawAlpha(). The sideeffect is that we use the direct paint in most cases now; so hopefully it pays off to do the (a bit more expensive) scale first. Change-Id: I3b6b275710220910709ae4345ad6be3d6e4bf79c
-rw-r--r--vcl/source/gdi/outdev2.cxx23
1 files changed, 22 insertions, 1 deletions
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx
index f362b32c73fc..501d42b236c4 100644
--- a/vcl/source/gdi/outdev2.cxx
+++ b/vcl/source/gdi/outdev2.cxx
@@ -990,7 +990,25 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize
if(aBmpEx.IsAlpha())
{
- ImplDrawAlpha( aBmpEx.GetBitmap(), aBmpEx.GetAlpha(), rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
+ Size aDestSizePixel(LogicToPixel(rDestSize));
+
+ BitmapEx aScaledBitmapEx(aBmpEx);
+ Point aSrcPtPixel(rSrcPtPixel);
+ Size aSrcSizePixel(rSrcSizePixel);
+
+ // we have beautiful scaling algorithms, let's use them
+ if (aDestSizePixel != rSrcSizePixel && rSrcSizePixel.Width() != 0 && rSrcSizePixel.Height() != 0)
+ {
+ double fScaleX = double(aDestSizePixel.Width()) / rSrcSizePixel.Width();
+ double fScaleY = double(aDestSizePixel.Height()) / rSrcSizePixel.Height();
+
+ aScaledBitmapEx.Scale(fScaleX, fScaleY);
+
+ aSrcSizePixel = aDestSizePixel;
+ aSrcPtPixel.X() = rSrcPtPixel.X() * fScaleX;
+ aSrcPtPixel.Y() = rSrcPtPixel.Y() * fScaleY;
+ }
+ ImplDrawAlpha(aScaledBitmapEx.GetBitmap(), aScaledBitmapEx.GetAlpha(), rDestPt, rDestSize, aSrcPtPixel, aSrcSizePixel);
return;
}
@@ -2045,6 +2063,9 @@ void OutputDevice::ImplDrawAlpha( const Bitmap& rBmp, const AlphaMask& rAlpha,
if( !bNativeAlpha
&& !aBmpRect.Intersection( Rectangle( rSrcPtPixel, rSrcSizePixel ) ).IsEmpty() )
{
+ // The scaling in this code path produces really ugly results - it
+ // does the most trivial scaling with no smoothing.
+
GDIMetaFile* pOldMetaFile = mpMetaFile;
const bool bOldMap = mbMap;
mpMetaFile = NULL; // fdo#55044 reset before GetBitmap!