Krita

Channel.h
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#ifndef LIBKIS_CHANNEL_H
7#define LIBKIS_CHANNEL_H
8
9#include <QObject>
10
11#include "kritalibkis_export.h"
12#include "libkis.h"
13
14#include <KoChannelInfo.h>
15#include <kis_node.h>
16
17/**
18 * A Channel represents a single channel in a Node. Krita does not
19 * use channels to store local selections: these are strictly the
20 * color and alpha channels.
21 */
22class KRITALIBKIS_EXPORT Channel : public QObject
23{
24 Q_OBJECT
25
26public:
27 explicit Channel(KisNodeSP node, KoChannelInfo *channel, QObject *parent = 0);
28 ~Channel() override;
29
30 bool operator==(const Channel &other) const;
31 bool operator!=(const Channel &other) const;
32
33 /**
34 * @brief visible checks whether this channel is visible in the node
35 * @return the status of this channel
36 */
37 bool visible() const;
38
39 /**
40 * @brief setvisible set the visibility of the channel to the given value.
41 */
42 void setVisible(bool value);
43
44 /**
45 * @return the name of the channel
46 */
47 QString name() const;
48
49 /**
50 * @returns the position of the first byte of the channel in the pixel
51 */
52 int position() const;
53
54 /**
55 * @return the number of bytes this channel takes
56 */
57 int channelSize() const;
58
59 /**
60 * @return the exact bounds of the channel. This can be smaller than the bounds of the Node this channel is part of.
61 */
62 QRect bounds() const;
63
64 /**
65 * Read the values of the channel into the a byte array for each pixel in the rect from the Node this channel is part of, and returns it.
66 *
67 * Note that if Krita is built with OpenEXR and the Node has the 16 bits floating point channel depth type, Krita returns
68 * 32 bits float for every channel; the libkis scripting API does not support half.
69 */
70 QByteArray pixelData(const QRect &rect) const;
71
72 /**
73 * @brief setPixelData writes the given data to the relevant channel in the Node. This is only possible for Nodes
74 * that have a paintDevice, so nothing will happen when trying to write to e.g. a group layer.
75 *
76 * Note that if Krita is built with OpenEXR and the Node has the 16 bits floating point channel depth type, Krita expects
77 * to be given a 4 byte, 32 bits float for every channel; the libkis scripting API does not support half.
78 *
79 * @param value a byte array with exactly enough bytes.
80 * @param rect the rectangle to write the bytes into
81 */
82 void setPixelData(QByteArray value, const QRect &rect);
83
84private:
85
86 struct Private;
87 Private *const d;
88
89};
90
91#endif // LIBKIS_CHANNEL_H
A Channel represents a single channel in a Node.
Definition Channel.h:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.