diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-06-15 18:33:38 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-06-17 14:25:54 +0200 |
commit | 5772cef244dbee5834efbc693bc714d89ae6301d (patch) | |
tree | 136d4491c9cffc3638f29588a1bb4b3568a63648 /sd | |
parent | 4dab8afe89c57318cc7503ae051963de89a6cd25 (diff) |
tdf#134210: Reimplement cropping from srcRect and fillRect
This avoids the scaling after the crop, since scaling is performed
anyway when applying BitmapMode_STRETCH. This improves resulting
bitmap quality.
Also consider the "crop to zero" case (when the sum of cropped
parts is equal to 100%). In that case, just use an empty graphic
as the fill bitmap.
This makes the differences between srcRect and fillRect processing
explicit, simplifies the code, avoids extra rounding inaccuracies,
and takes care of the edge cases that were considered in commit
2859ec288f2c1323ea3123d82cb1684b349ff598
Author Miklos Vajna <vmiklos@collabora.com>
Date Wed Jun 15 15:52:18 2022 +0200
oox: fix div by zero in lclCalculateCropPercentage()
The change in SdImportTest2::testTdf134210 is because we now don't
scale the cropped image. The previous value was an interpolated
color, while the new value is the actual color of pixel [0, 41] of
the original image.
Change-Id: I24fa9928cff32bcaa6a7b3e34def14700fddd7ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135917
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/croppedTo0.pptx | bin | 0 -> 32741 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests2.cxx | 10 |
2 files changed, 9 insertions, 1 deletions
diff --git a/sd/qa/unit/data/pptx/croppedTo0.pptx b/sd/qa/unit/data/pptx/croppedTo0.pptx Binary files differnew file mode 100644 index 000000000000..fecf53559b1f --- /dev/null +++ b/sd/qa/unit/data/pptx/croppedTo0.pptx diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index 3bddc580c07d..8ada9e682f39 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -135,6 +135,7 @@ public: void testTdf112209(); void testTdf128596(); void testDefaultTabStop(); + void testCropToZero(); CPPUNIT_TEST_SUITE(SdImportTest2); @@ -204,6 +205,7 @@ public: CPPUNIT_TEST(testTdf112209); CPPUNIT_TEST(testTdf128596); CPPUNIT_TEST(testDefaultTabStop); + CPPUNIT_TEST(testCropToZero); CPPUNIT_TEST_SUITE_END(); }; @@ -1293,7 +1295,7 @@ void SdImportTest2::testTdf134210() Graphic aGraphic(xGraphic); BitmapEx aBitmap(aGraphic.GetBitmapEx()); - CPPUNIT_ASSERT_EQUAL(Color(0x60563e), aBitmap.GetPixelColor(0, 0)); + CPPUNIT_ASSERT_EQUAL(Color(0x605741), aBitmap.GetPixelColor(0, 0)); xDocShRef->DoClose(); } @@ -2035,6 +2037,12 @@ void SdImportTest2::testDefaultTabStop() xDocShRef->DoClose(); } +void SdImportTest2::testCropToZero() +{ + // Must not crash because of division by zero + loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/croppedTo0.pptx"), PPTX); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); |