r14288 by fschmid - Xara Importer:: some more types of transparent fills supporter, for correct display we need gradient masks though.

scribus-commit scribus-commit at lists.scribus.net
Fri Nov 13 12:45:22 CET 2009


Revision: 14288
Author: fschmid
Date: 2009-11-13T03:57:44.772378Z
Commit message: Xara Importer:: some more types of transparent fills supporter, for correct display we need gradient masks though.

Changeset: 
M  /trunk/Scribus/scribus/plugins/xarimplugin/importxar.h
M  /trunk/Scribus/scribus/plugins/xarimplugin/importxar.cpp

Diffs:
Index: scribus/plugins/xarimplugin/importxar.cpp
===================================================================
--- scribus/plugins/xarimplugin/importxar.cpp	(revision 14287)
+++ scribus/plugins/xarimplugin/importxar.cpp	(revision 14288)
@@ -542,6 +542,14 @@
 		handleBitmapFill(ts, dataLen);
 	else if (tag == 166)
 		handleFlatFillTransparency(ts);
+	else if (tag == 167)
+		handleSimpleGradientTransparency(ts, dataLen, true);
+	else if (tag == 168)
+		handleSimpleGradientTransparency(ts, dataLen, true);
+	else if (tag == 169)
+		handleEllipticalGradientTransparency(ts, dataLen);
+	else if (tag == 173)
+		handleFlatLineTransparency(ts);
 	else if ((tag == 174) || (tag == 175))
 		handleLineEnd(ts);
 	else if (tag == 176)
@@ -679,9 +687,77 @@
 	ts >> transVal >> transType;
 	XarStyle *gc = m_gc.top();
 	if (transType > 0)
+	{
 		gc->FillOpacity = transVal / 255.0;
+		gc->FillBlend = convertBlendMode(transType);
+	}
 }
 
+void XarPlug::handleSimpleGradientTransparency(QDataStream &ts, quint32 dataLen, bool linear)
+{
+	XarStyle *gc = m_gc.top();
+	double blx, bly, brx, bry;
+	quint8 transStart, transEnd, transType;
+	readCoords(ts, blx, bly);
+	readCoords(ts, brx, bry);
+	ts >> transStart >> transEnd >> transType;
+	if (dataLen == 35)
+	{
+		double p, p1;
+		ts >> p >> p1;
+	}
+	if (transType > 0)
+	{
+		double s = transStart / 255.0;
+		double e = transEnd / 255.0;
+		gc->FillOpacity = (s + e) / 2.0;
+		gc->FillBlend = convertBlendMode(transType);
+	}
+}
+
+void XarPlug::handleEllipticalGradientTransparency(QDataStream &ts, quint32 dataLen)
+{
+	XarStyle *gc = m_gc.top();
+	double blx, bly, brx, bry, tlx, tly;
+	quint8 transStart, transEnd, transType;
+	readCoords(ts, blx, bly);
+	readCoords(ts, tlx, tly);
+	readCoords(ts, brx, bry);
+	ts >> transStart >> transEnd >> transType;
+	if (dataLen == 43)
+	{
+		double p, p1;
+		ts >> p >> p1;
+	}
+	if (transType > 0)
+	{
+		double s = transStart / 255.0;
+		double e = transEnd / 255.0;
+		gc->FillOpacity = (s + e) / 2.0;
+		gc->FillBlend = convertBlendMode(transType);
+	}
+}
+
+int XarPlug::convertBlendMode(int val)
+{
+	int ret = 0;
+	if (val == 2)
+		ret = 6;
+	else if (val == 3)
+		ret = 10;
+	else if (val == 5)
+		ret = 13;
+	else if (val == 7)
+		ret = 7;
+	else if (val == 9)
+		ret = 15;
+	else if (val == 10)
+		ret = 12;
+	else
+		ret = 0;
+	return ret;
+}
+
 void XarPlug::handleSimpleGradientElliptical(QDataStream &ts, quint32 dataLen)
 {
 	XarStyle *gc = m_gc.top();
@@ -1016,6 +1092,23 @@
 	}
 }
 
+void XarPlug::handleLineWidth(QDataStream &ts)
+{
+	XarStyle *gc = m_gc.top();
+	quint32 val;
+	ts >> val;
+	gc->LWidth = val / 1000.0;
+}
+
+void XarPlug::handleFlatLineTransparency(QDataStream &ts)
+{
+	quint8 transVal, transType;
+	ts >> transVal >> transType;
+	XarStyle *gc = m_gc.top();
+	if (transType > 0)
+		gc->StrokeOpacity = transVal / 255.0;
+}
+
 void XarPlug::handleFlatFill(QDataStream &ts)
 {
 	XarStyle *gc = m_gc.top();
@@ -1030,14 +1123,6 @@
 	}
 }
 
-void XarPlug::handleLineWidth(QDataStream &ts)
-{
-	XarStyle *gc = m_gc.top();
-	quint32 val;
-	ts >> val;
-	gc->LWidth = val / 1000.0;
-}
-
 void XarPlug::createPolygonItem(int type)
 {
 	int z;
@@ -1523,6 +1608,8 @@
 			PageItem *item = gc->Elements.at(a);
 			item->setFillColor(gc->FillCol);
 			item->setFillTransparency(gc->FillOpacity);
+			item->setFillBlendmode(gc->FillBlend);
+			item->setLineTransparency(gc->StrokeOpacity);
 			item->setLineWidth(gc->LWidth);
 			item->setLineColor(gc->StrokeCol);
 			item->setLineJoin(gc->PLineJoin);
Index: scribus/plugins/xarimplugin/importxar.h
===================================================================
--- scribus/plugins/xarimplugin/importxar.h	(revision 14287)
+++ scribus/plugins/xarimplugin/importxar.h	(revision 14288)
@@ -59,7 +59,9 @@
 		PLineJoin(Qt::BevelJoin),
 		StrokeCol("Black"),
 		FillOpacity(0.0),
+		FillBlend(0),
 		StrokeOpacity(0.0),
+		StrokeBlend(0),
 		clipPath(),
 		fillPattern(""),
 		patternScaleX(0),
@@ -101,7 +103,9 @@
 	Qt::PenJoinStyle PLineJoin;
 	QString StrokeCol;
 	double FillOpacity;
+	int    FillBlend;
 	double StrokeOpacity;
+	int    StrokeBlend;
 	FPointArray clipPath;
 	QString fillPattern;
 	double patternScaleX;
@@ -154,6 +158,9 @@
 	void handleLineJoin(QDataStream &ts);
 	void handleQuickShapeSimple(QDataStream &ts, quint32 dataLen);
 	void handleFlatFillTransparency(QDataStream &ts);
+	void handleSimpleGradientTransparency(QDataStream &ts, quint32 dataLen, bool linear);
+	void handleEllipticalGradientTransparency(QDataStream &ts, quint32 dataLen);
+	int  convertBlendMode(int val);
 	void handleSimpleGradientElliptical(QDataStream &ts, quint32 dataLen);
 	void handleMultiGradientElliptical(QDataStream &ts);
 	void handleMultiGradientSkewed(QDataStream &ts);
@@ -163,8 +170,9 @@
 	void handleBitmapFill(QDataStream &ts, quint32 dataLen);
 	void defineBitmap(QDataStream &ts, quint32 dataLen, quint32 tag);
 	void handleLineColor(QDataStream &ts);
+	void handleLineWidth(QDataStream &ts);
+	void handleFlatLineTransparency(QDataStream &ts);
 	void handleFlatFill(QDataStream &ts);
-	void handleLineWidth(QDataStream &ts);
 	void createPolylineItem(int type);
 	void createPolygonItem(int type);
 	void finishItem(int z);




More information about the scribus-commit mailing list