1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <cppunit/TestAssert.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
13 #include <cppunit/plugin/TestPlugIn.h>
15 #include <vcl/bitmap.hxx>
16 #include <vcl/alpha.hxx>
18 #include <bitmap/BitmapDisabledImageFilter.hxx>
19 #include <vcl/BitmapWriteAccess.hxx>
23 class BitmapProcessorTest
: public CppUnit::TestFixture
25 void testDisabledImage();
27 CPPUNIT_TEST_SUITE(BitmapProcessorTest
);
28 CPPUNIT_TEST(testDisabledImage
);
29 CPPUNIT_TEST_SUITE_END();
32 void BitmapProcessorTest::testDisabledImage()
35 Bitmap
aBitmap(Size(3, 3), vcl::PixelFormat::N24_BPP
);
37 BitmapScopedWriteAccess
pWriteAccess(aBitmap
);
38 pWriteAccess
->Erase(Color(ColorTransparency
, 0x00, 0x00, 0xFF, 0x00));
40 BitmapEx
aBitmapEx(aBitmap
);
41 BitmapDisabledImageFilter aDisabledImageFilter
;
42 BitmapEx
aDisabledBitmapEx(aDisabledImageFilter
.execute(aBitmapEx
));
43 Bitmap
aDisabledBitmap(aDisabledBitmapEx
.GetBitmap());
45 BitmapScopedReadAccess
pReadAccess(aDisabledBitmap
);
46 Color
aColor(pReadAccess
->GetPixel(0, 0));
47 CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor
);
52 Bitmap
aBitmap(Size(3, 3), vcl::PixelFormat::N24_BPP
);
54 BitmapScopedWriteAccess
pWriteAccess(aBitmap
);
55 pWriteAccess
->Erase(Color(ColorTransparency
, 0x00, 0x00, 0xFF, 0x00));
57 AlphaMask
aMask(Size(3, 3));
59 BitmapScopedWriteAccess
pWriteAccess(aMask
);
60 pWriteAccess
->Erase(Color(ColorTransparency
, 0x00, 0xAA, 0xAA, 0xAA));
63 BitmapEx
aBitmapEx(aBitmap
, aMask
);
64 BitmapDisabledImageFilter aDisabledImageFilter
;
65 BitmapEx
aDisabledBitmapEx(aDisabledImageFilter
.execute(aBitmapEx
));
67 Bitmap
aDisabledBitmap(aDisabledBitmapEx
.GetBitmap());
69 BitmapScopedReadAccess
pReadAccess(aDisabledBitmap
);
70 Color
aColor(pReadAccess
->GetPixel(0, 0));
71 CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor
);
73 AlphaMask
aDisabledAlphaMask(aDisabledBitmapEx
.GetAlphaMask());
75 BitmapScopedReadAccess
pReadAccess(aDisabledAlphaMask
);
76 Color
aColor(pReadAccess
->GetPixel(0, 0));
77 CPPUNIT_ASSERT_EQUAL(Color(0x0000AA), aColor
);
84 CPPUNIT_TEST_SUITE_REGISTRATION(BitmapProcessorTest
);
86 CPPUNIT_PLUGIN_IMPLEMENT();
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */