Krita Source Code Documentation
Loading...
Searching...
No Matches
KoRgbU16ColorSpace.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt <boud@valdyas.org>
3 * SPDX-FileCopyrightText: 2006 Cyrille Berger <cberger@cberger.net>
4 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8
10
11#include <limits.h>
12#include <stdlib.h>
13
14
15#include <klocalizedstring.h>
16
17#include "KoChannelInfo.h"
18#include "KoID.h"
19#include "KoIntegerMaths.h"
20
21#include "KoColorConversions.h"
24
26 KoSimpleColorSpace<KoBgrU16Traits>(colorSpaceId(),
27 i18n("RGB (16-bit integer/channel, unmanaged)"),
30{
31 addStandardDitherOps<KoBgrU16Traits>(this);
32}
33
37
38
40{
41 return QStringLiteral("RGBA16");
42}
43
48
49void KoRgbU16ColorSpace::fromQColor(const QColor& c, quint8 *dst) const
50{
51 QVector<float> channelValues;
52 channelValues << c.blueF() << c.greenF() << c.redF() << c.alphaF();
53 fromNormalisedChannelsValue(dst, channelValues);
54}
55
56void KoRgbU16ColorSpace::toQColor(const quint8 * src, QColor *c) const
57{
58 QVector<float> channelValues(4);
59 normalisedChannelsValue(src, channelValues);
60 c->setRgbF(channelValues[2], channelValues[1], channelValues[0], channelValues[3]);
61}
62void KoRgbU16ColorSpace::toHSY(const QVector<double> &channelValues, qreal *hue, qreal *sat, qreal *luma) const
63{
64
65 RGBToHSY(channelValues[0],channelValues[1],channelValues[2], hue, sat, luma);
66}
67
68QVector <double> KoRgbU16ColorSpace::fromHSY(qreal *hue, qreal *sat, qreal *luma) const
69{
70 QVector <double> channelValues(4);
71 HSYToRGB(*hue, *sat, *luma, &channelValues[0],&channelValues[1],&channelValues[2]);
72 channelValues[3]=1.0;
73 return channelValues;
74
75}
76
77void KoRgbU16ColorSpace::toYUV(const QVector<double> &channelValues, qreal *y, qreal *u, qreal *v) const
78{
79 RGBToYUV(channelValues[0],channelValues[1],channelValues[2], y, u, v);
80}
81
82QVector <double> KoRgbU16ColorSpace::fromYUV(qreal *y, qreal *u, qreal *v) const
83{
84 QVector <double> channelValues(4);
85 YUVToRGB(*y, *u, *v, &channelValues[0],&channelValues[1],&channelValues[2]);
86 channelValues[3]=1.0;
87 return channelValues;
88}
89
90void KoRgbU16ColorSpace::fillGrayBrushWithColorAndLightnessOverlay(quint8 *dst, const QRgb *brush, quint8 *brushColor, qint32 nPixels) const
91{
92 fillGrayBrushWithColorPreserveLightnessRGB<KoBgrU16Traits>(dst, brush, brushColor, 1.0, nPixels);
93}
94
95void KoRgbU16ColorSpace::fillGrayBrushWithColorAndLightnessWithStrength(quint8* dst, const QRgb* brush, quint8* brushColor, qreal strength, qint32 nPixels) const
96{
97 fillGrayBrushWithColorPreserveLightnessRGB<KoBgrU16Traits>(dst, brush, brushColor, strength, nPixels);
98}
99
100void KoRgbU16ColorSpace::modulateLightnessByGrayBrush(quint8 *dst, const QRgb *brush, qreal strength, qint32 nPixels) const
101{
102 modulateLightnessByGrayBrushRGB<KoBgrU16Traits>(dst, brush, strength, nPixels);
103}
qreal v
qreal u
void HSYToRGB(const qreal h, const qreal s, const qreal y, qreal *red, qreal *green, qreal *blue, qreal R, qreal G, qreal B)
void RGBToYUV(const qreal r, const qreal g, const qreal b, qreal *y, qreal *u, qreal *v, qreal R, qreal G, qreal B)
void RGBToHSY(const qreal r, const qreal g, const qreal b, qreal *h, qreal *s, qreal *y, qreal R, qreal G, qreal B)
void YUVToRGB(const qreal y, const qreal u, const qreal v, qreal *r, qreal *g, qreal *b, qreal R, qreal G, qreal B)
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
void fromNormalisedChannelsValue(quint8 *pixel, const QVector< float > &values) const override
void normalisedChannelsValue(const quint8 *pixel, QVector< float > &channels) const override
QVector< double > fromYUV(qreal *y, qreal *u, qreal *v) const override
void modulateLightnessByGrayBrush(quint8 *dst, const QRgb *brush, qreal strength, qint32 nPixels) const override
static QString colorSpaceId()
void fillGrayBrushWithColorAndLightnessOverlay(quint8 *dst, const QRgb *brush, quint8 *brushColor, qint32 nPixels) const override
void toQColor(const quint8 *src, QColor *c) const override
void toHSY(const QVector< double > &channelValues, qreal *hue, qreal *sat, qreal *luma) const override
void fromQColor(const QColor &color, quint8 *dst) const override
void fillGrayBrushWithColorAndLightnessWithStrength(quint8 *dst, const QRgb *brush, quint8 *brushColor, qreal strength, qint32 nPixels) const override
virtual KoColorSpace * clone() const
void toYUV(const QVector< double > &channelValues, qreal *y, qreal *u, qreal *v) const override
QVector< double > fromHSY(qreal *hue, qreal *sat, qreal *luma) const override
unsigned int QRgb