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

Classes

struct  JxlOutputProcessor
 

Functions

template<typename... Args>
QByteArray writeCMYKLayer (const KoID &id, Args &&...args)
 
template<typename CSTrait >
QByteArray writeCMYKPixels (bool isTrichromatic, int chPos, const int width, const int height, KisHLineConstIteratorSP it)
 

Function Documentation

◆ writeCMYKLayer()

template<typename... Args>
QByteArray JXLExpTool::writeCMYKLayer ( const KoID & id,
Args &&... args )
inline

Definition at line 65 of file kis_jpegxl_export_tools.h.

66{
67 if (id == Integer8BitsColorDepthID) {
68 return writeCMYKPixels<KoCmykU8Traits>(std::forward<Args>(args)...);
69 } else if (id == Integer16BitsColorDepthID) {
70 return writeCMYKPixels<KoCmykU16Traits>(std::forward<Args>(args)...);
71#ifdef HAVE_OPENEXR
72 } else if (id == Float16BitsColorDepthID) {
73 return writeCMYKPixels<KoCmykF16Traits>(std::forward<Args>(args)...);
74#endif
75 } else if (id == Float32BitsColorDepthID) {
76 return writeCMYKPixels<KoCmykF32Traits>(std::forward<Args>(args)...);
77 } else {
78 KIS_ASSERT_X(false, "JPEGXLExport::writeLayer", "unsupported bit depth!");
79 return QByteArray();
80 }
81}
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
#define KIS_ASSERT_X(cond, where, what)
Definition kis_assert.h:40

References Float16BitsColorDepthID, Float32BitsColorDepthID, Integer16BitsColorDepthID, Integer8BitsColorDepthID, and KIS_ASSERT_X.

◆ writeCMYKPixels()

template<typename CSTrait >
QByteArray JXLExpTool::writeCMYKPixels ( bool isTrichromatic,
int chPos,
const int width,
const int height,
KisHLineConstIteratorSP it )
inline

Definition at line 30 of file kis_jpegxl_export_tools.h.

31{
32 const int channels = isTrichromatic ? 3 : 1;
33 const int chSize = static_cast<int>(CSTrait::pixelSize / 5);
34 const int pxSize = chSize * channels;
35 const int chOffset = chPos * chSize;
36
37 QByteArray res;
38 res.resize(width * height * pxSize);
39
40 quint8 *ptr = reinterpret_cast<quint8 *>(res.data());
41
42 for (int y = 0; y < height; y++) {
43 for (int x = 0; x < width; x++) {
44 const quint8 *src = it->rawDataConst();
45
46 if (isTrichromatic) {
47 for (int i = 0; i < channels; i++) {
48 std::memcpy(ptr, src + (i * chSize), chSize);
49 ptr += chSize;
50 }
51 } else {
52 std::memcpy(ptr, src + chOffset, chSize);
53 ptr += chSize;
54 }
55
56 it->nextPixel();
57 }
58
59 it->nextRow();
60 }
61 return res;
62}
virtual const quint8 * rawDataConst() const =0
virtual bool nextPixel()=0
virtual void nextRow()=0

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