r22614 by jghali - #15392: RGB colours changed when exported to PDF and SVG

scribus-commit scribus-commit at lists.scribus.net
Sun Aug 5 16:31:59 UTC 2018


Author: jghali
Date: Sun Aug  5 16:31:59 2018
New Revision: 22614

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22614
Log:
#15392: RGB colours changed when exported to PDF and SVG

Added:
    trunk/Scribus/scribus/sccolorstructs.cpp
    trunk/Scribus/scribus/sccolorstructs.h
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/sccolor.cpp
    trunk/Scribus/scribus/sccolor.h
    trunk/Scribus/scribus/sccolorengine.cpp
    trunk/Scribus/scribus/sccolorengine.h
    trunk/Scribus/scribus/scribusstructs.h
    trunk/Scribus/scribus/util_color.h
    trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj
    trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters
    trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
    trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt	(original)
+++ trunk/Scribus/scribus/CMakeLists.txt	Sun Aug  5 16:31:59 2018
@@ -699,6 +699,7 @@
 	sccolor.cpp
 	sccolorengine.cpp
 	sccolorshade.cpp
+	sccolorstructs.cpp
 	scdocoutput.cpp
 	scdocoutput_ps2.cpp
 	scdomelement.cpp

Modified: trunk/Scribus/scribus/sccolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/sccolor.cpp
==============================================================================
--- trunk/Scribus/scribus/sccolor.cpp	(original)
+++ trunk/Scribus/scribus/sccolor.cpp	Sun Aug  5 16:31:59 2018
@@ -29,6 +29,7 @@
 #include "scconfig.h"
 #include "scribuscore.h"
 #include "scribusdoc.h"
+#include "scribusstructs.h"
 
 ScColor::ScColor(void)
 {
@@ -178,6 +179,21 @@
 	}
 }
 
+void  ScColor::getRawRGBColor(RGBColorF* rgb) const
+{
+	if (m_Model == colorModelRGB)
+	{
+		rgb->r = m_values[0];
+		rgb->g = m_values[1];
+		rgb->b = m_values[2];
+		return;
+	}
+
+	rgb->r = 1.0 - qMin(1.0, m_values[0] + m_values[3]);
+	rgb->g = 1.0 - qMin(1.0, m_values[1] + m_values[3]);
+	rgb->b = 1.0 - qMin(1.0, m_values[2] + m_values[3]);
+}
+
 void ScColor::getRawRGBColor(int *r, int *g, int *b) const
 {
 	if (m_Model == colorModelRGB)
@@ -185,29 +201,31 @@
 		*r = qRound(m_values[0] * 255.0);
 		*g = qRound(m_values[1] * 255.0);
 		*b = qRound(m_values[2] * 255.0);
-	}
-	else
-	{
-		*r = 255 - qMin(255, qRound((m_values[0] + m_values[3]) * 255.0));
-		*g = 255 - qMin(255, qRound((m_values[1] + m_values[3]) * 255.0));
-		*b = 255 - qMin(255, qRound((m_values[2] + m_values[3]) * 255.0));
-	}
-}
-
-QColor ScColor::getRawRGBColor() const
-{
-	if (m_Model == colorModelRGB)
-	{
-		int r = qRound(m_values[0] * 255.0);
-		int g = qRound(m_values[1] * 255.0);
-		int b = qRound(m_values[2] * 255.0);
-		return QColor(r, g, b);
+		return;
 	}
 
 	double dR = 1.0 - qMin(1.0, m_values[0] + m_values[3]);
 	double dG = 1.0 - qMin(1.0, m_values[1] + m_values[3]);
 	double dB = 1.0 - qMin(1.0, m_values[2] + m_values[3]);
-	return QColor(qRound(dR * 255.0), qRound(dG * 255.0), qRound(dB * 255.0));
+	*r = qRound(dR * 255.0);
+	*g = qRound(dG * 255.0);
+	*b = qRound(dB * 255.0);
+}
+
+QColor ScColor::getRawRGBColor() const
+{
+	if (m_Model == colorModelRGB)
+	{
+		double r = m_values[0];
+		double g = m_values[1];
+		double b = m_values[2];
+		return QColor::fromRgbF(r, g, b);
+	}
+
+	double dR = 1.0 - qMin(1.0, m_values[0] + m_values[3]);
+	double dG = 1.0 - qMin(1.0, m_values[1] + m_values[3]);
+	double dB = 1.0 - qMin(1.0, m_values[2] + m_values[3]);
+	return QColor::fromRgbF(dR, dG, dB);
 }
 
 void ScColor::getRGB(int *r, int *g, int *b) const

Modified: trunk/Scribus/scribus/sccolor.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/sccolor.h
==============================================================================
--- trunk/Scribus/scribus/sccolor.h	(original)
+++ trunk/Scribus/scribus/sccolor.h	Sun Aug  5 16:31:59 2018
@@ -31,8 +31,8 @@
 
 #include "scribusapi.h"
 
-class ScribusDoc;
-
+class  ScribusDoc;
+struct RGBColorF;
 
 /**
   *@author Franz Schmid
@@ -94,6 +94,7 @@
 
 	/** \brief Returns the RGB color  
 	* Must not be called if color is the None Color. */
+	void getRawRGBColor(RGBColorF* rgb) const;
 	void getRawRGBColor(int *r, int *g, int *b) const;
 	QColor getRawRGBColor() const;
 

Modified: trunk/Scribus/scribus/sccolorengine.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/sccolorengine.cpp
==============================================================================
--- trunk/Scribus/scribus/sccolorengine.cpp	(original)
+++ trunk/Scribus/scribus/sccolorengine.cpp	Sun Aug  5 16:31:59 2018
@@ -21,11 +21,12 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <cmath>
+
 #include "sccolorengine.h"
 #include "scribuscore.h"
 #include "scribusdoc.h"
 #include "colormgmt/sccolormgmtengine.h"
-#include <cmath>
 
 QColor ScColorEngine::getRGBColor(const ScColor& color, const ScribusDoc* doc)
 {
@@ -538,17 +539,17 @@
 	}
 	else if (color.getColorModel() == colorModelRGB)
 	{
-		int h, s, v, snew, vnew;
-		QColor tmpR = color.getRawRGBColor();
-		tmpR.getHsv(&h, &s, &v);
-		snew = qRound(s * level / 100.0);
-		vnew = 255 - qRound(((255 - v) * level / 100.0));
-		tmpR.setHsv(h, snew, vnew);
-		tmpR.getRgb(&rgb.r, &rgb.g, &rgb.b);
+		HSVColorF hsv;
+		RGBColorF rgbF;
+		color.getRawRGBColor(&rgbF);
+		rgbF.toHsv(hsv);
+		hsv.s = hsv.s * (level / 100.0);
+		hsv.v = 1.0 - (1.0 - hsv.v) * (level / 100.0);
+		hsv.toRgb(rgb);
 		//We could also compute rgb shade using rgb directly
-		/*rgb.CR = 255 - ((255 - color.CR) * level / 100);
-		rgb.MG = 255 - ((255 - color.MG) * level / 100);
-		rgb.YB = 255 - ((255 - color.YB) * level / 100);*/
+		/*rgb.r = 255 - ((255 - color.m_values[0]) * level / 100);
+		rgb.g = 255 - ((255 - color.m_values[1]) * level / 100);
+		rgb.b = 255 - ((255 - color.m_values[2]) * level / 100);*/
 	}
 	else if (color.getColorModel() == colorModelLab)
 	{
@@ -577,17 +578,12 @@
 	}
 	else if (color.getColorModel() == colorModelRGB)
 	{
-		int h, s, v, snew, vnew;
-		QColor tmpR = color.getRawRGBColor();
-		tmpR.getHsv(&h, &s, &v);
-		snew = qRound(s * level / 100.0);
-		vnew = 255 - qRound(((255 - v) * level / 100.0));
-		RGBColor tmpRgb;
-		tmpR.setHsv(h, snew, vnew);
-		tmpR.getRgb(&tmpRgb.r, &tmpRgb.g, &tmpRgb.b);
-		rgb.r = tmpRgb.r / 255.0;
-		rgb.g = tmpRgb.g / 255.0;
-		rgb.b = tmpRgb.b / 255.0;
+		HSVColorF hsv;
+		color.getRawRGBColor(&rgb);
+		rgb.toHsv(hsv);
+		hsv.s = hsv.s * (level / 100.0);
+		hsv.v = 1.0 - (1.0 - hsv.v) * (level / 100.0);
+		hsv.toRgb(rgb);
 		//We could also compute rgb shade using rgb directly
 		/*rgb.r = 1.0 - ((1.0 - color.m_values[0]) * level / 100);
 		rgb.g = 1.0 - ((1.0 - color.m_values[1]) * level / 100);

Modified: trunk/Scribus/scribus/sccolorengine.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/sccolorengine.h
==============================================================================
--- trunk/Scribus/scribus/sccolorengine.h	(original)
+++ trunk/Scribus/scribus/sccolorengine.h	Sun Aug  5 16:31:59 2018
@@ -26,7 +26,7 @@
 
 #include "scribusapi.h"
 #include "sccolor.h"
-#include "scribusstructs.h"
+#include "sccolorstructs.h"
 class ScribusDoc;
 
 class SCRIBUS_API ScColorEngine

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h	(original)
+++ trunk/Scribus/scribus/scribusstructs.h	Sun Aug  5 16:31:59 2018
@@ -31,6 +31,7 @@
 #include "fpointarray.h"
 #include "pageitem.h"
 #include "margins.h"
+#include "sccolorstructs.h"
 #include "scfonts.h"
 #include "scimagestructs.h"
 #include "sctextstruct.h"
@@ -38,44 +39,6 @@
 #include "colormgmt/sccolormgmtstructs.h"
 
 extern bool SCRIBUS_API compareDouble(double, double);
-
-struct RGBColor
-{
-	int r;
-	int g;
-	int b;
-	RGBColor() {r=g=b=0;}
-	void getValues(int& vr, int& vg, int& vb) { vr = r; vg = g; vb = b; }
-};
-
-struct RGBColorF
-{
-	double r;
-	double g;
-	double b;
-	RGBColorF() {r=g=b=0.0;}
-	void getValues(double& vr, double& vg, double& vb) { vr = r; vg = g; vb = b; }
-};
-
-struct CMYKColor
-{
-	int c;
-	int m;
-	int y;
-	int k;
-	CMYKColor() {c=m=y=k=0;}
-	void getValues(int& vc, int& vm, int& vy, int& vk) { vc = c; vm = m; vy = y; vk = k; }
-};
-
-struct CMYKColorF
-{
-	double c;
-	double m;
-	double y;
-	double k;
-	CMYKColorF() {c=m=y=k=0.0;}
-	void getValues(double& vc, double& vm, double& vy, double& vk) { vc = c; vm = m; vy = y; vk = k; }
-};
 
 struct CopyContentsBuffer
 {

Modified: trunk/Scribus/scribus/util_color.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/scribus/util_color.h
==============================================================================
--- trunk/Scribus/scribus/util_color.h	(original)
+++ trunk/Scribus/scribus/util_color.h	Sun Aug  5 16:31:59 2018
@@ -28,6 +28,7 @@
 QPixmap SCRIBUS_API *getSmallPixmap(QColor rgb);
 QPixmap SCRIBUS_API *getWidePixmap(QColor rgb);
 QPixmap SCRIBUS_API *getFancyPixmap(const ScColor& col, ScribusDoc* doc);
+
 /*! \brief Put toPaint pixmap into target at the x, y place.
 There is handled the alpha channel/transparency too. In the beginning
 is the target pixmap filled with all_transparent mask. In the case of
@@ -55,6 +56,7 @@
  * \param shade shade value.
  */
 QColor SCRIBUS_API getOldColorShade(const QColor& color, int shade);
+
 /*! \brief Compute color shade of a rgb color using pre-1.3.4 method
  * \param red the red component.
  * \param green the green component.
@@ -62,6 +64,7 @@
  * \param shade shade value.
  */
 QColor SCRIBUS_API getOldColorShade(uchar red, uchar green, uchar blue, int shade);
+
 /*! \brief Convert a color in RGB space to HSV space (Hue, Saturation, Value).
  * \param red the red component (modified in place).
  * \param green the green component (modified in place).
@@ -77,12 +80,14 @@
  * \param value the value component (modified in place).
  */
 void SCRIBUS_API HSVTORGB ( uchar& hue, uchar& saturation, uchar& value );
+
 /*! \brief Convert a color in RGB space to HLS space (Hue, Lightness, Saturation).
  * \param red the red component.
  * \param green the green component.
  * \param blue the blue component.
  */
 void SCRIBUS_API RGBTOHLS ( uchar& red, uchar& green, uchar& blue );
+
 /*! \brief Implement the HLS "double hex-cone".
  * \param n1 lightness fraction (?)
  * \param n2 saturation fraction (?)
@@ -90,6 +95,7 @@
  * \return HLS value.
  */
 double SCRIBUS_API HLSVALUE ( double n1, double n2, double hue );
+
 /*! \brief Convert a color in HLS space to RGB space.
  * \param hue the hue component (modified in place).
  * \param lightness the lightness component (modified in place).

Modified: trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj	Sun Aug  5 16:31:59 2018
@@ -345,6 +345,7 @@
     <ClInclude Include="..\..\..\scribus\palettes\paletteloader_swatchbook.h" />
     <ClInclude Include="..\..\..\scribus\pdfstructs.h" />
     <ClInclude Include="..\..\..\scribus\pdfwriter.h" />
+    <ClInclude Include="..\..\..\scribus\sccolorstructs.h" />
     <ClInclude Include="..\..\..\scribus\styles\cellstyle.h" />
     <moc Include="..\..\..\scribus\ui\charselect.h" />
     <moc Include="..\..\..\scribus\ui\charselectenhanced.h" />
@@ -882,6 +883,7 @@
     <ClCompile Include="..\..\..\scribus\pdfwriter.cpp" />
     <ClCompile Include="..\..\..\scribus\qtiocompressor.cpp" />
     <ClCompile Include="..\..\..\scribus\imagedataloaders\scimgdataloader_ora.cpp" />
+    <ClCompile Include="..\..\..\scribus\sccolorstructs.cpp" />
     <ClCompile Include="..\..\..\scribus\selectionrubberband.cpp" />
     <ClCompile Include="..\..\..\scribus\text\boxes.cpp" />
     <ClCompile Include="..\..\..\scribus\text\glyphcluster.cpp" />

Modified: trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters	Sun Aug  5 16:31:59 2018
@@ -794,6 +794,9 @@
     <ClInclude Include="..\..\..\scribus\pageitemiterator.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\scribus\sccolorstructs.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2474,6 +2477,9 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\..\scribus\pageitemiterator.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\sccolorstructs.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>

Modified: trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj	Sun Aug  5 16:31:59 2018
@@ -345,6 +345,7 @@
     <ClInclude Include="..\..\..\scribus\palettes\paletteloader_swatchbook.h" />
     <ClInclude Include="..\..\..\scribus\pdfstructs.h" />
     <ClInclude Include="..\..\..\scribus\pdfwriter.h" />
+    <ClInclude Include="..\..\..\scribus\sccolorstructs.h" />
     <ClInclude Include="..\..\..\scribus\styles\cellstyle.h" />
     <moc Include="..\..\..\scribus\ui\charselect.h" />
     <moc Include="..\..\..\scribus\ui\charselectenhanced.h" />
@@ -882,6 +883,7 @@
     <ClCompile Include="..\..\..\scribus\pdfwriter.cpp" />
     <ClCompile Include="..\..\..\scribus\qtiocompressor.cpp" />
     <ClCompile Include="..\..\..\scribus\imagedataloaders\scimgdataloader_ora.cpp" />
+    <ClCompile Include="..\..\..\scribus\sccolorstructs.cpp" />
     <ClCompile Include="..\..\..\scribus\selectionrubberband.cpp" />
     <ClCompile Include="..\..\..\scribus\text\boxes.cpp" />
     <ClCompile Include="..\..\..\scribus\text\glyphcluster.cpp" />

Modified: trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22614&path=/trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters	Sun Aug  5 16:31:59 2018
@@ -794,6 +794,9 @@
     <ClInclude Include="..\..\..\scribus\pageitemiterator.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\scribus\sccolorstructs.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2474,6 +2477,9 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\..\scribus\pageitemiterator.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\sccolorstructs.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>




More information about the scribus-commit mailing list