diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-01-22 15:59:14 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-22 16:02:16 +0000 |
commit | 4b9ecfd4f45501e4696f966c714fc2bcc43ce38b (patch) | |
tree | 916532b551f8851ce2ba8b191fc3e0937edd2b17 /vcl/source/gdi/bitmap3.cxx | |
parent | 134b523c425613848a2068f917c20a7a67fa0577 (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
Diffstat (limited to 'vcl/source/gdi/bitmap3.cxx')
-rw-r--r-- | vcl/source/gdi/bitmap3.cxx | 21 |
1 files changed, 14 insertions, 7 deletions
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 ); |