r25112 by jghali - #16822: Image Drop Shadow no longer exported to PDF

scribus-commit scribus-commit at lists.scribus.net
Thu Jun 30 20:15:23 UTC 2022


Author: jghali
Date: Thu Jun 30 20:15:23 2022
New Revision: 25112

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25112
Log:
#16822: Image Drop Shadow no longer exported to PDF

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25112&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Thu Jun 30 20:15:23 2022
@@ -4149,7 +4149,8 @@
 QByteArray PDFLibCore::PDF_PutSoftShadow(PageItem* ite)
 {
 	if (!Options.supportsTransparency() || !ite->hasSoftShadow() || ite->softShadowColor() == CommonStrings::None || !ite->printEnabled())
-		return "";
+		return QByteArray();
+
 	double maxSize;
 	QByteArray tmp("q\n");
 	double softShadowDPI = Options.Resolution;
@@ -4196,7 +4197,23 @@
 
 	ite->doc()->guidesPrefs().showControls = saveControl;
 	ite->setHasSoftShadow(savedShadow);
-	ScImage img = imgC.convertToFormat(QImage::Format_Alpha8).convertToFormat(QImage::Format_RGB32);
+
+	// Unfortunately imgC.convertToFormat(QImage::Format_Alpha8).convertToFormat(QImage::Format_RGB32)
+	// won't give use the expected result
+	QImage alphaImage(imgC.width(), imgC.height(), QImage::Format_RGB32);
+	for (int j = 0; j < imgC.height(); ++j)
+	{
+		const QRgb* srcScanLine = (const QRgb*) imgC.constScanLine(j);
+		QRgb* dstScanLine = (QRgb*) alphaImage.scanLine(j);
+		for (int i = 0; i < imgC.width(); ++i)
+		{
+			int alpha = qAlpha(*srcScanLine);
+			*dstScanLine = qRgb(alpha, alpha, alpha);
+			++srcScanLine;
+			++dstScanLine;
+		}
+	}
+	ScImage img = alphaImage;
 
 	PdfId maskObj = writer.newObject();
 	writer.startObj(maskObj);




More information about the scribus-commit mailing list