Kaydet (Commit) 71cca07f authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Remove old scale convolution methods from Bitmap.

Change-Id: I0265a4b4c7b2fda267eb56ef719fd6a53d49d460
üst baebeb7d
......@@ -345,15 +345,6 @@ public:
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 );
SAL_DLLPRIVATE bool ImplTransformBilinearFiltering( const double& rScaleX, const double& rScaleY,
const Rectangle& rRotatedRectangle, const long nAngle10, const Color& rFillColor );
SAL_DLLPRIVATE static void ImplCalculateContributions( const int aSourceSize, const int aDestinationSize,
int& aNumberOfContributions, double*& pWeights, int*& pPixels, int*& pCount,
Kernel& aKernel );
SAL_DLLPRIVATE bool ImplConvolutionPass( Bitmap& aNewBitmap, const int nNewSize, BitmapReadAccess* pReadAcc,
int aNumberOfContributions, double* pWeights, int* pPixels, int* pCount );
......
......@@ -3396,109 +3396,6 @@ sal_Bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
return bRet;
}
bool Bitmap::ImplScaleConvolution( const double& rScaleX, const double& rScaleY, Kernel& aKernel )
{
const long nWidth = GetSizePixel().Width();
const long nHeight = GetSizePixel().Height();
const long nNewWidth = FRound( nWidth * rScaleX );
const long nNewHeight = FRound( nHeight * rScaleY );
bool bResult;
BitmapReadAccess* pReadAcc;
Bitmap aNewBitmap;
int aNumberOfContributions;
double* pWeights;
int* pPixels;
int* pCount;
// Handle negative scales safely cf. other ImplScale methods
if( ( nNewWidth < 1L ) || ( nNewHeight < 1L ) )
return false;
// Do horizontal filtering
ImplCalculateContributions( nWidth, nNewWidth, aNumberOfContributions, pWeights, pPixels, pCount, aKernel );
pReadAcc = AcquireReadAccess();
aNewBitmap = Bitmap( Size( nHeight, nNewWidth ), 24);
bResult = ImplConvolutionPass( aNewBitmap, nNewWidth, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount );
ReleaseAccess( pReadAcc );
delete[] pWeights;
delete[] pCount;
delete[] pPixels;
if ( !bResult )
return bResult;
// Swap Bitmaps
ImplAssignWithSize( aNewBitmap );
// Do vertical filtering
ImplCalculateContributions( nHeight, nNewHeight, aNumberOfContributions, pWeights, pPixels, pCount, aKernel );
pReadAcc = AcquireReadAccess();
aNewBitmap = Bitmap( Size( nNewWidth, nNewHeight ), 24);
bResult = ImplConvolutionPass( aNewBitmap, nNewHeight, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount );
ReleaseAccess( pReadAcc );
delete[] pWeights;
delete[] pCount;
delete[] pPixels;
if ( !bResult )
return bResult;
ImplAssignWithSize( aNewBitmap );
return true;
}
void Bitmap::ImplCalculateContributions( const int aSourceSize, const int aDestinationSize, int& aNumberOfContributions,
double*& pWeights, int*& pPixels, int*& pCount, Kernel& aKernel)
{
const double aSamplingRadius = aKernel.GetWidth();
const double aScale = aDestinationSize / (double) aSourceSize;
const double aScaledRadius = (aScale < 1.0) ? aSamplingRadius / aScale : aSamplingRadius;
const double aFilterFactor = (aScale < 1.0) ? aScale : 1.0;
aNumberOfContributions = (int) ( 2 * ceil(aScaledRadius) + 1 );
pWeights = new double[ aDestinationSize*aNumberOfContributions ];
pPixels = new int[ aDestinationSize*aNumberOfContributions ];
pCount = new int[ aDestinationSize ];
double aWeight, aCenter;
int aIndex, aLeft, aRight;
int aPixelIndex, aCurrentCount;
for ( int i = 0; i < aDestinationSize; i++ )
{
aIndex = i * aNumberOfContributions;
aCurrentCount = 0;
aCenter = i / aScale;
aLeft = (int) floor(aCenter - aScaledRadius);
aRight = (int) ceil (aCenter + aScaledRadius);
for ( int j = aLeft; j <= aRight; j++ )
{
aWeight = aKernel.Calculate( aFilterFactor * ( aCenter - (double) j ) );
// Reduce calculations with ignoring weights of 0.0
if (fabs(aWeight) < 0.0001)
continue;
// Handling on edges
aPixelIndex = MinMax( j, 0, aSourceSize - 1);
pWeights[ aIndex + aCurrentCount ] = aWeight;
pPixels[ aIndex + aCurrentCount ] = aPixelIndex;
aCurrentCount++;
}
pCount[ i ] = aCurrentCount;
}
}
bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, const int nNewSize, BitmapReadAccess* pReadAcc, int aNumberOfContributions, double* pWeights, int* pPixels, int* pCount)
{
BitmapWriteAccess* pWriteAcc = aNewBitmap.AcquireWriteAccess();
......
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