tdf#134210: Reimplement cropping from srcRect and fillRect
commit66ae8a2c0e6d01d06a01fa877cf03507c0656f8d
authorMike Kaganski <mike.kaganski@collabora.com>
Wed, 15 Jun 2022 15:33:38 +0000 (15 18:33 +0300)
committerXisco Fauli <xiscofauli@libreoffice.org>
Tue, 28 Jun 2022 16:18:15 +0000 (28 18:18 +0200)
tree821e8f7e51cc4e92be88ccab91628d0be222b025
parentff6e536111a966f465c4756cbfa74935752df612
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>
(cherry picked from commit 5772cef244dbee5834efbc693bc714d89ae6301d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136038
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit c7a21bfed044154cac23328d37b46f34aeda0709)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136155
oox/source/drawingml/fillproperties.cxx
sd/qa/unit/data/pptx/croppedTo0.pptx [new file with mode: 0644]
sd/qa/unit/import-tests2.cxx