[Libreoffice-commits] core.git: include/vcl vcl/source

Caolán McNamara caolanm at redhat.com
Thu Jan 22 08:04:18 PST 2015


 include/vcl/bitmap.hxx     |    1 -
 vcl/source/gdi/bitmap3.cxx |   21 ++++++++++++++-------
 vcl/source/gdi/bitmap4.cxx |    4 ++--
 3 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 4b9ecfd4f45501e4696f966c714fc2bcc43ce38b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 22 15:59:14 2015 +0000

    Resolves: fdo#87639 Image-filter Smooth crashes
    
    regression from
    
    commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae
    Author: Thorsten Behrens <thb at 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

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 0fe2afa..25842c6 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 83ce47f..2bd586f 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 a18b9c2..bb588b5 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 );


More information about the Libreoffice-commits mailing list