nss: upgrade to release 3.73
[LibreOffice.git] / vcl / qa / cppunit / BitmapProcessorTest.cxx
blobe7793cf0a67fee54345c7ed74afb99afff460db9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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/bitmapaccess.hxx>
17 #include <vcl/alpha.hxx>
19 #include <BitmapDisabledImageFilter.hxx>
20 #include <bitmapwriteaccess.hxx>
22 namespace
24 class BitmapProcessorTest : public CppUnit::TestFixture
26 void testDisabledImage();
28 CPPUNIT_TEST_SUITE(BitmapProcessorTest);
29 CPPUNIT_TEST(testDisabledImage);
30 CPPUNIT_TEST_SUITE_END();
33 void BitmapProcessorTest::testDisabledImage()
36 Bitmap aBitmap(Size(3, 3), 24);
38 BitmapScopedWriteAccess pWriteAccess(aBitmap);
39 pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00));
41 BitmapEx aBitmapEx(aBitmap);
42 BitmapDisabledImageFilter aDisabledImageFilter;
43 BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx));
44 Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap());
46 Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap);
47 Color aColor(pReadAccess->GetPixel(0, 0));
48 CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor);
53 Bitmap aBitmap(Size(3, 3), 24);
55 BitmapScopedWriteAccess pWriteAccess(aBitmap);
56 pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00));
58 AlphaMask aMask(Size(3, 3));
60 AlphaScopedWriteAccess pWriteAccess(aMask);
61 pWriteAccess->Erase(Color(0x00, 0xAA, 0xAA, 0xAA));
64 BitmapEx aBitmapEx(aBitmap, aMask);
65 BitmapDisabledImageFilter aDisabledImageFilter;
66 BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx));
68 Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap());
70 Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap);
71 Color aColor(pReadAccess->GetPixel(0, 0));
72 CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor);
74 AlphaMask aDisabledAlphaMask(aDisabledBitmapEx.GetAlpha());
76 AlphaMask::ScopedReadAccess pReadAccess(aDisabledAlphaMask);
77 Color aColor(pReadAccess->GetPixel(0, 0));
78 CPPUNIT_ASSERT_EQUAL(Color(0x0000AA), aColor);
83 } // namespace
85 CPPUNIT_TEST_SUITE_REGISTRATION(BitmapProcessorTest);
87 CPPUNIT_PLUGIN_IMPLEMENT();
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */