Krita Source Code Documentation
Loading...
Searching...
No Matches
GrayU16ColorSpace.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006 Cyrille Berger <cberger@cberger.net>
3 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#include "GrayU16ColorSpace.h"
9
10#include <QDomElement>
11
12#include <QDebug>
13#include <klocalizedstring.h>
14
15#include <KoIntegerMaths.h>
17
20#include <kis_dom_utils.h>
21
23 : LcmsColorSpace<KoGrayU16Traits>(colorSpaceId(), name, TYPE_GRAYA_16, cmsSigGrayData, p)
24{
25 addChannel(new KoChannelInfo(i18n("Gray"), 0 * sizeof(quint16), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16));
26 addChannel(new KoChannelInfo(i18n("Alpha"), 1 * sizeof(quint16), 1, KoChannelInfo::ALPHA, KoChannelInfo::UINT16));
27
28 init();
29
30 addStandardCompositeOps<KoGrayU16Traits>(this);
31 addStandardDitherOps<KoGrayU16Traits>(this);
32}
33
38
39void GrayAU16ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const
40{
41 const KoGrayU16Traits::channels_type *p = reinterpret_cast<const KoGrayU16Traits::channels_type *>(pixel);
42 QDomElement labElt = doc.createElement("Gray");
44 labElt.setAttribute("space", profile()->name());
45 colorElt.appendChild(labElt);
46}
47
54
55void GrayAU16ColorSpace::toHSY(const QVector<double> &channelValues, qreal *, qreal *, qreal *luma) const
56{
57 *luma = channelValues[0];
58}
59
60QVector <double> GrayAU16ColorSpace::fromHSY(qreal *, qreal *, qreal *luma) const
61{
62 QVector <double> channelValues(2);
63 channelValues.fill(*luma);
64 channelValues[1]=1.0;
65 return channelValues;
66}
67
68void GrayAU16ColorSpace::toYUV(const QVector<double> &channelValues, qreal *y, qreal *, qreal *) const
69{
70 *y = channelValues[0];
71}
72
73QVector <double> GrayAU16ColorSpace::fromYUV(qreal *y, qreal *, qreal *) const
74{
75 QVector <double> channelValues(2);
76 channelValues.fill(*y);
77 channelValues[1]=1.0;
78 return channelValues;
79}
const Params2D p
QVector< double > fromYUV(qreal *y, qreal *u, qreal *v) const override
virtual KoColorSpace * clone() const
void toHSY(const QVector< double > &channelValues, qreal *hue, qreal *sat, qreal *luma) const override
void colorFromXML(quint8 *pixel, const QDomElement &elt) const override
GrayAU16ColorSpace(const QString &name, KoColorProfile *p)
QVector< double > fromHSY(qreal *hue, qreal *sat, qreal *luma) const override
void colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const override
void toYUV(const QVector< double > &channelValues, qreal *y, qreal *u, qreal *v) const override
@ ALPHA
The channel represents the opacity of a pixel.
@ COLOR
The channel represents a color.
@ UINT16
use this for an integer 16bits channel
static _Tdst scaleToA(_T a)
virtual void addChannel(KoChannelInfo *ci)
const KoColorProfile * profile() const override
double toDouble(const QString &str, bool *ok=nullptr)
QString toString(const QString &value)
_channels_type_ channels_type
the type of the value of the channels of this color space