Commit 44d96f90 authored by Boudewijn Rempt's avatar Boudewijn Rempt

BUG:352982 Add a 16 bits floating point Grayscale colorspace

parent 67cf2ee2
......@@ -13,6 +13,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/cmyk_f32
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/gray_u8
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/gray_u16
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/gray_f16
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/gray_f32
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/lab_u8
${CMAKE_CURRENT_SOURCE_DIR}/colorspaces/lab_u16
......@@ -52,6 +53,7 @@ set ( lcmsengine_SRCS
colorspaces/gray_u8/GrayU8ColorSpace.cpp
colorspaces/gray_u16/GrayU16ColorSpace.cpp
colorspaces/gray_f16/GrayF16ColorSpace.cpp
colorspaces/gray_f32/GrayF32ColorSpace.cpp
colorspaces/lab_u8/LabU8ColorSpace.cpp
......
......@@ -68,6 +68,7 @@
#include <half.h>
#ifdef HAVE_LCMS24
#include "colorspaces/gray_f16/GrayF16ColorSpace.h"
#include "colorspaces/xyz_f16/XyzF16ColorSpace.h"
#include "colorspaces/rgb_f16/RgbF16ColorSpace.h"
#endif
......@@ -189,6 +190,11 @@ LcmsEnginePlugin::LcmsEnginePlugin(QObject *parent, const QVariantList &)
registry->add(new GrayAU8ColorSpaceFactory());
registry->add(new GrayAU16ColorSpaceFactory());
#ifdef HAVE_LCMS24
#ifdef HAVE_OPENEXR
registry->add(new GrayF16ColorSpaceFactory());
#endif
#endif
registry->add(new GrayF32ColorSpaceFactory());
KoHistogramProducerFactoryRegistry::instance()->add(
......@@ -198,6 +204,14 @@ LcmsEnginePlugin::LcmsEnginePlugin(QObject *parent, const QVariantList &)
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicU16HistogramProducer>
(KoID("GRAYA16HISTO", i18n("GRAY/Alpha16 Histogram")), GrayAColorModelID.id(), Integer16BitsColorDepthID.id()));
#ifdef HAVE_LCMS24
#ifdef HAVE_OPENEXR
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF16HalfHistogramProducer>
(KoID("GRAYF16HISTO", i18n("GRAYF16 Histogram")), GrayAColorModelID.id(), Float16BitsColorDepthID.id()));
#endif
#endif
KoHistogramProducerFactoryRegistry::instance()->add(
new KoBasicHistogramProducerFactory<KoBasicF32HistogramProducer>
......
/*
* Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 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.
*/
#include "GrayF16ColorSpace.h"
#include <QDomElement>
#include <kdebug.h>
#include <klocale.h>
#include <KoIntegerMaths.h>
#include <KoColorSpaceRegistry.h>
#include "compositeops/KoCompositeOps.h"
GrayF16ColorSpace::GrayF16ColorSpace(const QString &name, KoColorProfile *p)
: LcmsColorSpace<KoGrayF16Traits>(colorSpaceId(), name, TYPE_GRAYA_HALF_FLT, cmsSigGrayData, p)
{
const IccColorProfile* icc_p = dynamic_cast<const IccColorProfile*>(p);
Q_ASSERT(icc_p);
addChannel(new KoChannelInfo(i18n("Gray"), 0 * sizeof(float), 0, KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, 2, Qt::gray));
addChannel(new KoChannelInfo(i18n("Alpha"), 1 * sizeof(float), 1, KoChannelInfo::ALPHA, KoChannelInfo::FLOAT16, 2));
init();
addStandardCompositeOps<KoGrayF16Traits>(this);
}
KoColorSpace* GrayF16ColorSpace::clone() const
{
return new GrayF16ColorSpace(name(), profile()->clone());
}
void GrayF16ColorSpace::colorToXML(const quint8* pixel, QDomDocument& doc, QDomElement& colorElt) const
{
const KoGrayF16Traits::channels_type* p = reinterpret_cast<const KoGrayF16Traits::channels_type*>(pixel);
QDomElement labElt = doc.createElement("Gray");
labElt.setAttribute("g", KoColorSpaceMaths< KoGrayF16Traits::channels_type, qreal>::scaleToA(p[0]));
labElt.setAttribute("space", profile()->name());
colorElt.appendChild(labElt);
}
void GrayF16ColorSpace::colorFromXML(quint8* pixel, const QDomElement& elt) const
{
KoGrayF16Traits::channels_type* p = reinterpret_cast<KoGrayF16Traits::channels_type*>(pixel);
p[0] = KoColorSpaceMaths< qreal, KoGrayF16Traits::channels_type >::scaleToA(elt.attribute("g").toDouble());
p[1] = 1.0;
}
/*
* Copyright (c) 2004-2006 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 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 COLORSPACE_GRAYSCALE_F16_H_
#define COLORSPACE_GRAYSCALE_F16_H_
#include <klocale.h>
#include <KoColorSpaceTraits.h>
#include <KoColorModelStandardIds.h>
#include "LcmsColorSpace.h"
#define TYPE_GRAYA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2))
class GrayF16ColorSpace : public LcmsColorSpace<KoGrayF16Traits>
{
public:
GrayF16ColorSpace(const QString &name, KoColorProfile *p);
virtual bool willDegrade(ColorSpaceIndependence) const {
return false;
}
virtual KoID colorModelId() const {
return GrayAColorModelID;
}
virtual KoID colorDepthId() const {
return Float16BitsColorDepthID;
}
virtual KoColorSpace* clone() const;
virtual void colorToXML(const quint8* pixel, QDomDocument& doc, QDomElement& colorElt) const;
virtual void colorFromXML(quint8* pixel, const QDomElement& elt) const;
static QString colorSpaceId()
{
return "GRAYAF16";
}
virtual bool hasHighDynamicRange() const
{
return true;
}
};
class GrayF16ColorSpaceFactory : public LcmsColorSpaceFactory
{
public:
GrayF16ColorSpaceFactory()
: LcmsColorSpaceFactory(TYPE_GRAYA_HALF_FLT, cmsSigGrayData)
{
}
virtual QString id() const {
return GrayF16ColorSpace::colorSpaceId();
}
virtual QString name() const {
return i18n("Grayscale/Alpha (16-bit float/channel)");
}
virtual KoID colorModelId() const {
return GrayAColorModelID;
}
virtual KoID colorDepthId() const {
return Float16BitsColorDepthID;
}
virtual int referenceDepth() const {
return 16;
}
virtual bool userVisible() const {
return true;
}
virtual KoColorSpace *createColorSpace(const KoColorProfile *p) const {
return new GrayF16ColorSpace(name(), p->clone());
}
virtual QString defaultProfile() const {
return "gray built-in";
}
virtual bool isHdr() const
{
return true;
}
};
#endif // KIS_STRATEGY_COLORSPACE_GRAYSCALE_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