diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-06-22 15:50:30 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-06-22 16:50:18 +0200 |
commit | baca49fdda5e350b7b0f122d50739ee98cc6fe25 (patch) | |
tree | c3b4c7bf29d7b9a343a0591d981721e31f6f262e /svtools/source/graphic | |
parent | 0c10b8ff9fa115ec2c315bd75a9eddc1cd4c0ac2 (diff) |
try somewhat harder to smoothscale objects (bnc#765998)
The used bilinear algorithm is apparently of a rather low quality,
use the new generic box algorithm instead. That makes it somewhat
slower, but the result is cached, and hopefully the speed difference
is not that significant.
Change-Id: I5a4dbe4851d467babc0d0fdcc3375b35441daf93
Diffstat (limited to 'svtools/source/graphic')
-rw-r--r-- | svtools/source/graphic/grfmgr2.cxx | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index a03c668f5de1..f4ab6ca32971 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -342,34 +342,7 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut, sal_Bool bHMirr = ( rAttr.GetMirrorFlags() & BMP_MIRROR_HORZ ) != 0; sal_Bool bVMirr = ( rAttr.GetMirrorFlags() & BMP_MIRROR_VERT ) != 0; - if( nFlags & GRFMGR_DRAW_BILINEAR ) - { - const double fRevScaleX = ( nNewW > 1L ) ? ( (double) ( nW - 1L ) / ( nNewW - 1L ) ) : 0.0; - const double fRevScaleY = ( nNewH > 1L ) ? ( (double) ( nH - 1L ) / ( nNewH - 1L ) ) : 0.0; - - // create horizontal mapping table - for( nX = 0L, nTmpX = nW - 1L, nTmp = nW - 2L; nX < nNewW; nX++ ) - { - fTmp = nX * fRevScaleX; - - if( bHMirr ) - fTmp = nTmpX - fTmp; - - pMapFX[ nX ] = (long) ( ( fTmp - ( pMapIX[ nX ] = MinMax( (long) fTmp, 0, nTmp ) ) ) * 1048576. ); - } - - // create vertical mapping table - for( nY = 0L, nTmpY = nH - 1L, nTmp = nH - 2L; nY < nNewH; nY++ ) - { - fTmp = nY * fRevScaleY; - - if( bVMirr ) - fTmp = nTmpY - fTmp; - - pMapFY[ nY ] = (long) ( ( fTmp - ( pMapIY[ nY ] = MinMax( (long) fTmp, 0, nTmp ) ) ) * 1048576. ); - } - } - else + if( !( nFlags & GRFMGR_DRAW_SMOOTHSCALE )) { // #98290# Use a different mapping for non-interpolating mode, to avoid missing rows/columns const double fRevScaleX = ( nNewW > 1L ) ? ( (double) nW / nNewW ) : 0.0; @@ -451,7 +424,22 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut, bRet = ( aOutBmpEx = aBmpEx ).Scale( aUnrotatedSzPix ); if( bRet ) - aOutBmpEx.Rotate( nRot10, COL_TRANSPARENT ); + bRet = aOutBmpEx.Rotate( nRot10, COL_TRANSPARENT ); + } + else if( nFlags & GRFMGR_DRAW_SMOOTHSCALE ) + { + // Scale using the Box filter, rather than this algorithm, as that one provides + // better quality, while being somewhat slower (the result should be cached though). + aOutBmpEx = aBmpEx; + bRet = true; + if( bHMirr || bVMirr ) + bRet = aOutBmpEx.Mirror(( bHMirr ? BMP_MIRROR_HORZ : BMP_MIRROR_NONE ) + | ( bVMirr ? BMP_MIRROR_VERT : BMP_MIRROR_NONE )); + if( bRet ) + bRet = aOutBmpEx.Rotate( nRot10, COL_TRANSPARENT ); + if( bRet ) // scale as last (rotating would destroy the smooth scaling) + bRet = aOutBmpEx.Scale( Size( nEndX - nStartX + 1, nEndY - nStartY + 1 ), + BMP_SCALE_BOX ); } else { @@ -477,6 +465,17 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut, { if( bSimple ) bRet = ( aOutBmpEx = aBmpEx ).Scale( Size( nEndX - nStartX + 1, nEndY - nStartY + 1 ) ); + else if( nFlags & GRFMGR_DRAW_SMOOTHSCALE ) + { + // Scale using the Box filter, rather than this algorithm, as that one provides + // better quality, while being somewhat slower (the result should be cached though). + aOutBmpEx = aBmpEx; + bRet = aOutBmpEx.Scale( Size( nEndX - nStartX + 1, nEndY - nStartY + 1 ), + BMP_SCALE_BOX ); + if( bRet && ( bHMirr || bVMirr )) + bRet = aOutBmpEx.Mirror(( bHMirr ? BMP_MIRROR_HORZ : BMP_MIRROR_NONE ) + | ( bVMirr ? BMP_MIRROR_VERT : BMP_MIRROR_NONE )); + } else { bRet = ImplCreateScaled( aBmpEx, |