Krita Source Code Documentation
Loading...
Searching...
No Matches
Gray Namespace Reference

Functions

template<int endValue0, int endValue1, int luma, bool hasAlpha>
void applyAlpha (const quint8 *data, uint8_t *ptrA, const int strideA, int x, int y)
 
template<int luma, bool hasAlpha>
void applyAlpha (KisHLineIteratorSP it, const uint8_t *imgA, int strideA, int x, int y)
 
template<int endValue0, int endValue1, int luma>
void applyValue (const quint8 *data, uint8_t *ptrG, int strideG, int x, int y)
 
template<int luma>
void applyValue (KisHLineIteratorSP it, const uint8_t *imgG, int strideG, int x, int y)
 
template<int luma, bool hasAlpha>
void readLayer (const int width, const int height, KisHLineIteratorSP it, const uint8_t *imgG, const uint8_t *imgA, const int strideG, const int strideA)
 
template<typename... Args>
auto readPlanarLayer (const int luma, Args &&...args)
 
template<int luma, typename... Args>
auto readPlanarWithLuma (bool hasAlpha, Args &&...args)
 
template<int endValue0, int endValue1, int luma, bool hasAlpha>
void writeLayer (const int width, const int height, uint8_t *ptrG, const int strideG, uint8_t *ptrA, const int strideA, KisHLineConstIteratorSP it)
 
template<typename... Args>
auto writePlanarLayer (QSysInfo::Endian endian, Args &&...args)
 
template<int endValue0, int endValue1, int luma, typename... Args>
auto writePlanarWithAlpha (bool hasAlpha, Args &&...args)
 
template<int endValue0, int endValue1, typename... Args>
auto writePlanarWithLuma (const int luma, Args &&...args)
 

Detailed Description

SPDX-FileCopyrightText: 2020-2021 Wolthera van Hövell tot Westerflier griff.nosp@m.inva.nosp@m.lley@.nosp@m.gmai.nosp@m.l.com SPDX-FileCopyrightText: 2021 L. E. Segovia amy@a.nosp@m.mysp.nosp@m.ark.m.nosp@m.e

SPDX-License-Identifier: GPL-2.0-or-later

Function Documentation

◆ applyAlpha() [1/2]

template<int endValue0, int endValue1, int luma, bool hasAlpha>
void Gray::applyAlpha ( const quint8 * data,
uint8_t * ptrA,
const int strideA,
int x,
int y )
inline

Definition at line 42 of file kis_heif_export_tools.h.

43{
44 if (hasAlpha) {
45 if (luma == 8) {
46 ptrA[y * strideA + x] = KoGrayU8Traits::opacityU8(data);
47 } else {
48 uint16_t vA = qBound<uint16_t>(
49 0,
50 static_cast<uint16_t>(KoGrayU16Traits::opacityF(data)
51 * max12bit),
52 max12bit);
53 ptrA[(x * 2) + y * strideA + endValue0] = (uint8_t)(vA >> 8);
54 ptrA[(x * 2) + y * strideA + endValue1] = (uint8_t)(vA & 0xFF);
55 }
56 }
57}
static constexpr uint16_t max12bit
static quint8 opacityU8(const quint8 *U8_pixel)
static qreal opacityF(const quint8 *U8_pixel)

References max12bit, KoColorSpaceTrait< _channels_type_, _channels_nb_, _alpha_pos_ >::opacityF(), and KoColorSpaceTrait< _channels_type_, _channels_nb_, _alpha_pos_ >::opacityU8().

◆ applyAlpha() [2/2]

template<int luma, bool hasAlpha>
void Gray::applyAlpha ( KisHLineIteratorSP it,
const uint8_t * imgA,
int strideA,
int x,
int y )
inline

Definition at line 52 of file kis_heif_import_tools.h.

57{
58 if (hasAlpha) {
59 if (luma == 8) {
60 KoGrayU8Traits::setOpacity(it->rawData(),
61 quint8(imgA[y * strideA + x]),
62 1);
63 } else {
64 uint16_t source =
65 KoGrayU16Traits::nativeArray(imgA)[y * (strideA / 2) + x];
66 if (luma == 10) {
68 it->rawData(),
69 static_cast<qreal>(float(0x0fff & (source))
71 1);
72 } else if (luma == 12) {
74 it->rawData(),
75 static_cast<qreal>(float(0x0fff & (source))
77 1);
78 } else {
80 it->rawData(),
81 static_cast<qreal>(float(source) * multiplier16bit),
82 1);
83 }
84 }
85 } else {
86 if (luma == 8) {
88 } else {
90 }
91 }
92}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
const quint8 OPACITY_OPAQUE_U8
static constexpr float multiplier12bit
static constexpr float multiplier10bit
static constexpr float multiplier16bit
static const channels_type * nativeArray(const quint8 *a)
static void setOpacity(quint8 *pixels, quint8 alpha, qint32 nPixels)

References multiplier10bit, multiplier12bit, multiplier16bit, KoColorSpaceTrait< _channels_type_, _channels_nb_, _alpha_pos_ >::nativeArray(), OPACITY_OPAQUE_U8, KoColorSpaceTrait< _channels_type_, _channels_nb_, _alpha_pos_ >::setOpacity(), and source().

◆ applyValue() [1/2]

template<int endValue0, int endValue1, int luma>
void Gray::applyValue ( const quint8 * data,
uint8_t * ptrG,
int strideG,
int x,
int y )
inline

Definition at line 24 of file kis_heif_export_tools.h.

25{
26 if (luma == 8) {
27 ptrG[y * strideG + x] = KoGrayU8Traits::gray(data);
28 } else {
29 uint16_t v = qBound<uint16_t>(
30 0,
31 static_cast<uint16_t>(float(KoGrayU16Traits::gray(data))
33 max12bit);
34 ptrG[(x * 2) + y * strideG + endValue0] = static_cast<uint8_t>(v >> 8);
35 ptrG[(x * 2) + y * strideG + endValue1] =
36 static_cast<uint8_t>(v & 0xFF);
37 }
38}
qreal v
static channels_type gray(const quint8 *data)

References KoGrayTraits< quint16 >::gray(), KoGrayTraits< quint8 >::gray(), max12bit, multiplier16bit, and v.

◆ applyValue() [2/2]

template<int luma>
void Gray::applyValue ( KisHLineIteratorSP it,
const uint8_t * imgG,
int strideG,
int x,
int y )
inline

Definition at line 21 of file kis_heif_import_tools.h.

26{
27 if (luma == 8) {
28 KoGrayU8Traits::setGray(it->rawData(), imgG[y * strideG + x]);
29 } else {
30 uint16_t source =
31 KoGrayU16Traits::nativeArray(imgG)[y * (strideG / 2) + (x)];
32
33 if (luma == 10) {
35 it->rawData(),
36 static_cast<uint16_t>(float(0x03ffu & (source))
38 } else if (luma == 12) {
40 it->rawData(),
41 static_cast<uint16_t>(float(0x0fffu & (source))
43 } else {
45 it->rawData(),
46 static_cast<uint16_t>(float(source) * multiplier16bit));
47 }
48 }
49}
static constexpr float max16bit
static void setGray(quint8 *data, channels_type nv)
Set the gray component.

References max16bit, multiplier10bit, multiplier12bit, multiplier16bit, KoColorSpaceTrait< _channels_type_, _channels_nb_, _alpha_pos_ >::nativeArray(), KoGrayTraits< quint16 >::setGray(), KoGrayTraits< quint8 >::setGray(), and source().

◆ readLayer()

template<int luma, bool hasAlpha>
void Gray::readLayer ( const int width,
const int height,
KisHLineIteratorSP it,
const uint8_t * imgG,
const uint8_t * imgA,
const int strideG,
const int strideA )
inline

Definition at line 95 of file kis_heif_import_tools.h.

102{
103 for (int y = 0; y < height; y++) {
104 for (int x = 0; x < width; x++) {
105 applyValue<luma>(it, imgG, strideG, x, y);
106
107 applyAlpha<luma, hasAlpha>(it, imgA, strideA, x, y);
108 it->nextPixel();
109 }
110
111 it->nextRow();
112 }
113}

◆ readPlanarLayer()

template<typename... Args>
auto Gray::readPlanarLayer ( const int luma,
Args &&... args )
inline

Definition at line 126 of file kis_heif_import_tools.h.

127{
128 if (luma == 8) {
129 return readPlanarWithLuma<8>(std::forward<Args>(args)...);
130 } else if (luma == 10) {
131 return readPlanarWithLuma<10>(std::forward<Args>(args)...);
132 } else if (luma == 12) {
133 return readPlanarWithLuma<12>(std::forward<Args>(args)...);
134 } else {
135 return readPlanarWithLuma<16>(std::forward<Args>(args)...);
136 }
137}

◆ readPlanarWithLuma()

template<int luma, typename... Args>
auto Gray::readPlanarWithLuma ( bool hasAlpha,
Args &&... args )
inline

Definition at line 116 of file kis_heif_import_tools.h.

117{
118 if (hasAlpha) {
119 return Gray::readLayer<luma, true>(std::forward<Args>(args)...);
120 } else {
121 return Gray::readLayer<luma, false>(std::forward<Args>(args)...);
122 }
123}

◆ writeLayer()

template<int endValue0, int endValue1, int luma, bool hasAlpha>
void Gray::writeLayer ( const int width,
const int height,
uint8_t * ptrG,
const int strideG,
uint8_t * ptrA,
const int strideA,
KisHLineConstIteratorSP it )
inline

Definition at line 60 of file kis_heif_export_tools.h.

67{
68 for (int y = 0; y < height; y++) {
69 for (int x = 0; x < width; x++) {
70 const uint8_t *data = it->rawDataConst();
71
72 applyValue<endValue0, endValue1, luma>(data, ptrG, strideG, x, y);
73
74 applyAlpha<endValue0, endValue1, luma, hasAlpha>(data,
75 ptrA,
76 strideA,
77 x,
78 y);
79
80 it->nextPixel();
81 }
82
83 it->nextRow();
84 }
85}
virtual const quint8 * rawDataConst() const =0
virtual bool nextPixel()=0
virtual void nextRow()=0

References KisBaseConstIteratorNG::nextPixel(), KisHLineConstIteratorNG::nextRow(), and KisBaseConstAccessor::rawDataConst().

◆ writePlanarLayer()

template<typename... Args>
auto Gray::writePlanarLayer ( QSysInfo::Endian endian,
Args &&... args )
inline

Definition at line 112 of file kis_heif_export_tools.h.

113{
114 if (endian == QSysInfo::LittleEndian) {
115 return Gray::writePlanarWithLuma<1, 0>(std::forward<Args>(args)...);
116 } else {
117 return Gray::writePlanarWithLuma<0, 1>(std::forward<Args>(args)...);
118 }
119}

◆ writePlanarWithAlpha()

template<int endValue0, int endValue1, int luma, typename... Args>
auto Gray::writePlanarWithAlpha ( bool hasAlpha,
Args &&... args )
inline

Definition at line 88 of file kis_heif_export_tools.h.

89{
90 if (hasAlpha) {
91 return Gray::writeLayer<endValue0, endValue1, luma, true>(
92 std::forward<Args>(args)...);
93 } else {
94 return Gray::writeLayer<endValue0, endValue1, luma, false>(
95 std::forward<Args>(args)...);
96 }
97}

◆ writePlanarWithLuma()

template<int endValue0, int endValue1, typename... Args>
auto Gray::writePlanarWithLuma ( const int luma,
Args &&... args )
inline

Definition at line 100 of file kis_heif_export_tools.h.

101{
102 if (luma == 8) {
103 return writePlanarWithAlpha<endValue0, endValue1, 8>(
104 std::forward<Args>(args)...);
105 } else {
106 return writePlanarWithAlpha<endValue0, endValue1, 12>(
107 std::forward<Args>(args)...);
108 }
109}