Resolves: #i121233# Added bitmap scaling methods BMP_SCALE_SUPER

added from symphony, also BMP_SCALE_LANCZOS, BMP_SCALE_BICUBIC,
BMP_SCALE_BILINEAR and BMP_SCALE_BOX.

Changed defaults for internal scalings, enhanced PDF export when reduched DPI
is used, added BMP_SCALE_BESTQUALITY and BMP_SCALE_FASTESTINTERPOLATE as new
default for Bitmap::Scale

(cherry picked from commit bf734a151dc5169b65cf5d2a127e4142b765326c)

Conflicts:
	canvas/source/vcl/canvasbitmaphelper.cxx
	canvas/source/vcl/canvashelper.cxx
	sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
	vcl/inc/vcl/alpha.hxx
	vcl/inc/vcl/bitmap.hxx
	vcl/inc/vcl/bitmapex.hxx
	vcl/source/gdi/bitmap3.cxx
	vcl/source/gdi/impgraph.cxx
	vcl/source/gdi/pdfwriter_impl2.cxx
	vcl/source/helper/canvasbitmap.cxx

(cherry picked from commit 593c86280b64d97725adde0c0a0cc4f090fb2310)

Change-Id: I41cf0a7e11bdbc6510e22e762486420995ba739b
This commit is contained in:
Armin Le Grand 2012-10-29 16:20:25 +00:00 committed by Caolán McNamara
parent d6fd3fa6e8
commit 44fb0ceeb9
21 changed files with 1343 additions and 78 deletions

View File

@ -120,7 +120,7 @@ namespace vclcanvas
BitmapEx aRes( mpBackBuffer->getBitmapReference() );
aRes.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
beFast ? BMP_SCALE_FAST : BMP_SCALE_DEFAULT );
beFast ? BMP_SCALE_DEFAULT : BMP_SCALE_BESTQUALITY );
return uno::Reference< rendering::XBitmap >(
new CanvasBitmap( aRes, *mpDevice, mpOutDevReference ) );

View File

@ -942,7 +942,7 @@ namespace vclcanvas
Bitmap aBitmap( rOutDev.GetBitmap(aEmptyPoint, aBmpSize) );
aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
beFast ? BMP_SCALE_FAST : BMP_SCALE_DEFAULT );
beFast ? BMP_SCALE_DEFAULT : BMP_SCALE_BESTQUALITY );
return uno::Reference< rendering::XBitmap >(
new CanvasBitmap( aBitmap, *mpDevice, mpOutDev ) );

View File

@ -480,7 +480,7 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview )
{
Size aSizeBitmap( ( aSizePoint.Width() + 7 ) & ~7, aSizePoint.Height() );
Bitmap aTmpBitmap( pPreview->GetBitmap() );
aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_BEST );
aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_BESTQUALITY );
aTmpBitmap.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
BitmapReadAccess* pAcc = aTmpBitmap.AcquireReadAccess();
if ( pAcc )

View File

@ -1318,13 +1318,13 @@ void AddonsOptions_Impl::ReadImageFromURL( ImageSize nImageSize, const OUString&
if ( aBmpSize != aNoScaleSize )
{
BitmapEx aNoScaleBmp( aBitmapEx );
aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_BEST );
aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_BESTQUALITY );
}
else
aImageNoScale = Image( aBitmapEx );
if ( aBmpSize != aSize )
aBitmapEx.Scale( aSize, BMP_SCALE_BEST );
aBitmapEx.Scale( aSize, BMP_SCALE_BESTQUALITY );
aImage = Image( aBitmapEx );
}
@ -1472,7 +1472,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_BEST );
aBitmapEx.Scale( aSize, BMP_SCALE_BESTQUALITY );
if( !aBitmapEx.IsTransparent() )
{

View File

@ -188,7 +188,7 @@ sal_Bool ImageButtonToolbarController::ReadImageFromURL( sal_Bool bBigImage, con
{
::Size aNoScaleSize( aBmpSize.Width(), aSize.Height() );
if ( aBmpSize != aNoScaleSize )
aBitmapEx.Scale( aNoScaleSize, BMP_SCALE_BEST );
aBitmapEx.Scale( aNoScaleSize, BMP_SCALE_BESTQUALITY );
aImage = Image( aBitmapEx );
return sal_True;
}

View File

@ -35,15 +35,17 @@
#define BMP_SCALE_NONE 0x00000000UL
#define BMP_SCALE_FAST 0x00000001UL
#define BMP_SCALE_INTERPOLATE 0x00000002UL
#define BMP_SCALE_LANCZOS 0x00000003UL
#define BMP_SCALE_BICUBIC 0x00000004UL
#define BMP_SCALE_BILINEAR 0x00000005UL
#define BMP_SCALE_BOX 0x00000006UL
#define BMP_SCALE_SUPER 0x00000003UL
#define BMP_SCALE_LANCZOS 0x00000004UL
#define BMP_SCALE_BICUBIC 0x00000005UL
#define BMP_SCALE_BILINEAR 0x00000006UL
#define BMP_SCALE_BOX 0x00000007UL
// 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_SCALE_BESTQUALITY BMP_SCALE_LANCZOS
#define BMP_SCALE_DEFAULT BMP_SCALE_SUPER
#define BMP_DITHER_NONE 0x00000000UL
#define BMP_DITHER_MATRIX 0x00000001UL
@ -198,21 +200,21 @@ public:
Kernel () {}
virtual ~Kernel() {}
virtual double GetWidth() = 0;
virtual double Calculate( double x ) = 0;
virtual double GetWidth() const = 0;
virtual double Calculate( double x ) const = 0;
};
class Lanczos3Kernel : public Kernel
{
public:
virtual double GetWidth() { return 3.0; }
virtual double Calculate (double x)
virtual double GetWidth() const { return 3.0; }
virtual double Calculate (double x) const
{
return (-3.0 <= x && x < 3.0) ? SincFilter(x) * SincFilter( x / 3.0 ) : 0.0;
}
inline double SincFilter(double x)
inline double SincFilter(double x) const
{
if (x == 0.0)
{
@ -224,8 +226,8 @@ public:
};
class BicubicKernel : public Kernel {
virtual double GetWidth() { return 2.0; }
virtual double Calculate (double x)
virtual double GetWidth() const { return 2.0; }
virtual double Calculate (double x) const
{
if (x < 0.0)
{
@ -245,8 +247,8 @@ class BicubicKernel : public Kernel {
};
class BilinearKernel : public Kernel {
virtual double GetWidth() { return 1.0; }
virtual double Calculate (double x)
virtual double GetWidth() const { return 1.0; }
virtual double Calculate (double x) const
{
if (x < 0.0)
{
@ -261,8 +263,8 @@ class BilinearKernel : public Kernel {
};
class BoxKernel : public Kernel {
virtual double GetWidth() { return 0.5; }
virtual double Calculate (double x)
virtual double GetWidth() const { return 0.5; }
virtual double Calculate (double x) const
{
if (-0.5 <= x && x < 0.5)
return 1.0;
@ -328,8 +330,11 @@ public:
BitmapWriteAccess& rAcc, sal_Bool bRLE4 );
SAL_DLLPRIVATE static sal_Bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bRLE4 );
SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew);
SAL_DLLPRIVATE sal_Bool ImplScaleFast( const double& rScaleX, const double& rScaleY );
SAL_DLLPRIVATE sal_Bool ImplScaleInterpolate( const double& rScaleX, const double& rScaleY );
SAL_DLLPRIVATE sal_Bool ImplScaleSuper( const double& rScaleX, const double& rScaleY );
SAL_DLLPRIVATE sal_Bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, const Kernel& aKernel);
SAL_DLLPRIVATE bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, Kernel& aKernel);
SAL_DLLPRIVATE bool ImplTransformAveraging( const double& rScaleX, const double& rScaleY,
const Rectangle& rRotatedRectangle, const long nAngle10, const Color& rFillColor );

View File

@ -80,7 +80,7 @@ void InterpolateFixedBitmap( FixedBitmap * pBitmap )
{
Bitmap aBmp( pBitmap->GetBitmap() );
Size aSize = pBitmap->GetSizePixel();
aBmp.Scale( aSize, BMP_SCALE_BEST );
aBmp.Scale( aSize, BMP_SCALE_BESTQUALITY );
pBitmap->SetBitmap( aBmp );
}

View File

@ -223,7 +223,7 @@ BitmapEx SlideRenderer::CreatePreview (
BitmapEx aScaledPreview = aPreview.GetBitmapEx();
aScaledPreview.Scale(
Size(aPreviewSize.Width,aPreviewSize.Height),
BMP_SCALE_BEST);
BMP_SCALE_BESTQUALITY);
return aScaledPreview;
}
}

View File

@ -76,7 +76,7 @@ Bitmap BitmapFactory::CreateBitmap (
false).GetBitmapEx().GetBitmap());
if (bDoSuperSampling)
{
aPreview.Scale(rPixelSize, BMP_SCALE_BEST);
aPreview.Scale(rPixelSize, BMP_SCALE_BESTQUALITY);
}
return aPreview;

View File

@ -149,15 +149,15 @@ FramePainter::OffsetBitmap::OffsetBitmap (
const sal_Int32 nSideBitmapSize (64);
if (nHorizontalPosition == 0 && nVerticalPosition == 0)
{
maBitmap.Scale(Size(nSideBitmapSize,nSideBitmapSize), BMP_SCALE_FAST);
maBitmap.Scale(Size(nSideBitmapSize,nSideBitmapSize));
}
else if (nHorizontalPosition == 0)
{
maBitmap.Scale(Size(nSideBitmapSize,aSize.Height()), BMP_SCALE_FAST);
maBitmap.Scale(Size(nSideBitmapSize,aSize.Height()));
}
else if (nVerticalPosition == 0)
{
maBitmap.Scale(Size(maBitmap.GetSizePixel().Width(), nSideBitmapSize), BMP_SCALE_FAST);
maBitmap.Scale(Size(maBitmap.GetSizePixel().Width(), nSideBitmapSize));
}
}

View File

@ -207,7 +207,7 @@ Point InsertionIndicatorOverlay::PaintRepresentatives (
// Paint the preview.
Bitmap aPreview (rRepresentatives[nIndex].maBitmap);
aPreview.Scale(aPreviewSize, BMP_SCALE_BEST);
aPreview.Scale(aPreviewSize, BMP_SCALE_BESTQUALITY);
rContent.DrawBitmapEx(aPageOffset, aPreview);
// When the page is marked as excluded from the slide show then

View File

@ -501,7 +501,7 @@ Image PreviewRenderer::ScaleBitmap (
// Paint the bitmap scaled to the desired width.
BitmapEx aScaledBitmap (rBitmapEx.GetBitmap());
aScaledBitmap.Scale (aPreviewSize, BMP_SCALE_BEST);
aScaledBitmap.Scale (aPreviewSize, BMP_SCALE_BESTQUALITY);
mpPreviewDevice->DrawBitmap (
Point(1,1),
aPreviewSize,

View File

@ -1533,7 +1533,7 @@ void SfxAppToolBoxControl_Impl::SetImage( const String &rURL )
if ( bBig && aImage.GetSizePixel() != aBigSize )
{
BitmapEx aScaleBmpEx( aImage.GetBitmapEx() );
aScaleBmpEx.Scale( aBigSize, BMP_SCALE_BEST );
aScaleBmpEx.Scale( aBigSize, BMP_SCALE_BESTQUALITY );
GetToolBox().SetItemImage( GetId(), Image( aScaleBmpEx ) );
}
else

View File

@ -228,7 +228,7 @@ sal_uLong CompressGraphicsDialog::GetSelectedInterpolationType()
} else if ( aSelectionText == "None" ) {
return BMP_SCALE_FAST;
}
return BMP_SCALE_BEST;
return BMP_SCALE_BESTQUALITY;
}
void CompressGraphicsDialog::Compress(SvStream& aStream)

View File

@ -102,7 +102,7 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
std::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_BEST ) )
(double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_BESTQUALITY ) )
{
aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
bRet = sal_True;

View File

@ -664,7 +664,7 @@ namespace
sal_Bool bModified( sal_False );
BitmapEx aBitmapEx = aImage.GetBitmapEx();
bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_BEST );
bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_BESTQUALITY );
if ( bModified )
aImage = Image( aBitmapEx );

File diff suppressed because it is too large Load Diff

View File

@ -353,7 +353,9 @@ sal_Bool BitmapEx::Scale( const double& rScaleX, const double& rScaleY, sal_uLon
bRet = aBitmap.Scale( rScaleX, rScaleY, nScaleFlag );
if( bRet && ( eTransparent == TRANSPARENT_BITMAP ) && !!aMask )
aMask.Scale( rScaleX, rScaleY, BMP_SCALE_FAST );
{
aMask.Scale( rScaleX, rScaleY, nScaleFlag );
}
aBitmapSize = aBitmap.GetSizePixel();
@ -663,7 +665,7 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize
}
aScaledSize = Size( imgNewWidth, imgNewHeight );
aRet.Scale( aScaledSize, BMP_SCALE_BEST );
aRet.Scale( aScaledSize, BMP_SCALE_BESTQUALITY );
}
else
{

View File

@ -126,10 +126,16 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
aNewBmpSize.Width() = FRound( fMaxPixelX );
aNewBmpSize.Height() = FRound( fMaxPixelX / fBmpWH);
}
if( aNewBmpSize.Width() && aNewBmpSize.Height() )
aBitmapEx.Scale( aNewBmpSize, BMP_SCALE_BEST );
{
// #i121233# Use best quality for PDF exports
aBitmapEx.Scale( aNewBmpSize, BMP_SCALE_BESTQUALITY );
}
else
{
aBitmapEx.SetEmpty();
}
}
}

View File

@ -450,7 +450,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_DEFAULT );
aNewBmp.Scale( sizeFromRealSize2D( newSize ), beFast ? BMP_SCALE_DEFAULT : BMP_SCALE_BESTQUALITY );
return uno::Reference<rendering::XBitmap>( new VclCanvasBitmap( aNewBmp ) );
}

View File

@ -174,7 +174,7 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
else
{
Bitmap aPreviewBitmap(maPreviewBitmap);
aPreviewBitmap.Scale(maPreviewSize, BMP_SCALE_BEST);
aPreviewBitmap.Scale(maPreviewSize, BMP_SCALE_BESTQUALITY);
DrawBitmap(aOffset, aPreviewBitmap);
}