summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-01-22 15:59:14 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-01-22 16:02:16 +0000
commit4b9ecfd4f45501e4696f966c714fc2bcc43ce38b (patch)
tree916532b551f8851ce2ba8b191fc3e0937edd2b17
parent134b523c425613848a2068f917c20a7a67fa0577 (diff)
Resolves: fdo#87639 Image-filter Smooth crashes
regression from commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Author: Thorsten Behrens <thb@documentfoundation.org> Date: Sun Nov 2 22:37:32 2014 +0100 coverity#1242508: swapped arguments rename the variables to indicate which are source and which are dest indexes and that the aNewBitmap argument is always, and assert that it must be, of equivalent rotated source to the Bitmap which has ImplConvolutionPass called on it. Change-Id: If9715b9f29655da66c6981c0f7cab3d89c528ed7
-rw-r--r--include/vcl/bitmap.hxx1
-rw-r--r--vcl/source/gdi/bitmap3.cxx21
-rw-r--r--vcl/source/gdi/bitmap4.cxx4
3 files changed, 16 insertions, 10 deletions
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 0fe2afa4eda1..25842c6d53e6 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -807,7 +807,6 @@ public:
SAL_DLLPRIVATE bool ImplConvolutionPass(
Bitmap& aNewBitmap,
- const int nNewSize,
BitmapReadAccess* pReadAcc,
int aNumberOfContributions,
double* pWeights,
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 83ce47fff5b0..2bd586f5f24c 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -2593,7 +2593,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
return bRet;
}
-bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, const int nNewSize, BitmapReadAccess* pReadAcc, int aNumberOfContributions, double* pWeights, int* pPixels, int* pCount)
+bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess* pReadAcc, int aNumberOfContributions, double* pWeights, int* pPixels, int* pCount)
{
BitmapWriteAccess* pWriteAcc = aNewBitmap.AcquireWriteAccess();
@@ -2601,25 +2601,28 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, const int nNewSize, BitmapR
return false;
const int nHeight = GetSizePixel().Height();
+ assert(GetSizePixel().Height() == aNewBitmap.GetSizePixel().Width());
+ const int nWidth = GetSizePixel().Width();
+ assert(GetSizePixel().Width() == aNewBitmap.GetSizePixel().Height());
BitmapColor aColor;
double aValueRed, aValueGreen, aValueBlue;
double aSum, aWeight;
int aBaseIndex, aIndex;
- for ( int y = 0; y < nHeight; y++ )
+ for (int nSourceY = 0; nSourceY < nHeight; ++nSourceY)
{
- for ( int x = 0; x < nNewSize; x++ )
+ for (int nSourceX = 0; nSourceX < nWidth; ++nSourceX)
{
- aBaseIndex = x * aNumberOfContributions;
+ aBaseIndex = nSourceX * aNumberOfContributions;
aSum = aValueRed = aValueGreen = aValueBlue = 0.0;
- for ( int j=0; j < pCount[x]; j++ )
+ for (int j = 0; j < pCount[nSourceX]; ++j)
{
aIndex = aBaseIndex + j;
aSum += aWeight = pWeights[ aIndex ];
- aColor = pReadAcc->GetColor( y, pPixels[ aIndex ] );
+ aColor = pReadAcc->GetColor(nSourceY, pPixels[aIndex]);
aValueRed += aWeight * aColor.GetRed();
aValueGreen += aWeight * aColor.GetGreen();
@@ -2630,7 +2633,11 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, const int nNewSize, BitmapR
(sal_uInt8) MinMax( aValueRed / aSum, 0, 255 ),
(sal_uInt8) MinMax( aValueGreen / aSum, 0, 255 ),
(sal_uInt8) MinMax( aValueBlue / aSum, 0, 255 ) );
- pWriteAcc->SetPixel( y, x, aResultColor );
+
+ int nDestX = nSourceY;
+ int nDestY = nSourceX;
+
+ pWriteAcc->SetPixel(nDestY, nDestX, aResultColor);
}
}
aNewBitmap.ReleaseAccess( pWriteAcc );
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index a18b9c26b71e..bb588b54d373 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -1099,7 +1099,7 @@ bool Bitmap::ImplSeparableBlurFilter(const double radius)
// switch coordinates as convolution pass transposes result
Bitmap aNewBitmap( Size( nHeight, nWidth ), 24 );
- bool bResult = ImplConvolutionPass( aNewBitmap, nWidth, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount );
+ bool bResult = ImplConvolutionPass( aNewBitmap, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount );
// Cleanup
ReleaseAccess( pReadAcc );
@@ -1121,7 +1121,7 @@ bool Bitmap::ImplSeparableBlurFilter(const double radius)
pReadAcc = AcquireReadAccess();
aNewBitmap = Bitmap( Size( nWidth, nHeight ), 24 );
- bResult = ImplConvolutionPass( aNewBitmap, nHeight, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount );
+ bResult = ImplConvolutionPass( aNewBitmap, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount );
// Cleanup
ReleaseAccess( pReadAcc );