[Libreoffice-commits] .: canvas/source cui/source filter/source framework/source sd/source sfx2/source svtools/source svx/source toolkit/source vcl/inc vcl/source

Lubos Lunak llunak at kemper.freedesktop.org
Fri Jun 22 08:40:32 PDT 2012


 canvas/source/vcl/canvasbitmaphelper.cxx                       |    2 +-
 canvas/source/vcl/canvashelper.cxx                             |    2 +-
 cui/source/dialogs/cuigrfflt.cxx                               |    2 +-
 filter/source/graphicfilter/eps/eps.cxx                        |    2 +-
 framework/source/fwe/classes/addonsoptions.cxx                 |    6 +++---
 framework/source/uielement/imagebuttontoolbarcontroller.cxx    |    2 +-
 sd/source/ui/dlg/dlgass.cxx                                    |    2 +-
 sd/source/ui/presenter/SlideRenderer.cxx                       |    2 +-
 sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx            |    2 +-
 sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx |    2 +-
 sd/source/ui/tools/PreviewRenderer.cxx                         |    2 +-
 sfx2/source/toolbox/tbxitem.cxx                                |    2 +-
 svtools/source/graphic/grfmgr2.cxx                             |   10 ++++------
 svx/source/gallery2/galobj.cxx                                 |    2 +-
 toolkit/source/awt/vclxmenu.cxx                                |    2 +-
 vcl/inc/vcl/bitmap.hxx                                         |    9 +++++++--
 vcl/inc/vcl/bitmapex.hxx                                       |    4 ++--
 vcl/source/gdi/bitmapex.cxx                                    |    2 +-
 vcl/source/gdi/pdfwriter_impl2.cxx                             |    2 +-
 vcl/source/helper/canvasbitmap.cxx                             |    2 +-
 20 files changed, 32 insertions(+), 29 deletions(-)

New commits:
commit ceb8b18f5b7437ba7438c428c3c78e4d8d67fee3
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Jun 22 17:19:12 2012 +0200

    use generic names rather than specific algorithm names when scaling
    
    The Lanczos scaling is of very good quality, but it's rather slow,
    which can be very noticeable with large images, so it's not a very
    good default for everything. And in general, it's not good to refer
    to a specific algorithm when all one usually wants is fast/default/best.
    
    Some of these changes are a bit of a guess between default/best,
    but the general logic is that best should be used only for images
    that won't be large or where the possible waiting does not matter.
    
    Change-Id: I53765507ecb7ed167890f6dd05e73fe53ffd0231

diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx
index cceaf7b..e86b629 100644
--- a/canvas/source/vcl/canvasbitmaphelper.cxx
+++ b/canvas/source/vcl/canvasbitmaphelper.cxx
@@ -129,7 +129,7 @@ namespace vclcanvas
         BitmapEx aRes( mpBackBuffer->getBitmapReference() );
 
         aRes.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
-                     beFast ? BMP_SCALE_FAST : BMP_SCALE_LANCZOS );
+                     beFast ? BMP_SCALE_FAST : BMP_SCALE_DEFAULT );
 
         return uno::Reference< rendering::XBitmap >(
             new CanvasBitmap( aRes, *mpDevice, mpOutDevReference ) );
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index ba36f40..7dc4751 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -927,7 +927,7 @@ namespace vclcanvas
         Bitmap aBitmap( rOutDev.GetBitmap(aEmptyPoint, aBmpSize) );
 
         aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
-                       beFast ? BMP_SCALE_FAST : BMP_SCALE_LANCZOS );
+                       beFast ? BMP_SCALE_FAST : BMP_SCALE_DEFAULT );
 
         return uno::Reference< rendering::XBitmap >(
             new CanvasBitmap( aBitmap, *mpDevice, mpOutDev ) );
diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx
index 0b846cb..310c54a 100644
--- a/cui/source/dialogs/cuigrfflt.cxx
+++ b/cui/source/dialogs/cuigrfflt.cxx
@@ -133,7 +133,7 @@ GraphicFilterDialog::GraphicFilterDialog( Window* pParent, const ResId& rResId,
         {
             BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
 
-            if( aBmpEx.Scale( aGrfSize, BMP_SCALE_LANCZOS ) )
+            if( aBmpEx.Scale( aGrfSize, BMP_SCALE_DEFAULT ) )
                 maGraphic = aBmpEx;
         }
     }
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index 4cb6509..8e2c2aa 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -499,7 +499,7 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview )
     {
         Size aSizeBitmap( ( aSizePoint.Width() + 7 ) & ~7, aSizePoint.Height() );
         Bitmap aTmpBitmap( pPreview->GetBitmap() );
-        aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_LANCZOS );
+        aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_BEST );
         aTmpBitmap.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
         BitmapReadAccess* pAcc = aTmpBitmap.AcquireReadAccess();
         if ( pAcc )
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index 844f109..f284d77 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -1358,13 +1358,13 @@ void AddonsOptions_Impl::ReadImageFromURL( ImageSize nImageSize, const ::rtl::OU
             if ( aBmpSize != aNoScaleSize )
             {
                 BitmapEx aNoScaleBmp( aBitmapEx );
-                aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_LANCZOS );
+                aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_BEST );
             }
             else
                 aImageNoScale = Image( aBitmapEx );
 
             if ( aBmpSize != aSize )
-                aBitmapEx.Scale( aSize, BMP_SCALE_LANCZOS );
+                aBitmapEx.Scale( aSize, BMP_SCALE_BEST );
 
             aImage = Image( aBitmapEx );
         }
@@ -1512,7 +1512,7 @@ sal_Bool AddonsOptions_Impl::CreateImageFromSequence( Image& rImage, sal_Bool bB
 
         // Scale bitmap to fit the correct size for the menu/toolbar. Use best quality
         if ( aBitmapEx.GetSizePixel() != aSize )
-            aBitmapEx.Scale( aSize, BMP_SCALE_LANCZOS );
+            aBitmapEx.Scale( aSize, BMP_SCALE_BEST );
 
         if( !aBitmapEx.IsTransparent() )
         {
diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
index a1a494a..3d47d4c 100644
--- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
@@ -214,7 +214,7 @@ sal_Bool ImageButtonToolbarController::ReadImageFromURL( sal_Bool bBigImage, con
         {
             ::Size aNoScaleSize( aBmpSize.Width(), aSize.Height() );
             if ( aBmpSize != aNoScaleSize )
-                aBitmapEx.Scale( aNoScaleSize, BMP_SCALE_LANCZOS );
+                aBitmapEx.Scale( aNoScaleSize, BMP_SCALE_BEST );
             aImage = Image( aBitmapEx );
             return sal_True;
         }
diff --git a/sd/source/ui/dlg/dlgass.cxx b/sd/source/ui/dlg/dlgass.cxx
index 9b780fe..cb41669 100644
--- a/sd/source/ui/dlg/dlgass.cxx
+++ b/sd/source/ui/dlg/dlgass.cxx
@@ -93,7 +93,7 @@ void InterpolateFixedBitmap( FixedBitmap * pBitmap )
 {
     Bitmap aBmp( pBitmap->GetBitmap() );
     Size aSize = pBitmap->GetSizePixel();
-    aBmp.Scale( aSize, BMP_SCALE_LANCZOS );
+    aBmp.Scale( aSize, BMP_SCALE_BEST );
     pBitmap->SetBitmap( aBmp );
 }
 
diff --git a/sd/source/ui/presenter/SlideRenderer.cxx b/sd/source/ui/presenter/SlideRenderer.cxx
index 5c3b4ba..1100d78 100644
--- a/sd/source/ui/presenter/SlideRenderer.cxx
+++ b/sd/source/ui/presenter/SlideRenderer.cxx
@@ -233,7 +233,7 @@ BitmapEx SlideRenderer::CreatePreview (
         BitmapEx aScaledPreview = aPreview.GetBitmapEx();
         aScaledPreview.Scale(
             Size(aPreviewSize.Width,aPreviewSize.Height),
-            BMP_SCALE_LANCZOS);
+            BMP_SCALE_BEST);
         return aScaledPreview;
     }
 }
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
index 503498c..2d901ef 100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
@@ -87,7 +87,7 @@ Bitmap BitmapFactory::CreateBitmap (
         false).GetBitmapEx().GetBitmap());
     if (bDoSuperSampling && gbAllowSuperSampling)
     {
-        aPreview.Scale(rPixelSize, BMP_SCALE_LANCZOS);
+        aPreview.Scale(rPixelSize, BMP_SCALE_BEST);
     }
 
     return aPreview;
diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
index 464f5cd..dec938a 100644
--- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
+++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
@@ -216,7 +216,7 @@ Point InsertionIndicatorOverlay::PaintRepresentatives (
         const Size aSuperSampleSize(
             aPreviewSize.Width()*gnSuperScaleFactor,
             aPreviewSize.Height()*gnSuperScaleFactor);
-        aPreview.Scale(aPreviewSize, BMP_SCALE_LANCZOS);
+        aPreview.Scale(aPreviewSize, BMP_SCALE_BEST);
         rContent.DrawBitmapEx(aPageOffset, aPreview);
 
         // When the page is marked as excluded from the slide show then
diff --git a/sd/source/ui/tools/PreviewRenderer.cxx b/sd/source/ui/tools/PreviewRenderer.cxx
index 4b831c2..bc1015b 100644
--- a/sd/source/ui/tools/PreviewRenderer.cxx
+++ b/sd/source/ui/tools/PreviewRenderer.cxx
@@ -512,7 +512,7 @@ Image PreviewRenderer::ScaleBitmap (
 
         // Paint the bitmap scaled to the desired width.
         BitmapEx aScaledBitmap (rBitmapEx.GetBitmap());
-        aScaledBitmap.Scale (aPreviewSize, BMP_SCALE_LANCZOS);
+        aScaledBitmap.Scale (aPreviewSize, BMP_SCALE_BEST);
         mpPreviewDevice->DrawBitmap (
             Point(1,1),
             aPreviewSize,
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index 478addb..137d080 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -1549,7 +1549,7 @@ void SfxAppToolBoxControl_Impl::SetImage( const String &rURL )
     if ( bBig && aImage.GetSizePixel() != aBigSize )
     {
         BitmapEx aScaleBmpEx( aImage.GetBitmapEx() );
-        aScaleBmpEx.Scale( aBigSize, BMP_SCALE_LANCZOS );
+        aScaleBmpEx.Scale( aBigSize, BMP_SCALE_BEST );
         GetToolBox().SetItemImage( GetId(), Image( aScaleBmpEx ) );
     }
     else
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index f4ab6ca..8c20523 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -428,7 +428,7 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut,
                 }
                 else if( nFlags & GRFMGR_DRAW_SMOOTHSCALE )
                 {
-                    // Scale using the Box filter, rather than this algorithm, as that one provides
+                    // Scale using Bitmap::Scale() rather than this algorithm, as that one provides
                     // better quality, while being somewhat slower (the result should be cached though).
                     aOutBmpEx = aBmpEx;
                     bRet = true;
@@ -438,8 +438,7 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut,
                     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 );
+                        bRet = aOutBmpEx.Scale( Size( nEndX - nStartX + 1, nEndY - nStartY + 1 ));
                 }
                 else
                 {
@@ -467,11 +466,10 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOut,
                         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
+                    // Scale using Bitmap::Scale() 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 );
+                        bRet = aOutBmpEx.Scale( Size( nEndX - nStartX + 1, nEndY - nStartY + 1 ));
                         if( bRet && ( bHMirr || bVMirr ))
                             bRet = aOutBmpEx.Mirror(( bHMirr ? BMP_MIRROR_HORZ : BMP_MIRROR_NONE )
                                     | ( bVMirr ? BMP_MIRROR_VERT : BMP_MIRROR_NONE ));
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index a05616f..945c23f 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -111,7 +111,7 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
                                       Max( (long) (fFactor < 1. ? S_THUMB : S_THUMB / fFactor), 8L ) );
 
                 if( aThumbBmp.Scale( (double) aNewSize.Width() / aBmpSize.Width(),
-                                     (double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_LANCZOS ) )
+                                     (double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_BEST ) )
                 {
                     aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
                     bRet = sal_True;
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index c0746a4..b12d795 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -678,7 +678,7 @@ namespace
 
                 sal_Bool bModified( sal_False );
                 BitmapEx aBitmapEx = aImage.GetBitmapEx();
-                bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_LANCZOS );
+                bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_BEST );
 
                 if ( bModified )
                     aImage = Image( aBitmapEx );
diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx
index 2fbe184..06f2bf1 100644
--- a/vcl/inc/vcl/bitmap.hxx
+++ b/vcl/inc/vcl/bitmap.hxx
@@ -54,6 +54,11 @@
 #define BMP_SCALE_BILINEAR          0x00000005UL
 #define BMP_SCALE_BOX               0x00000006UL
 
+// Aliases, try to use these two (or BMP_SCALE_FAST/BMP_SCALE_NONE),
+// use a specific algorithm only if you really need to.
+#define BMP_SCALE_BEST              BMP_SCALE_LANCZOS
+#define BMP_SCALE_DEFAULT           BMP_SCALE_BOX
+
 // -----------------------------------------------------------------------------
 
 #define BMP_DITHER_NONE             0x00000000UL
@@ -630,7 +635,7 @@ public:
         @return sal_True, if the operation was completed successfully.
      */
     sal_Bool                    Scale( const Size& rNewSize,
-                                   sal_uLong nScaleFlag = BMP_SCALE_LANCZOS );
+                                   sal_uLong nScaleFlag = BMP_SCALE_DEFAULT );
 
     /** Scale the bitmap
 
@@ -643,7 +648,7 @@ public:
         @return sal_True, if the operation was completed successfully.
      */
     sal_Bool                    Scale( const double& rScaleX, const double& rScaleY,
-                                   sal_uLong nScaleFlag = BMP_SCALE_LANCZOS );
+                                   sal_uLong nScaleFlag = BMP_SCALE_DEFAULT );
 
     /** Rotate bitmap by the specified angle
 
diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx
index f1f46d3..845981a 100644
--- a/vcl/inc/vcl/bitmapex.hxx
+++ b/vcl/inc/vcl/bitmapex.hxx
@@ -254,7 +254,7 @@ public:
 
         @return sal_True, if the operation was completed successfully.
      */
-    sal_Bool                Scale( const Size& rNewSize, sal_uLong nScaleFlag = BMP_SCALE_LANCZOS );
+    sal_Bool                Scale( const Size& rNewSize, sal_uLong nScaleFlag = BMP_SCALE_DEFAULT );
 
     /** Scale the bitmap
 
@@ -266,7 +266,7 @@ public:
 
         @return sal_True, if the operation was completed successfully.
      */
-    sal_Bool                Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag = BMP_SCALE_LANCZOS );
+    sal_Bool                Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag = BMP_SCALE_DEFAULT );
 
     /** Rotate bitmap by the specified angle
 
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 72c91e4..d1d4262 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -754,7 +754,7 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize
         }
 
         aScaledSize = Size( imgNewWidth, imgNewHeight );
-        aRet.Scale( aScaledSize, BMP_SCALE_LANCZOS );
+        aRet.Scale( aScaledSize, BMP_SCALE_BEST );
     }
     else
     {
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 3fc7fac..d7998c9 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -139,7 +139,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
                     aNewBmpSize.Height() = FRound( fMaxPixelX / fBmpWH);
                 }
                 if( aNewBmpSize.Width() && aNewBmpSize.Height() )
-                    aBitmapEx.Scale( aNewBmpSize, BMP_SCALE_LANCZOS );
+                    aBitmapEx.Scale( aNewBmpSize, BMP_SCALE_BEST );
                 else
                     aBitmapEx.SetEmpty();
             }
diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx
index 854dea4..b2f145d 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -460,7 +460,7 @@ uno::Reference< rendering::XBitmap > SAL_CALL VclCanvasBitmap::getScaledBitmap(
     SolarMutexGuard aGuard;
 
     BitmapEx aNewBmp( m_aBitmap );
-    aNewBmp.Scale( sizeFromRealSize2D( newSize ), beFast ? BMP_SCALE_FAST : BMP_SCALE_LANCZOS );
+    aNewBmp.Scale( sizeFromRealSize2D( newSize ), beFast ? BMP_SCALE_FAST : BMP_SCALE_DEFAULT );
     return uno::Reference<rendering::XBitmap>( new VclCanvasBitmap( aNewBmp ) );
 }
 


More information about the Libreoffice-commits mailing list