Related: tdf#151898 consider surface scaling if prescale with Bitmap::Scale
whose introduction dates back to:
commit c0ce7ca4884f7f6d1016bd1dbcc22066cb4a7797
Date: Sat Jul 7 13:07:03 2012 +0200
Prescale image with Bitmap::Scale to improve quality.
don't prescale past the level of detail that the surface could retain
Change-Id: I1022688d45d2bb7b692f4ba619198fccea8eab36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142596
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 53a9f77..49bdf98 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -154,10 +154,20 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize,
{
if (nAction == MetaActionType::BMPSCALE && CanSubsampleBitmap())
{
const double nScaleX = aPosAry.mnDestWidth / static_cast<double>(aPosAry.mnSrcWidth);
const double nScaleY = aPosAry.mnDestHeight / static_cast<double>(aPosAry.mnSrcHeight);
double nScaleX = aPosAry.mnDestWidth / static_cast<double>(aPosAry.mnSrcWidth);
double nScaleY = aPosAry.mnDestHeight / static_cast<double>(aPosAry.mnSrcHeight);
// If subsampling, use Bitmap::Scale() for subsampling of better quality.
// but hidpi surfaces like the cairo one have their own scale, so don't downscale
// past the surface scaling which can retain the extra detail
double fScale(1.0);
if (mpGraphics->ShouldDownscaleIconsAtSurface(&fScale))
{
nScaleX *= fScale;
nScaleY *= fScale;
}
if ( nScaleX < 1.0 || nScaleY < 1.0 )
{
aBmp.Scale(nScaleX, nScaleY);