vcl/source/outdev/bitmap.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
New commits: commit 3cfeeb2ea83edbf99d4e3bb6e0b67538f03f783d Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Nov 11 15:12:30 2022 +0000 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Mon Nov 14 06:34:32 2022 +0100 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 <fit...@ubuntu.com> diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 53a9f774b71d..49bdf9826398 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);