r14510 by jghali - very first bits of colorspace support

scribus-commit scribus-commit at lists.scribus.net
Mon Jan 11 00:55:30 CET 2010


Revision: 14510
Author: jghali
Date: 2010-01-10T10:38:10.720554Z
Commit message: very first bits of colorspace support

Changeset: 
M  /trunk/Scribus/scribus/colormgmt/sccolormgmtstructs.h
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata.cpp
M  /trunk/Scribus/scribus/colormgmt/CMakeLists.txt
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata.h
M  /trunk/Scribus/win32/vc8/Scribus.vcproj
M  /trunk/Scribus/scribus/colormgmt/sccolormgmtstructs.cpp

Diffs:
Index: scribus/colormgmt/sccolorspacedata.cpp
===================================================================
--- scribus/colormgmt/sccolorspacedata.cpp	(revision 0)
+++ scribus/colormgmt/sccolorspacedata.cpp	(revision 14510)
@@ -0,0 +1,105 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+
+#include "sccolorspacedata.h"
+#include "sccolormgmtengine.h"
+
+ScColorTransform ScColorSpaceData::createTransform(const ScColorSpaceData& outputSpace, eRenderIntent renderIntent, 
+	                               long transformFlags)
+{
+	ScColorTransform colorTransform;
+	if (m_profile && outputSpace.profile())
+	{
+		colorTransform = m_profile.engine().createTransform(m_profile, m_colorFormat, 
+		                                    outputSpace.profile(), outputSpace.colorFormat(), 
+											renderIntent, transformFlags);
+	}
+	return colorTransform;
+}
+
+ScColorTransform ScColorSpaceData::createTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+                                   eRenderIntent renderIntent, long transformFlags)
+{
+	ScColorTransform colorTransform;
+	if (m_profile)
+	{
+		colorTransform = m_profile.engine().createTransform(m_profile, m_colorFormat, 
+		                                    outputProfile, outputFormat, renderIntent, 
+											transformFlags);
+	}
+	return colorTransform;
+}
+
+ScColorTransform ScColorSpaceData::createProofingTransform(const ScColorSpaceData& outputSpace, const ScColorProfile& proofing, 
+	                               eRenderIntent renderIntent,  eRenderIntent proofingIntent, long transformFlags)
+{
+	ScColorTransform colorTransform;
+	if (m_profile && outputSpace.profile())
+	{
+		colorTransform = m_profile.engine().createProofingTransform(m_profile, m_colorFormat, 
+		                                    outputSpace.profile(), outputSpace.colorFormat(), 
+											proofing, renderIntent, proofingIntent, transformFlags);
+	}
+	return colorTransform;
+}
+
+ScColorTransform ScColorSpaceData::createProofingTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+                                   const ScColorProfile& proofing, eRenderIntent renderIntent, 
+                                   eRenderIntent proofingIntent, long transformFlags)
+{
+	ScColorTransform colorTransform;
+	if (m_profile)
+	{
+		colorTransform = m_profile.engine().createProofingTransform(m_profile, m_colorFormat, 
+		                                    outputProfile, outputFormat, proofing, renderIntent, 
+											proofingIntent, transformFlags);
+	}
+	return colorTransform;
+}
+
+bool ScColorSpaceData::convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	                     void* dataIn, void* dataOut, uint numElems, ScColorTransform* lastTrans)
+{
+	ScColorTransform transform;
+	if (lastTrans)
+		transform = *lastTrans;
+	if (!transform)
+		transform = createTransform(data, renderIntent, transformFlags);	
+
+	bool success = false;
+	if (transform)
+	{
+		success = transform.apply(dataIn, dataOut, numElems);
+		if (!this->hasAlphaChannel() && data.hasAlphaChannel())
+			data.flattenAlpha(dataOut, numElems);
+		success = true;
+	}
+	return success;
+}
+
+bool ScColorSpaceData::convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	                     void* dataIn, QIODevice* device, uint numElems, ScColorTransform* lastTrans)
+{
+	bool success = false;
+	uint numChannels = data.numChannels();
+	uint bytesPerChannels = data.bytesPerChannel();
+	uint dataSize    = numChannels * bytesPerChannels * numElems;
+	if (dataSize == 0)
+		return false;
+	char *dataBuffer = (char*) malloc(dataSize);
+	if (dataBuffer)
+	{
+		success = convert(data, renderIntent, transformFlags, dataIn, dataBuffer, numElems, lastTrans);
+		if (success)
+		{
+			qint64 written = device->write((const char*) dataBuffer, dataSize);
+			success = (written == (qint64) dataSize);
+		}
+		free(dataBuffer);
+	}
+	return success;
+}
\ No newline at end of file
Index: scribus/colormgmt/sccolorspacedata.h
===================================================================
--- scribus/colormgmt/sccolorspacedata.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata.h	(revision 14510)
@@ -0,0 +1,57 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+
+#ifndef SCCOLORSPACEDATA_H
+#define SCCOLORSPACEDATA_H
+
+#include <QIODevice>
+#include "sccolormgmtelem.h"
+#include "sccolorprofile.h"
+#include "sccolortransform.h"
+#include "sccolormgmtstructs.h"
+
+class ScColorSpaceData : public ScColorMgmtElem
+{
+protected:
+	eColorFormat   m_colorFormat;
+	ScColorProfile m_profile;
+	
+public:
+
+	eColorType   type() const             { return colorFormatType(m_colorFormat); }
+	eColorFormat colorFormat() const      { return m_colorFormat; }
+	const ScColorProfile& profile() const { return m_profile; }
+
+	uint  numChannels(void)     const { return colorFormatNumChannels(m_colorFormat); }
+	uint  bytesPerChannel(void) const { return colorFormatBytesPerChannel(m_colorFormat); }
+	bool  hasAlphaChannel(void) const { return colorFormatHasAlpha(m_colorFormat); }
+
+	// Restore full opacity of alpha channel
+	virtual void flattenAlpha(void* dataIn, uint numElems) = 0;
+
+	// Function to create transform to a specific output color space
+	virtual ScColorTransform createTransform(const ScColorSpaceData& outputSpace, eRenderIntent renderIntent, 
+	                                         long transformFlags);
+	virtual ScColorTransform createTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+											 eRenderIntent renderIntent, long transformFlags);
+
+	// Function to create proofing transform to a specific output color space and a specific proofing device
+	virtual ScColorTransform createProofingTransform(const ScColorSpaceData& outputSpace, const ScColorProfile& proofing, 
+	                                         eRenderIntent renderIntent,  eRenderIntent proofingIntent, 
+											 long transformFlags);
+	virtual ScColorTransform createProofingTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+											 const ScColorProfile& proofing, eRenderIntent renderIntent, 
+	                                         eRenderIntent proofingIntent, long transformFlags);
+
+	// Convert color data to a specific color space
+	virtual bool convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	                     void* dataIn, void* dataOut, uint numElems, ScColorTransform* lastTrans = 0);
+	virtual bool convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	                     void* dataIn, QIODevice* device, uint numElems, ScColorTransform* lastTrans = 0);
+};
+
+#endif
Index: scribus/colormgmt/sccolormgmtstructs.cpp
===================================================================
--- scribus/colormgmt/sccolormgmtstructs.cpp	(revision 14509)
+++ scribus/colormgmt/sccolormgmtstructs.cpp	(revision 14510)
@@ -18,3 +18,125 @@
             (v1.proofingIntent  == v2.proofingIntent) &&
 			(v1.flags  == v2.flags));
 }
+
+eColorType colorFormatType(eColorFormat format)
+{
+	eColorType type = Color_Unknown;
+	switch (format)
+	{
+	case Format_RGB_8:
+	case Format_RGB_16:
+	case Format_RGBA_8:
+	case Format_RGBA_16:
+	case Format_ARGB_8:
+	case Format_ARGB_16:
+	case Format_BGRA_8:
+	case Format_BGRA_16:
+		type = Color_RGB;
+		break;
+	case Format_CMYK_8:
+	case Format_CMYK_16:
+	case Format_CMYKA_8:
+	case Format_CMYKA_16:
+	case Format_YMCK_8:
+	case Format_YMCK_16:
+		type = Color_CMYK;
+		break;
+	case Format_GRAY_8:
+	case Format_GRAY_16:
+		type = Color_Gray;
+		break;
+	case Format_LabA_8:
+		type = Color_Lab;
+		break;
+	}
+	return type;
+}
+
+uint colorFormatNumChannels(eColorFormat format)
+{
+	uint channels = 0;
+	switch (format)
+	{
+	case Format_RGB_8:
+	case Format_RGB_16:
+		channels = 3;
+		break;
+	case Format_RGBA_8:
+	case Format_RGBA_16:
+	case Format_ARGB_8:
+	case Format_ARGB_16:
+	case Format_BGRA_8:
+	case Format_BGRA_16:
+	case Format_CMYK_8:
+	case Format_CMYK_16:
+		channels = 4;
+		break;
+	case Format_CMYKA_8:
+	case Format_CMYKA_16:
+		channels = 5;
+		break;
+	case Format_YMCK_8:
+	case Format_YMCK_16:
+		channels = 4;
+		break;
+	case Format_GRAY_8:
+	case Format_GRAY_16:
+		channels = 1;
+		break;
+	case Format_LabA_8:
+		channels = 4;
+		break;
+	}
+	return channels;
+}
+
+uint colorFormatBytesPerChannel(eColorFormat format)
+{
+	uint bytes = 0;
+	switch (format)
+	{
+	case Format_RGB_8:
+	case Format_RGBA_8:
+	case Format_ARGB_8:
+	case Format_BGRA_8:
+	case Format_CMYK_8:
+	case Format_CMYKA_8:
+	case Format_YMCK_8:
+	case Format_GRAY_8:
+	case Format_LabA_8:
+		bytes = 1;
+		break;
+	case Format_RGB_16:
+	case Format_RGBA_16:
+	case Format_ARGB_16:
+	case Format_BGRA_16:
+	case Format_CMYK_16:
+	case Format_CMYKA_16:
+	case Format_YMCK_16:
+	case Format_GRAY_16:
+		bytes = 2;
+		break;
+	}
+	return bytes;
+}
+
+bool colorFormatHasAlpha(eColorFormat format)
+{
+	bool hasAlpha = false;
+	switch (format)
+	{
+	case Format_RGBA_8:
+	case Format_RGBA_16:
+	case Format_ARGB_8:
+	case Format_ARGB_16:
+	case Format_BGRA_8:
+	case Format_BGRA_16:
+	case Format_CMYKA_8:
+	case Format_CMYKA_16:
+	case Format_LabA_8:
+		hasAlpha = true;
+		break;
+	}
+	return hasAlpha;
+}
Index: scribus/colormgmt/sccolormgmtstructs.h
===================================================================
--- scribus/colormgmt/sccolormgmtstructs.h	(revision 14509)
+++ scribus/colormgmt/sccolormgmtstructs.h	(revision 14510)
@@ -11,6 +11,8 @@
 #include "icc34.h" //part of lcms1
 #include <QString>
 
+// If you change that enum do not forget to update functions
+// colorFormatType() and colorFormatHasAlpha()
 typedef enum
 {
 	Format_Undefined,
@@ -35,6 +37,15 @@
 
 typedef enum
 {
+	Color_Unknown,
+	Color_RGB,
+	Color_CMYK,
+	Color_Gray,
+	Color_Lab
+} eColorType;
+
+typedef enum
+{
 	Ctf_BlackPointCompensation = 1,
 	Ctf_BlackPreservation      = 2,
 	Ctf_Softproofing           = 4,
@@ -86,4 +97,9 @@
 
 bool operator==(const ScColorTransformInfo& v1, const ScColorTransformInfo& v2);
 
+eColorType colorFormatType(eColorFormat format);
+uint       colorFormatNumChannels(eColorFormat format);
+uint       colorFormatBytesPerChannel(eColorFormat format);
+bool       colorFormatHasAlpha(eColorFormat format);
+
 #endif
Index: scribus/colormgmt/CMakeLists.txt
===================================================================
--- scribus/colormgmt/CMakeLists.txt	(revision 14509)
+++ scribus/colormgmt/CMakeLists.txt	(revision 14510)
@@ -11,6 +11,7 @@
 	sccolormgmtstructs.cpp
 	sccolorprofile.cpp
 	sccolorprofilecache.cpp
+	sccolorspacedata.cpp
 	sccolortransform.cpp
 	sccolortransformpool.cpp
 	sclcmscolormgmtengineimpl.cpp
Index: win32/vc8/Scribus.vcproj
===================================================================
--- win32/vc8/Scribus.vcproj	(revision 14509)
+++ win32/vc8/Scribus.vcproj	(revision 14510)
@@ -1584,6 +1584,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\ui\scmwmenumanager.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\scpageoutput.cpp"
 				>
 			</File>
@@ -11565,6 +11569,54 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\ui\scmwmenumanager.h"
+				>
+				<FileConfiguration
+					Name="Debug-cairo|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Moc&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\moc.exe &quot;$(InputPath)&quot; -o  &quot;$(InputDir)\moc_$(InputName).cpp&quot;"
+						AdditionalDependencies="$(QT4_DIR)\bin\moc.exe"
+						Outputs="$(InputDir)\moc_$(InputName).cpp"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-cairo|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Moc&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\moc.exe &quot;$(InputPath)&quot; -o  &quot;$(InputDir)\moc_$(InputName).cpp&quot;"
+						AdditionalDependencies="$(QT4_DIR)\bin\moc.exe"
+						Outputs="$(InputDir)\moc_$(InputName).cpp"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug-arthur|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Moc&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\moc.exe &quot;$(InputPath)&quot; -o  &quot;$(InputDir)\moc_$(InputName).cpp&quot;"
+						AdditionalDependencies="$(QT4_DIR)\bin\moc.exe"
+						Outputs="$(InputDir)\moc_$(InputName).cpp"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-arthur|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Moc&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\moc.exe &quot;$(InputPath)&quot; -o  &quot;$(InputDir)\moc_$(InputName).cpp&quot;"
+						AdditionalDependencies="$(QT4_DIR)\bin\moc.exe"
+						Outputs="$(InputDir)\moc_$(InputName).cpp"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\scribus\scpageoutput.h"
 				>
 			</File>
@@ -20568,6 +20620,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\colormgmt\sccolortransform.cpp"
 				>
 			</File>




More information about the scribus-commit mailing list