diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-15 14:49:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-16 10:07:07 +0100 |
commit | 63a68064bb33f180b8a231f7524d99405d910226 (patch) | |
tree | 7ecf05b057c5ca4d80a48af045998a4b34484561 /vcl/qa | |
parent | d534a4c7b45ff254b339e806c6a11f13d9ff0043 (diff) |
make the Color constructors explicitly specify transparency
to reduce the churn, we leave the existing constructor in place,
and add a clang plugin to detect when the value passed to the
existing constructor may contain transparency/alpha data.
i.e. we leave expressions like Color(0xffffff) alone, but
warn about any non-constant expression, and any expression
like Color(0xff000000)
Change-Id: Id2ce58e08882d9b7bd0b9f88eca97359dcdbcc8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109362
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/BitmapExTest.cxx | 12 | ||||
-rw-r--r-- | vcl/qa/cppunit/BitmapProcessorTest.cxx | 6 | ||||
-rw-r--r-- | vcl/qa/cppunit/BitmapTest.cxx | 14 | ||||
-rw-r--r-- | vcl/qa/cppunit/ScanlineToolsTest.cxx | 15 | ||||
-rw-r--r-- | vcl/qa/cppunit/bitmapcolor.cxx | 2 | ||||
-rw-r--r-- | vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 27 | ||||
-rw-r--r-- | vcl/qa/cppunit/png/PngFilterTest.cxx | 120 |
7 files changed, 118 insertions, 78 deletions
diff --git a/vcl/qa/cppunit/BitmapExTest.cxx b/vcl/qa/cppunit/BitmapExTest.cxx index 5e18b990f77d..5e0fe1dddfc6 100644 --- a/vcl/qa/cppunit/BitmapExTest.cxx +++ b/vcl/qa/cppunit/BitmapExTest.cxx @@ -37,17 +37,18 @@ void BitmapExTest::testGetPixelColor24_8() Bitmap aBitmap(Size(3, 3), 24); { BitmapScopedWriteAccess pWriteAccess(aBitmap); - pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00)); + pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0x00, 0xFF, 0x00)); } AlphaMask aMask(Size(3, 3)); { AlphaScopedWriteAccess pWriteAccess(aMask); - pWriteAccess->Erase(Color(0x00, 0xAA, 0xAA, 0xAA)); + pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0xAA, 0xAA, 0xAA)); } BitmapEx aBitmapEx(aBitmap, aMask); - CPPUNIT_ASSERT_EQUAL(Color(0xAA, 0x00, 0xFF, 0x00), aBitmapEx.GetPixelColor(0, 0)); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xAA, 0x00, 0xFF, 0x00), + aBitmapEx.GetPixelColor(0, 0)); } void BitmapExTest::testGetPixelColor32() @@ -61,12 +62,13 @@ void BitmapExTest::testGetPixelColor32() Bitmap aBitmap(Size(3, 3), 32); { BitmapScopedWriteAccess pWriteAccess(aBitmap); - pWriteAccess->Erase(Color(0xAA, 0x00, 0xFF, 0x00)); + pWriteAccess->Erase(Color(ColorTransparency, 0xAA, 0x00, 0xFF, 0x00)); } BitmapEx aBitmapEx(aBitmap); - CPPUNIT_ASSERT_EQUAL(Color(0xAA, 0x00, 0xFF, 0x00), aBitmapEx.GetPixelColor(0, 0)); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xAA, 0x00, 0xFF, 0x00), + aBitmapEx.GetPixelColor(0, 0)); } void BitmapExTest::testTransformBitmapEx() diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx index 2cc0cbe783d6..07e49b47ca1b 100644 --- a/vcl/qa/cppunit/BitmapProcessorTest.cxx +++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx @@ -35,7 +35,7 @@ void BitmapProcessorTest::testDisabledImage() Bitmap aBitmap(Size(3, 3), 24); { BitmapScopedWriteAccess pWriteAccess(aBitmap); - pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00)); + pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0x00, 0xFF, 0x00)); } BitmapEx aBitmapEx(aBitmap); BitmapDisabledImageFilter aDisabledImageFilter; @@ -52,12 +52,12 @@ void BitmapProcessorTest::testDisabledImage() Bitmap aBitmap(Size(3, 3), 24); { BitmapScopedWriteAccess pWriteAccess(aBitmap); - pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00)); + pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0x00, 0xFF, 0x00)); } AlphaMask aMask(Size(3, 3)); { AlphaScopedWriteAccess pWriteAccess(aMask); - pWriteAccess->Erase(Color(0x00, 0xAA, 0xAA, 0xAA)); + pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0xAA, 0xAA, 0xAA)); } BitmapEx aBitmapEx(aBitmap, aMask); diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 56395358863b..0c96977a880a 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -562,7 +562,7 @@ void BitmapTest::testErase() { Bitmap::ScopedReadAccess pReadAccess(aBitmap); BitmapColor aColor(pReadAccess->GetPixel(0, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x11, 0x22, 0x33, 0x00), aColor); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x11, 0x22, 0x33, 0x00), aColor); } } @@ -577,20 +577,20 @@ void BitmapTest::testBitmap32() Bitmap aBitmap(Size(3, 3), 32); { BitmapScopedWriteAccess pWriteAccess(aBitmap); - pWriteAccess->Erase(Color(0xFF, 0x11, 0x22, 0x33)); - pWriteAccess->SetPixel(1, 1, BitmapColor(0x44, 0xFF, 0xBB, 0x00)); - pWriteAccess->SetPixel(2, 2, BitmapColor(0x99, 0x77, 0x66, 0x55)); + pWriteAccess->Erase(Color(ColorTransparency, 0xFF, 0x11, 0x22, 0x33)); + pWriteAccess->SetPixel(1, 1, BitmapColor(ColorTransparency, 0x44, 0xFF, 0xBB, 0x00)); + pWriteAccess->SetPixel(2, 2, BitmapColor(ColorTransparency, 0x99, 0x77, 0x66, 0x55)); } { Bitmap::ScopedReadAccess pReadAccess(aBitmap); BitmapColor aColor = pReadAccess->GetPixel(0, 0); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x00, 0xFF), aColor); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x00, 0xFF), aColor); aColor = pReadAccess->GetPixel(1, 1); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x44, 0xFF, 0xBB, 0x00), aColor); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x44, 0xFF, 0xBB, 0x00), aColor); aColor = pReadAccess->GetPixel(2, 2); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x99, 0x77, 0x66, 0x55), aColor); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x99, 0x77, 0x66, 0x55), aColor); } } diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx b/vcl/qa/cppunit/ScanlineToolsTest.cxx index bf053d3bc890..c6751b827ca1 100644 --- a/vcl/qa/cppunit/ScanlineToolsTest.cxx +++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx @@ -42,8 +42,9 @@ void ScanlineToolsTest::ScanlineTransformer_32_ARGB() pScanlineTransformer->startLine(aScanLine.data()); std::vector<Color> aColors{ - Color(0, 10, 250, 120), Color(50, 30, 230, 110), Color(100, 50, 210, 100), - Color(150, 70, 190, 90), Color(200, 90, 170, 80), + Color(ColorTransparency, 0, 10, 250, 120), Color(ColorTransparency, 50, 30, 230, 110), + Color(ColorTransparency, 100, 50, 210, 100), Color(ColorTransparency, 150, 70, 190, 90), + Color(ColorTransparency, 200, 90, 170, 80), }; for (Color const& aColor : aColors) @@ -70,8 +71,9 @@ void ScanlineToolsTest::ScanlineTransformer_24_BGR() pScanlineTransformer->startLine(aScanLine.data()); std::vector<Color> aColors{ - Color(0, 10, 250, 120), Color(50, 30, 230, 110), Color(100, 50, 210, 100), - Color(150, 70, 190, 90), Color(200, 90, 170, 80), + Color(ColorTransparency, 0, 10, 250, 120), Color(ColorTransparency, 50, 30, 230, 110), + Color(ColorTransparency, 100, 50, 210, 100), Color(ColorTransparency, 150, 70, 190, 90), + Color(ColorTransparency, 200, 90, 170, 80), }; for (Color const& aColor : aColors) @@ -91,8 +93,9 @@ void ScanlineToolsTest::ScanlineTransformer_24_BGR() void ScanlineToolsTest::ScanlineTransformer_8bit_Palette() { std::vector<Color> aColors{ - Color(0, 10, 250, 120), Color(50, 30, 230, 110), Color(100, 50, 210, 100), - Color(150, 70, 190, 90), Color(200, 90, 170, 80), + Color(ColorTransparency, 0, 10, 250, 120), Color(ColorTransparency, 50, 30, 230, 110), + Color(ColorTransparency, 100, 50, 210, 100), Color(ColorTransparency, 150, 70, 190, 90), + Color(ColorTransparency, 200, 90, 170, 80), }; BitmapPalette aPalette(256); diff --git a/vcl/qa/cppunit/bitmapcolor.cxx b/vcl/qa/cppunit/bitmapcolor.cxx index 7329564d46c4..f62e19dabcd5 100644 --- a/vcl/qa/cppunit/bitmapcolor.cxx +++ b/vcl/qa/cppunit/bitmapcolor.cxx @@ -137,7 +137,7 @@ void BitmapColorTest::colorClassConstructor() // Transparency / Alpha { - BitmapColor aBmpColor(Color(255, 128, 64, 0)); + BitmapColor aBmpColor(Color(ColorTransparency, 255, 128, 64, 0)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(128), aBmpColor.GetRed()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(64), diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx index 201d10e56fd3..bbf8a38da0f6 100644 --- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx +++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx @@ -152,20 +152,23 @@ void BitmapRenderTest::testDrawAlphaBitmapEx() } // Check the bitmap has pixels we expect - CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0x00, 0x00, 0x00), aBitmapEx.GetPixelColor(0, 0)); - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0xFF, 0x00), aBitmapEx.GetPixelColor(1, 1)); - CPPUNIT_ASSERT_EQUAL(Color(0x7F, 0x00, 0xFF, 0x00), aBitmapEx.GetPixelColor(2, 2)); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xFF, 0x00, 0x00, 0x00), + aBitmapEx.GetPixelColor(0, 0)); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x00, 0xFF, 0xFF, 0x00), + aBitmapEx.GetPixelColor(1, 1)); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x7F, 0x00, 0xFF, 0x00), + aBitmapEx.GetPixelColor(2, 2)); pVDev->DrawBitmapEx(Point(), aBitmapEx); - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0xFF, 0xFF), pVDev->GetPixel(Point(0, 0))); - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0xFF, 0x00), pVDev->GetPixel(Point(1, 1))); + CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0xFF, 0xFF), pVDev->GetPixel(Point(0, 0))); + CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0xFF, 0x00), pVDev->GetPixel(Point(1, 1))); #if defined(_WIN32) || defined(MACOSX) || defined(IOS) // sometimes on Windows we get rounding error in blending so let's ignore this on Windows for now. - CPPUNIT_ASSERT_LESS(2, deltaColor(Color(0x00, 0x7F, 0xFF, 0x7F), pVDev->GetPixel(Point(2, 2)))); + CPPUNIT_ASSERT_LESS(2, deltaColor(Color(0x7F, 0xFF, 0x7F), pVDev->GetPixel(Point(2, 2)))); #else - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x7F, 0xFF, 0x7F), pVDev->GetPixel(Point(2, 2))); + CPPUNIT_ASSERT_EQUAL(Color(0x7F, 0xFF, 0x7F), pVDev->GetPixel(Point(2, 2))); #endif } @@ -211,14 +214,14 @@ void BitmapRenderTest::testAlphaVirtualDevice() #endif // Draw an semi-transparent pixel - pAlphaVirtualDevice->DrawPixel(Point(0, 0), Color(0x44, 0x22, 0xff, 0x55)); + pAlphaVirtualDevice->DrawPixel(Point(0, 0), Color(ColorTransparency, 0x44, 0x22, 0xff, 0x55)); aColor = pAlphaVirtualDevice->GetPixel(Point(0, 0)); // Read back the semi-transparent pixel #if defined _WIN32 - CPPUNIT_ASSERT_LESS(6, deltaColor(Color(0x4422FF55), aColor)); + CPPUNIT_ASSERT_LESS(6, deltaColor(Color(ColorTransparency, 0x4422FF55), aColor)); #else - CPPUNIT_ASSERT_EQUAL(Color(0x4422FF55), aColor); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x4422FF55), aColor); #endif // Read back the BitmapEx and check the semi-transparent pixel @@ -228,9 +231,9 @@ void BitmapRenderTest::testAlphaVirtualDevice() aColor = aBitmap.GetPixelColor(0, 0); #if defined _WIN32 - CPPUNIT_ASSERT_LESS(6, deltaColor(Color(0x4422FF55), aColor)); + CPPUNIT_ASSERT_LESS(6, deltaColor(Color(ColorTransparency, 0x4422FF55), aColor)); #else - CPPUNIT_ASSERT_EQUAL(Color(0x4422FF55), aColor); + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x4422FF55), aColor); #endif } diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 42a25652134f..28e6c719f6fd 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -70,15 +70,23 @@ void PngFilterTest::testPng() if (pAccess->GetBitCount() == 24 || pAccess->GetBitCount() == 32) { - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(0, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(3, 3)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(3, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(0, 3)); - - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x00, 0x00), pAccess->GetPixel(1, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x00, 0x00), pAccess->GetPixel(1, 2)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x00, 0x00), pAccess->GetPixel(2, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x00, 0x00), pAccess->GetPixel(2, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(0, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(3, 3)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(3, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(0, 3)); + + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x00, 0x00), + pAccess->GetPixel(1, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x00, 0x00), + pAccess->GetPixel(1, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x00, 0x00), + pAccess->GetPixel(2, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x00, 0x00), + pAccess->GetPixel(2, 2)); } else { @@ -102,15 +110,23 @@ void PngFilterTest::testPng() CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Height()); if (pAccess->GetBitCount() == 24 || pAccess->GetBitCount() == 32) { - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(0, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(3, 3)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(3, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(0, 3)); - - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0x00, 0x00, 0x00), pAccess->GetPixel(1, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0xFF, 0x00, 0x00), pAccess->GetPixel(1, 2)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0xFF, 0x00), pAccess->GetPixel(2, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0x00, 0x00), pAccess->GetPixel(2, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(0, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(3, 3)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(3, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(0, 3)); + + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0x00, 0x00, 0x00), + pAccess->GetPixel(1, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0xFF, 0x00, 0x00), + pAccess->GetPixel(1, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0xFF, 0x00), + pAccess->GetPixel(2, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0x00, 0x00), + pAccess->GetPixel(2, 2)); } else { @@ -134,15 +150,23 @@ void PngFilterTest::testPng() if (pAccess->GetBitCount() == 24) { - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(0, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(3, 3)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(3, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x00), pAccess->GetPixel(0, 3)); - - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0x00, 0x00, 0x00), pAccess->GetPixel(1, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0xFF, 0x00, 0x00), pAccess->GetPixel(1, 2)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0xFF, 0x00), pAccess->GetPixel(2, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0x00, 0x00), pAccess->GetPixel(2, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(0, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(3, 3)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(3, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x00), + pAccess->GetPixel(0, 3)); + + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0x00, 0x00, 0x00), + pAccess->GetPixel(1, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0xFF, 0x00, 0x00), + pAccess->GetPixel(1, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0xFF, 0x00), + pAccess->GetPixel(2, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0x00, 0x00), + pAccess->GetPixel(2, 2)); AlphaMask aAlpha = aBitmapEx.GetAlpha(); { @@ -151,36 +175,44 @@ void PngFilterTest::testPng() CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAlphaAccess->Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAlphaAccess->Height()); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x80, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x80, 0x00), pAlphaAccess->GetPixel(0, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x80, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x80, 0x00), pAlphaAccess->GetPixel(3, 3)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x80, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x80, 0x00), pAlphaAccess->GetPixel(3, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x80, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x80, 0x00), pAlphaAccess->GetPixel(0, 3)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x40, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x40, 0x00), pAlphaAccess->GetPixel(1, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0xC0, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0xC0, 0x00), pAlphaAccess->GetPixel(1, 2)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0xC0, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0xC0, 0x00), pAlphaAccess->GetPixel(2, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0x40, 0x00), + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x40, 0x00), pAlphaAccess->GetPixel(2, 2)); } } else if (pAccess->GetBitCount() == 32) { - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x80), pAccess->GetPixel(0, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x80), pAccess->GetPixel(3, 3)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x80), pAccess->GetPixel(3, 0)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0xFF, 0x80), pAccess->GetPixel(0, 3)); - - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0x00, 0x00, 0x40), pAccess->GetPixel(1, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0xFF, 0x00, 0xC0), pAccess->GetPixel(1, 2)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0x00, 0xFF, 0xC0), pAccess->GetPixel(2, 1)); - CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xFF, 0x00, 0x40), pAccess->GetPixel(2, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x80), + pAccess->GetPixel(0, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x80), + pAccess->GetPixel(3, 3)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x80), + pAccess->GetPixel(3, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0xFF, 0x80), + pAccess->GetPixel(0, 3)); + + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0x00, 0x00, 0x40), + pAccess->GetPixel(1, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0xFF, 0x00, 0xC0), + pAccess->GetPixel(1, 2)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0xFF, 0xC0), + pAccess->GetPixel(2, 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0xFF, 0xFF, 0x00, 0x40), + pAccess->GetPixel(2, 2)); } else { |