summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-11-11 15:12:30 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-11-11 20:35:40 +0100
commitc2c37eadf32c80bcd8f168b9fc67f32002b3cb07 (patch)
tree5cde10e32cf6ab4078c5567f76ecbf91cddcc17a
parent7986d35eee84fdf391c563602fb348758e1cd254 (diff)
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/+/142591 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/outdev/bitmap.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index f489efd7a038..45e3b0d3ede1 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);