Kaydet (Commit) 4be8cc07 authored tarafından Armin Le Grand's avatar Armin Le Grand

Added ColorDepth change test with assertion to the Bitmap::Scale method

üst 61e12761
...@@ -906,10 +906,13 @@ sal_Bool Bitmap::ImplConvertGhosted() ...@@ -906,10 +906,13 @@ sal_Bool Bitmap::ImplConvertGhosted()
sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag ) sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag )
{ {
bool bRetval(false);
#ifdef DBG_UTIL #ifdef DBG_UTIL
// #121233# allow to test the different scalers in debug build with source // #121233# allow to test the different scalers in debug build with source
// level debugger (change nNumber to desired action) // level debugger (change nNumber to desired action)
static sal_uInt16 nNumber(0); static sal_uInt16 nNumber(0);
const sal_uInt16 nStartCount(GetBitCount());
switch(nNumber) switch(nNumber)
{ {
...@@ -929,7 +932,7 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong ...@@ -929,7 +932,7 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong
if(basegfx::fTools::equalZero(rScaleX) && basegfx::fTools::equalZero(rScaleY)) if(basegfx::fTools::equalZero(rScaleX) && basegfx::fTools::equalZero(rScaleY))
{ {
// no scale // no scale
return true; bRetval = true;
} }
else else
{ {
...@@ -949,17 +952,17 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong ...@@ -949,17 +952,17 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong
default: default:
case BMP_SCALE_NONE : case BMP_SCALE_NONE :
{ {
return false; bRetval = false;
break; break;
} }
case BMP_SCALE_FAST : case BMP_SCALE_FAST :
{ {
return ImplScaleFast( rScaleX, rScaleY ); bRetval = ImplScaleFast( rScaleX, rScaleY );
break; break;
} }
case BMP_SCALE_INTERPOLATE : case BMP_SCALE_INTERPOLATE :
{ {
return ImplScaleInterpolate( rScaleX, rScaleY ); bRetval = ImplScaleInterpolate( rScaleX, rScaleY );
break; break;
} }
case BMP_SCALE_SUPER : case BMP_SCALE_SUPER :
...@@ -967,12 +970,12 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong ...@@ -967,12 +970,12 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong
if(GetSizePixel().Width() < 2 || GetSizePixel().Height() < 2) if(GetSizePixel().Width() < 2 || GetSizePixel().Height() < 2)
{ {
// fallback to ImplScaleFast // fallback to ImplScaleFast
return ImplScaleFast( rScaleX, rScaleY ); bRetval = ImplScaleFast( rScaleX, rScaleY );
} }
else else
{ {
// #121233# use method from symphony // #121233# use method from symphony
return ImplScaleSuper( rScaleX, rScaleY ); bRetval = ImplScaleSuper( rScaleX, rScaleY );
} }
break; break;
} }
...@@ -980,35 +983,41 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong ...@@ -980,35 +983,41 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uLong
{ {
const Lanczos3Kernel kernel; const Lanczos3Kernel kernel;
return ImplScaleConvolution( rScaleX, rScaleY, kernel); bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel);
break; break;
} }
case BMP_SCALE_BICUBIC : case BMP_SCALE_BICUBIC :
{ {
const BicubicKernel kernel; const BicubicKernel kernel;
return ImplScaleConvolution( rScaleX, rScaleY, kernel ); bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel );
break; break;
} }
case BMP_SCALE_BILINEAR : case BMP_SCALE_BILINEAR :
{ {
const BilinearKernel kernel; const BilinearKernel kernel;
return ImplScaleConvolution( rScaleX, rScaleY, kernel ); bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel );
break; break;
} }
case BMP_SCALE_BOX : case BMP_SCALE_BOX :
{ {
const BoxKernel kernel; const BoxKernel kernel;
return ImplScaleConvolution( rScaleX, rScaleY, kernel ); bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel );
break; break;
} }
} }
} }
// should not happen #ifdef DBG_UTIL
return false; if(bRetval && nStartCount != GetBitCount())
{
OSL_ENSURE(false, "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
}
#endif
return bRetval;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment