summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/qa/cppunit/pdfexport/data/bitmap-scaledown.odtbin0 -> 13423 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx46
-rw-r--r--vcl/source/outdev/bitmapex.cxx10
3 files changed, 40 insertions, 16 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/bitmap-scaledown.odt b/vcl/qa/cppunit/pdfexport/data/bitmap-scaledown.odt
new file mode 100644
index 000000000000..da9b167fd9d7
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/bitmap-scaledown.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 03aed3112d64..fb821a7777e4 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1638,7 +1638,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128630)
// The document has one page.
CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
- // Assert the aspect ratio of the only bitmap on the page.
+ // Assert the size of the only bitmap on the page.
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
CPPUNIT_ASSERT(pPdfPage);
int nPageObjectCount = pPdfPage->getObjectCount();
@@ -1651,12 +1651,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128630)
std::unique_ptr<vcl::pdf::PDFiumBitmap> pBitmap = pPageObject->getImageBitmap();
CPPUNIT_ASSERT(pBitmap);
int nWidth = pBitmap->getWidth();
- int nHeight = pBitmap->getHeight();
// 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);
+ // - Expected: 466
+ // - Actual : 289
+ // i.e. the rotated + scaled arrow was more thin than it should be.
+ CPPUNIT_ASSERT_EQUAL(466, nWidth);
+ int nHeight = pBitmap->getHeight();
+ CPPUNIT_ASSERT_EQUAL(466, nHeight);
}
}
@@ -3451,6 +3452,39 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfImageEncryption)
// missing encryption.
CPPUNIT_ASSERT_EQUAL(2, pPageObject->getFormObjectCount());
}
+
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testBitmapScaledown)
+{
+ // Given a document with an upscaled and rotated barcode bitmap in it:
+ aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+
+ // When saving as PDF:
+ saveAsPDF(u"bitmap-scaledown.odt");
+
+ // Then verify that the bitmap is not downscaled:
+ std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport();
+ CPPUNIT_ASSERT(pPdfDocument);
+ CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
+ CPPUNIT_ASSERT(pPdfPage);
+ int nPageObjectCount = pPdfPage->getObjectCount();
+ for (int i = 0; i < nPageObjectCount; ++i)
+ {
+ std::unique_ptr<vcl::pdf::PDFiumPageObject> pPageObject = pPdfPage->getObject(i);
+ if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Image)
+ continue;
+
+ std::unique_ptr<vcl::pdf::PDFiumBitmap> pBitmap = pPageObject->getImageBitmap();
+ CPPUNIT_ASSERT(pBitmap);
+ // In-file sizes: good is 2631x380, bad is 1565x14.
+ int nWidth = pBitmap->getWidth();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 2616
+ // - Actual : 1565
+ // i.e. the bitmap in the pdf result was small enough to be blurry.
+ CPPUNIT_ASSERT_EQUAL(2616, nWidth);
+ }
+}
} // end anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx
index 55a166c6e5ba..fc966b53c3d2 100644
--- a/vcl/source/outdev/bitmapex.cxx
+++ b/vcl/source/outdev/bitmapex.cxx
@@ -624,19 +624,9 @@ void OutputDevice::DrawTransformedBitmapEx(
aTransformed = BitmapEx(aContent, aMaskBmp);
}
- // Remove scaling from aFulltransform: we transform due to shearing or rotation, scaling
- // will happen according to aDestSize.
basegfx::B2DVector aFullScale, aFullTranslate;
double fFullRotate, fFullShearX;
aFullTransform.decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX);
- // Require positive scaling, negative scaling would loose horizontal or vertical flip.
- if (aFullScale.getX() > 0 && aFullScale.getY() > 0)
- {
- basegfx::B2DHomMatrix aTransform = basegfx::utils::createScaleB2DHomMatrix(
- rOriginalSizePixel.getWidth() / aFullScale.getX(),
- rOriginalSizePixel.getHeight() / aFullScale.getY());
- aFullTransform *= aTransform;
- }
double fSourceRatio = 1.0;
if (rOriginalSizePixel.getHeight() != 0)