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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // autogenerated file with codegen.pl
22 #include "cppunit/TestAssert.h"
23 #include "cppunit/TestFixture.h"
24 #include "cppunit/extensions/HelperMacros.h"
26 #include <basegfx/vector/b2isize.hxx>
27 #include <basegfx/range/b2ibox.hxx>
28 #include <basegfx/point/b2ipoint.hxx>
29 #include <basegfx/polygon/b2dpolygon.hxx>
30 #include <basegfx/polygon/b2dpolygontools.hxx>
31 #include <basegfx/polygon/b2dpolypolygon.hxx>
32 #include <basegfx/polygon/b2dpolypolygontools.hxx>
34 #include <basebmp/color.hxx>
35 #include <basebmp/scanlineformats.hxx>
36 #include <basebmp/bitmapdevice.hxx>
39 using namespace ::basebmp
;
43 class BmpMaskTest
: public CppUnit::TestFixture
46 BitmapDeviceSharedPtr mpDevice1bpp
;
47 BitmapDeviceSharedPtr mpMaskBmp1bpp
;
48 BitmapDeviceSharedPtr mpBmp1bpp
;
49 BitmapDeviceSharedPtr mpDevice32bpp
;
50 BitmapDeviceSharedPtr mpBmp32bpp
;
52 void implTestBmpBasics(const BitmapDeviceSharedPtr
& rDevice
,
53 const BitmapDeviceSharedPtr
& rBmp
)
55 rDevice
->clear(Color(0));
56 const Color
aCol(0xFFFFFFFF);
58 const basegfx::B2IBox
aSourceRect(0,0,10,10);
59 const basegfx::B2IBox
aDestAll(0,0,10,10);
61 rDevice
->drawMaskedBitmap(
67 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 30",
68 countPixel( rDevice
, aCol
) == 30);
71 void implTestBmpScaledClip(const BitmapDeviceSharedPtr
& rDevice
,
72 const BitmapDeviceSharedPtr
& rBmp
)
74 rDevice
->clear(Color(0));
75 const Color
aCol(0xFFFFFFFF);
77 const basegfx::B2IBox
aSourceRect(0,0,10,10);
78 const basegfx::B2IBox
aDestLeftTop(0,0,6,6);
80 rDevice
->drawMaskedBitmap(
86 CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 12",
87 countPixel( rDevice
, aCol
) == 12);
93 const basegfx::B2ISize
aSize(10,10);
94 mpDevice1bpp
= createBitmapDevice( aSize
,
96 Format::ONE_BIT_MSB_PAL
);
97 mpDevice32bpp
= createBitmapDevice( aSize
,
99 Format::THIRTYTWO_BIT_TC_MASK
);
101 mpMaskBmp1bpp
= createBitmapDevice( aSize
,
103 Format::ONE_BIT_MSB_GREY
);
105 mpBmp1bpp
= createBitmapDevice( aSize
,
107 Format::ONE_BIT_MSB_PAL
);
108 mpBmp32bpp
= createBitmapDevice( aSize
,
110 Format::THIRTYTWO_BIT_TC_MASK
);
112 OUString
aSvg( "m 0 0h5v10h5v-5h-10z" );
114 basegfx::B2DPolyPolygon aPoly
;
115 basegfx::tools::importFromSvgD( aPoly
, aSvg
);
116 const Color
aColWhite(0xFFFFFFFF);
117 const Color
aColBlack(0);
118 mpBmp1bpp
->fillPolyPolygon(
122 mpBmp32bpp
->fillPolyPolygon(
127 aSvg
= "m 0 0 h6 v10 h-6z" ;
130 basegfx::tools::importFromSvgD( aPoly
, aSvg
);
131 mpMaskBmp1bpp
->clear(aColWhite
);
132 mpMaskBmp1bpp
->fillPolyPolygon(
140 implTestBmpBasics( mpDevice1bpp
, mpBmp1bpp
);
141 implTestBmpBasics( mpDevice32bpp
, mpBmp32bpp
);
146 implTestBmpScaledClip( mpDevice1bpp
, mpBmp1bpp
);
147 implTestBmpScaledClip( mpDevice32bpp
, mpBmp32bpp
);
150 // Change the following lines only, if you add, remove or rename
151 // member functions of the current class,
152 // because these macros are need by auto register mechanism.
154 CPPUNIT_TEST_SUITE(BmpMaskTest
);
155 CPPUNIT_TEST(testBmpBasics
);
156 CPPUNIT_TEST(testBmpClip
);
157 CPPUNIT_TEST_SUITE_END();
160 CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest
);
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */