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

Functions

template<typename... Args>
auto writeInterleavedLayer (QSysInfo::Endian endian, Args &&...args)
 
template<int endValue0, int endValue1, typename... Args>
auto writeInterleavedWithAlpha (bool hasAlpha, Args &&...args)
 
template<int endValue0, int endValue1, int channels>
void writeLayerImpl (const int width, const int height, uint8_t *ptr, const int stride, KisHLineConstIteratorSP it)
 

Function Documentation

◆ writeInterleavedLayer()

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

Definition at line 222 of file kis_heif_export_tools.h.

223{
224 if (endian == QSysInfo::LittleEndian) {
225 return writeInterleavedWithAlpha<1, 0>(std::forward<Args>(args)...);
226 } else {
227 return writeInterleavedWithAlpha<0, 1>(std::forward<Args>(args)...);
228 }
229}

◆ writeInterleavedWithAlpha()

template<int endValue0, int endValue1, typename... Args>
auto HDRInt::writeInterleavedWithAlpha ( bool hasAlpha,
Args &&... args )
inline

Definition at line 210 of file kis_heif_export_tools.h.

211{
212 if (hasAlpha) {
213 return HDRInt::writeLayerImpl<endValue0, endValue1, 4>(
214 std::forward<Args>(args)...);
215 } else {
216 return HDRInt::writeLayerImpl<endValue0, endValue1, 3>(
217 std::forward<Args>(args)...);
218 }
219}

◆ writeLayerImpl()

template<int endValue0, int endValue1, int channels>
void HDRInt::writeLayerImpl ( const int width,
const int height,
uint8_t * ptr,
const int stride,
KisHLineConstIteratorSP it )
inline

Definition at line 171 of file kis_heif_export_tools.h.

176{
177 std::array<KoBgrU16Traits::channels_type, channels> pixelValues{};
178
179 for (int y = 0; y < height; y++) {
180 for (int x = 0; x < width; x++) {
181 const quint8 *data = it->rawDataConst();
182 pixelValues[0] = KoBgrU16Traits::red(data);
183 pixelValues[1] = KoBgrU16Traits::green(data);
184 pixelValues[2] = KoBgrU16Traits::blue(data);
185 if (channels == 4) {
186 pixelValues[3] = static_cast<KoBgrU16Traits::channels_type>(
188 }
189
190 for (int ch = 0; ch < channels; ch++) {
191 uint16_t v = qBound<uint16_t>(
192 0,
193 static_cast<uint16_t>(float(pixelValues[ch])
195 max12bit);
196 ptr[2 * (x * channels) + y * stride + endValue0 + (ch * 2)] =
197 static_cast<uint8_t>(v >> 8);
198 ptr[2 * (x * channels) + y * stride + endValue1 + (ch * 2)] =
199 static_cast<uint8_t>(v & 0xFF);
200 }
201
202 it->nextPixel();
203 }
204
205 it->nextRow();
206 }
207}
qreal v
static constexpr float max16bit
static constexpr uint16_t max12bit
static constexpr float multiplier16bit
virtual const quint8 * rawDataConst() const =0
virtual bool nextPixel()=0
virtual void nextRow()=0
static channels_type blue(const quint8 *data)
static channels_type green(const quint8 *data)
static channels_type red(const quint8 *data)
_channels_type_ channels_type
the type of the value of the channels of this color space
static qreal opacityF(const quint8 *U8_pixel)

References KoBgrTraits< quint16 >::blue(), KoBgrTraits< quint16 >::green(), max12bit, max16bit, multiplier16bit, KisBaseConstIteratorNG::nextPixel(), KisHLineConstIteratorNG::nextRow(), KoColorSpaceTrait< _channels_type_, _channels_nb_, _alpha_pos_ >::opacityF(), KisBaseConstAccessor::rawDataConst(), KoBgrTraits< quint16 >::red(), and v.