Related: tdf#151898 consider surface scaling if prescale with Bitmap::Scale

whose introduction dates back to:

commit c0ce7ca488
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>
This commit is contained in:
Caolán McNamara
2022-11-11 20:35:40 +01:00
parent 7986d35eee
commit c2c37eadf3
+12 -2
View File
@@ -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);