diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-03-29 14:35:11 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-03-29 18:26:31 +0900 |
commit | 024bc58aefdce2becb170939eac68e18cce2977c (patch) | |
tree | 9c70bb27395211a86efb1d05ac71438bacd0f5b8 /vcl/qa/cppunit/BitmapTest.cxx | |
parent | 0bd502af47b53bc4340df7874bd726361e3bbad9 (diff) |
vcl: test for bitmap convert, use scoped read/write access
Change-Id: I702d3e1ced356efce28ebfec141776f07645b2f9
Diffstat (limited to 'vcl/qa/cppunit/BitmapTest.cxx')
-rw-r--r-- | vcl/qa/cppunit/BitmapTest.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index cc8534f22a6a..dc2070ddcae3 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -25,13 +25,49 @@ namespace class BitmapTest : public CppUnit::TestFixture { + void testConvert(); void testScale(); CPPUNIT_TEST_SUITE(BitmapTest); + CPPUNIT_TEST(testConvert); CPPUNIT_TEST(testScale); CPPUNIT_TEST_SUITE_END(); }; +void BitmapTest::testConvert() +{ + Bitmap aBitmap(Size(10, 10), 8); + + aBitmap.Erase(COL_LIGHTGRAYBLUE); + + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), aBitmap.GetBitCount()); + { + Bitmap::ScopedReadAccess pReadAccess(aBitmap); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pReadAccess->GetBitCount()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(10), pReadAccess->GetScanlineSize()); + CPPUNIT_ASSERT(pReadAccess->HasPalette()); + const BitmapColor& rColor = pReadAccess->GetPaletteColor(pReadAccess->GetPixelIndex(1, 1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(rColor.GetRed())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(rColor.GetGreen())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(255), sal_Int32(rColor.GetBlue())); + } + + aBitmap.Convert(BMP_CONVERSION_24BIT); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount()); + { + Bitmap::ScopedReadAccess pReadAccess(aBitmap); + // 24 bit Bitmap on SVP backend uses 32bit BGRX format + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(32), pReadAccess->GetBitCount()); + CPPUNIT_ASSERT_EQUAL(sal_uLong(40), pReadAccess->GetScanlineSize()); + CPPUNIT_ASSERT(!pReadAccess->HasPalette()); + Color aColor = pReadAccess->GetPixel(0, 0); + CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(aColor.GetRed())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(aColor.GetGreen())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(255), sal_Int32(aColor.GetBlue())); + } +} + void BitmapTest::testScale() { bool bExportBitmap(false); |