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-10-12 18:52:31 +0200 |
commit | 73e73ca997fa921d76752b36e62bb5795b77d676 (patch) | |
tree | 061db87ed225f495ab704d263365a0a1359b18dd /svtools | |
parent | 744213cca0377417ca7dabed238d184ffecbfc11 (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')
-rw-r--r-- | svtools/inc/svtools/grfmgr.hxx | 4 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr2.cxx | 57 |
2 files changed, 30 insertions, 31 deletions
diff --git a/svtools/inc/svtools/grfmgr.hxx b/svtools/inc/svtools/grfmgr.hxx index edb3db1b0f5d..438efcdb8f1d 100644 --- a/svtools/inc/svtools/grfmgr.hxx +++ b/svtools/inc/svtools/grfmgr.hxx @@ -38,11 +38,11 @@ #define GRFMGR_DRAW_NOTCACHED 0x00000000UL #define GRFMGR_DRAW_CACHED 0x00000001UL -#define GRFMGR_DRAW_BILINEAR 0x00000002UL +#define GRFMGR_DRAW_SMOOTHSCALE 0x00000002UL #define GRFMGR_DRAW_USE_DRAWMODE_SETTINGS 0x00000004UL #define GRFMGR_DRAW_SUBSTITUTE 0x00000008UL #define GRFMGR_DRAW_NO_SUBSTITUTE 0x00000010UL -#define GRFMGR_DRAW_STANDARD (GRFMGR_DRAW_CACHED|GRFMGR_DRAW_BILINEAR) +#define GRFMGR_DRAW_STANDARD (GRFMGR_DRAW_CACHED|GRFMGR_DRAW_SMOOTHSCALE) // -------------------- // - AutoSwap Defines - diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index 4e7da1ba59c2..6bf2bc52df72 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -344,34 +344,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; @@ -453,7 +426,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 { @@ -479,6 +467,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, |