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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 8 16:21:30 UTC 2021


 include/vcl/BitmapColor.hxx                     |   13 ----------
 vcl/qa/cppunit/BitmapScaleTest.cxx              |    2 -
 vcl/qa/cppunit/BitmapTest.cxx                   |    2 -
 vcl/qa/cppunit/bitmapcolor.cxx                  |   31 ++++++++++++------------
 vcl/source/bitmap/BitmapDisabledImageFilter.cxx |    2 -
 vcl/source/bitmap/BitmapReadAccess.cxx          |    8 +++---
 vcl/source/bitmap/BitmapTools.cxx               |    2 -
 7 files changed, 24 insertions(+), 36 deletions(-)

New commits:
commit 6911375ab66df6fd4cb2b922ea1c9e57b4fcd3b2
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Jan 8 13:45:05 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 8 17:20:48 2021 +0100

    Remove BitmapColor::GetAlpha
    
    since its implementation is completely wrong - alpha and transparency
    are not the same thing, they are inverses of each other.
    
    Change-Id: Id9e00b8296391befd471345b6c86e0493a9e3f3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108964
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/BitmapColor.hxx b/include/vcl/BitmapColor.hxx
index 0ae0370455a9..634ae6902d27 100644
--- a/include/vcl/BitmapColor.hxx
+++ b/include/vcl/BitmapColor.hxx
@@ -34,9 +34,6 @@ public:
 
     inline sal_uInt8    GetIndex() const;
     inline void         SetIndex( sal_uInt8 cIndex );
-
-    inline sal_uInt8    GetAlpha() const;
-    inline void         SetAlpha( sal_uInt8 cAlpha );
 };
 
 inline BitmapColor::BitmapColor()
@@ -68,16 +65,6 @@ inline void BitmapColor::SetIndex( sal_uInt8 cIndex )
     SetBlue(cIndex);
 }
 
-inline sal_uInt8 BitmapColor::GetAlpha() const
-{
-    return GetTransparency();
-}
-
-inline void BitmapColor::SetAlpha( sal_uInt8 cAlpha )
-{
-    SetTransparency(cAlpha);
-}
-
 #endif // INCLUDED_VCL_BITMAPCOLOR_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx
index 09ec8f9a3728..285799e2da52 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -64,7 +64,7 @@ void assertColorsAreSimilar(int maxDifference, const std::string& message,
     if (abs(expected.GetRed() - actual.GetRed()) <= maxDifference
         && abs(expected.GetGreen() - actual.GetGreen()) <= maxDifference
         && abs(expected.GetBlue() - actual.GetBlue()) <= maxDifference
-        && abs(expected.GetAlpha() - actual.GetAlpha()) <= maxDifference)
+        && abs(expected.GetTransparency() - actual.GetTransparency()) <= maxDifference)
     {
         return;
     }
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 56395358863b..c2f2b592309f 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -73,7 +73,7 @@ void assertColorsAreSimilar(int maxDifference, const std::string& message,
     if (abs(expected.GetRed() - actual.GetRed()) <= maxDifference
         && abs(expected.GetGreen() - actual.GetGreen()) <= maxDifference
         && abs(expected.GetBlue() - actual.GetBlue()) <= maxDifference
-        && abs(expected.GetAlpha() - actual.GetAlpha()) <= maxDifference)
+        && abs(expected.GetTransparency() - actual.GetTransparency()) <= maxDifference)
     {
         return;
     }
diff --git a/vcl/qa/cppunit/bitmapcolor.cxx b/vcl/qa/cppunit/bitmapcolor.cxx
index eafa4d13805c..58d889a3d8a5 100644
--- a/vcl/qa/cppunit/bitmapcolor.cxx
+++ b/vcl/qa/cppunit/bitmapcolor.cxx
@@ -56,7 +56,8 @@ void BitmapColorTest::defaultConstructor()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(0), aBmpColor.GetRed());
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen());
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), aBmpColor.GetAlpha());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                 aBmpColor.GetTransparency());
 }
 
 void BitmapColorTest::colorValueConstructor()
@@ -68,8 +69,8 @@ void BitmapColorTest::colorValueConstructor()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0),
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                     aBmpColor.GetTransparency());
     }
 
     {
@@ -80,8 +81,8 @@ void BitmapColorTest::colorValueConstructor()
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(128),
                                      aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                     aBmpColor.GetTransparency());
     }
 
     {
@@ -92,8 +93,8 @@ void BitmapColorTest::colorValueConstructor()
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255),
                                      aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                     aBmpColor.GetTransparency());
     }
 }
 
@@ -106,8 +107,8 @@ void BitmapColorTest::colorClassConstructor()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0),
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                     aBmpColor.GetTransparency());
     }
 
     {
@@ -118,8 +119,8 @@ void BitmapColorTest::colorClassConstructor()
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(127),
                                      aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                     aBmpColor.GetTransparency());
     }
 
     {
@@ -130,8 +131,8 @@ void BitmapColorTest::colorClassConstructor()
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255),
                                      aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0),
+                                     aBmpColor.GetTransparency());
     }
 
     // Transparency / Alpha
@@ -142,8 +143,8 @@ void BitmapColorTest::colorClassConstructor()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(64),
                                      aBmpColor.GetGreen());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(255),
-                                     aBmpColor.GetAlpha());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255),
+                                     aBmpColor.GetTransparency());
     }
 }
 
diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
index 25f32d69f0c6..47e6527953ed 100644
--- a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
+++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
@@ -40,7 +40,7 @@ BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx) const
                 // Get the luminance from RGB color and remap the value from 0-255 to 160-224
                 const BitmapColor aColor = pRead->GetPixelFromData(pReadScan, nX);
                 sal_uInt8 nLum(aColor.GetLuminance() / 4 + 160);
-                BitmapColor aGreyValue(nLum, nLum, nLum, aColor.GetAlpha());
+                BitmapColor aGreyValue(nLum, nLum, nLum, aColor.GetTransparency());
                 pGrey->SetPixelOnData(pGreyScan, nX, aGreyValue);
             }
         }
diff --git a/vcl/source/bitmap/BitmapReadAccess.cxx b/vcl/source/bitmap/BitmapReadAccess.cxx
index 9b5218065a3c..29df1f28c3b6 100644
--- a/vcl/source/bitmap/BitmapReadAccess.cxx
+++ b/vcl/source/bitmap/BitmapReadAccess.cxx
@@ -427,7 +427,7 @@ void BitmapReadAccess::SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long n
 {
     pScanline = pScanline + nX * 4;
 
-    sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+    sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency();
     *pScanline++ = alpha;
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
@@ -476,7 +476,7 @@ void BitmapReadAccess::SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long n
 {
     pScanline = pScanline + nX * 4;
 
-    sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+    sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency();
     *pScanline++ = alpha;
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
@@ -525,7 +525,7 @@ void BitmapReadAccess::SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long n
 {
     pScanline = pScanline + nX * 4;
 
-    sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+    sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency();
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
@@ -574,7 +574,7 @@ void BitmapReadAccess::SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long n
 {
     pScanline = pScanline + nX * 4;
 
-    sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+    sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency();
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
     *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 3d2ee474554f..3c654aaf6980 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -1101,7 +1101,7 @@ bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult)
             {
                 const BitmapColor aColor = pReadAccess->GetPixelFromData(aReadScan, nX);
                 BitmapColor aResultColor(aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue());
-                BitmapColor aResultColorAlpha(aColor.GetAlpha(), aColor.GetAlpha(), aColor.GetAlpha());
+                BitmapColor aResultColorAlpha(aColor.GetTransparency(), aColor.GetTransparency(), aColor.GetTransparency());
 
                 pResultBitmapAccess->SetPixelOnData(aResultScan, nX, aResultColor);
                 pResultAlphaAccess->SetPixelOnData(aResultScanAlpha, nX, aResultColorAlpha);


More information about the Libreoffice-commits mailing list