r18627 by fschmid - Fixed Bug #11865: PDF with scanned images can't be opened correctly

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 8 17:31:43 UTC 2013


Author: fschmid
Date: Sun Dec  8 17:31:43 2013
New Revision: 18627

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18627
Log:
Fixed Bug #11865: PDF with scanned images can't be opened correctly

Modified:
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18627&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Sun Dec  8 17:31:43 2013
@@ -1479,6 +1479,18 @@
 	}
 }
 
+void SlaOutputDev::updateFillColor(GfxState *state)
+{
+	CurrFillShade = 100;
+	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
+}
+
+void SlaOutputDev::updateStrokeColor(GfxState *state)
+{
+	CurrStrokeShade = 100;
+	CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade);
+}
+
 void SlaOutputDev::clip(GfxState *state)
 {
 //	qDebug() << "Clip";
@@ -1586,15 +1598,13 @@
 	ctm = state->getCTM();
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	int shade = 100;
-	CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &shade);
 	QString output = convertPath(state->getPath());
 	getPenState(state);
 	if ((m_Elements->count() != 0) && (output == Coords))			// Path is the same as in last fill
 	{
 		PageItem* ite = m_Elements->last();
 		ite->setLineColor(CurrColorStroke);
-		ite->setLineShade(shade);
+		ite->setLineShade(CurrStrokeShade);
 		ite->setLineEnd(PLineEnd);
 		ite->setLineJoin(PLineJoin);
 		ite->setLineWidth(state->getTransformedLineWidth());
@@ -1629,7 +1639,7 @@
 				{
 					lItem->setLineColor(CurrColorStroke);
 					lItem->setLineWidth(state->getTransformedLineWidth());
-					lItem->setLineShade(shade);
+					lItem->setLineShade(CurrStrokeShade);
 					lItem->setLineTransparency(1.0 - state->getStrokeOpacity());
 					lItem->setLineBlendmode(getBlendMode(state));
 					lItem->setLineEnd(PLineEnd);
@@ -1641,7 +1651,7 @@
 				}
 				else
 				{
-					ite->setLineShade(shade);
+					ite->setLineShade(CurrStrokeShade);
 					ite->setLineTransparency(1.0 - state->getStrokeOpacity());
 					ite->setLineBlendmode(getBlendMode(state));
 					ite->setLineEnd(PLineEnd);
@@ -1656,7 +1666,7 @@
 			}
 			else
 			{
-				ite->setLineShade(shade);
+				ite->setLineShade(CurrStrokeShade);
 				ite->setLineTransparency(1.0 - state->getStrokeOpacity());
 				ite->setLineBlendmode(getBlendMode(state));
 				ite->setLineEnd(PLineEnd);
@@ -1679,8 +1689,6 @@
 	ctm = state->getCTM();
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	FPointArray out;
 	QString output = convertPath(state->getPath());
 	out.parseSVG(output);
@@ -1699,7 +1707,7 @@
 		ite->PoLine = out.copy();
 		ite->ClipEdited = true;
 		ite->FrameType = 3;
-		ite->setFillShade(shade);
+		ite->setFillShade(CurrFillShade);
 		ite->setLineShade(100);
 		ite->setFillEvenOdd(false);
 		ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -1725,8 +1733,6 @@
 	ctm = state->getCTM();
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	FPointArray out;
 	QString output = convertPath(state->getPath());
 	out.parseSVG(output);
@@ -1745,7 +1751,7 @@
 		ite->PoLine = out.copy();
 		ite->ClipEdited = true;
 		ite->FrameType = 3;
-		ite->setFillShade(shade);
+		ite->setFillShade(CurrFillShade);
 		ite->setLineShade(100);
 		ite->setFillEvenOdd(true);
 		ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -1825,7 +1831,6 @@
 	GrEndY = gr.point(1).y() - crect.y();
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	QString output = QString("M %1 %2").arg(0.0).arg(0.0);
 	output += QString("L %1 %2").arg(crect.width()).arg(0.0);
 	output += QString("L %1 %2").arg(crect.width()).arg(crect.height());
@@ -1838,7 +1843,7 @@
 	PageItem* ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(shade);
+	ite->setFillShade(CurrFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -1928,7 +1933,6 @@
 	GrFocalY = gr.point(2).y() - crect.y();
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	QString output = QString("M %1 %2").arg(0.0).arg(0.0);
 	output += QString("L %1 %2").arg(crect.width()).arg(0.0);
 	output += QString("L %1 %2").arg(crect.width()).arg(crect.height());
@@ -1941,7 +1945,7 @@
 	PageItem* ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(shade);
+	ite->setFillShade(CurrFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -1966,8 +1970,6 @@
 {
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	double xmin, ymin, xmax, ymax;
 	// get the clip region bbox
 	state->getClipBBox(&xmin, &ymin, &xmax, &ymax);
@@ -1988,7 +1990,7 @@
 	PageItem* ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(100);
+	ite->setFillShade(CurrFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -2007,6 +2009,7 @@
 	double x0, y0, x1, y1, x2, y2;
 	for (int i = 0; i < shading->getNTriangles(); i++)
 	{
+		int shade = 100;
 		meshGradientPatch patchM;
 		shading->getTriangle(i, &x0, &y0, &color[0],  &x1, &y1, &color[1],  &x2, &y2, &color[2]);
 		patchM.BL.resetTo(FPoint(x0, y0));
@@ -2048,8 +2051,6 @@
 //	qDebug() << "mesh shaded fill";
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	double xmin, ymin, xmax, ymax;
 	// get the clip region bbox
 	state->getClipBBox(&xmin, &ymin, &xmax, &ymax);
@@ -2070,7 +2071,7 @@
 	PageItem* ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(shade);
+	ite->setFillShade(CurrFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -2089,6 +2090,7 @@
 	ite->meshGradientPatches.clear();
 	for (int i = 0; i < shading->getNPatches(); i++)
 	{
+		int shade = 100;
 		GfxPatch *patch = shading->getPatch(i);
 		GfxColor color;
 		meshGradientPatch patchM;
@@ -2271,8 +2273,6 @@
 	}
 	double xCoor = m_doc->currentPage()->xOffset();
 	double yCoor = m_doc->currentPage()->yOffset();
-	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	double xmin, ymin, xmax, ymax;
 	// get the clip region bbox
 	state->getClipBBox(&xmin, &ymin, &xmax, &ymax);
@@ -2290,7 +2290,7 @@
 	ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(shade);
+	ite->setFillShade(CurrFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
@@ -2364,9 +2364,7 @@
 			}
 		}
 	}
-	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
-	QColor backColor = ScColorEngine::getShadeColorProof(m_doc->PageColors[CurrColorFill], m_doc, shade);
+	QColor backColor = ScColorEngine::getShadeColorProof(m_doc->PageColors[CurrColorFill], m_doc, CurrFillShade);
 	QImage res = QImage(width, height, QImage::Format_ARGB32);
 	res.fill(backColor.rgb());
 	unsigned char cc, cm, cy, ck;
@@ -3549,8 +3547,6 @@
 			m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
 			double xCoor = m_doc->currentPage()->xOffset();
 			double yCoor = m_doc->currentPage()->yOffset();
-			int shade = 100;
-			CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 			FPointArray textPath;
 			textPath.fromQPainterPath(qPath);
 			FPoint wh = textPath.WidthHeight();
@@ -3567,7 +3563,7 @@
 				ite->PoLine = textPath.copy();
 				ite->ClipEdited = true;
 				ite->FrameType = 3;
-				ite->setFillShade(shade);
+				ite->setFillShade(CurrFillShade);
 				ite->setFillEvenOdd(false);
 				ite->setFillTransparency(1.0 - state->getFillOpacity());
 				ite->setFillBlendmode(getBlendMode(state));
@@ -3577,12 +3573,11 @@
 				m_doc->AdjustItemSize(ite);
 				if ((render & 3) == 1 || (render & 3) == 2)
 				{
-					CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &shade);
 					ite->setLineColor(CurrColorStroke);
 					ite->setLineWidth(state->getTransformedLineWidth());
 					ite->setLineTransparency(1.0 - state->getStrokeOpacity());
 					ite->setLineBlendmode(getBlendMode(state));
-					ite->setLineShade(shade);
+					ite->setLineShade(CurrStrokeShade);
 				}
 				m_Elements->append(ite);
 				if (m_groupStack.count() != 0)
@@ -3621,8 +3616,6 @@
 		QTransform mm;
 		mm.translate(0, -pat.height * tline.length());
 		mm = orig_ctm * mm;
-		int shade = 100;
-		CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 		int z = 0;
 		if (m_Font_Pattern_Map[fRefID].colored)
 			z = m_doc->itemAdd(PageItem::Symbol, PageItem::Unspecified, xCoor + mm.dx(), yCoor + mm.dy(), pat.width * tline.length(), pat.height * tline.length(), 0, CommonStrings::None, CommonStrings::None, true);
@@ -3636,7 +3629,7 @@
 		m_doc->RotMode(3);
 		m_doc->RotateItem(-tline.angle(), b);
 		m_doc->RotMode(0);
-		b->setFillShade(shade);
+		b->setFillShade(CurrFillShade);
 		b->setFillEvenOdd(false);
 		b->setFillTransparency(1.0 - state->getFillOpacity());
 		b->setFillBlendmode(getBlendMode(state));
@@ -3647,7 +3640,7 @@
 			b->setPattern(m_Font_Pattern_Map[fRefID].pattern);
 		else
 		{
-			b->setFillShade(shade);
+			b->setFillShade(CurrFillShade);
 			b->setPatternMask(m_Font_Pattern_Map[fRefID].pattern);
 			b->setMaskTransform(b->width() / pat.width * 100, b->height() / pat.height * 100, 0, 0, 0, 0, 0);
 			b->setMaskType(3);
@@ -3724,8 +3717,8 @@
 			QTransform mm;
 			mm.translate(0, -pat.height * tline.length());
 			mm = f3e.ctm * mm;
-			int shade = 100;
-			CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
+		//	int shade = 100;
+		//	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 			int z = 0;
 			if (f3e.colored)
 				z = m_doc->itemAdd(PageItem::Symbol, PageItem::Unspecified, xCoor + mm.dx(), yCoor + mm.dy(), pat.width * tline.length(), pat.height * tline.length(), 0, CommonStrings::None, CommonStrings::None, true);
@@ -3749,7 +3742,7 @@
 				b->setPattern(id);
 			else
 			{
-				b->setFillShade(shade);
+				b->setFillShade(CurrFillShade);
 				b->setPatternMask(id);
 				b->setMaskTransform(b->width() / pat.width * 100, b->height() / pat.height * 100, 0, 0, 0, 0, 0);
 				b->setMaskType(3);

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18627&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h Sun Dec  8 17:31:43 2013
@@ -236,7 +236,8 @@
 	virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/);
 	virtual void clearSoftMask(GfxState * /*state*/);
 
-//	virtual void updateFillColor(GfxState *state);
+	virtual void updateFillColor(GfxState *state);
+	virtual void updateStrokeColor(GfxState *state);
 	virtual void updateFont(GfxState *state);
 	//----- text drawing
 	virtual void beginTextObject(GfxState *state);
@@ -266,7 +267,9 @@
 	QString UnicodeParsedString(GooString *s1);
 	bool pathIsClosed;
 	QString CurrColorFill;
+	int CurrFillShade;
 	QString CurrColorStroke;
+	int CurrStrokeShade;
 	Qt::PenCapStyle PLineEnd;
 	Qt::PenJoinStyle PLineJoin;
 	QVector<double> DashValues;




More information about the scribus-commit mailing list