r14825 by fschmid - Fixed Bug #8878: strange results when applying pattern based transparency

scribus-commit scribus-commit at lists.scribus.net
Fri Feb 26 15:40:27 CET 2010


Revision: 14825
Author: fschmid
Date: 2010-02-26T14:31:01.665936Z
Commit message: Fixed Bug #8878: strange results when applying pattern based transparency

Changeset: 
M  /trunk/Scribus/scribus/pageitem_imageframe.cpp
M  /trunk/Scribus/scribus/pdflib_core.cpp
M  /trunk/Scribus/scribus/scpainter.cpp
M  /trunk/Scribus/scribus/scpainter.h

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 14824)
+++ scribus/pdflib_core.cpp	(revision 14825)
@@ -5842,7 +5842,7 @@
 			double r, g, b;
 			qStopColor.getRgbF(&r, &g, &b);
 			if ((GType == 4) || (GType == 5))
-				a = 1.0 - (0.3 * r + 0.59 * g + 0.11 * b);
+				a = /* 1.0 - */ (0.3 * r + 0.59 * g + 0.11 * b);
 			if ((cst == 0) && (actualStop != 0.0))
 			{
 				StopVec.append(0.0);
@@ -5870,7 +5870,7 @@
 			PutDoc("/ShadingType 3\n");
 		PutDoc("/ColorSpace /DeviceGray\n");
 		PutDoc("/Extend [true true]\n");
-		if (GType == 1)
+		if ((GType == 1) || (GType == 4))
 			PutDoc("/Coords ["+FToStr(StartX)+" "+FToStr(-StartY)+" "+FToStr(EndX)+" "+FToStr(-EndY)+"]\n");
 		else
 			PutDoc("/Coords ["+FToStr(FocalX)+" "+FToStr(-FocalY)+" 0.0 "+FToStr(StartX)+" "+FToStr(-StartY)+" "+FToStr(sqrt(pow(EndX - StartX, 2) + pow(EndY - StartY,2)))+"]\n");
@@ -6332,8 +6332,11 @@
 	colorShades.clear();
 	QTransform mpa;
 	bool spotMode = false;
-	mpa.translate(currItem->xPos() - ActPageP->xOffset(), ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()));
-	mpa.rotate(-currItem->rotation());
+	if (inPattern == 0)
+	{
+		mpa.translate(currItem->xPos() - ActPageP->xOffset(), ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()));
+		mpa.rotate(-currItem->rotation());
+	}
 	if (Gskew == 90)
 		Gskew = 1;
 	else if (Gskew == 180)
Index: scribus/scpainter.cpp
===================================================================
--- scribus/scpainter.cpp	(revision 14824)
+++ scribus/scpainter.cpp	(revision 14825)
@@ -1175,7 +1175,7 @@
 			double r, g, b;
 			qStopColor.getRgbF(&r, &g, &b);
 			if (maskMode == 3)
-				a = 1.0 - (0.3 * r + 0.59 * g + 0.11 * b);
+				a = /* 1.0 - */(0.3 * r + 0.59 * g + 0.11 * b);
 			cairo_pattern_add_color_stop_rgba (pat, colorStops[ offset ]->rampPoint, r, g, b, a);
 		}
 		cairo_matrix_t matrix;
@@ -1217,10 +1217,10 @@
 				{
 					r = *s;
 					if (qAlpha(r) == 0)
-						k = 255;
+						k = 0; // 255;
 					else
 						k = qMin(qRound(0.3 * qRed(r) + 0.59 * qGreen(r) + 0.11 * qBlue(r)), 255);
-					*s = qRgba(qRed(r), qGreen(r), qBlue(r), 255 - k);
+					*s = qRgba(qRed(r), qGreen(r), qBlue(r), /* 255 - */ k);
 					s++;
 				}
 			}
@@ -2055,7 +2055,7 @@
 #endif
 }
 
-void ScPainter::drawImage( QImage *image )
+void ScPainter::drawImage( QImage *image)
 {
 #ifdef HAVE_CAIRO
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 6)
Index: scribus/pageitem_imageframe.cpp
===================================================================
--- scribus/pageitem_imageframe.cpp	(revision 14824)
+++ scribus/pageitem_imageframe.cpp	(revision 14825)
@@ -142,9 +142,46 @@
 						p->scale(1, -1);
 					}
 					p->translate(LocalX*LocalScX, LocalY*LocalScY);
+					double mscalex = 1.0 / LocalScX;
+					double mscaley = 1.0 / LocalScY;
 					p->scale(LocalScX, LocalScY);
 					if (pixm.imgInfo.lowResType != 0)
+					{
 						p->scale(pixm.imgInfo.lowResScale, pixm.imgInfo.lowResScale);
+						mscalex *= 1.0 / pixm.imgInfo.lowResScale;
+						mscaley *= 1.0 / pixm.imgInfo.lowResScale;
+					}
+					if ((GrMask == 1) || (GrMask == 2) || (GrMask == 4) || (GrMask == 5))
+					{
+						if ((GrMask == 1) || (GrMask == 2))
+							p->setMaskMode(1);
+						else
+							p->setMaskMode(3);
+						if ((!gradientMaskVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientMaskVal)))
+							gradientMaskVal = "";
+						if (!(gradientMaskVal.isEmpty()) && (m_Doc->docGradients.contains(gradientMaskVal)))
+							mask_gradient = m_Doc->docGradients[gradientMaskVal];
+						p->mask_gradient = mask_gradient;
+						if ((GrMask == 1) || (GrMask == 4))
+							p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX * mscalex, GrMaskStartY * mscaley), FPoint(GrMaskEndX * mscalex, GrMaskEndY * mscaley), FPoint(GrMaskStartX * mscalex, GrMaskStartY * mscaley), GrMaskScale, GrMaskSkew);
+						else
+							p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX * mscalex, GrMaskStartY * mscaley), FPoint(GrMaskEndX * mscalex, GrMaskEndY * mscaley), FPoint(GrMaskFocalX * mscalex, GrMaskFocalY * mscaley), GrMaskScale, GrMaskSkew);
+					}
+					else if ((GrMask == 3) || (GrMask == 6))
+					{
+						if ((patternMaskVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternMaskVal)))
+							p->setMaskMode(0);
+						else
+						{
+							p->setPatternMask(&m_Doc->docPatterns[patternMaskVal], patternMaskScaleX * mscalex, patternMaskScaleY * mscaley, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY);
+							if (GrMask == 3)
+								p->setMaskMode(2);
+							else
+								p->setMaskMode(4);
+						}
+					}
+					else
+						p->setMaskMode(0);
 					p->drawImage(pixm.qImagePtr());
 				}
 			}
Index: scribus/scpainter.h
===================================================================
--- scribus/scpainter.h	(revision 14824)
+++ scribus/scpainter.h	(revision 14825)
@@ -78,7 +78,7 @@
 	
 	virtual void setClipPath();
 
-	virtual void drawImage( QImage *image );
+	virtual void drawImage( QImage *image);
 	virtual void setupPolygon(FPointArray *points, bool closed = true);
 	virtual void drawPolygon();
 	virtual void drawPolyLine();




More information about the scribus-commit mailing list