Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi Tomaz,

On 2012-06-03 at 20:46 +0200, Quikee wrote:

I implemented Lanczos resampling for bug fdo#46378. Lanczos resampling
is a lot better than currently available resampling methods (FAST and
INTERPOLATE). Currently the lanczos resampling is only enabled for PDF
export.

Great stuff, thank you so much!  I've pushed that to master

http://cgit.freedesktop.org/libreoffice/core/commit/?id=47e0df5cebc05576e55210c5dd408a6f3eb91700

with some minor modifications:

- changed sal_Bool -> bool (we prefer the native bool in the new code)
- modified one method to be void (it always returned true)
- added your real name as the author (please set your git config \
  --global user.name)
- and reverted the _LANCZOS use for the PDF export for now - sorry for
  that; but I am afraid there must be a small glitch somewhere :-(

How did I find out; I told myself "let's be bold, and default to
Lanczos" ;-) - and tried with the attached 2 patches, but from some
reason the start screen looks like the attached "start.png" then - can
you please have a look?

Thank you so much for your work - if you can fix that, and ideally add a
unit test, or few, I am all for enabling it for 3.6 even a bit later as
a late feature; hopefully we might find 2 more approvals for that :-)

All the best,
Kendy
From acf4bad74a885c05bea074a641bad96da5b7dc89 Mon Sep 17 00:00:00 2001
From: Jan Holesovsky <kendy@suse.cz>
Date: Mon, 4 Jun 2012 14:47:18 +0200
Subject: [PATCH 2/3] Use BMP_SCALE_LANCZOS instead of BMP_SCALE_INTERPOLATE.

Where we explicitly ask for better quality, use BMP_SCALE_LANCZOS, instead of
BMP_SCALE_INTERPOLATE.

Change-Id: I28ddf3290204532a8660e09ee9ab0949b6ce1c73
---
 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     |    4 ++--
 .../uielement/imagebuttontoolbarcontroller.cxx     |    2 +-
 sd/source/ui/dlg/dlgass.cxx                        |    2 +-
 sd/source/ui/presenter/SlideRenderer.cxx           |    2 +-
 .../ui/slidesorter/cache/SlsBitmapFactory.cxx      |    2 +-
 .../view/SlsInsertionIndicatorOverlay.cxx          |    2 +-
 sd/source/ui/tools/PreviewRenderer.cxx             |    2 +-
 sfx2/source/toolbox/tbxitem.cxx                    |    2 +-
 svx/source/gallery2/galobj.cxx                     |    2 +-
 toolkit/source/awt/vclxmenu.cxx                    |    2 +-
 vcl/source/gdi/bitmapex.cxx                        |    2 +-
 vcl/source/helper/canvasbitmap.cxx                 |    2 +-
 16 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx
index 3032c18..cceaf7b 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_INTERPOLATE );
+                     beFast ? BMP_SCALE_FAST : BMP_SCALE_LANCZOS );
 
         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 83f3ccf..ba36f40 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_INTERPOLATE );
+                       beFast ? BMP_SCALE_FAST : BMP_SCALE_LANCZOS );
 
         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 21ccf63..c1b3ad4 100644
--- a/cui/source/dialogs/cuigrfflt.cxx
+++ b/cui/source/dialogs/cuigrfflt.cxx
@@ -126,7 +126,7 @@ GraphicFilterDialog::GraphicFilterDialog( Window* pParent, const ResId& rResId,
         {
             BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
 
-            if( aBmpEx.Scale( aGrfSize, BMP_SCALE_INTERPOLATE ) )
+            if( aBmpEx.Scale( aGrfSize, BMP_SCALE_LANCZOS ) )
                 maGraphic = aBmpEx;
         }
     }
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index 8a1410f..9350687 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_INTERPOLATE );
+        aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_LANCZOS );
         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 d1e488f..a6a29b5 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_INTERPOLATE );
+                aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_LANCZOS );
             }
             else
                 aImageNoScale = Image( aBitmapEx );
 
             if ( aBmpSize != aSize )
-                aBitmapEx.Scale( aSize, BMP_SCALE_INTERPOLATE );
+                aBitmapEx.Scale( aSize, BMP_SCALE_LANCZOS );
 
             aImage = Image( aBitmapEx );
         }
diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx 
b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
index 55f82dc..a1a494a 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_INTERPOLATE );
+                aBitmapEx.Scale( aNoScaleSize, BMP_SCALE_LANCZOS );
             aImage = Image( aBitmapEx );
             return sal_True;
         }
diff --git a/sd/source/ui/dlg/dlgass.cxx b/sd/source/ui/dlg/dlgass.cxx
index cd61216..8d0009c 100644
--- a/sd/source/ui/dlg/dlgass.cxx
+++ b/sd/source/ui/dlg/dlgass.cxx
@@ -92,7 +92,7 @@ void InterpolateFixedBitmap( FixedBitmap * pBitmap )
 {
     Bitmap aBmp( pBitmap->GetBitmap() );
     Size aSize = pBitmap->GetSizePixel();
-    aBmp.Scale( aSize, BMP_SCALE_INTERPOLATE );
+    aBmp.Scale( aSize, BMP_SCALE_LANCZOS );
     pBitmap->SetBitmap( aBmp );
 }
 
diff --git a/sd/source/ui/presenter/SlideRenderer.cxx b/sd/source/ui/presenter/SlideRenderer.cxx
index b7ce080..5c3b4ba 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_INTERPOLATE);
+            BMP_SCALE_LANCZOS);
         return aScaledPreview;
     }
 }
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx 
b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
index 871713c..503498c 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_INTERPOLATE);
+        aPreview.Scale(rPixelSize, BMP_SCALE_LANCZOS);
     }
 
     return aPreview;
diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx 
b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
index 6bde0447..464f5cd 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_INTERPOLATE);
+        aPreview.Scale(aPreviewSize, BMP_SCALE_LANCZOS);
         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 fb81193..4b831c2 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_INTERPOLATE);
+        aScaledBitmap.Scale (aPreviewSize, BMP_SCALE_LANCZOS);
         mpPreviewDevice->DrawBitmap (
             Point(1,1),
             aPreviewSize,
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index d288eef..d220e71 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -1550,7 +1550,7 @@ void SfxAppToolBoxControl_Impl::SetImage( const String &rURL )
     if ( bBig && aImage.GetSizePixel() != aBigSize )
     {
         BitmapEx aScaleBmpEx( aImage.GetBitmapEx() );
-        aScaleBmpEx.Scale( aBigSize, BMP_SCALE_INTERPOLATE );
+        aScaleBmpEx.Scale( aBigSize, BMP_SCALE_LANCZOS );
         GetToolBox().SetItemImage( GetId(), Image( aScaleBmpEx ) );
     }
     else
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index b2ca476..a05616f 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_INTERPOLATE ) )
+                                     (double) aNewSize.Height() / aBmpSize.Height(), 
BMP_SCALE_LANCZOS ) )
                 {
                     aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
                     bRet = sal_True;
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index d45d5dc..c629d67 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -680,7 +680,7 @@ namespace
 
                 sal_Bool bModified( sal_False );
                 BitmapEx aBitmapEx = aImage.GetBitmapEx();
-                bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_INTERPOLATE );
+                bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_LANCZOS );
 
                 if ( bModified )
                     aImage = Image( aBitmapEx );
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index f4e8e5b..72c91e4 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_INTERPOLATE );
+        aRet.Scale( aScaledSize, BMP_SCALE_LANCZOS );
     }
     else
     {
diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx
index a7aebc2..854dea4 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_INTERPOLATE 
);
+    aNewBmp.Scale( sizeFromRealSize2D( newSize ), beFast ? BMP_SCALE_FAST : BMP_SCALE_LANCZOS );
     return uno::Reference<rendering::XBitmap>( new VclCanvasBitmap( aNewBmp ) );
 }
 
-- 
1.7.8.3

From 0b1509fea0591cda70d64e6761373283b0574c7c Mon Sep 17 00:00:00 2001
From: Jan Holesovsky <kendy@suse.cz>
Date: Mon, 4 Jun 2012 15:02:45 +0200
Subject: [PATCH 3/3] Let's be bold, and default to the nice method when
 scaling.

[ie. use BMP_SCALE_FAST only where explicitly asked for.]

Change-Id: Ia5eccc786262216a803b989b073ffd9c1ed78377
---
 vcl/inc/vcl/bitmap.hxx   |    4 ++--
 vcl/inc/vcl/bitmapex.hxx |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx
index 14aae27..8b11318 100644
--- a/vcl/inc/vcl/bitmap.hxx
+++ b/vcl/inc/vcl/bitmap.hxx
@@ -538,7 +538,7 @@ public:
         @return sal_True, if the operation was completed successfully.
      */
     sal_Bool                    Scale( const Size& rNewSize,
-                                   sal_uLong nScaleFlag = BMP_SCALE_FAST );
+                                   sal_uLong nScaleFlag = BMP_SCALE_LANCZOS );
 
     /** Scale the bitmap
 
@@ -551,7 +551,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_FAST );
+                                   sal_uLong nScaleFlag = BMP_SCALE_LANCZOS );
 
     /** Rotate bitmap by the specified angle
 
diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx
index c9e4627..f1f46d3 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_FAST );
+    sal_Bool                Scale( const Size& rNewSize, sal_uLong nScaleFlag = BMP_SCALE_LANCZOS 
);
 
     /** 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_FAST );
+    sal_Bool                Scale( const double& rScaleX, const double& rScaleY, sal_uLong 
nScaleFlag = BMP_SCALE_LANCZOS );
 
     /** Rotate bitmap by the specified angle
 
-- 
1.7.8.3

Attachment: start.png
Description: PNG image


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.