r17919 by fschmid - Postscript Exporter: fixed non working mesh gradients in patterns.

scribus-commit scribus-commit at lists.scribus.net
Thu Nov 29 20:55:27 UTC 2012


Author: fschmid
Date: Thu Nov 29 20:55:27 2012
New Revision: 17919

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17919
Log:
Postscript Exporter: fixed non working mesh gradients in patterns.

Modified:
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/pslib.h

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17919&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Thu Nov 29 20:55:27 2012
@@ -3790,14 +3790,12 @@
 
 void PSLib::HandleMeshGradient(PageItem* c, bool gcr)
 {
-	QString GCol;
 	QString hs,ss,vs,ks;
 	int ch,cs,cv,ck;
 	QStringList cols;
 	QStringList colorValues;
 	QStringList spotColorSet;
 	QStringList tmpAddedColors;
-	QString entx = "";
 	tmpAddedColors.clear();
 	QList<int> colsSh;
 	for (int grow = 0; grow < c->meshGradientArray.count(); grow++)
@@ -3877,7 +3875,6 @@
 	if ((DoSep) || (GraySc))
 	{
 		PutStream("/ColorSpace /DeviceGray\n");
-		entx = "0 1";
 	}
 	else if ((useSpotColors) && ((spotColorSet.count() > 0) && (spotColorSet.count() < 28)))
 	{
@@ -3885,7 +3882,6 @@
 		for (int sc = 0; sc < spotColorSet.count(); sc++)
 		{
 			PutStream(" ("+spotColorSet.at(sc)+")");
-			entx += " 0 1";
 		}
 		PutStream("]\n");
 		PutStream("/DeviceCMYK\n");
@@ -3917,19 +3913,10 @@
 	else
 	{
 		PutStream("/ColorSpace /DeviceCMYK\n");
-		entx = "0 1 0 1 0 1 0 1";
-	}
-	PutStream("/BitsPerCoordinate 32\n");
-	PutStream("/BitsPerComponent 16\n");
-	PutStream("/BitsPerFlag 8\n");
-	PutStream("/Decode [-40000 40000 -40000 40000 "+entx+"]\n");
-	PutStream("/DataSource currentfile /ASCII85Decode filter /FlateDecode filter\n");
-	PutStream(">>\n");
-	PutStream(">>\n");
-	PutStream("[1 0 0 1 0 0] makepattern\n");
-	QByteArray vertStream;
-	QDataStream vst(&vertStream, QIODevice::WriteOnly);
-	vst.setByteOrder(QDataStream::BigEndian);
+	}
+	PutStream("/DataSource [\n");
+	QString vertStream;
+	QTextStream vst(&vertStream, QIODevice::WriteOnly);
 	quint8 flg = 0;
 	for (int grow = 0; grow < c->meshGradientArray.count()-1; grow++)
 	{
@@ -3943,22 +3930,23 @@
 			int colInd2 = grow * c->meshGradientArray[grow].count() + gcol + 1;
 			int colInd3 = (grow + 1) * c->meshGradientArray[grow].count() + gcol + 1;
 			int colInd4 = (grow + 1) * c->meshGradientArray[grow].count() + gcol;
-			vst << flg;
-			vst << encode32dVal(mp4.gridPoint.x()) << encode32dVal(-mp4.gridPoint.y()) << encode32dVal(mp4.controlTop.x()) << encode32dVal(-mp4.controlTop.y()) << encode32dVal(mp1.controlBottom.x()) << encode32dVal(-mp1.controlBottom.y());
-			vst << encode32dVal(mp1.gridPoint.x()) << encode32dVal(-mp1.gridPoint.y()) << encode32dVal(mp1.controlRight.x()) << encode32dVal(-mp1.controlRight.y()) << encode32dVal(mp2.controlLeft.x()) << encode32dVal(-mp2.controlLeft.y());
-			vst << encode32dVal(mp2.gridPoint.x()) << encode32dVal(-mp2.gridPoint.y()) << encode32dVal(mp2.controlBottom.x()) << encode32dVal(-mp2.controlBottom.y()) << encode32dVal(mp3.controlTop.x()) << encode32dVal(-mp3.controlTop.y());
-			vst << encode32dVal(mp3.gridPoint.x()) << encode32dVal(-mp3.gridPoint.y()) << encode32dVal(mp3.controlLeft.x()) << encode32dVal(-mp3.controlLeft.y()) << encode32dVal(mp4.controlRight.x()) << encode32dVal(-mp4.controlRight.y());
-			vst << encode32dVal(mp4.controlColor.x()) << encode32dVal(-mp4.controlColor.y());
-			vst << encode32dVal(mp1.controlColor.x()) << encode32dVal(-mp1.controlColor.y());
-			vst << encode32dVal(mp2.controlColor.x()) << encode32dVal(-mp2.controlColor.y());
-			vst << encode32dVal(mp3.controlColor.x()) << encode32dVal(-mp3.controlColor.y());
-			encodeColor(vst, colorValues[colInd4]);
-			encodeColor(vst, colorValues[colInd1]);
-			encodeColor(vst, colorValues[colInd2]);
-			encodeColor(vst, colorValues[colInd3]);
-		}
-	}
-	PutImageDataToStream(vertStream);
+			vst << flg << "\n";
+			vst << mp4.gridPoint.x() << " " << -mp4.gridPoint.y() << " " << mp4.controlTop.x() << " " << -mp4.controlTop.y() << " " << mp1.controlBottom.x() << " " << -mp1.controlBottom.y() << "\n";
+			vst << mp1.gridPoint.x() << " " << -mp1.gridPoint.y() << " " << mp1.controlRight.x() << " " << -mp1.controlRight.y() << " " << mp2.controlLeft.x() << " " << -mp2.controlLeft.y() << "\n";
+			vst << mp2.gridPoint.x() << " " << -mp2.gridPoint.y() << " " << mp2.controlBottom.x() << " " << -mp2.controlBottom.y() << " " << mp3.controlTop.x() << " " << -mp3.controlTop.y() << "\n";
+			vst << mp3.gridPoint.x() << " " << -mp3.gridPoint.y() << " " << mp3.controlLeft.x() << " " << -mp3.controlLeft.y() << " " << mp4.controlRight.x() << " " << -mp4.controlRight.y() << "\n";
+			vst << mp4.controlColor.x() << " " << -mp4.controlColor.y() << "\n";
+			vst << mp1.controlColor.x() << " " << -mp1.controlColor.y() << "\n";
+			vst << mp2.controlColor.x() << " " << -mp2.controlColor.y() << "\n";
+			vst << mp3.controlColor.x() << " " << -mp3.controlColor.y() << "\n";
+			vst << colorValues[colInd4] << " " << colorValues[colInd1] << " " << colorValues[colInd2] << " " << colorValues[colInd3] << "\n";
+		}
+	}
+	PutStream(vertStream);
+	PutStream("]\n");
+	PutStream(">>\n");
+	PutStream(">>\n");
+	PutStream("[1 0 0 1 0 0] makepattern\n");
 	PutStream("setpattern\n");
 	if (fillRule)
 		PutStream("eofill\n");
@@ -3976,14 +3964,12 @@
 
 void PSLib::HandlePatchMeshGradient(PageItem* c, bool gcr)
 {
-	QString GCol;
 	QString hs,ss,vs,ks;
 	int ch,cs,cv,ck;
 	QStringList cols;
 	QStringList colorValues;
 	QStringList spotColorSet;
 	QList<int> colsSh;
-	QString entx = "";
 	for (int col = 0; col < c->meshGradientPatches.count(); col++)
 	{
 		meshGradientPatch patch = c->meshGradientPatches[col];
@@ -4071,16 +4057,13 @@
 	if ((DoSep) || (GraySc))
 	{
 		PutStream("/ColorSpace /DeviceGray\n");
-		entx = "0 1";
 	}
 	else if ((useSpotColors) && ((spotColorSet.count() > 0) && (spotColorSet.count() < 28)))
 	{
-		entx = "0 1 0 1 0 1 0 1";
 		PutStream("/ColorSpace [ /DeviceN [/Cyan /Magenta /Yellow /Black");
 		for (int sc = 0; sc < spotColorSet.count(); sc++)
 		{
 			PutStream(" ("+spotColorSet.at(sc)+")");
-			entx += " 0 1";
 		}
 		PutStream("]\n");
 		PutStream("/DeviceCMYK\n");
@@ -4112,19 +4095,10 @@
 	else
 	{
 		PutStream("/ColorSpace /DeviceCMYK\n");
-		entx = "0 1 0 1 0 1 0 1";
-	}
-	PutStream("/BitsPerCoordinate 32\n");
-	PutStream("/BitsPerComponent 16\n");
-	PutStream("/BitsPerFlag 8\n");
-	PutStream("/Decode [-40000 40000 -40000 40000 "+entx+"]\n");
-	PutStream("/DataSource currentfile /ASCII85Decode filter /FlateDecode filter\n");
-	PutStream(">>\n");
-	PutStream(">>\n");
-	PutStream("[1 0 0 1 0 0] makepattern\n");
-	QByteArray vertStream;
-	QDataStream vst(&vertStream, QIODevice::WriteOnly);
-	vst.setByteOrder(QDataStream::BigEndian);
+	}
+	PutStream("/DataSource [\n");
+	QString vertStream;
+	QTextStream vst(&vertStream, QIODevice::WriteOnly);
 	quint8 flg = 0;
 	for (int col = 0; col < c->meshGradientPatches.count(); col++)
 	{
@@ -4137,49 +4111,28 @@
 		int colInd2 = 4 * col + 1;
 		int colInd3 = 4 * col + 2;
 		int colInd4 = 4 * col + 3;
-		vst << flg;
-		vst << encode32dVal(mp4.gridPoint.x()) << encode32dVal(-mp4.gridPoint.y()) << encode32dVal(mp4.controlTop.x()) << encode32dVal(-mp4.controlTop.y()) << encode32dVal(mp1.controlBottom.x()) << encode32dVal(-mp1.controlBottom.y());
-		vst << encode32dVal(mp1.gridPoint.x()) << encode32dVal(-mp1.gridPoint.y()) << encode32dVal(mp1.controlRight.x()) << encode32dVal(-mp1.controlRight.y()) << encode32dVal(mp2.controlLeft.x()) << encode32dVal(-mp2.controlLeft.y());
-		vst << encode32dVal(mp2.gridPoint.x()) << encode32dVal(-mp2.gridPoint.y()) << encode32dVal(mp2.controlBottom.x()) << encode32dVal(-mp2.controlBottom.y()) << encode32dVal(mp3.controlTop.x()) << encode32dVal(-mp3.controlTop.y());
-		vst << encode32dVal(mp3.gridPoint.x()) << encode32dVal(-mp3.gridPoint.y()) << encode32dVal(mp3.controlLeft.x()) << encode32dVal(-mp3.controlLeft.y()) << encode32dVal(mp4.controlRight.x()) << encode32dVal(-mp4.controlRight.y());
-		vst << encode32dVal(mp4.controlColor.x()) << encode32dVal(-mp4.controlColor.y());
-		vst << encode32dVal(mp1.controlColor.x()) << encode32dVal(-mp1.controlColor.y());
-		vst << encode32dVal(mp2.controlColor.x()) << encode32dVal(-mp2.controlColor.y());
-		vst << encode32dVal(mp3.controlColor.x()) << encode32dVal(-mp3.controlColor.y());
-		encodeColor(vst, colorValues[colInd4]);
-		encodeColor(vst, colorValues[colInd1]);
-		encodeColor(vst, colorValues[colInd2]);
-		encodeColor(vst, colorValues[colInd3]);
-	}
-	PutImageDataToStream(vertStream);
+		vst << flg << "\n";
+		vst << mp4.gridPoint.x() << " " << -mp4.gridPoint.y() << " " << mp4.controlTop.x() << " " << -mp4.controlTop.y() << " " << mp1.controlBottom.x() << " " << -mp1.controlBottom.y() << "\n";
+		vst << mp1.gridPoint.x() << " " << -mp1.gridPoint.y() << " " << mp1.controlRight.x() << " " << -mp1.controlRight.y() << " " << mp2.controlLeft.x() << " " << -mp2.controlLeft.y() << "\n";
+		vst << mp2.gridPoint.x() << " " << -mp2.gridPoint.y() << " " << mp2.controlBottom.x() << " " << -mp2.controlBottom.y() << " " << mp3.controlTop.x() << " " << -mp3.controlTop.y() << "\n";
+		vst << mp3.gridPoint.x() << " " << -mp3.gridPoint.y() << " " << mp3.controlLeft.x() << " " << -mp3.controlLeft.y() << " " << mp4.controlRight.x() << " " << -mp4.controlRight.y() << "\n";
+		vst << mp4.controlColor.x() << " " << -mp4.controlColor.y() << "\n";
+		vst << mp1.controlColor.x() << " " << -mp1.controlColor.y() << "\n";
+		vst << mp2.controlColor.x() << " " << -mp2.controlColor.y() << "\n";
+		vst << mp3.controlColor.x() << " " << -mp3.controlColor.y() << "\n";
+		vst << colorValues[colInd4] << " " << colorValues[colInd1] << " " << colorValues[colInd2] << " " << colorValues[colInd3] << "\n";
+	}
+	PutStream(vertStream);
+	PutStream("]\n");
+	PutStream(">>\n");
+	PutStream(">>\n");
+	PutStream("[1 0 0 1 0 0] makepattern\n");
 	PutStream("setpattern\n");
 	if (fillRule)
 		PutStream("eofill\n");
 	else
 		PutStream("fill\n");
 	return;
-}
-
-
-quint32 PSLib::encode32dVal(double val)
-{
-	quint32 res = static_cast<quint32>(((val - (-40000.0)) / 80000.0) * 0xFFFFFFFF);
-	return res;
-}
-
-quint16 PSLib::encode16dVal(double val)
-{
-	quint16 m = val * 0xFFFF;
-	return m;
-}
-
-void PSLib::encodeColor(QDataStream &vs, QString col)
-{
-	QStringList gcol = col.split(" ");
-	for (int gcs = 0; gcs < gcol.count(); gcs++)
-	{
-		vs << encode16dVal(gcol[gcs].toDouble());
-	}
 }
 
 void PSLib::HandleDiamondGradient(PageItem* c, bool gcr)

Modified: trunk/Scribus/scribus/pslib.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17919&path=/trunk/Scribus/scribus/pslib.h
==============================================================================
--- trunk/Scribus/scribus/pslib.h (original)
+++ trunk/Scribus/scribus/pslib.h Thu Nov 29 20:55:27 2012
@@ -159,10 +159,6 @@
 		void WriteASCII85Bytes(const QByteArray& array);
 		void WriteASCII85Bytes(const unsigned char* array, int length);
 
-		quint32 encode32dVal(double val);
-		quint16 encode16dVal(double val);
-		void encodeColor(QDataStream &vs, QString col);
-
 		void paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& endOffsetFactors, bool gcr);
 
 		Optimization optimization;




More information about the scribus-commit mailing list