[Libreoffice-commits] core.git: vcl/qa vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 12 07:48:21 UTC 2019
vcl/qa/cppunit/pdfexport/data/tdf128630.odp |binary
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 36 ++++++++++++++++++++++++++++
vcl/source/outdev/bitmap.cxx | 14 ++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)
New commits:
commit c465d920f4fe15c6e614beffb80b53d24a3dc5c7
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Nov 11 21:09:14 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Nov 12 08:47:16 2019 +0100
tdf#128630 vcl PDF export: fix aspect ratio when scaling rotated image
Regression from commit 68549e00d5e23aa22bc974a8151d93cd948444b3 (vcl,
BitmapEx transformed draw: special-case simple rotations, 2019-10-10),
the intention there was to fix an error on the last col/row of a bitmap,
but that was only tested with input where the aspect ratio doesn't
change on scaling.
Fix the problem by going back to the original way in the "aspect ratio
changes" case.
Change-Id: I52bed503ddaadbbbdf64ac6fec2fe268153866f1
Reviewed-on: https://gerrit.libreoffice.org/82467
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf128630.odp b/vcl/qa/cppunit/pdfexport/data/tdf128630.odp
new file mode 100644
index 000000000000..d216504b7329
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf128630.odp differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 22585a9827eb..02e597c76dd5 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -128,6 +128,7 @@ public:
void testTdf66597_3();
void testTdf109143();
void testTdf105954();
+ void testTdf128630();
void testTdf106702();
void testTdf113143();
void testTdf115262();
@@ -164,6 +165,7 @@ public:
CPPUNIT_TEST(testTdf66597_3);
CPPUNIT_TEST(testTdf109143);
CPPUNIT_TEST(testTdf105954);
+ CPPUNIT_TEST(testTdf128630);
CPPUNIT_TEST(testTdf106702);
CPPUNIT_TEST(testTdf113143);
CPPUNIT_TEST(testTdf115262);
@@ -1510,6 +1512,40 @@ void PdfExportTest::testTdf105954()
CPPUNIT_ASSERT_LESS(static_cast<unsigned int>(250), aMeta.width);
}
+void PdfExportTest::testTdf128630()
+{
+ // Import the bugdoc and export as PDF.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf128630.odp";
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("impress_pdf_Export");
+ DocumentHolder pPdfDocument = exportAndParse(aURL, aMediaDescriptor);
+
+ // The document has one page.
+ CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get()));
+
+ // Assert the aspect ratio of the only bitmap on the page.
+ PageHolder pPdfPage(FPDF_LoadPage(pPdfDocument.get(), /*page_index=*/0));
+ CPPUNIT_ASSERT(pPdfPage.get());
+ int nPageObjectCount = FPDFPage_CountObjects(pPdfPage.get());
+ for (int i = 0; i < nPageObjectCount; ++i)
+ {
+ FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage.get(), i);
+ if (FPDFPageObj_GetType(pPageObject) != FPDF_PAGEOBJ_IMAGE)
+ continue;
+
+ FPDF_BITMAP pBitmap = FPDFImageObj_GetBitmap(pPageObject);
+ CPPUNIT_ASSERT(pBitmap);
+ int nWidth = FPDFBitmap_GetWidth(pBitmap);
+ int nHeight = FPDFBitmap_GetHeight(pBitmap);
+ FPDFBitmap_Destroy(pBitmap);
+ // Without the accompanying fix in place, this test would have failed with:
+ // assertion failed
+ // - Expression: nWidth != nHeight
+ // i.e. the bitmap lost its custom aspect ratio during export.
+ CPPUNIT_ASSERT(nWidth != nHeight);
+ }
+}
+
void PdfExportTest::testTdf106702()
{
// Import the bugdoc and export as PDF.
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 93c1f76aef1f..f0a20db1a41e 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -1285,8 +1285,20 @@ void OutputDevice::DrawTransformedBitmapEx(
aFullTransform *= aTransform;
}
- if (bSheared)
+ double fSourceRatio = 1.0;
+ if (rOriginalSizePixel.getHeight() != 0)
{
+ fSourceRatio = rOriginalSizePixel.getWidth() / rOriginalSizePixel.getHeight();
+ }
+ double fTargetRatio = 1.0;
+ if (aFullScale.getY() != 0)
+ {
+ fTargetRatio = aFullScale.getX() / aFullScale.getY();
+ }
+ bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio);
+ if (bSheared || !bAspectRatioKept)
+ {
+ // Not only rotation, or scaling does not keep aspect ratio.
aTransformed = aTransformed.getTransformed(
aFullTransform,
aVisibleRange,
More information about the Libreoffice-commits
mailing list