Commit 2d9e9d46 authored by Emanuele Tamponi's avatar Emanuele Tamponi

Various changes. Most important:

- now the color space loading code is much cleaner
- the tests have been rewritted in order to do some checks and they works great
- the mixing test has been disabled (completely removed) because I need to rewrite
  it as it will be the base upon which I'll draw all the graphs I'll need in future
  works.

svn path=/trunk/koffice/; revision=757448
parent 417c04b7
......@@ -73,6 +73,13 @@ bool KisIlluminantProfile::load()
QDataStream data(&file);
{
// Clear previous data
if (m_T)
gsl_matrix_free(m_T);
if (m_P)
gsl_vector_free(m_P);
}
{
// Profile name
QString name;
......
......@@ -45,6 +45,11 @@ struct KisKSColorSpaceTrait : public KoColorSpaceTrait<_TYPE_, 2*_wavelen_number
return d[2*wavelen+1];
}
inline static _TYPE_ &nativealpha(quint8* data)
{
return reinterpret_cast<_TYPE_ *>(data)[2*_wavelen_number_];
}
inline static const _TYPE_ &K(const quint8* data, const quint32 wavelen)
{
const _TYPE_ *d = reinterpret_cast<const _TYPE_ *>(data);
......@@ -56,6 +61,11 @@ struct KisKSColorSpaceTrait : public KoColorSpaceTrait<_TYPE_, 2*_wavelen_number
const _TYPE_ *d = reinterpret_cast<const _TYPE_ *>(data);
return d[2*wavelen+1];
}
inline static const _TYPE_ &nativealpha(const quint8* data)
{
return reinterpret_cast<const _TYPE_ *>(data)[2*_wavelen_number_];
}
};
#endif // KIS_KS_COLORSPACE_TRAITS_H_
......@@ -77,7 +77,7 @@ public:
for (int i = 0; i < 3; i++)
dst[2-i] = KoColorSpaceMaths<double,quint16>::scaleToA(gsl_vector_get(m_rgbvec, i));
dst[3] = KoColorSpaceMaths<_TYPE_,quint16>::scaleToA(CSTrait::alpha(src));
dst[3] = KoColorSpaceMaths<_TYPE_,quint16>::scaleToA(CSTrait::nativealpha(src));
src += CSTrait::pixelSize;
dst += 4;
......
......@@ -134,7 +134,7 @@ public:
memmove(m_cache.value(m_lookup), dst, pixelSize-4);
}
CSTrait::setAlpha(dst, KoColorSpaceMaths<quint16,quint8>::scaleToA(src[3]), 1);
CSTrait::nativealpha(dst) = KoColorSpaceMaths<quint16,float>::scaleToA(src[3]);
src += 4;
dst += pixelSize;
......
......@@ -42,114 +42,42 @@ KSColorSpacesPlugin::KSColorSpacesPlugin(QObject *parent, const QStringList &)
: QObject(parent)
{
QStringList list;
QString curr;
KisIlluminantProfile *ill;
KoColorSpaceRegistry *f = KoColorSpaceRegistry::instance();
KGlobal::mainComponent().dirs()->addResourceType("illuminant_profiles", 0, "share/apps/krita/illuminants");
list = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "*.ill", KStandardDirs::Recursive);
foreach(curr, list) {
ill = new KisIlluminantProfile(curr);
f->addProfile(ill);
}
foreach(QString curr, list)
f->addProfile(new KisIlluminantProfile(curr));
curr = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_6_high.ill", KStandardDirs::Recursive)[0];
ill = new KisIlluminantProfile(curr);
{
KoColorSpace *colorSpaceKSQP = new KisKSQPColorSpace<float,6>(ill->clone());
KoColorSpaceFactory *csf = new KisKSQPColorSpaceFactory<float,6>();
Q_CHECK_PTR(colorSpaceKSQP);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSQP6F32HISTO", i18n("6-pairs KS QP F32 Histogram")), colorSpaceKSQP) );
}
f->add(new KisKSLCColorSpaceFactory<float,6>);
f->add(new KisKSLCColorSpaceFactory<float,9>);
f->add(new KisKSQPColorSpaceFactory<float,6>);
f->add(new KisKSQPColorSpaceFactory<float,9>);
#ifdef HAVE_OPENEXR
{
KoColorSpace *colorSpaceKSQP = new KisKSQPColorSpace<half,6>(ill->clone());
KoColorSpaceFactory *csf = new KisKSQPColorSpaceFactory<half,6>();
Q_CHECK_PTR(colorSpaceKSQP);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSQP6F16HISTO", i18n("6-pairs KS QP Half Histogram")), colorSpaceKSQP) );
}
f->add(new KisKSLCColorSpaceFactory<half,6>);
f->add(new KisKSLCColorSpaceFactory<half,9>);
f->add(new KisKSQPColorSpaceFactory<half,6>);
f->add(new KisKSQPColorSpaceFactory<half,9>);
#endif
delete ill;
curr = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_6_high.ill", KStandardDirs::Recursive)[0];
ill = new KisIlluminantProfile(curr);
{
KoColorSpace *colorSpaceKS = new KisKSLCColorSpace<float,6>(ill->clone());
KoColorSpaceFactory *csf = new KisKSLCColorSpaceFactory<float,6>();
Q_CHECK_PTR(colorSpaceKS);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSLC6F32HISTO", i18n("6-pairs KS LC F32 Histogram")), colorSpaceKS) );
}
QVector<const KoColorSpace *> css;
css.append(f->colorSpace(KisKSLCColorSpace<float,6>::ColorSpaceId().id(),0));
css.append(f->colorSpace(KisKSLCColorSpace<float,9>::ColorSpaceId().id(),0));
css.append(f->colorSpace(KisKSQPColorSpace<float,6>::ColorSpaceId().id(),0));
css.append(f->colorSpace(KisKSQPColorSpace<float,9>::ColorSpaceId().id(),0));
#ifdef HAVE_OPENEXR
{
KoColorSpace *colorSpaceKS = new KisKSLCColorSpace<half,6>(ill->clone());
KoColorSpaceFactory *csf = new KisKSLCColorSpaceFactory<half,6>();
Q_CHECK_PTR(colorSpaceKS);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSLC6F16HISTO", i18n("6-pairs KS LC Half Histogram")), colorSpaceKS) );
}
css.append(f->colorSpace(KisKSLCColorSpace<half,6>::ColorSpaceId().id(),0));
css.append(f->colorSpace(KisKSLCColorSpace<half,9>::ColorSpaceId().id(),0));
css.append(f->colorSpace(KisKSQPColorSpace<half,6>::ColorSpaceId().id(),0));
css.append(f->colorSpace(KisKSQPColorSpace<half,9>::ColorSpaceId().id(),0));
#endif
delete ill;
curr = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_9_high.ill", KStandardDirs::Recursive)[0];
ill = new KisIlluminantProfile(curr);
{
KoColorSpace *colorSpaceKS = new KisKSLCColorSpace<float,9>(ill->clone());
KoColorSpaceFactory *csf = new KisKSLCColorSpaceFactory<float,9>();
Q_CHECK_PTR(colorSpaceKS);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSLC9F32HISTO", i18n("9-pairs KS LC F32 Histogram")), colorSpaceKS) );
}
#ifdef HAVE_OPENEXR
{
KoColorSpace *colorSpaceKS = new KisKSLCColorSpace<half,9>(ill->clone());
KoColorSpaceFactory *csf = new KisKSLCColorSpaceFactory<half,9>();
Q_CHECK_PTR(colorSpaceKS);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSLC9F16HISTO", i18n("9-pairs KS LC Half Histogram")), colorSpaceKS) );
}
#endif
delete ill;
/*
curr = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_12_high.ill", KStandardDirs::Recursive)[0];
ill = new KisIlluminantProfile(curr);
{
KoColorSpace *colorSpaceKS = new KisKSLCColorSpace<float,12>(ill->clone());
KoColorSpaceFactory *csf = new KisKSLCColorSpaceFactory<float,12>();
Q_CHECK_PTR(colorSpaceKS);
f->add(csf);
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSLC12F32HISTO", i18n("12-pairs KS LC F32 Histogram")), colorSpaceKS) );
}
#ifdef HAVE_OPENEXR
{
KoColorSpace *colorSpaceKS = new KisKSLCColorSpace<half,12>(ill->clone());
KoColorSpaceFactory *csf = new KisKSLCColorSpaceFactory<half,12>();
Q_CHECK_PTR(colorSpaceKS);
f->add(csf);
foreach(const KoColorSpace *cs, css) {
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID("KSLC12F16HISTO", i18n("12-pairs KS LC Half Histogram")), colorSpaceKS) );
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
(KoID(cs->id()+"HISTO", i18n(QString("%1 Histogram").arg(cs->name()).toUtf8().data())), cs->clone()));
}
#endif
delete ill;
*/
}
KSColorSpacesPlugin::~KSColorSpacesPlugin()
......
......@@ -29,7 +29,6 @@ class ChannelConverterTest : public QObject
private slots:
void testKSReflectance();
// void testRGBsRGB();
};
......
......@@ -18,14 +18,17 @@
*/
#include <qtest_kde.h>
#include "kis_illuminant_profile_test.h"
#include "kis_illuminant_profile.h"
#include <KGlobal>
#include <KLocale>
#include <KStandardDirs>
#include <QString>
#include <QStringList>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
......@@ -59,44 +62,77 @@ void gsl_print(const gsl_vector *V, const char *name)
cout << endl;
}
void KisIlluminantProfileTest::testLoading()
void KisIlluminantProfileTest::initTestCase()
{
KGlobal::mainComponent().dirs()->addResourceType("illuminant_profiles", 0, "share/apps/krita/illuminants");
QString d659 = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_9_low.ill", KStandardDirs::Recursive)[0];
list = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "*.ill", KStandardDirs::Recursive);
}
KisIlluminantProfile *p = new KisIlluminantProfile;
QVERIFY(p->valid() == false);
p->setFileName(d659);
QVERIFY(p->valid() == false);
p->load();
QVERIFY(p->valid() == true);
qDebug() << "Profile name: " << p->name();
QVERIFY(p->wavelenghts() == 9);
QCOMPARE(p->Kblack(), 4.3);
QCOMPARE(p->Sblack(), 0.14);
gsl_print(p->T(), "Transformation matrix: ");
gsl_print(p->P(), "Positions vector: ");
delete p;
void KisIlluminantProfileTest::testLoading()
{
QString d9low = list.filter("9_low")[0];
QString d9high = list.filter("9_high")[0];
KisIlluminantProfile *p1 = new KisIlluminantProfile;
QVERIFY(p1->valid() == false);
p1->setFileName(d9low);
QVERIFY(p1->valid() == false);
p1->load();
QVERIFY(p1->valid() == true);
QVERIFY(p1->wavelenghts() == 9);
QCOMPARE(p1->Kblack(), 4.3);
QCOMPARE(p1->Sblack(), 0.14);
gsl_print(p1->T(), "Transformation matrix: ");
gsl_print(p1->P(), "Positions vector: ");
KisIlluminantProfile *p2 = dynamic_cast<KisIlluminantProfile*>(p1->clone());
delete p1;
QVERIFY(p2->valid() == true);
QVERIFY(p2->wavelenghts() == 9);
QCOMPARE(p2->Kblack(), 4.3);
QCOMPARE(p2->Sblack(), 0.14);
gsl_print(p2->T(), "Transformation matrix: ");
gsl_print(p2->P(), "Positions vector: ");
p2->setFileName(d9high);
QVERIFY(p2->valid() == true);
p2->load();
QVERIFY(p2->valid() == true);
QVERIFY(p2->wavelenghts() == 9);
QCOMPARE(p2->Kblack(), 11.0);
QCOMPARE(p2->Sblack(), 0.35);
gsl_print(p2->T(), "Transformation matrix: ");
gsl_print(p2->P(), "Positions vector: ");
delete p2;
p1 = new KisIlluminantProfile(d9low);
QVERIFY(p2->valid() == true);
QVERIFY(p2->wavelenghts() == 9);
QCOMPARE(p2->Kblack(), 4.3);
QCOMPARE(p2->Sblack(), 0.14);
gsl_print(p2->T(), "Transformation matrix: ");
gsl_print(p2->P(), "Positions vector: ");
delete p1;
}
void KisIlluminantProfileTest::testSaving()
{
QString d659 = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_9_low.ill", KStandardDirs::Recursive)[0];
QString d659 = list.filter("9_low")[0];
KisIlluminantProfile *p = new KisIlluminantProfile(d659);
p->save("D659Save.ill");
delete p;
p = new KisIlluminantProfile("D659Save.ill");
p = new KisIlluminantProfile("D659Save.ill");
QVERIFY(p->valid() == true);
// QVERIFY(p->name() == "D65 9 Test Profile");
qDebug() << "Profile name: " << p->name();
QVERIFY(p->wavelenghts() == 9);
QCOMPARE(p->Kblack(), 4.3);
QCOMPARE(p->Sblack(), 0.14);
gsl_print(p->T(), "Transformation matrix: ");
gsl_print(p->P(), "Positions vector: ");
delete p;
}
......
......@@ -21,15 +21,21 @@
#define KIS_ILLUMINANT_PROFILE_TEST_H_
#include <QtTest/QtTest>
#include <QStringList>
class KisIlluminantProfileTest : public QObject
{
Q_OBJECT
private slots:
private slots:
void testLoading();
void testSaving();
void initTestCase();
void testLoading();
void testSaving();
private:
QStringList list;
};
......
......@@ -18,9 +18,9 @@
*/
#include <qtest_kde.h>
#include "kis_ks_colorspace_test.h"
#include "kis_illuminant_profile.h"
#include "kis_ks_colorspace_test.h"
#include "kis_ksqp_colorspace.h"
#include "kis_kslc_colorspace.h"
......@@ -30,308 +30,170 @@
#include <KLocale>
#include <KStandardDirs>
void KisKSColorSpaceTest::testConstructor()
{
KGlobal::mainComponent().dirs()->addResourceType("illuminant_profiles", 0, "share/apps/krita/illuminants");
QString d659 = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_9_high.ill", KStandardDirs::Recursive)[0];
#include <QStringList>
#include <QVector>
KisIlluminantProfile *p = new KisIlluminantProfile(d659);
KisKSQPColorSpace<float,9> *cs = new KisKSQPColorSpace<float,9>(p);
QVERIFY(cs->profileIsCompatible(p) == true);
delete cs;
}
#include <cmath>
#include <ctime>
template<typename type, int n>
void print_vector(quint8 *v, const QString &text)
template<typename type>
void print_vector(int n, const quint8 *v, const QString &text)
{
QString vstr;
qDebug() << text;
for (int i = 0; i < n; i++)
vstr += QString::number(reinterpret_cast<type*>(v)[i]/256) + " ";
vstr += QString::number(reinterpret_cast<const type*>(v)[i]) + " ";
qDebug() << vstr;
}
#define N 9
void KisKSColorSpaceTest::testToFromRgbA16()
void KisKSColorSpaceTest::initTestCase()
{
QString d65 = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_9_high.ill", KStandardDirs::Recursive)[0];
const KisIlluminantProfile *profile = new KisIlluminantProfile(d65);
const KoColorSpace *cs = KoColorSpaceRegistry::instance()->colorSpace(KisKSLCColorSpace<float,N>::ColorSpaceId().id(), profile);
QVERIFY2(cs != 0, "Created colorspace");
QVERIFY(cs->profileIsCompatible(profile));
quint8 *rgb1;
quint8 *kas1 = new quint8[2*cs->pixelSize()];
quint8 *rgb2 = new quint8[2*8];
quint32 val = 65535;
quint16 blue[4] = { val, 0, 0, val };
quint16 green[4] = { 0, val, 0, val };
quint16 red[4] = { 0, 0, val, val };
quint16 yellow[4] = { 0, val, val, val };
quint16 bluegreen[8] = { val, 0, 0, val, 0, val, 0, val };
rgb1 = reinterpret_cast<quint8*>(blue);
print_vector<quint16, 4>(rgb1, "BLUE:");
cs->fromRgbA16(rgb1, kas1, 1);
print_vector<float, 2*N+1>(kas1, "BLUE IN KS:");
cs->toRgbA16(kas1, rgb2, 1);
print_vector<quint16, 4>(rgb2, "BLUE AGAIN:");
// QVERIFY(rgb1[0] == rgb2[0]);
// QVERIFY(rgb1[1] == rgb2[1]);
// QVERIFY(rgb1[2] == rgb2[2]);
// QVERIFY(rgb1[3] == rgb2[3]);
rgb1 = reinterpret_cast<quint8*>(green);
cs->fromRgbA16(rgb1, kas1, 1);
cs->toRgbA16(kas1, rgb2, 1);
print_vector<quint16, 4>(rgb1, "GREEN:");
print_vector<float, 2*N+1>(kas1, "GREEN IN KS:");
print_vector<quint16, 4>(rgb2, "GREEN AGAIN:");
// QVERIFY(rgb1[0] == rgb2[0]);
// QVERIFY(rgb1[1] == rgb2[1]);
// QVERIFY(rgb1[2] == rgb2[2]);
// QVERIFY(rgb1[3] == rgb2[3]);
rgb1 = reinterpret_cast<quint8*>(red);
cs->fromRgbA16(rgb1, kas1, 1);
cs->toRgbA16(kas1, rgb2, 1);
print_vector<quint16, 4>(rgb1, "RED:");
print_vector<float, 2*N+1>(kas1, "RED IN KS:");
print_vector<quint16, 4>(rgb2, "RED AGAIN:");
// QVERIFY(rgb1[0] == rgb2[0]);
// QVERIFY(rgb1[1] == rgb2[1]);
// QVERIFY(rgb1[2] == rgb2[2]);
// QVERIFY(rgb1[3] == rgb2[3]);
rgb1 = reinterpret_cast<quint8*>(yellow);
cs->fromRgbA16(rgb1, kas1, 1);
cs->toRgbA16(kas1, rgb2, 1);
print_vector<quint16, 4>(rgb1, "YELLOW:");
print_vector<float, 2*N+1>(kas1, "YELLOW IN KS:");
print_vector<quint16, 4>(rgb2, "YELLOW AGAIN:");
// QVERIFY(rgb1[0] == rgb2[0]);
// QVERIFY(rgb1[1] == rgb2[1]);
// QVERIFY(rgb1[2] == rgb2[2]);
// QVERIFY(rgb1[3] == rgb2[3]);
rgb1 = reinterpret_cast<quint8*>(bluegreen);
cs->fromRgbA16(rgb1, kas1, 2);
cs->toRgbA16(kas1, rgb2, 2);
print_vector<quint16, 8>(rgb1, "BLUE AND GREEN:");
print_vector<float, 2*2*N+1>(kas1, "BLUE AND GREEN IN KS:");
print_vector<quint16, 8>(rgb2, "BLUE AND GREEN AGAIN:");
// QVERIFY(rgb1[0] == rgb2[0]);
// QVERIFY(rgb1[1] == rgb2[1]);
// QVERIFY(rgb1[2] == rgb2[2]);
// QVERIFY(rgb1[3] == rgb2[3]);
// QVERIFY(rgb1[4] == rgb2[4]);
// QVERIFY(rgb1[5] == rgb2[5]);
// QVERIFY(rgb1[6] == rgb2[6]);
// QVERIFY(rgb1[7] == rgb2[7]);
delete [] kas1;
delete [] rgb2;
delete profile;
srand( time(0) );
KGlobal::mainComponent().dirs()->addResourceType("illuminant_profiles", 0, "share/apps/krita/illuminants");
list = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "*.ill", KStandardDirs::Recursive);
}
void KisKSColorSpaceTest::testMixing()
void KisKSColorSpaceTest::testConstructor()
{
QString d65 = KGlobal::mainComponent().dirs()->findAllResources("illuminant_profiles", "D65_9_high.ill", KStandardDirs::Recursive)[0];
const KisIlluminantProfile *profile = new KisIlluminantProfile(d65);
const KoColorSpace *cs = KoColorSpaceRegistry::instance()->colorSpace(KisKSLCColorSpace<float,N>::ColorSpaceId().id(), profile);
QVERIFY2(cs != 0, "Created colorspace");
QVERIFY(cs->profileIsCompatible(profile));
quint8 *rgb1, *rgb2;
quint8 *kas1 = new quint8[cs->pixelSize()];
quint8 *kas2 = new quint8[cs->pixelSize()];
quint8 *kasm = new quint8[cs->pixelSize()];
quint8 *rgbm = new quint8[2*4];
quint32 val1 = 65535, val2 = 10000;
quint16 red[4] = { 0, val2, val1, val1 };
quint16 green[4] = { val2, val1, val2, val1 };
quint16 blue[4] = { val1, val2, 0, val1 };
quint16 yellow[4] = { 0, val1, val1, val1 };
quint16 violet[4] = { val1, 0, val1, val1 };
quint16 cyan[4] = { val1, val1, 0, val1 };
rgb1 = reinterpret_cast<quint8*>(red);
rgb2 = reinterpret_cast<quint8*>(green);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "RED + GREEN IN KS:");
print_vector<quint16,4>(rgbm, "RED + GREEN IN RBG:");
rgb1 = reinterpret_cast<quint8*>(red);
rgb2 = reinterpret_cast<quint8*>(blue);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "RED + BLUE IN KS:");
print_vector<quint16,4>(rgbm, "RED + BLUE IN RBG:");
rgb1 = reinterpret_cast<quint8*>(red);
rgb2 = reinterpret_cast<quint8*>(yellow);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "RED + YELLOW IN KS:");
print_vector<quint16,4>(rgbm, "RED + YELLOW IN RBG:");
QString d656 = list.filter("6_high")[0];
QString d659 = list.filter("9_high")[0];
rgb1 = reinterpret_cast<quint8*>(red);
rgb2 = reinterpret_cast<quint8*>(violet);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "RED + VIOLET IN KS:");
print_vector<quint16,4>(rgbm, "RED + VIOLET IN RBG:");
KisIlluminantProfile *p6 = new KisIlluminantProfile(d656);
KisIlluminantProfile *p9 = new KisIlluminantProfile(d659);
rgb1 = reinterpret_cast<quint8*>(red);
rgb2 = reinterpret_cast<quint8*>(cyan);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "RED + CYAN IN KS:");
print_vector<quint16,4>(rgbm, "RED + CYAN IN RBG:");
KisKSColorSpace<float,6> *cs6 = new KisKSQPColorSpace<float,6>(p6->clone());
KisKSColorSpace<float,9> *cs9 = new KisKSQPColorSpace<float,9>(p9->clone());
rgb1 = reinterpret_cast<quint8*>(green);
rgb2 = reinterpret_cast<quint8*>(blue);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "GREEN + BLUE IN KS:");
print_vector<quint16,4>(rgbm, "GREEN + BLUE IN RBG:");
QVERIFY(cs6->profileIsCompatible(p9) == false);
QVERIFY(cs6->profileIsCompatible(p6) == true);
rgb1 = reinterpret_cast<quint8*>(green);
rgb2 = reinterpret_cast<quint8*>(yellow);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "GREEN + YELLOW IN KS:");
print_vector<quint16,4>(rgbm, "GREEN + YELLOW IN RBG:");
QVERIFY(cs9->profileIsCompatible(p6) == false);
QVERIFY(cs9->profileIsCompatible(p9) == true);
rgb1 = reinterpret_cast<quint8*>(green);
rgb2 = reinterpret_cast<quint8*>(violet);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "GREEN + VIOLET IN KS:");
print_vector<quint16,4>(rgbm, "GREEN + VIOLET IN RBG:");
delete cs6;
delete cs9;
rgb1 = reinterpret_cast<quint8*>(green);
rgb2 = reinterpret_cast<quint8*>(cyan);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "GREEN + CYAN IN KS:");
print_vector<quint16,4>(rgbm, "GREEN + CYAN IN RBG:");
cs6 = new KisKSLCColorSpace<float,6>(p6->clone());
cs9 = new KisKSLCColorSpace<float,9>(p9->clone());
rgb1 = reinterpret_cast<quint8*>(blue);
rgb2 = reinterpret_cast<quint8*>(yellow);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "BLUE + YELLOW IN KS:");
print_vector<quint16,4>(rgbm, "BLUE + YELLOW IN RBG:");
QVERIFY(cs6->profileIsCompatible(p9) == false);
QVERIFY(cs6->profileIsCompatible(p6) == true);
rgb1 = reinterpret_cast<quint8*>(blue);
rgb2 = reinterpret_cast<quint8*>(violet);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);
for (int i = 0; i < 2*N+1; i++)
reinterpret_cast<float*>(kasm)[i] = (reinterpret_cast<float*>(kas1)[i] +
reinterpret_cast<float*>(kas2)[i]) / 2.0;
cs->toRgbA16(kasm, rgbm, 1);
// print_vector<float,2*N+1>(kasm, "BLUE + VIOLET IN KS:");
print_vector<quint16,4>(rgbm, "BLUE + VIOLET IN RBG:");
QVERIFY(cs9->profileIsCompatible(p6) == false);
QVERIFY(cs9->profileIsCompatible(p9) == true);
rgb1 = reinterpret_cast<quint8*>(blue);
rgb2 = reinterpret_cast<quint8*>(cyan);
cs->fromRgbA16(rgb1, kas1, 1);
cs->fromRgbA16(rgb2, kas2, 1);