Commit 589be1db authored by Cyrille Berger's avatar Cyrille Berger

* up the requirement to the upcoming OpenCTL 0.9.2

* add a pigment ctl module with some "utils" functions
* add a decent default function to convert to QImage
* add the start of a CTL based XYZ32F
* make Color Conversion Transformation Factory aware that they can be limited to working with a specific profile
* fix rgb hdr color space conversion, alpha shall not be pseudo-gamma corrected
(* the perspective grid tool was ported, remove the message)


svn path=/trunk/koffice/; revision=786387
parent f86ef644
......@@ -11,14 +11,14 @@ if(OPENCTL_DEFINITIONS AND OPENCTL_LIBRARIES)
FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/bin/ /usr/local/bin )
# query pkg-config asking for OpenCTL == 0.9.1
EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --exact-version=0.9.1 OpenCTL RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
# query pkg-config asking for OpenCTL == 0.9.2
EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --exact-version=0.9.2 OpenCTL RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
if(_return_VALUE STREQUAL "0")
set(OPENCTL_FOUND TRUE)
set(HAVE_OPENCTL TRUE)
else(_return_VALUE STREQUAL "0")
message(STATUS "OpenCTL != 0.9.1 was found")
message(STATUS "OpenCTL != 0.9.2 was found")
endif(_return_VALUE STREQUAL "0")
endif(OPENCTL_DEFINITIONS AND OPENCTL_LIBRARIES)
......
if(OPENCTL_FOUND)
add_subdirectory( lms_f32 )
add_subdirectory( xyz_float_hdr.ctl )
else(OPENCTL_FOUND)
add_subdirectory( xyz_float_hdr )
endif(OPENCTL_FOUND)
add_subdirectory( rgb_float_hdr )
add_subdirectory( gray_u8_no_alpha )
add_subdirectory( gray_u16_no_alpa )
add_subdirectory( xyz_u16 )
add_subdirectory( xyz_float_hdr )
add_subdirectory( ycbcr )
add_subdirectory( extensions )
......@@ -23,7 +23,6 @@
#include <KoColorModelStandardIds.h>
#include <KoColorSpaceRegistry.h>
#include <KoCtlColorProfile.h>
#include <KoCtlColorConversionTransformation.h>
#include "compositeops/KoCompositeOpOver.h"
#include "compositeops/KoCompositeOpErase.h"
......@@ -129,7 +128,7 @@ QString KisLmsAF32ColorSpaceFactory::defaultProfile()
bool KisLmsAF32ColorSpaceFactory::profileIsCompatible(const KoColorProfile* profile) const
{
const KoCtlColorProfile* ctlp = dynamic_cast<const KoCtlColorProfile*>(profile);
if(ctlp && ctlp->colorModel().id() == "LMSA" && ctlp->colorDepth().id() == "F32")
if(ctlp && ctlp->colorModel() == "LMSA" && ctlp->colorDepth() == "F32")
{
return true;
}
......@@ -153,11 +152,16 @@ int KisLmsAF32ColorSpaceFactory::referenceDepth() const
QList<KoColorConversionTransformationFactory*> KisLmsAF32ColorSpaceFactory::colorConversionLinks() const
{
QList<const KoColorProfile*> profiles = KoColorSpaceRegistry::instance()->profilesFor( this );
QList<KoColorConversionTransformationFactory*> list;
// Conversion to LMSA Float 32bit
list.append(new KoCtlColorConversionTransformationFactory( RGBAColorModelID.id(), Float32BitsColorDepthID.id(), LMSAColorModelID.id(), Float32BitsColorDepthID.id() ) );
// Conversion from LMSA Float 32bit
list.append(new KoCtlColorConversionTransformationFactory( LMSAColorModelID.id(), Float32BitsColorDepthID.id(), RGBAColorModelID.id(), Float32BitsColorDepthID.id() ) );
foreach(const KoColorProfile* profile, profiles)
{
const KoCtlColorProfile* ctlprofile = dynamic_cast<const KoCtlColorProfile*>( profile );
if(ctlprofile)
{
list += ctlprofile->createColorConversionTransformationFactories();
}
}
return list;
}
......
......@@ -35,9 +35,19 @@ class KisExposureCorrectedIntegerRgbToFloatRgbConversionTransformation : public
Q_ASSERT(hdrProfile);
const typename _src_CSTraits_::channels_type* src = _src_CSTraits_::nativeArray(srcU8);
typename _dst_CSTraits_::channels_type* dst = _dst_CSTraits_::nativeArray(dstU8);
for(quint32 i = 0; i< _src_CSTraits_::channels_nb * nPixels;i++)
for(quint32 i = 0; i< nPixels;i++)
{
dst[i] = hdrProfile->displayToChannel( KoColorSpaceMaths<typename _src_CSTraits_::channels_type, quint16>::scaleToA(src[i]) );
for(quint32 j = 0; j < 4; j++)
{
if( j == _dst_CSTraits_::alpha_pos)
{
dst[j] = KoColorSpaceMaths<typename _src_CSTraits_::channels_type, quint16>::scaleToA(src[j]);
} else {
dst[j] = hdrProfile->displayToChannel( KoColorSpaceMaths<typename _src_CSTraits_::channels_type, quint16>::scaleToA(src[j]) );
}
}
dst += 4;
src += 4;
}
}
};
......@@ -78,9 +88,19 @@ class KisExposureCorrectedFloatRgbToIntegerRgbConversionTransformation : public
Q_ASSERT(hdrProfile);
const typename _src_CSTraits_::channels_type* src = _src_CSTraits_::nativeArray(srcU8);
typename _dst_CSTraits_::channels_type* dst = _dst_CSTraits_::nativeArray(dstU8);
for(quint32 i = 0; i< _src_CSTraits_::channels_nb * nPixels;i++)
for(quint32 i = 0; i< nPixels;i++)
{
dst[i] = KoColorSpaceMaths<quint16, typename _dst_CSTraits_::channels_type>::scaleToA(hdrProfile->channelToDisplay( src[i])) ;
for(quint32 j = 0; j < 4; j++)
{
if( j == _dst_CSTraits_::alpha_pos)
{
dst[j] = KoColorSpaceMaths<typename _src_CSTraits_::channels_type, quint16>::scaleToA(src[j]);
} else {
dst[j] = KoColorSpaceMaths<quint16, typename _dst_CSTraits_::channels_type>::scaleToA(hdrProfile->channelToDisplay( src[j]));
}
}
dst += 4;
src += 4;
}
}
};
......
set(kritaxyzfloathdrplugin_PART_SRCS xyz_float_hdr.cc kis_xyz_f32_hdr_colorspace.cc )
kde4_add_plugin(kritaxyzfloathdrplugin ${kritaxyzfloathdrplugin_PART_SRCS})
target_link_libraries(kritaxyzfloathdrplugin ${KDE4_KDECORE_LIBS} pigmentcms)
install(TARGETS kritaxyzfloathdrplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install( FILES kritaxyzfloathdrplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES
xyzaf32.ctlp
DESTINATION ${DATA_INSTALL_DIR}/pigmentcms/ctlprofiles)
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef _KIS_LAB_TO_XYZ_COLOR_CONVERSION_TRANSFORMATION_H_
#define _KIS_LAB_TO_XYZ_COLOR_CONVERSION_TRANSFORMATION_H_
#include <KoColorConversionTransformation.h>
#define UINT16_TO_FLOAT(v) (KoColorSpaceMaths<quint16, typename _xyz_CSTraits_::channels_type >::scaleToA(v))
#define L_TO_FLOAT(v) (UINT16_TO_FLOAT(v) * 100.0)
#define ab_TO_FLOAT(v) ((UINT16_TO_FLOAT(v) - 0.5) * 200.0)
template< typename _xyz_CSTraits_>
class KisLabToXyzColorConversionTransformation : public KoColorConversionTransformation {
public:
KisLabToXyzColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs) : KoColorConversionTransformation(srcCs, dstCs)
{
}
virtual void transform(const quint8 *src8, quint8 *dst8, qint32 nPixels) const
{
const KoLabU16Traits::Pixel* src = reinterpret_cast<const KoLabU16Traits::Pixel*>(src8);
typename _xyz_CSTraits_::Pixel* dst = reinterpret_cast<typename _xyz_CSTraits_::Pixel*>(dst8);
while(nPixels > 0)
{
double fy = ( L_TO_FLOAT(src->L ) + 16.0) / 116.0;
double fx = fy + ab_TO_FLOAT(src->a ) / 500.0;
double fz = fy - ab_TO_FLOAT(src->b ) / 200.0;
dst->X = f_lab_to_xyz(fx, X_r);
dst->Y = f_lab_to_xyz(fy, Y_r);
dst->Z = f_lab_to_xyz(fz, Z_r);
dst->alpha = UINT16_TO_FLOAT(src->alpha);
nPixels--;
dst++;
src++;
}
}
private:
inline double f_lab_to_xyz(double v, double r) const
{
if( v > delta)
{
return r * pow(v, 3.0);
} else {
return r * (v - 16.0 / 116.0) * 3.0 * delta *delta;
}
}
};
template<typename _xyz_CSTraits_>
class KisLabToXyzColorConversionTransformationFactory : public KoColorConversionTransformationFactory {
public:
KisLabToXyzColorConversionTransformationFactory(QString _dstDepthId) : KoColorConversionTransformationFactory(LABAColorModelID.id(), Integer16BitsColorDepthID.id(), XYZAColorModelID.id(), _dstDepthId)
{}
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual) const
{
Q_UNUSED(renderingIntent);
Q_ASSERT(canBeSource(srcColorSpace));
Q_ASSERT(canBeDestination(dstColorSpace));
return new KisLabToXyzColorConversionTransformation<_xyz_CSTraits_>(srcColorSpace, dstColorSpace);
}
virtual bool conserveColorInformation() const
{
return true;
}
virtual bool conserveDynamicRange() const
{
return false;
}
private:
bool hdr;
};
#endif
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef _KIS_RGB_TO_XYZ_COLOR_CONVERSION_TRANSFORMATION_H_
#define _KIS_RGB_TO_XYZ_COLOR_CONVERSION_TRANSFORMATION_H_
#include <KoColorConversionTransformation.h>
template< typename _rgb_CSTraits_, typename _xyz_CSTraits_>
class KisRgbToXyzColorConversionTransformation : public KoColorConversionTransformation {
public:
KisRgbToXyzColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs) : KoColorConversionTransformation(srcCs, dstCs)
{
}
virtual void transform(const quint8 *src8, quint8 *dst8, qint32 nPixels) const
{
const typename _rgb_CSTraits_::Pixel* src = reinterpret_cast<const typename _rgb_CSTraits_::Pixel*>(src8);
typename _xyz_CSTraits_::Pixel* dst = reinterpret_cast<typename _xyz_CSTraits_::Pixel*>(dst8);
while(nPixels > 0)
{
dst->X = 0.412400 * src->red + 0.357579 * src->green + 0.180464 * src->blue;
dst->Y = 0.212656 * src->red + 0.715158 * src->green + 0.072186 * src->blue;
dst->Z = 0.019332 * src->red + 0.119193 * src->green + 0.950444 * src->blue;
dst->alpha = src->alpha;
nPixels--;
dst++;
src++;
}
}
};
template<typename _rgb_CSTraits_, typename _xyz_CSTraits_>
class KisRgbToXyzColorConversionTransformationFactory : public KoColorConversionTransformationFactory {
public:
KisRgbToXyzColorConversionTransformationFactory(QString _srcDepthId, QString _dstDepthId) : KoColorConversionTransformationFactory(RGBAColorModelID.id(), _srcDepthId, XYZAColorModelID.id(), _dstDepthId)
{}
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual) const
{
Q_UNUSED(renderingIntent);
Q_ASSERT(canBeSource(srcColorSpace));
Q_ASSERT(canBeDestination(dstColorSpace));
return new KisRgbToXyzColorConversionTransformation<_rgb_CSTraits_, _xyz_CSTraits_>(srcColorSpace, dstColorSpace);
}
virtual bool conserveColorInformation() const
{
return true;
}
virtual bool conserveDynamicRange() const
{
return true;
}
private:
bool hdr;
};
#endif
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kis_xyz_f16_hdr_colorspace.h"
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kis_xyz_f32_hdr_colorspace.h"
#include "colorprofiles/KoCtlColorProfile.h"
#include <KoColorConversionTransformationFactory.h>
#include <KoCtlColorConversionTransformation.h>
KisXyzF32HDRColorSpace::KisXyzF32HDRColorSpace( const KoCtlColorProfile *p)
: KisXyzFloatHDRColorSpace<XyzF32Traits>(colorSpaceId(), i18n("XYZ (32-bit float/channel) for High Dynamic Range imaging"), p)
{
}
QString KisXyzF32HDRColorSpace::colorSpaceId()
{
return QString("XyzAF32");
}
QList<KoColorConversionTransformationFactory*> KisXyzF32HDRColorSpaceFactory::colorConversionLinks() const
{
QList<const KoColorProfile*> profiles = KoColorSpaceRegistry::instance()->profilesFor( this );
QList<KoColorConversionTransformationFactory*> list;
foreach(const KoColorProfile* profile, profiles)
{
const KoCtlColorProfile* ctlprofile = dynamic_cast<const KoCtlColorProfile*>( profile );
if(ctlprofile)
{
list += ctlprofile->createColorConversionTransformationFactories();
}
}
return list;
}
KoColorSpace* KisXyzF32HDRColorSpace::clone() const
{
return new KisXyzF32HDRColorSpace( static_cast<const KoCtlColorProfile*>(profile()) );
}
KoColorSpace* KisXyzF32HDRColorSpaceFactory::createColorSpace( const KoColorProfile * p) const {
return new KisXyzF32HDRColorSpace( dynamic_cast<const KoCtlColorProfile*>(p) );
}
bool KisXyzF32HDRColorSpaceFactory::profileIsCompatible(const KoColorProfile* profile) const
{
const KoCtlColorProfile* ctlp = dynamic_cast<const KoCtlColorProfile*>(profile);
if(ctlp && ctlp->colorModel() == "XYZA" && ctlp->colorDepth() == "F32")
{
return true;
}
return false;
}
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_XYZ_F32_HDR_COLORSPACE_H_
#define _KIS_XYZ_F32_HDR_COLORSPACE_H_
#include <KoColorSpaceTraits.h>
#include <KoColorModelStandardIds.h>
#include "kis_xyz_hdr_colorspace.h"
typedef KoXyzTraits<float> XyzF32Traits;
class KisXyzF32HDRColorSpace : public KisXyzFloatHDRColorSpace<XyzF32Traits>
{
public:
KisXyzF32HDRColorSpace( const KoCtlColorProfile *p);
virtual KoID colorModelId() const { return XYZAColorModelID; }
virtual KoID colorDepthId() const { return Float32BitsColorDepthID; }
/**
* The ID that identifies this colorspace. Pass this as the colorSpaceId parameter
* to the KoColorSpaceRegistry::colorSpace() functions to obtain this colorspace.
* This is the value that the member function id() returns.
*/
static QString colorSpaceId();
virtual KoColorSpace* clone() const;
};
class KisXyzF32HDRColorSpaceFactory : public KoColorSpaceFactory
{
public:
/**
* Krita definition for use in .kra files and internally: unchanging name +
* i18n'able description.
*/
virtual QString id() const { return KisXyzF32HDRColorSpace::colorSpaceId(); }
virtual QString name() const { return i18n("XYZ (32-bit float/channel) for High Dynamic Range imaging"); }
virtual KoID colorModelId() const { return XYZAColorModelID; }
virtual KoID colorDepthId() const { return Float32BitsColorDepthID; }
virtual bool userVisible() const { return true; }
virtual int referenceDepth() const { return 32; }
virtual bool isIcc() const { return false; }
virtual bool isHdr() const { return true; }
virtual QList<KoColorConversionTransformationFactory*> colorConversionLinks() const;
virtual KoColorConversionTransformationFactory* createICCColorConversionTransformationFactory(QString _colorModelId, QString _colorDepthId) const
{
Q_UNUSED(_colorModelId);
Q_UNUSED(_colorDepthId);
return 0;
}
virtual KoColorSpace *createColorSpace( const KoColorProfile * p) const;
virtual bool profileIsCompatible(const KoColorProfile* profile) const;
QString defaultProfile() const { return "Standard XYZ"; }
};
#endif
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_XYZ_HDR_COLORSPACE_H_
#define _KIS_XYZ_HDR_COLORSPACE_H_
#include <QDomElement>
#include <math.h>
#include "KoIncompleteColorSpace.h"
#include "KoColorSpaceRegistry.h"
#include "compositeops/KoCompositeOpOver.h"
#include "compositeops/KoCompositeOpErase.h"
#include "KoCtlMonoTypeColorSpace.h"
template <class _CSTraits>
class KisXyzFloatHDRColorSpace : public KoCtlMonoTypeColorSpace<_CSTraits>
{
public:
KisXyzFloatHDRColorSpace(const QString &id, const QString &name, const KoCtlColorProfile *profile)
: KoCtlMonoTypeColorSpace<_CSTraits>(id, name, KoColorSpaceRegistry::instance()->lab16(""), profile)
{
Q_UNUSED(profile);
const KoChannelInfo::enumChannelValueType channelValueType = KoColorSpaceMathsTraits<typename _CSTraits::channels_type>::channelValueType;
const int channelSize = sizeof(typename _CSTraits::channels_type);
this->addChannel(new KoChannelInfo(i18n("X"),
_CSTraits::x_pos * channelSize,
KoChannelInfo::COLOR,
channelValueType,
channelSize,
QColor(255,0,0)));
this->addChannel(new KoChannelInfo(i18n("Y"),
_CSTraits::y_pos * channelSize,
KoChannelInfo::COLOR,
channelValueType,
channelSize,
QColor(0,255,0)));
this->addChannel(new KoChannelInfo(i18n("Z"),
_CSTraits::z_pos * channelSize,
KoChannelInfo::COLOR,
channelValueType,
channelSize,
QColor(0,0,255)));
this->addChannel(new KoChannelInfo(i18n("Alpha"),
_CSTraits::alpha_pos * channelSize,
KoChannelInfo::ALPHA,
channelValueType,
channelSize));
addCompositeOp( new KoCompositeOpOver<_CSTraits>( this ) );
addCompositeOp( new KoCompositeOpErase<_CSTraits>( this ) );
}
virtual void colorToXML( const quint8* pixel, QDomDocument& doc, QDomElement& colorElt) const
{
const typename _CSTraits::Pixel* p = reinterpret_cast<const typename _CSTraits::Pixel*>( pixel );
QDomElement labElt = doc.createElement( "XYZ" );
labElt.setAttribute("x", KoColorSpaceMaths< typename _CSTraits::channels_type, double>::scaleToA( p->X) );
labElt.setAttribute("y", KoColorSpaceMaths< typename _CSTraits::channels_type, double>::scaleToA( p->Y) );
labElt.setAttribute("z", KoColorSpaceMaths< typename _CSTraits::channels_type, double>::scaleToA( p->Z) );
labElt.setAttribute("space", "xyz" );
colorElt.appendChild( labElt );
}
virtual void colorFromXML( quint8* pixel, const QDomElement& elt) const
{
typename _CSTraits::Pixel* p = reinterpret_cast<typename _CSTraits::Pixel*>( pixel );
p->X = KoColorSpaceMaths< double, typename _CSTraits::channels_type >::scaleToA(elt.attribute("x").toDouble());
p->Y = KoColorSpaceMaths< double, typename _CSTraits::channels_type >::scaleToA(elt.attribute("y").toDouble());
p->Z = KoColorSpaceMaths< double, typename _CSTraits::channels_type >::scaleToA(elt.attribute("z").toDouble());
}
public:
virtual bool profileIsCompatible(const KoColorProfile* profile) const
{
return profile == 0;
}
virtual bool willDegrade(ColorSpaceIndependence /*independence*/) const
{
// Currently all levels of colorspace independence will degrade floating point
// colorspaces images.
return true;
}
};
#endif