1*69de5a4cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*69de5a4cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*69de5a4cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*69de5a4cSAndrew Rist * distributed with this work for additional information 6*69de5a4cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*69de5a4cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*69de5a4cSAndrew Rist * "License"); you may not use this file except in compliance 9*69de5a4cSAndrew Rist * with the License. You may obtain a copy of the License at 10*69de5a4cSAndrew Rist * 11*69de5a4cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*69de5a4cSAndrew Rist * 13*69de5a4cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*69de5a4cSAndrew Rist * software distributed under the License is distributed on an 15*69de5a4cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*69de5a4cSAndrew Rist * KIND, either express or implied. See the License for the 17*69de5a4cSAndrew Rist * specific language governing permissions and limitations 18*69de5a4cSAndrew Rist * under the License. 19*69de5a4cSAndrew Rist * 20*69de5a4cSAndrew Rist *************************************************************/ 21*69de5a4cSAndrew Rist 22*69de5a4cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // autogenerated file with codegen.pl 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "preextstl.h" 27cdf0e10cSrcweir #include "cppunit/TestAssert.h" 28cdf0e10cSrcweir #include "cppunit/TestFixture.h" 29cdf0e10cSrcweir #include "cppunit/extensions/HelperMacros.h" 30cdf0e10cSrcweir #include "postextstl.h" 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx> 33cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx> 34cdf0e10cSrcweir #include <basegfx/point/b2ipoint.hxx> 35cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 36cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 37cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx> 38cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <basebmp/color.hxx> 41cdf0e10cSrcweir #include <basebmp/scanlineformats.hxx> 42cdf0e10cSrcweir #include <basebmp/bitmapdevice.hxx> 43cdf0e10cSrcweir #include <basebmp/debug.hxx> 44cdf0e10cSrcweir #include "tools.hxx" 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include <iostream> 47cdf0e10cSrcweir #include <fstream> 48cdf0e10cSrcweir 49cdf0e10cSrcweir using namespace ::basebmp; 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace 52cdf0e10cSrcweir { 53cdf0e10cSrcweir /* 54cdf0e10cSrcweir std::ofstream output("32bpp_test.dump"); 55cdf0e10cSrcweir debugDump( rDevice, output ); 56cdf0e10cSrcweir std::ofstream output2("32bpp_bmp.dump"); 57cdf0e10cSrcweir debugDump( rBmp, output2 ); 58cdf0e10cSrcweir */ 59cdf0e10cSrcweir 60cdf0e10cSrcweir class BmpTest : public CppUnit::TestFixture 61cdf0e10cSrcweir { 62cdf0e10cSrcweir private: 63cdf0e10cSrcweir BitmapDeviceSharedPtr mpDevice1bpp; 64cdf0e10cSrcweir BitmapDeviceSharedPtr mpBmp1bpp; 65cdf0e10cSrcweir BitmapDeviceSharedPtr mpDevice32bpp; 66cdf0e10cSrcweir BitmapDeviceSharedPtr mpBmp32bpp; 67cdf0e10cSrcweir implTestBmpBasics(const BitmapDeviceSharedPtr & rDevice,const BitmapDeviceSharedPtr & rBmp)68cdf0e10cSrcweir void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice, 69cdf0e10cSrcweir const BitmapDeviceSharedPtr& rBmp) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir rDevice->clear(Color(0)); 72cdf0e10cSrcweir const Color aCol(0xFFFFFFFF); 73cdf0e10cSrcweir 74cdf0e10cSrcweir const basegfx::B2IRange aSourceRect(0,0,10,10); 75cdf0e10cSrcweir const basegfx::B2IRange aDestLeftTop(0,0,4,4); 76cdf0e10cSrcweir const basegfx::B2IRange aDestRightTop(6,0,10,4); 77cdf0e10cSrcweir const basegfx::B2IRange aDestLeftBottom(0,6,4,10); 78cdf0e10cSrcweir const basegfx::B2IRange aDestRightBottom(6,6,10,10); 79cdf0e10cSrcweir 80cdf0e10cSrcweir rDevice->drawBitmap( 81cdf0e10cSrcweir rBmp, 82cdf0e10cSrcweir aSourceRect, 83cdf0e10cSrcweir aDestLeftTop, 84cdf0e10cSrcweir DrawMode_PAINT ); 85cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 8", 86cdf0e10cSrcweir countPixel( rDevice, aCol ) == 8); 87cdf0e10cSrcweir 88cdf0e10cSrcweir rDevice->drawBitmap( 89cdf0e10cSrcweir rBmp, 90cdf0e10cSrcweir aSourceRect, 91cdf0e10cSrcweir aDestRightTop, 92cdf0e10cSrcweir DrawMode_PAINT ); 93cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 16", 94cdf0e10cSrcweir countPixel( rDevice, aCol ) == 16); 95cdf0e10cSrcweir 96cdf0e10cSrcweir rDevice->drawBitmap( 97cdf0e10cSrcweir rBmp, 98cdf0e10cSrcweir aSourceRect, 99cdf0e10cSrcweir aDestLeftBottom, 100cdf0e10cSrcweir DrawMode_PAINT ); 101cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 24", 102cdf0e10cSrcweir countPixel( rDevice, aCol ) == 24); 103cdf0e10cSrcweir 104cdf0e10cSrcweir rDevice->drawBitmap( 105cdf0e10cSrcweir rBmp, 106cdf0e10cSrcweir aSourceRect, 107cdf0e10cSrcweir aDestRightBottom, 108cdf0e10cSrcweir DrawMode_PAINT ); 109cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 32", 110cdf0e10cSrcweir countPixel( rDevice, aCol ) == 32); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir implTestBmpClip(const BitmapDeviceSharedPtr & rDevice,const BitmapDeviceSharedPtr & rBmp)113cdf0e10cSrcweir void implTestBmpClip(const BitmapDeviceSharedPtr& rDevice, 114cdf0e10cSrcweir const BitmapDeviceSharedPtr& rBmp) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir rDevice->clear(Color(0)); 117cdf0e10cSrcweir const Color aCol(0xFFFFFFFF); 118cdf0e10cSrcweir 119cdf0e10cSrcweir const basegfx::B2IRange aSourceRect(0,0,10,10); 120cdf0e10cSrcweir const basegfx::B2IRange aDestLeftTop(-2,-2,2,2); 121cdf0e10cSrcweir const basegfx::B2IRange aDestRightTop(8,-2,12,2); 122cdf0e10cSrcweir const basegfx::B2IRange aDestLeftBottom(-2,8,2,12); 123cdf0e10cSrcweir const basegfx::B2IRange aDestRightBottom(8,8,12,12); 124cdf0e10cSrcweir 125cdf0e10cSrcweir rDevice->drawBitmap( 126cdf0e10cSrcweir rBmp, 127cdf0e10cSrcweir aSourceRect, 128cdf0e10cSrcweir aDestLeftTop, 129cdf0e10cSrcweir DrawMode_PAINT ); 130cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4", 131cdf0e10cSrcweir countPixel( rDevice, aCol ) == 4); 132cdf0e10cSrcweir 133cdf0e10cSrcweir rDevice->drawBitmap( 134cdf0e10cSrcweir rBmp, 135cdf0e10cSrcweir aSourceRect, 136cdf0e10cSrcweir aDestLeftBottom, 137cdf0e10cSrcweir DrawMode_PAINT ); 138cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4(c)", 139cdf0e10cSrcweir countPixel( rDevice, aCol ) == 4); 140cdf0e10cSrcweir 141cdf0e10cSrcweir rDevice->drawBitmap( 142cdf0e10cSrcweir rBmp, 143cdf0e10cSrcweir aSourceRect, 144cdf0e10cSrcweir aDestRightBottom, 145cdf0e10cSrcweir DrawMode_PAINT ); 146cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 8", 147cdf0e10cSrcweir countPixel( rDevice, aCol ) == 8); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir public: setUp()151cdf0e10cSrcweir void setUp() 152cdf0e10cSrcweir { 153cdf0e10cSrcweir const basegfx::B2ISize aSize(10,10); 154cdf0e10cSrcweir mpDevice1bpp = createBitmapDevice( aSize, 155cdf0e10cSrcweir true, 156cdf0e10cSrcweir Format::ONE_BIT_MSB_PAL ); 157cdf0e10cSrcweir mpDevice32bpp = createBitmapDevice( aSize, 158cdf0e10cSrcweir true, 159cdf0e10cSrcweir Format::THIRTYTWO_BIT_TC_MASK ); 160cdf0e10cSrcweir 161cdf0e10cSrcweir mpBmp1bpp = createBitmapDevice( aSize, 162cdf0e10cSrcweir true, 163cdf0e10cSrcweir Format::ONE_BIT_MSB_PAL ); 164cdf0e10cSrcweir mpBmp32bpp = createBitmapDevice( aSize, 165cdf0e10cSrcweir true, 166cdf0e10cSrcweir Format::THIRTYTWO_BIT_TC_MASK ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir ::rtl::OUString aSvg = ::rtl::OUString::createFromAscii( 169cdf0e10cSrcweir "m 0 0h5v10h5v-5h-10z" ); 170cdf0e10cSrcweir 171cdf0e10cSrcweir basegfx::B2DPolyPolygon aPoly; 172cdf0e10cSrcweir basegfx::tools::importFromSvgD( aPoly, aSvg ); 173cdf0e10cSrcweir const Color aCol(0xFFFFFFFF); 174cdf0e10cSrcweir mpBmp1bpp->fillPolyPolygon( 175cdf0e10cSrcweir aPoly, 176cdf0e10cSrcweir aCol, 177cdf0e10cSrcweir DrawMode_PAINT ); 178cdf0e10cSrcweir mpBmp32bpp->fillPolyPolygon( 179cdf0e10cSrcweir aPoly, 180cdf0e10cSrcweir aCol, 181cdf0e10cSrcweir DrawMode_PAINT ); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir testBmpBasics()184cdf0e10cSrcweir void testBmpBasics() 185cdf0e10cSrcweir { 186cdf0e10cSrcweir implTestBmpBasics( mpDevice1bpp, mpBmp1bpp ); 187cdf0e10cSrcweir implTestBmpBasics( mpDevice32bpp, mpBmp32bpp ); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir testBmpClip()190cdf0e10cSrcweir void testBmpClip() 191cdf0e10cSrcweir { 192cdf0e10cSrcweir implTestBmpClip( mpDevice1bpp, mpBmp1bpp ); 193cdf0e10cSrcweir implTestBmpClip( mpDevice32bpp, mpBmp32bpp ); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir // Change the following lines only, if you add, remove or rename 197cdf0e10cSrcweir // member functions of the current class, 198cdf0e10cSrcweir // because these macros are need by auto register mechanism. 199cdf0e10cSrcweir 200cdf0e10cSrcweir CPPUNIT_TEST_SUITE(BmpTest); 201cdf0e10cSrcweir CPPUNIT_TEST(testBmpBasics); 202cdf0e10cSrcweir CPPUNIT_TEST(testBmpClip); 203cdf0e10cSrcweir CPPUNIT_TEST_SUITE_END(); 204cdf0e10cSrcweir }; 205cdf0e10cSrcweir 206cdf0e10cSrcweir // ----------------------------------------------------------------------------- 207cdf0e10cSrcweir CPPUNIT_TEST_SUITE_REGISTRATION(BmpTest); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir 211cdf0e10cSrcweir // ----------------------------------------------------------------------------- 212cdf0e10cSrcweir 213cdf0e10cSrcweir // this macro creates an empty function, which will called by the RegisterAllFunctions() 214cdf0e10cSrcweir // to let the user the possibility to also register some functions by hand. 215cdf0e10cSrcweir //NOADDITIONAL; 216cdf0e10cSrcweir 217