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

Armin Le Grand alg at apache.org
Thu Jan 16 01:34:26 PST 2014


 vcl/source/gdi/bitmapex.cxx |   74 +++++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 27 deletions(-)

New commits:
commit e7d5f5e3f0941ff2f0311845e84da87d7477c7b0
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Jan 15 15:27:52 2014 +0000

    Resolves: #i123690# handle the extremes Width or Height equal one
    
    (cherry picked from commit f3263e7b8bfe740f8e1e7825214e3936cc938ea9)
    
    Change-Id: I8d65ffa45ae69fe64826f8f49e4e6282b9db9807

diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 6deb1db..c9a0196 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -1239,53 +1239,73 @@ BitmapEx VCL_DLLPUBLIC createBlendFrame(
             long x(0);
             long y(0);
 
-            // x == 0, y == 0
-            pContent->SetPixel(y, x, aColorTopLeft);
-            pAlpha->SetPixelIndex(y, x, nAlpha);
+            // x == 0, y == 0, top-left corner
+            pContent->SetPixel(0, 0, aColorTopLeft);
+            pAlpha->SetPixelIndex(0, 0, nAlpha);
 
-            for(x = 1; x < nW - 1; x++) // y == 0
+            // y == 0, top line left to right
+            for(x = 1; x < nW - 1; x++)
             {
                 Color aMix(aColorTopLeft);
 
                 aMix.Merge(aColorTopRight, 255 - sal_uInt8((x * 255) / nW));
-                pContent->SetPixel(y, x, aMix);
-                pAlpha->SetPixelIndex(y, x, nAlpha);
+                pContent->SetPixel(0, x, aMix);
+                pAlpha->SetPixelIndex(0, x, nAlpha);
             }
 
-            // x == nW - 1, y == 0
-            pContent->SetPixel(y, x, aColorTopRight);
-            pAlpha->SetPixelIndex(y, x, nAlpha);
+            // x == nW - 1, y == 0, top-right corner
+            // #i123690# Caution! When nW is 1, x == nW is possible (!)
+            if(x < nW)
+            {
+                pContent->SetPixel(0, x, aColorTopRight);
+                pAlpha->SetPixelIndex(0, x, nAlpha);
+            }
 
-            for(y = 1; y < nH - 1; y++) // x == 0 and nW - 1
+            // x == 0 and nW - 1, left and right line top-down
+            for(y = 1; y < nH - 1; y++)
             {
                 Color aMixA(aColorTopLeft);
-                Color aMixB(aColorTopRight);
 
                 aMixA.Merge(aColorBottomLeft, 255 - sal_uInt8((y * 255) / nH));
                 pContent->SetPixel(y, 0, aMixA);
                 pAlpha->SetPixelIndex(y, 0, nAlpha);
 
-                aMixB.Merge(aColorBottomRight, 255 - sal_uInt8((y * 255) / nH));
-                pContent->SetPixel(y, nW - 1, aMixB);
-                pAlpha->SetPixelIndex(y, nW - 1, nAlpha);
-            }
+                // #i123690# Caution! When nW is 1, x == nW is possible (!)
+                if(x < nW)
+                {
+                    Color aMixB(aColorTopRight);
 
-            x = 0; // x == 0, y == nH - 1
-            pContent->SetPixel(y, x, aColorBottomLeft);
-            pAlpha->SetPixelIndex(y, x, nAlpha);
+                    aMixB.Merge(aColorBottomRight, 255 - sal_uInt8((y * 255) / nH));
+                    pContent->SetPixel(y, x, aMixB);
+                    pAlpha->SetPixelIndex(y, x, nAlpha);
+                }
+            }
 
-            for(x = 1; x < nW - 1; x++) // y == nH - 1
+            // #i123690# Caution! When nH is 1, y == nH is possible (!)
+            if(y < nH)
             {
-                Color aMix(aColorBottomLeft);
+                // x == 0, y == nH - 1, bottom-left corner
+                pContent->SetPixel(y, 0, aColorBottomLeft);
+                pAlpha->SetPixelIndex(y, 0, nAlpha);
 
-                aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - 0)* 255) / nW));
-                pContent->SetPixel(y, x, aMix);
-                pAlpha->SetPixelIndex(y, x, nAlpha);
-            }
+                // y == nH - 1, bottom line left to right
+                for(x = 1; x < nW - 1; x++)
+                {
+                    Color aMix(aColorBottomLeft);
+
+                    aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - 0)* 255) / nW));
+                    pContent->SetPixel(y, x, aMix);
+                    pAlpha->SetPixelIndex(y, x, nAlpha);
+                }
 
-            // x == nW - 1, y == nH - 1
-            pContent->SetPixel(y, x, aColorBottomRight);
-            pAlpha->SetPixelIndex(y, x, nAlpha);
+                // x == nW - 1, y == nH - 1, bottom-right corner
+                // #i123690# Caution! When nW is 1, x == nW is possible (!)
+                if(x < nW)
+                {
+                    pContent->SetPixel(y, x, aColorBottomRight);
+                    pAlpha->SetPixelIndex(y, x, nAlpha);
+                }
+            }
 
             aContent.ReleaseAccess(pContent);
             aAlpha.ReleaseAccess(pAlpha);


More information about the Libreoffice-commits mailing list