diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-09-03 18:55:08 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-09-08 10:11:42 +0200 |
commit | 6d6c0e2c35186323bb5af35f5a58a2c9d9baa1ed (patch) | |
tree | 3d92d4a0adacc9b16444f4051ebc79f26cc738eb /vcl/qa | |
parent | f83d1b824c1abd07d24318adda6c876b9471ccec (diff) |
vcl: migrate GetDownsampledBitmap() from OutputDevice to vcl::bitmap
Change-Id: Iee6caa8292472a3acca66d670a113b701f4b637e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121581
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/BitmapTest.cxx | 25 | ||||
-rw-r--r-- | vcl/qa/cppunit/outdev.cxx | 71 |
2 files changed, 18 insertions, 78 deletions
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 25630ea9cabb..9d4cbb592f68 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -11,21 +11,22 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/plugin/TestPlugIn.h> -#include <unordered_map> +#include <config_features.h> +#include <rtl/strbuf.hxx> + +#include <vcl/BitmapTools.hxx> #include <vcl/bitmap.hxx> #include <vcl/virdev.hxx> - -#include <rtl/strbuf.hxx> -#include <config_features.h> #include <vcl/skia/SkiaHelper.hxx> #include <vcl/BitmapMonochromeFilter.hxx> #include <bitmap/BitmapWriteAccess.hxx> - -#include <svdata.hxx> -#include <salinst.hxx> #include <bitmap/Octree.hxx> +#include <salinst.hxx> +#include <svdata.hxx> + +#include <unordered_map> namespace { @@ -46,6 +47,7 @@ class BitmapTest : public CppUnit::TestFixture void testDitherSize(); void testMirror(); void testCrop(); + void testCroppedDownsampledBitmap(); CPPUNIT_TEST_SUITE(BitmapTest); CPPUNIT_TEST(testCreation); @@ -63,6 +65,7 @@ class BitmapTest : public CppUnit::TestFixture CPPUNIT_TEST(testDitherSize); CPPUNIT_TEST(testMirror); CPPUNIT_TEST(testCrop); + CPPUNIT_TEST(testCroppedDownsampledBitmap); CPPUNIT_TEST_SUITE_END(); }; @@ -687,6 +690,14 @@ void BitmapTest::testMirror() } } +void BitmapTest::testCroppedDownsampledBitmap() +{ + Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP); + Bitmap aDownsampledBmp(vcl::bitmap::GetDownsampledBitmap(Size(10, 10), Point(20, 20), + Size(5, 5), aBitmap, 72, 72)); + CPPUNIT_ASSERT(aDownsampledBmp.IsEmpty()); +} + void BitmapTest::testCrop() { Bitmap aBitmap(Bitmap(Size(16, 16), vcl::PixelFormat::N24_BPP)); diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 0a635a1a139d..5f78c5127807 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -44,7 +44,6 @@ public: void testDrawScalePartBitmap(); void testDrawTransformedBitmapEx(); void testDrawTransformedBitmapExFlip(); - void testCroppedDownsampledBitmap(); void testRTL(); void testRTLGuard(); void testDefaultFillColor(); @@ -78,7 +77,6 @@ public: CPPUNIT_TEST(testGetReadableFontColorWindow); CPPUNIT_TEST(testDrawTransformedBitmapEx); CPPUNIT_TEST(testDrawTransformedBitmapExFlip); - CPPUNIT_TEST(testCroppedDownsampledBitmap); CPPUNIT_TEST(testRTL); CPPUNIT_TEST(testRTLGuard); CPPUNIT_TEST(testDefaultFillColor); @@ -514,75 +512,6 @@ void VclOutdevTest::testDrawTransformedBitmapExFlip() CPPUNIT_ASSERT_EQUAL_MESSAGE(ss.str(), COL_BLACK, Color(aColor)); } -namespace -{ -class DownsampleBitmapTester : public OutputDevice -{ -public: - DownsampleBitmapTester() - : OutputDevice(OUTDEV_VIRDEV) - , maBitmap(Bitmap(Size(16, 16), vcl::PixelFormat::N24_BPP)) - { - SetDPIX(96); - SetDPIY(96); - } - - bool AcquireGraphics() const { return true; } - void ReleaseGraphics(bool) {} - bool UsePolyPolygonForComplexGradient() { return false; } - - Bitmap testCropFullyOutsideBounds() - { - return GetDownsampledBitmap(Size(10, 10), Point(20, 20), Size(5, 5), maBitmap, 72, 72); - } - - Bitmap testCropSameSize() - { - return GetDownsampledBitmap(Size(10, 10), Point(0, 0), maBitmap.GetSizePixel(), maBitmap, - 72, 72); - } - - Bitmap testFullyOvercrop() - { - return GetDownsampledBitmap(Size(10, 10), Point(0, 0), Size(100, 100), maBitmap, 72, 72); - } - - Bitmap testPartiallyOvercrop() - { - return GetDownsampledBitmap(Size(10, 10), Point(10, 10), Size(100, 100), maBitmap, 72, 72); - } - -private: - Bitmap maBitmap; -}; -} - -void VclOutdevTest::testCroppedDownsampledBitmap() -{ - ScopedVclPtrInstance<DownsampleBitmapTester> pTester; - - { - Bitmap aDownsampledBmp(pTester->testCropFullyOutsideBounds()); - CPPUNIT_ASSERT_MESSAGE("Crop was fully outside of bitmap bounds", - aDownsampledBmp.IsEmpty()); - } - - { - Bitmap aDownsampledBmp(pTester->testCropSameSize()); - CPPUNIT_ASSERT_MESSAGE("Crop same size as bitmap", !aDownsampledBmp.IsEmpty()); - } - - { - Bitmap aDownsampledBmp(pTester->testFullyOvercrop()); - CPPUNIT_ASSERT_MESSAGE("Crop larger than bitmap", !aDownsampledBmp.IsEmpty()); - } - - { - Bitmap aDownsampledBmp(pTester->testPartiallyOvercrop()); - CPPUNIT_ASSERT_MESSAGE("Crop partially overcrops bitmap", !aDownsampledBmp.IsEmpty()); - } -} - void VclOutdevTest::testRTL() { ScopedVclPtrInstance<vcl::Window> pWindow(nullptr, WB_APP | WB_STDWORK); |