r14963 by jghali - more colorspace work

scribus-commit scribus-commit at lists.scribus.net
Sun Apr 11 16:30:53 CEST 2010


Revision: 14963
Author: jghali
Date: 2010-04-11T14:21:22.776958Z
Commit message: more colorspace work

Changeset: 
A  /trunk/Scribus/scribus/colormgmt/sccolorspace.h
M  /trunk/Scribus/scribus/colormgmt/CMakeLists.txt
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata_laba.h
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata_gray.h
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata_cmyk.h
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata_cmyka.h
A  /trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.cpp
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata_rgb.h
M  /trunk/Scribus/scribus/colormgmt/sccolorspacedata.cpp
A  /trunk/Scribus/scribus/colormgmt/sccolorspacedata_rgba.h
M  /trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.h
M  /trunk/Scribus/scribus/colormgmt/sccolormgmtengine.cpp
M  /trunk/Scribus/scribus/colormgmt/sccolorspacedata.h
A  /trunk/Scribus/scribus/colormgmt/sccolorspace.cpp
M  /trunk/Scribus/win32/vc8/Scribus.vcproj
M  /trunk/Scribus/scribus/colormgmt/sccolormgmtengine.h

Diffs:
Index: scribus/colormgmt/sccolorspacedata_gray.h
===================================================================
--- scribus/colormgmt/sccolorspacedata_gray.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata_gray.h	(revision 14963)
@@ -0,0 +1,34 @@
+#ifndef SCCOLORSPACEDATA_GRAY_H
+#define SCCOLORSPACEDATA_GRAY_H
+
+#include <cassert>
+#include <climits>
+#include <limits>
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+
+template<typename T, eColorFormat COLORFORMAT>
+class ScColorSpaceDataTempl_Gray : public ScColorSpaceData
+{
+public:
+	ScColorSpaceDataTempl_Gray(ScColorProfile& profile);
+
+	virtual void flattenAlpha(void* dataIn, uint numElems) const {};
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+ScColorSpaceDataTempl_Gray<T, COLORFORMAT>::ScColorSpaceDataTempl_Gray(ScColorProfile& profile)
+{
+	m_colorFormat = COLORFORMAT;
+	m_profile     = profile;
+	assert(m_colorFormat == Format_GRAY_8 || m_colorFormat == Format_GRAY_16);
+	if (m_profile)
+	{
+		assert(m_profile.colorSpace() == ColorSpace_Gray);
+	}
+};
+
+typedef ScColorSpaceDataTempl_Gray<unsigned char , Format_GRAY_8>  ScColorSpaceData_GRAY8;
+typedef ScColorSpaceDataTempl_Gray<unsigned short, Format_GRAY_16> ScColorSpaceData_GRAY16;
+
+#endif
Index: scribus/colormgmt/sccolorspacedata_cmyk.h
===================================================================
--- scribus/colormgmt/sccolorspacedata_cmyk.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata_cmyk.h	(revision 14963)
@@ -0,0 +1,59 @@
+#ifndef SCCOLORSPACEDATA_CMYK_H
+#define SCCOLORSPACEDATA_CMYK_H
+
+#include <cassert>
+#include <climits>
+#include <limits>
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+
+template<typename T, eColorFormat COLORFORMAT>
+class ScColorSpaceDataTempl_CMYK : public ScColorSpaceData
+{
+protected:
+	int m_cIndex;
+	int m_mIndex;
+	int m_yIndex;
+	int m_kIndex;
+
+public:
+	ScColorSpaceDataTempl_CMYK(ScColorProfile& profile);
+
+	virtual void flattenAlpha(void* dataIn, uint numElems) const {};
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+ScColorSpaceDataTempl_CMYK<T, COLORFORMAT>::ScColorSpaceDataTempl_CMYK(ScColorProfile& profile)
+{
+	m_colorFormat = COLORFORMAT;
+	m_profile     = profile;
+	if (m_colorFormat == Format_CMYK_8 || m_colorFormat == Format_CMYK_16)
+	{
+		m_cIndex = 0;
+		m_mIndex = 1;
+		m_yIndex = 2;
+		m_kIndex = 3;
+	}
+	else if (m_colorFormat == Format_YMCK_8 || m_colorFormat == Format_YMCK_16)
+	{
+		m_cIndex = 2;
+		m_mIndex = 1;
+		m_yIndex = 0;
+		m_kIndex = 3;
+	}
+	else
+	{
+		assert(false);
+	}
+	if (m_profile)
+	{
+		assert(m_profile.colorSpace() == ColorSpace_Cmyk || m_profile.colorSpace() == ColorSpace_Cmy);
+	}
+};
+
+typedef ScColorSpaceDataTempl_CMYK<unsigned char , Format_CMYK_8>  ScColorSpaceData_CMYK8;
+typedef ScColorSpaceDataTempl_CMYK<unsigned short, Format_CMYK_16> ScColorSpaceData_CMYK16;
+typedef ScColorSpaceDataTempl_CMYK<unsigned char , Format_YMCK_8>  ScColorSpaceData_YMCK8;
+typedef ScColorSpaceDataTempl_CMYK<unsigned short, Format_YMCK_16> ScColorSpaceData_YMCK16;
+
+#endif
Index: scribus/colormgmt/sccolormgmtenginedata.cpp
===================================================================
--- scribus/colormgmt/sccolormgmtenginedata.cpp	(revision 0)
+++ scribus/colormgmt/sccolormgmtenginedata.cpp	(revision 14963)
@@ -0,0 +1,67 @@
+/*
+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 "sccolormgmtenginedata.h"
+#include "sccolorspacedata_cmyk.h"
+#include "sccolorspacedata_cmyka.h"
+#include "sccolorspacedata_gray.h"
+#include "sccolorspacedata_laba.h"
+#include "sccolorspacedata_rgb.h"
+#include "sccolorspacedata_rgba.h"
+
+ScColorSpace ScColorMgmtEngineData::createColorSpace(ScColorProfile& profile, eColorFormat colorFormat)
+{
+	ScColorSpace colorSpace;
+	eColorSpaceType profileCSpace = profile.colorSpace();
+	if (profileCSpace == ColorSpace_Rgb)
+	{
+		if (colorFormat == Format_RGB_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_RGB8(profile));
+		else if (colorFormat == Format_RGB_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_RGB16(profile));
+		else if (colorFormat == Format_RGBA_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_RGBA8(profile));
+		else if (colorFormat == Format_RGBA_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_RGBA16(profile));
+		else if (colorFormat == Format_ARGB_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_ARGB8(profile));
+		else if (colorFormat == Format_ARGB_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_ARGB16(profile));
+		else if (colorFormat == Format_BGRA_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_BGRA8(profile));
+		else if (colorFormat == Format_BGRA_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_BGRA16(profile));
+	}
+	else if (profileCSpace == ColorSpace_Cmyk)
+	{
+		if (colorFormat == Format_CMYK_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_CMYK8(profile));
+		else if (colorFormat == Format_CMYK_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_CMYK16(profile));
+		else if (colorFormat == Format_CMYKA_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_CMYKA8(profile));
+		else if (colorFormat == Format_CMYKA_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_CMYKA16(profile));
+		else if (colorFormat == Format_YMCK_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_YMCK8(profile));
+		else if (colorFormat == Format_YMCK_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_YMCK16(profile));
+	}
+	else if (profileCSpace == ColorSpace_Gray)
+	{
+		if (colorFormat == Format_GRAY_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_GRAY8(profile));
+		else if (colorFormat == Format_GRAY_16)
+			colorSpace = ScColorSpace(new ScColorSpaceData_GRAY16(profile));
+	}
+	else if (profileCSpace == ColorSpace_Lab)
+	{
+		if (colorFormat == Format_LabA_8)
+			colorSpace = ScColorSpace(new ScColorSpaceData_LabA8(profile));
+	}
+	return colorSpace;
+}
Index: scribus/colormgmt/sccolorspacedata.h
===================================================================
--- scribus/colormgmt/sccolorspacedata.h	(revision 14962)
+++ scribus/colormgmt/sccolorspacedata.h	(revision 14963)
@@ -30,8 +30,11 @@
 	uint  bytesPerChannel(void) const { return colorFormatBytesPerChannel(m_colorFormat); }
 	bool  hasAlphaChannel(void) const { return colorFormatHasAlpha(m_colorFormat); }
 
+	virtual ScColorMgmtEngine& engine() { return m_profile.engine(); }
+	virtual const ScColorMgmtEngine& engine() const { return m_profile.engine(); }
+
 	// Restore full opacity of alpha channel
-	virtual void flattenAlpha(void* dataIn, uint numElems) = 0;
+	virtual void flattenAlpha(void* dataIn, uint numElems) const = 0;
 
 	// Function to create transform to a specific output color space
 	virtual ScColorTransform createTransform(const ScColorSpaceData& outputSpace, eRenderIntent renderIntent, 
Index: scribus/colormgmt/sccolorspace.cpp
===================================================================
--- scribus/colormgmt/sccolorspace.cpp	(revision 0)
+++ scribus/colormgmt/sccolorspace.cpp	(revision 14963)
@@ -0,0 +1,123 @@
+/*
+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 "sccolorspace.h"
+
+ScColorSpace::ScColorSpace() : m_data(NULL)
+{
+}
+
+ScColorSpace::ScColorSpace(ScColorSpaceData* data) : m_data(data)
+{
+}
+
+ScColorSpace::ScColorSpace(const QSharedPointer<ScColorSpaceData>& data) : m_data(data)
+{
+}
+
+eColorType ScColorSpace::type() const
+{
+	if (m_data)
+		return m_data->type();
+	return Color_Unknown;
+}
+
+eColorFormat ScColorSpace::colorFormat() const
+{
+	if (m_data)
+		return m_data->colorFormat();
+	return Format_Undefined;
+}
+
+ScColorProfile ScColorSpace::profile() const
+{
+	if (m_data)
+		return m_data->profile();
+	return ScColorProfile();
+}
+
+uint ScColorSpace::numChannels(void) const
+{
+	if (m_data)
+		return m_data->numChannels();
+	return 0;
+}
+
+uint ScColorSpace::bytesPerChannel(void) const
+{
+	if (m_data)
+		return m_data->bytesPerChannel();
+	return 0;
+}
+
+bool ScColorSpace::hasAlphaChannel(void) const
+{
+	if (m_data)
+		return m_data->hasAlphaChannel();
+	return false;
+}
+
+void ScColorSpace::flattenAlpha(void* dataIn, uint numElems)
+{
+	if (m_data)
+		m_data->flattenAlpha(dataIn, numElems);
+}
+
+ScColorTransform ScColorSpace::createTransform(const ScColorSpaceData& outputSpace, eRenderIntent renderIntent, 
+	                                 long transformFlags)
+{
+	if (m_data)
+		m_data->createTransform(outputSpace, renderIntent, transformFlags);
+	return ScColorTransform();
+}
+
+ScColorTransform ScColorSpace::createTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+	                                 eRenderIntent renderIntent, long transformFlags)
+{
+	if (m_data)
+		m_data->createTransform(outputProfile, outputFormat, renderIntent, transformFlags);
+	return ScColorTransform();
+}
+
+ScColorTransform ScColorSpace::createProofingTransform(const ScColorSpaceData& outputSpace, const ScColorProfile& proofing, 
+	                                         eRenderIntent renderIntent,  eRenderIntent proofingIntent, 
+											 long transformFlags)
+{
+	if (m_data)
+		m_data->createProofingTransform(outputSpace, proofing, renderIntent, proofingIntent, transformFlags);
+	return ScColorTransform();
+}
+
+ScColorTransform ScColorSpace::createProofingTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+											 const ScColorProfile& proofing, eRenderIntent renderIntent, 
+	                                         eRenderIntent proofingIntent, long transformFlags)
+{
+	if (m_data)
+		m_data->createProofingTransform(outputProfile, outputFormat, proofing, renderIntent, proofingIntent, transformFlags);
+	return ScColorTransform();
+}
+
+bool ScColorSpace::convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	             void* dataIn, void* dataOut, uint numElems, ScColorTransform* lastTrans)
+{
+	if (m_data)
+		return m_data->convert(data, renderIntent, transformFlags, dataIn, dataOut, numElems, lastTrans);
+	return false;
+}
+
+bool ScColorSpace::convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	             void* dataIn, QIODevice* device, uint numElems, ScColorTransform* lastTrans)
+{
+	if (m_data)
+		return m_data->convert(data, renderIntent, transformFlags, dataIn, device, numElems, lastTrans);
+	return false;
+}
+
+bool ScColorSpace::operator==(const ScColorSpace& other) const
+{
+	return m_data == other.m_data;
+}
\ No newline at end of file
Index: scribus/colormgmt/sccolormgmtengine.h
===================================================================
--- scribus/colormgmt/sccolormgmtengine.h	(revision 14962)
+++ scribus/colormgmt/sccolormgmtengine.h	(revision 14963)
@@ -45,6 +45,8 @@
 	                                 const ScColorProfile& outputProfile, eColorFormat outputFormat,
 	                                 const ScColorProfile& proofingProfile, eRenderIntent renderIntent, 
 									 eRenderIntent proofingIntent, long transformFlags);
+
+	ScColorSpace createColorSpace(ScColorProfile& profile, eColorFormat colorFormat);
 									 
 	// color engine equality operator function
 	bool operator==(const ScColorMgmtEngine& other) const;
Index: scribus/colormgmt/CMakeLists.txt
===================================================================
--- scribus/colormgmt/CMakeLists.txt	(revision 14962)
+++ scribus/colormgmt/CMakeLists.txt	(revision 14963)
@@ -6,12 +6,14 @@
 
 SET(SCRIBUS_COLORMGMT_LIB_SOURCES
 	sccolormgmtengine.cpp
+	sccolormgmtenginedata.cpp
 	sccolormgmtenginefactory.cpp
 	sccolormgmtimplelem.cpp
 	sccolormgmtstructs.cpp
 	sccolorprofile.cpp
 	sccolorprofilecache.cpp
 	sccolorprofiledata.cpp
+	sccolorspace.cpp
 	sccolorspacedata.cpp
 	sccolortransform.cpp
 	sccolortransformpool.cpp
Index: scribus/colormgmt/sccolorspacedata_laba.h
===================================================================
--- scribus/colormgmt/sccolorspacedata_laba.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata_laba.h	(revision 14963)
@@ -0,0 +1,62 @@
+#ifndef SCCOLORSPACEDATA_LABA_H
+#define SCCOLORSPACEDATA_LABA_H
+
+#include <cassert>
+#include <climits>
+#include <limits>
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+
+template<typename T, eColorFormat COLORFORMAT>
+class ScColorSpaceDataTempl_LabA : public ScColorSpaceData
+{
+protected:
+	int m_LIndex;
+	int m_aIndex;
+	int m_bIndex;
+	int m_AIndex;
+
+public:
+	ScColorSpaceDataTempl_LabA(ScColorProfile& profile);
+
+	virtual void flattenAlpha(void* dataIn, uint numElems) const;
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+ScColorSpaceDataTempl_LabA<T, COLORFORMAT>::ScColorSpaceDataTempl_LabA(ScColorProfile& profile)
+{
+	m_colorFormat = COLORFORMAT;
+	m_profile     = profile;
+	if (m_colorFormat == Format_LabA_8)
+	{
+		m_LIndex = 0;
+		m_aIndex = 1;
+		m_bIndex = 2;
+		m_AIndex = 3;
+	}
+	else
+	{
+		assert(false);
+	}
+	if (m_profile)
+	{
+		assert(m_profile.colorSpace() == ColorSpace_Lab);
+	}
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+void ScColorSpaceDataTempl_LabA<T, COLORFORMAT>::flattenAlpha(void* dataIn, uint numElems) const
+{
+	typename T* data   = ((T*) dataIn) + m_aIndex;
+	typename T  nLimit = std::numeric_limits<T>::max();
+	while (numElems > 0)
+	{
+		(*data++) = nLimit;
+		data += 4;
+		--numElems;
+	};
+};
+
+typedef ScColorSpaceDataTempl_LabA<char, Format_LabA_8>  ScColorSpaceData_LabA8;
+
+#endif
Index: scribus/colormgmt/sccolorspacedata_cmyka.h
===================================================================
--- scribus/colormgmt/sccolorspacedata_cmyka.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata_cmyka.h	(revision 14963)
@@ -0,0 +1,65 @@
+#ifndef SCCOLORSPACEDATA_CMYKA_H
+#define SCCOLORSPACEDATA_CMYKA_H
+
+#include <cassert>
+#include <climits>
+#include <limits>
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+
+template<typename T, eColorFormat COLORFORMAT>
+class ScColorSpaceDataTempl_CMYKA : public ScColorSpaceData
+{
+protected:
+	int m_cIndex;
+	int m_mIndex;
+	int m_yIndex;
+	int m_kIndex;
+	int m_aIndex;
+
+public:
+	ScColorSpaceDataTempl_CMYKA(ScColorProfile& profile);
+
+	virtual void flattenAlpha(void* dataIn, uint numElems) const;
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+ScColorSpaceDataTempl_CMYKA<T, COLORFORMAT>::ScColorSpaceDataTempl_CMYKA(ScColorProfile& profile)
+{
+	m_colorFormat = COLORFORMAT;
+	m_profile     = profile;
+	if (m_colorFormat == Format_CMYKA_8 || m_colorFormat == Format_CMYKA_16)
+	{
+		m_cIndex = 0;
+		m_mIndex = 1;
+		m_yIndex = 2;
+		m_kIndex = 3;
+		m_aIndex = 4;
+	}
+	else
+	{
+		assert(false);
+	}
+	if (m_profile)
+	{
+		assert(m_profile.colorSpace() == ColorSpace_Cmyk || m_profile.colorSpace() == ColorSpace_Cmy);
+	}
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+void ScColorSpaceDataTempl_CMYKA<T, COLORFORMAT>::flattenAlpha(void* dataIn, uint numElems) const
+{
+	typename T* data   = ((T*) dataIn) + m_aIndex;
+	typename T  nLimit = std::numeric_limits<T>::max();
+	while (numElems > 0)
+	{
+		(*data++) = nLimit;
+		data += 5;
+		--numElems;
+	};
+};
+
+typedef ScColorSpaceDataTempl_CMYKA<unsigned char , Format_CMYKA_8>  ScColorSpaceData_CMYKA8;
+typedef ScColorSpaceDataTempl_CMYKA<unsigned short, Format_CMYKA_16> ScColorSpaceData_CMYKA16;
+
+#endif
Index: scribus/colormgmt/sccolorspacedata_rgb.h
===================================================================
--- scribus/colormgmt/sccolorspacedata_rgb.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata_rgb.h	(revision 14963)
@@ -0,0 +1,48 @@
+#ifndef SCCOLORSPACEDATA_RGB_H
+#define SCCOLORSPACEDATA_RGB_H
+
+#include <cassert>
+#include <climits>
+#include <limits>
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+
+template<typename T, eColorFormat COLORFORMAT>
+class ScColorSpaceDataTempl_RGB : public ScColorSpaceData
+{
+protected:
+	int m_rIndex;
+	int m_gIndex;
+	int m_bIndex;
+
+public:
+	ScColorSpaceDataTempl_RGB(ScColorProfile& profile);
+
+	virtual void flattenAlpha(void* dataIn, uint numElems) const {};
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+ScColorSpaceDataTempl_RGB<T, COLORFORMAT>::ScColorSpaceDataTempl_RGB(ScColorProfile& profile)
+{
+	m_colorFormat = COLORFORMAT;
+	m_profile     = profile;
+	if (m_colorFormat == Format_RGB_8 || m_colorFormat == Format_RGB_16)
+	{
+		m_rIndex = 0;
+		m_gIndex = 1;
+		m_bIndex = 2;
+	}
+	else
+	{
+		assert(false);
+	}
+	if (m_profile)
+	{
+		assert(m_profile.colorSpace() == ColorSpace_Rgb);
+	}
+};
+
+typedef ScColorSpaceDataTempl_RGB<unsigned char , Format_RGB_8>  ScColorSpaceData_RGB8;
+typedef ScColorSpaceDataTempl_RGB<unsigned short, Format_RGB_16> ScColorSpaceData_RGB16;
+
+#endif
Index: scribus/colormgmt/sccolorspacedata.cpp
===================================================================
--- scribus/colormgmt/sccolorspacedata.cpp	(revision 14962)
+++ scribus/colormgmt/sccolorspacedata.cpp	(revision 14963)
@@ -77,6 +77,8 @@
 		success = transform.apply(dataIn, dataOut, numElems);
 		if (!this->hasAlphaChannel() && data.hasAlphaChannel())
 			data.flattenAlpha(dataOut, numElems);
+		if (lastTrans && (transform != *lastTrans))
+			*lastTrans = transform;
 		success = true;
 	}
 	return success;
Index: scribus/colormgmt/sccolorspacedata_rgba.h
===================================================================
--- scribus/colormgmt/sccolorspacedata_rgba.h	(revision 0)
+++ scribus/colormgmt/sccolorspacedata_rgba.h	(revision 14963)
@@ -0,0 +1,81 @@
+#ifndef SCCOLORSPACEDATA_RGBA_H
+#define SCCOLORSPACEDATA_RGBA_H
+
+#include <cassert>
+#include <climits>
+#include <limits>
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+
+template<typename T, eColorFormat COLORFORMAT>
+class ScColorSpaceDataTempl_RGBA : public ScColorSpaceData
+{
+protected:
+	int m_rIndex;
+	int m_gIndex;
+	int m_bIndex;
+	int m_aIndex;
+
+public:
+	ScColorSpaceDataTempl_RGBA(ScColorProfile& profile);
+
+	virtual void flattenAlpha(void* dataIn, uint numElems) const;
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+ScColorSpaceDataTempl_RGBA<T, COLORFORMAT>::ScColorSpaceDataTempl_RGBA(ScColorProfile& profile)
+{
+	m_colorFormat = COLORFORMAT;
+	m_profile     = profile;
+	if (m_colorFormat == Format_RGBA_8 || m_colorFormat == Format_RGBA_16)
+	{
+		m_rIndex = 0;
+		m_gIndex = 1;
+		m_bIndex = 2;
+		m_aIndex = 3;
+	}
+	else if (m_colorFormat == Format_ARGB_8 || m_colorFormat == Format_ARGB_16)
+	{
+		m_rIndex = 1;
+		m_gIndex = 2;
+		m_bIndex = 3;
+		m_aIndex = 0;
+	}
+	else if (m_colorFormat == Format_BGRA_8 || m_colorFormat == Format_BGRA_16)
+	{
+		m_rIndex = 2;
+		m_gIndex = 1;
+		m_bIndex = 0;
+		m_aIndex = 3;
+	}
+	else
+	{
+		assert(false);
+	}
+	if (m_profile)
+	{
+		assert(m_profile.colorSpace() == ColorSpace_Rgb);
+	}
+};
+
+template<typename T, eColorFormat COLORFORMAT>
+void ScColorSpaceDataTempl_RGBA<T, COLORFORMAT>::flattenAlpha(void* dataIn, uint numElems) const
+{
+	typename T* data   = ((T*) dataIn) + m_aIndex;
+	typename T  nLimit = std::numeric_limits<T>::max();
+	while (numElems > 0)
+	{
+		(*data++) = nLimit;
+		data += 4;
+		--numElems;
+	};
+};
+
+typedef ScColorSpaceDataTempl_RGBA<unsigned char , Format_RGBA_8>  ScColorSpaceData_RGBA8;
+typedef ScColorSpaceDataTempl_RGBA<unsigned short, Format_RGBA_16> ScColorSpaceData_RGBA16;
+typedef ScColorSpaceDataTempl_RGBA<unsigned char , Format_ARGB_8>  ScColorSpaceData_ARGB8;
+typedef ScColorSpaceDataTempl_RGBA<unsigned short, Format_ARGB_16> ScColorSpaceData_ARGB16;
+typedef ScColorSpaceDataTempl_RGBA<unsigned char , Format_BGRA_8>  ScColorSpaceData_BGRA8;
+typedef ScColorSpaceDataTempl_RGBA<unsigned short, Format_BGRA_16> ScColorSpaceData_BGRA16;
+
+#endif
Index: scribus/colormgmt/sccolormgmtenginedata.h
===================================================================
--- scribus/colormgmt/sccolormgmtenginedata.h	(revision 14962)
+++ scribus/colormgmt/sccolormgmtenginedata.h	(revision 14963)
@@ -13,6 +13,7 @@
 
 #include "sccolormgmtstructs.h"
 #include "sccolorprofile.h"
+#include "sccolorspace.h"
 #include "sccolortransform.h"
 #include "sccolortransformpool.h"
 
@@ -61,6 +62,8 @@
 	                                         const ScColorProfile& outputProfile, eColorFormat outputFormat,
 											 const ScColorProfile& proofing, eRenderIntent renderIntent, 
 	                                         eRenderIntent proofingIntent, long transformFlags) = 0;
+
+	virtual ScColorSpace createColorSpace(ScColorProfile& profile, eColorFormat colorFormat);
 };
 
 #endif
Index: scribus/colormgmt/sccolormgmtengine.cpp
===================================================================
--- scribus/colormgmt/sccolormgmtengine.cpp	(revision 14962)
+++ scribus/colormgmt/sccolormgmtengine.cpp	(revision 14963)
@@ -74,6 +74,11 @@
 	                                       proofingProfile, renderIntent, proofingIntent, transformFlags);
 }
 
+ScColorSpace ScColorMgmtEngine::createColorSpace(ScColorProfile& profile, eColorFormat colorFormat)
+{
+	return m_data->createColorSpace(profile, colorFormat);
+}
+
 bool ScColorMgmtEngine::operator==(const ScColorMgmtEngine& other) const
 {
 	return m_data == other.m_data;
Index: scribus/colormgmt/sccolorspace.h
===================================================================
--- scribus/colormgmt/sccolorspace.h	(revision 0)
+++ scribus/colormgmt/sccolorspace.h	(revision 14963)
@@ -0,0 +1,73 @@
+/*
+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 SCCOLORSPACE_H
+#define SCCOLORSPACE_H
+
+#include <QSharedPointer>
+#include <QWeakPointer>
+#include "scribusapi.h"
+#include "sccolorprofile.h"
+#include "sccolorspacedata.h"
+#include "sccolortransform.h"
+
+class SCRIBUS_API ScColorSpace
+{
+public:
+	ScColorSpace();
+	ScColorSpace(ScColorSpaceData*);
+	ScColorSpace(const QSharedPointer<ScColorSpaceData>&);
+
+	ScColorMgmtEngine& engine() { return m_data->engine(); }
+	const ScColorMgmtEngine& engine() const { return m_data->engine(); }
+
+	inline bool isNull()    const { return m_data.isNull(); }
+	inline operator bool () const { return !isNull(); }
+
+	eColorType   type() const;
+	eColorFormat colorFormat() const;
+	ScColorProfile profile() const;
+
+	uint  numChannels(void)     const;
+	uint  bytesPerChannel(void) const;
+	bool  hasAlphaChannel(void) const;
+
+	// Restore full opacity of alpha channel
+	void flattenAlpha(void* dataIn, uint numElems);
+
+	// Function to create transform to a specific output color space
+	ScColorTransform createTransform(const ScColorSpaceData& outputSpace, eRenderIntent renderIntent, 
+	                                 long transformFlags);
+	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
+	ScColorTransform createProofingTransform(const ScColorSpaceData& outputSpace, const ScColorProfile& proofing, 
+	                                         eRenderIntent renderIntent,  eRenderIntent proofingIntent, 
+											 long transformFlags);
+	ScColorTransform createProofingTransform(const ScColorProfile& outputProfile, eColorFormat outputFormat,
+											 const ScColorProfile& proofing, eRenderIntent renderIntent, 
+	                                         eRenderIntent proofingIntent, long transformFlags);
+
+	// Convert color data to a specific color space
+	bool convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	             void* dataIn, void* dataOut, uint numElems, ScColorTransform* lastTrans = 0);
+	bool convert(ScColorSpaceData& data, eRenderIntent renderIntent, long transformFlags, 
+	             void* dataIn, QIODevice* device, uint numElems, ScColorTransform* lastTrans = 0);
+
+	const ScColorSpaceData* data() const { return m_data.data(); }
+
+	bool operator==(const ScColorSpace& cspace) const;
+
+protected:
+	QSharedPointer<ScColorSpaceData> m_data;
+
+	QWeakPointer<ScColorSpaceData>   weakRef()   const { return m_data.toWeakRef(); }
+	QSharedPointer<ScColorSpaceData> strongRef() const { return m_data; }
+};
+
+#endif
Index: win32/vc8/Scribus.vcproj
===================================================================
--- win32/vc8/Scribus.vcproj	(revision 14962)
+++ win32/vc8/Scribus.vcproj	(revision 14963)
@@ -15646,6 +15646,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\ui\ui_gradientvectorbase.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\ui\ui_gtfiledialog.h"
 				>
 			</File>
@@ -17580,6 +17584,54 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\scribus\ui\gradientvectorbase.ui"
+				>
+				<FileConfiguration
+					Name="Debug-cairo|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Uic&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\uic.exe &quot;$(InputPath)&quot; -o &quot;$(InputDir)\ui_$(InputName).h&quot;&#x0D;&#x0A;"
+						AdditionalDependencies="$(QT4_DIR)\bin\uic.exe"
+						Outputs="$(InputDir)\ui_$(InputName).h"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-cairo|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Uic&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\uic.exe &quot;$(InputPath)&quot; -o &quot;$(InputDir)\ui_$(InputName).h&quot;&#x0D;&#x0A;"
+						AdditionalDependencies="$(QT4_DIR)\bin\uic.exe"
+						Outputs="$(InputDir)\ui_$(InputName).h"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug-arthur|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Uic&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\uic.exe &quot;$(InputPath)&quot; -o &quot;$(InputDir)\ui_$(InputName).h&quot;&#x0D;&#x0A;"
+						AdditionalDependencies="$(QT4_DIR)\bin\uic.exe"
+						Outputs="$(InputDir)\ui_$(InputName).h"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-arthur|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Uic&apos;ing $(InputFileName)"
+						CommandLine="$(QT4_DIR)\bin\uic.exe &quot;$(InputPath)&quot; -o &quot;$(InputDir)\ui_$(InputName).h&quot;&#x0D;&#x0A;"
+						AdditionalDependencies="$(QT4_DIR)\bin\uic.exe"
+						Outputs="$(InputDir)\ui_$(InputName).h"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\scribus\ui\gtfiledialog.ui"
 				>
 				<FileConfiguration
@@ -20724,6 +20776,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\colormgmt\sccolormgmtenginedata.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\colormgmt\sccolormgmtenginedata.h"
 				>
 			</File>
@@ -20776,6 +20832,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspace.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspace.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\colormgmt\sccolorspacedata.cpp"
 				>
 			</File>
@@ -20784,6 +20848,30 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata_cmyk.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata_cmyka.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata_gray.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata_laba.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata_rgb.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\scribus\colormgmt\sccolorspacedata_rgba.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\colormgmt\sccolortransform.cpp"
 				>
 			</File>




More information about the scribus-commit mailing list