vcl: test BitmapAlphaClampFilter
Change-Id: Ie44884a3010cd26b057bac593059a4bd0a3aabc8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173345 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
393b1a5de4
commit
05c01410f3
@@ -10,12 +10,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <config_options.h>
|
|
||||||
#include <vcl/BitmapFilter.hxx>
|
#include <vcl/BitmapFilter.hxx>
|
||||||
|
|
||||||
/** If the alpha is beyond a certain threshold, make it fully transparent
|
/** If the alpha is beyond a certain threshold, make it fully transparent
|
||||||
*/
|
*/
|
||||||
class UNLESS_MERGELIBS(VCL_DLLPUBLIC) BitmapAlphaClampFilter final : public BitmapFilter
|
class VCL_DLLPUBLIC BitmapAlphaClampFilter final : public BitmapFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BitmapAlphaClampFilter(sal_uInt8 cThreshold)
|
BitmapAlphaClampFilter(sal_uInt8 cThreshold)
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include <tools/stream.hxx>
|
#include <tools/stream.hxx>
|
||||||
#include <vcl/graphicfilter.hxx>
|
#include <vcl/graphicfilter.hxx>
|
||||||
|
|
||||||
|
#include <vcl/BitmapAlphaClampFilter.hxx>
|
||||||
#include <vcl/BitmapArithmeticBlendFilter.hxx>
|
#include <vcl/BitmapArithmeticBlendFilter.hxx>
|
||||||
#include <vcl/BitmapDarkenBlendFilter.hxx>
|
#include <vcl/BitmapDarkenBlendFilter.hxx>
|
||||||
#include <vcl/BitmapLightenBlendFilter.hxx>
|
#include <vcl/BitmapLightenBlendFilter.hxx>
|
||||||
@@ -41,6 +42,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testClampAlpha();
|
||||||
void testBlurCorrectness();
|
void testBlurCorrectness();
|
||||||
void testBasicMorphology();
|
void testBasicMorphology();
|
||||||
void testPerformance();
|
void testPerformance();
|
||||||
@@ -53,6 +55,7 @@ public:
|
|||||||
void testArithmeticBlendFilter();
|
void testArithmeticBlendFilter();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(BitmapFilterTest);
|
CPPUNIT_TEST_SUITE(BitmapFilterTest);
|
||||||
|
CPPUNIT_TEST(testClampAlpha);
|
||||||
CPPUNIT_TEST(testBlurCorrectness);
|
CPPUNIT_TEST(testBlurCorrectness);
|
||||||
CPPUNIT_TEST(testBasicMorphology);
|
CPPUNIT_TEST(testBasicMorphology);
|
||||||
CPPUNIT_TEST(testPerformance);
|
CPPUNIT_TEST(testPerformance);
|
||||||
@@ -91,6 +94,22 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void BitmapFilterTest::testClampAlpha()
|
||||||
|
{
|
||||||
|
// Setup test bitmap
|
||||||
|
Size aSize(1, 1);
|
||||||
|
Bitmap aBitmap24Bit(aSize, vcl::PixelFormat::N24_BPP);
|
||||||
|
|
||||||
|
{
|
||||||
|
BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit);
|
||||||
|
aWriteAccess->Erase(COL_RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
BitmapEx aBitmapEx24Bit(aBitmap24Bit);
|
||||||
|
BitmapFilter::Filter(aBitmapEx24Bit, BitmapAlphaClampFilter(0x7F));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(0xFF), aBitmapEx24Bit.GetAlpha(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
void BitmapFilterTest::testBlurCorrectness()
|
void BitmapFilterTest::testBlurCorrectness()
|
||||||
{
|
{
|
||||||
// Setup test bitmap
|
// Setup test bitmap
|
||||||
|
Reference in New Issue
Block a user