Krita Source Code Documentation
Loading...
Searching...
No Matches
GrayU8ColorSpace.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#include <GrayU8ColorSpace.h>
8
9#include <QDomElement>
10
11#include <QDebug>
12#include <klocalizedstring.h>
13
14#include <KoIntegerMaths.h>
16
19#include <kis_dom_utils.h>
20
22 : LcmsColorSpace<KoGrayU8Traits>(colorSpaceId(), name, TYPE_GRAYA_8, cmsSigGrayData, p)
23{
26
27 init();
28
29 addStandardCompositeOps<KoGrayU8Traits>(this);
30 addStandardDitherOps<KoGrayU8Traits>(this);
31}
32
37
38void GrayAU8ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const
39{
40 const KoGrayU8Traits::channels_type *p = reinterpret_cast<const KoGrayU8Traits::channels_type *>(pixel);
41 QDomElement labElt = doc.createElement("Gray");
43 labElt.setAttribute("space", profile()->name());
44 colorElt.appendChild(labElt);
45}
46
53
54void GrayAU8ColorSpace::toHSY(const QVector<double> &channelValues, qreal *, qreal *, qreal *luma) const
55{
56 *luma = channelValues[0];
57}
58
59QVector <double> GrayAU8ColorSpace::fromHSY(qreal *, qreal *, qreal *luma) const
60{
61 QVector <double> channelValues(2);
62 channelValues.fill(*luma);
63 channelValues[1]=1.0;
64 return channelValues;
65}
66
67void GrayAU8ColorSpace::toYUV(const QVector<double> &channelValues, qreal *y, qreal *, qreal *) const
68{
69 *y = channelValues[0];
70}
71
72QVector <double> GrayAU8ColorSpace::fromYUV(qreal *y, qreal *, qreal *) const
73{
74 QVector <double> channelValues(2);
75 channelValues.fill(*y);
76 channelValues[1]=1.0;
77 return channelValues;
78}
const Params2D p
GrayAU8ColorSpace(const QString &name, KoColorProfile *p)
void toHSY(const QVector< double > &channelValues, qreal *hue, qreal *sat, qreal *luma) const override
void colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const override
QVector< double > fromHSY(qreal *hue, qreal *sat, qreal *luma) const override
void colorFromXML(quint8 *pixel, const QDomElement &elt) const override
void toYUV(const QVector< double > &channelValues, qreal *y, qreal *u, qreal *v) const override
virtual KoColorSpace * clone() const
QVector< double > fromYUV(qreal *y, qreal *u, qreal *v) const override
@ ALPHA
The channel represents the opacity of a pixel.
@ COLOR
The channel represents a color.
@ UINT8
use this for an unsigned integer 8bits 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