r25117 by jghali - #16824: Drop shadow of very large shapes shows up wrong in exported PDF

scribus-commit scribus-commit at lists.scribus.net
Mon Jul 11 18:17:21 UTC 2022


Author: jghali
Date: Mon Jul 11 18:17:20 2022
New Revision: 25117

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25117
Log:
#16824: Drop shadow of very large shapes shows up wrong in exported PDF

Modified:
    branches/Version15x/Scribus/scribus/pdflib_core.cpp

Modified: branches/Version15x/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25117&path=/branches/Version15x/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- branches/Version15x/Scribus/scribus/pdflib_core.cpp	(original)
+++ branches/Version15x/Scribus/scribus/pdflib_core.cpp	Mon Jul 11 18:17:20 2022
@@ -4149,20 +4149,23 @@
 QByteArray PDFLibCore::PDF_PutSoftShadow(PageItem* ite)
 {
 	if (!Options.supportsTransparency() || !ite->hasSoftShadow() || ite->softShadowColor() == CommonStrings::None || !ite->printEnabled())
-		return "";
-	double maxSize;
+		return QByteArray();
+
 	QByteArray tmp("q\n");
-	double softShadowDPI = Options.Resolution;
-	int pixelRadius = qRound(ite->softShadowBlurRadius() / 72.0 * softShadowDPI);
 	tmp += "1 0 0 1 " + FToStr(ite->softShadowXOffset() - ite->softShadowBlurRadius()) + " " + FToStr(-(ite->softShadowYOffset() + ite->softShadowBlurRadius())) + " cm\n";
 	if (ite->isPathText())
 		ite->updatePolyClip();
 	tmp += "1 0 0 1 " + FToStr(-(ite->xPos() - ite->visualXPos())) + " " + FToStr(ite->yPos() - ite->visualYPos()) + " cm\n";
 	tmp += "1 0 0 1 0 " + FToStr(-ite->visualHeight()) + " cm\n";
 	tmp += FToStr(ite->visualWidth() + 2 * ite->softShadowBlurRadius()) + " 0 0 " + FToStr(ite->visualHeight() + 2 * ite->softShadowBlurRadius()) + " 0 0 cm\n" ;
-	maxSize = qMax(ite->visualWidth(), ite->visualHeight());
-	maxSize = qMin(3000.0, maxSize * (softShadowDPI / 72.0));
-	maxSize = ceil(maxSize);
+
+	double softShadowDPI = Options.Resolution;
+	double maxSize1 = qMax(ite->visualWidth(), ite->visualHeight());
+	double maxSize2 = qMin(3000.0, maxSize1 * (softShadowDPI / 72.0));
+	double maxSize = ceil(maxSize2);
+	double zoomFactor = maxSize2 / maxSize1;
+	int pixelRadius = qRound(ite->softShadowBlurRadius() * zoomFactor);
+
 	bool saveControl = ite->doc()->guidesPrefs().showControls;
 	ite->doc()->guidesPrefs().showControls = false;
 	bool savedShadow = ite->hasSoftShadow();
@@ -4175,18 +4178,20 @@
 	ite->setFillTransparency(transF);
 	ite->setLineTransparency(transS);
 	QImage imgC = imgA.copy(-pixelRadius, -pixelRadius, imgA.width() + 2 * pixelRadius, imgA.height() + 2 * pixelRadius); // Add border
+
 	ScPainter *p = new ScPainter(&imgC, imgC.width(), imgC.height(), 1, 0);
-	p->setZoomFactor(softShadowDPI / 72.0);
+	p->setZoomFactor(zoomFactor);
 	p->save();
 	p->blur(pixelRadius);
 	p->restore();
 	p->end();
 	delete p;
+
 	if (ite->softShadowErasedByObject())
 	{
 		ScPainter *p = new ScPainter(&imgC, imgC.width(), imgC.height(), 1, 0);
 		p->translate(pixelRadius, pixelRadius);
-		p->translate(-ite->softShadowXOffset() * (softShadowDPI / 72.0), -ite->softShadowYOffset() * (softShadowDPI / 72.0));
+		p->translate(-ite->softShadowXOffset() * zoomFactor, -ite->softShadowYOffset() * zoomFactor);
 		p->beginLayer(1.0, 18);
 		p->drawImage(&imgA);
 		p->endLayer();




More information about the scribus-commit mailing list