summaryrefslogtreecommitdiff
path: root/vcl/source
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-02-03 09:50:13 +0000
commit5781e575c6d0ad38f7eb591b88d4d588351247d0 (patch)
tree84aa2f06a0babc164a18c883f56cc5501c0b5731 /vcl/source
parent86df2b436d387ff1282089267e1837f17aff5cda (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 (cherry picked from commit 4b9ecfd4f45501e4696f966c714fc2bcc43ce38b) Reviewed-on: https://gerrit.libreoffice.org/14115 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/bitmap3.cxx21
-rw-r--r--vcl/source/gdi/bitmap4.cxx4
2 files changed, 16 insertions, 9 deletions
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 211516045adb..a99cd7705d2b 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 32ca3cc4412d..b995d0a1b021 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 );