summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-06-22 17:19:12 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-06-22 17:40:09 +0200
commitceb8b18f5b7437ba7438c428c3c78e4d8d67fee3 (patch)
treed37c8b63df0d31eceabb9976bc0a642699b9e658
parent7cb232e6ee80994cf1f8cb17d34e09eb98fdabc7 (diff)
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
-rw-r--r--canvas/source/vcl/canvasbitmaphelper.cxx2
-rw-r--r--canvas/source/vcl/canvashelper.cxx2
-rw-r--r--cui/source/dialogs/cuigrfflt.cxx2
-rw-r--r--filter/source/graphicfilter/eps/eps.cxx2
-rw-r--r--framework/source/fwe/classes/addonsoptions.cxx6
-rw-r--r--framework/source/uielement/imagebuttontoolbarcontroller.cxx2
-rw-r--r--sd/source/ui/dlg/dlgass.cxx2
-rw-r--r--sd/source/ui/presenter/SlideRenderer.cxx2
-rw-r--r--sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx2
-rw-r--r--sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx2
-rw-r--r--sd/source/ui/tools/PreviewRenderer.cxx2
-rw-r--r--sfx2/source/toolbox/tbxitem.cxx2
-rw-r--r--svtools/source/graphic/grfmgr2.cxx10
-rw-r--r--svx/source/gallery2/galobj.cxx2
-rw-r--r--toolkit/source/awt/vclxmenu.cxx2
-rw-r--r--vcl/inc/vcl/bitmap.hxx9
-rw-r--r--vcl/inc/vcl/bitmapex.hxx4
-rw-r--r--vcl/source/gdi/bitmapex.cxx2
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx2
-rw-r--r--vcl/source/helper/canvasbitmap.cxx2
20 files changed, 32 insertions, 29 deletions
diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx
index cceaf7b93b9a..e86b629acfbc 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 ba36f4082fa1..7dc47519682c 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 0b846cbdea32..310c54ad5e3e 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 4cb6509e2aad..8e2c2aa0b7c1 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 844f109af0ce..f284d77688a4 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 a1a494ab4177..3d47d4c4d2c8 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 9b780fe833d3..cb41669f0781 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 5c3b4ba8804a..1100d78c43cc 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 503498ceec5b..2d901efae1ce 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 464f5cdd13c0..dec938a25d8b 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 4b831c2c4894..bc1015b26483 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 478addb99c7d..137d08015e72 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 f4ab6ca32971..8c2052367db4 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 a05616f28fa2..945c23f121de 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 c0746a45d9ad..b12d79510ab1 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 2fbe1848c427..06f2bf1b7ae0 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 f1f46d3aec35..845981aa5c1e 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 72c91e43003f..d1d42629f7b1 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 3fc7fac69b14..d7998c9b1264 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 854dea4dfaac..b2f145de07c5 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 ) );
}