calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / BitmapProcessorTest.cxx
blobb855aa146ed804ce044e3d52e3fcbbbce0c9eece
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/alpha.hxx>
18 #include <bitmap/BitmapDisabledImageFilter.hxx>
19 #include <bitmap/BitmapWriteAccess.hxx>
21 namespace
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 Bitmap::ScopedReadAccess 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 AlphaScopedWriteAccess 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 Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap);
70 Color aColor(pReadAccess->GetPixel(0, 0));
71 CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor);
73 AlphaMask aDisabledAlphaMask(aDisabledBitmapEx.GetAlpha());
75 AlphaMask::ScopedReadAccess pReadAccess(aDisabledAlphaMask);
76 Color aColor(pReadAccess->GetPixel(0, 0));
77 CPPUNIT_ASSERT_EQUAL(Color(0x0000AA), aColor);
82 } // namespace
84 CPPUNIT_TEST_SUITE_REGISTRATION(BitmapProcessorTest);
86 CPPUNIT_PLUGIN_IMPLEMENT();
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */