Commit 7fed4e56 authored by Emanuele Tamponi's avatar Emanuele Tamponi

More changes.

svn path=/trunk/koffice/; revision=752155
parent f115ce9d
......@@ -41,19 +41,19 @@ KisIlluminantProfile::KisIlluminantProfile(const KisIlluminantProfile &profile)
setInfo(profile.info());
m_valid = profile.valid();
if (profile.valid()) {
m_T = gsl_matrix_alloc(profile.m_T->size1, profile.m_T->size2);
m_P = gsl_vector_alloc(profile.m_P->size);
gsl_matrix_memcpy(m_T, profile.m_T);
gsl_vector_memcpy(m_P, profile.m_P);
m_T = gsl_matrix_float_alloc(profile.m_T->size1, profile.m_T->size2);
m_P = gsl_vector_float_alloc(profile.m_P->size);
gsl_matrix_float_memcpy(m_T, profile.m_T);
gsl_vector_float_memcpy(m_P, profile.m_P);
}
}
KisIlluminantProfile::~KisIlluminantProfile()
{
if (m_T)
gsl_matrix_free(m_T);
gsl_matrix_float_free(m_T);
if (m_P)
gsl_vector_free(m_P);
gsl_vector_float_free(m_P);
}
KoColorProfile *KisIlluminantProfile::clone() const
......@@ -83,11 +83,11 @@ bool KisIlluminantProfile::load() // TODO Info
int m, n;
double c;
data >> m >> n;
m_T = gsl_matrix_alloc(m, n);
m_T = gsl_matrix_float_alloc(m, n);
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
data >> c;
gsl_matrix_set(m_T, i, j, c);
gsl_matrix_float_set(m_T, i, j, (float)c);
}
}
}
......@@ -97,15 +97,23 @@ bool KisIlluminantProfile::load() // TODO Info
double c;
data >> l;
if ((size_t)l != m_T->size2) {
gsl_matrix_free(m_T); m_T = 0;
gsl_matrix_float_free(m_T); m_T = 0;
return false;
}
m_P = gsl_vector_alloc(l);
m_P = gsl_vector_float_alloc(l);
for (int i = 0; i < l; i++) {
data >> c;
gsl_vector_set(m_P, i, c);
gsl_vector_float_set(m_P, i, (float)c);
}
}
{
// Scattering of white lead and absorption of black lead
double c;
data >> c;
S_w = (float)c;
data >> c;
K_b = (float)c;
}
m_valid = true;
return true;
......@@ -125,11 +133,13 @@ bool KisIlluminantProfile::save(const QString &fileName)
data << (int)m_T->size1 << (int)m_T->size2;
for (int i = 0; i < (int)m_T->size1; i++)
for (int j = 0; j < (int)m_T->size2; j++)
data << gsl_matrix_get(m_T, i, j);
data << (double)gsl_matrix_float_get(m_T, i, j);
data << (int)m_P->size;
for (int i = 0; i < (int)m_P->size; i++)
data << gsl_vector_get(m_P, i);
data << (double)gsl_vector_float_get(m_P, i);
data << (double)S_w << (double)K_b;
return true;
}
......@@ -44,15 +44,16 @@ class KisIlluminantProfile : public KoColorProfile {
bool operator==(const KoColorProfile &op2) const
{ return (name()+info() == op2.name()+op2.info()); }
gsl_matrix *T() const { return m_T; }
gsl_vector *P() const { return m_P; }
int wavelenghts() { return m_P->size; }
gsl_matrix_float *T() const { return m_T; }
gsl_vector_float *P() const { return m_P; }
int wavelenghts() const { return m_P->size; }
private:
gsl_matrix *m_T;
gsl_vector *m_P;
gsl_matrix_float *m_T;
gsl_vector_float *m_P;
bool m_valid;
float S_w, K_b;
};
#endif // KIS_ILLUMINANT_PROFILE_H_
......@@ -28,8 +28,8 @@
#include <gsl/gsl_vector.h>
KisKS3ColorSpace::KisKS3ColorSpace(KoColorProfile *p)
: parent( "KS3CS" + p->name(),
"KS 3 Color Space with profile " + p->name(),
: parent( "ks3colorspace",
"KS Color Space - 3 wavelenghts",
KoColorSpaceRegistry::instance()->rgb16("") )
{
if (!profileIsCompatible(p))
......@@ -75,3 +75,8 @@ void KisKS3ColorSpace::fromRgbA16(const quint8 *srcU8, quint8 *dstU8, quint32 nP
void KisKS3ColorSpace::toRgbA16(const quint8 *srcU8, quint8 *dstU8, quint32 nPixels) const
{
}
bool KisKS3ColorSpace::operator==(const KoColorSpace& rhs) const
{
return (rhs.id() == id()) && (*rhs.profile() == *profile());
}
......@@ -44,6 +44,8 @@ class KisKS3ColorSpace : public KoIncompleteColorSpace<KisKS3ColorSpaceTrait>
void fromRgbA16(const quint8 *srcU8, quint8 *dstU8, quint32 nPixels) const;
void toRgbA16(const quint8 *srcU8, quint8 *dstU8, quint32 nPixels) const;
bool operator==(const KoColorSpace& rhs) const;
private:
KisIlluminantProfile *m_profile;
......
......@@ -15,4 +15,4 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
\ No newline at end of file
*/
......@@ -17,11 +17,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KS_REF_CONVERSIONS_H_
#define KS_REF_CONVERSIONS_H_
#ifndef KS_REF_CONVERTER_H_
#define KS_REF_CONVERTER_H_
class KSReflectanceConverter {
public:
KSReflectanceConverter(float whiteS, float blackK);
~KSReflectanceConverter();
void KStoReflectance(float K, float S, float &R);
void ReflectancetoKS(float R, float &K, float &S);
private:
float S_w, K_b;
};
#endif // KS_REF_CONVERSIONS_H_
#endif // KS_REF_CONVERTER_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment