13#include <KoColorModelStandardIds.h>
15#include <KoColorSpaceRegistry.h>
16#include <KoColorSpace.h>
17#include <kis_sequential_iterator.h>
24struct Channel::Private {
28 KoChannelInfo *channel {0};
32Channel::Channel(KisNodeSP node, KoChannelInfo *channel,
QObject *parent)
46bool Channel::operator==(
const Channel &other)
const
48 return (d->node == other.d->node
49 && d->channel == other.d->channel);
52bool Channel::operator!=(
const Channel &other)
const
54 return !(operator==(other));
60 if (!d->node || !d->channel)
return false;
61 if (!d->node->inherits(
"KisLayer"))
return false;
65 for (uint i = 0; i < channelInfo.
size(); ++i) {
66 if (channelInfo[i] == d->channel) {
68 const QBitArray& flags = layer->channelFlags();
78 if (!d->node || !d->channel)
return;
79 if (!d->node->inherits(
"KisLayer"))
return;
89 for (uint i = 0; i < channelInfo.
size(); ++i) {
90 if (channelInfo[i] == d->channel) {
92 layer->setChannelFlags(flags);
101 return d->channel->name();
106 return d->channel->pos();
111 return d->channel->size();
116 if (!d->node || !d->channel)
return QRect();
118 QRect rect = d->node->exactBounds();
120 KisPaintDeviceSP dev;
121 if (d->node->colorSpace()->colorDepthId() == Integer8BitsColorDepthID) {
122 dev =
new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8());
124 else if (d->node->colorSpace()->colorDepthId() == Integer16BitsColorDepthID) {
125 dev =
new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha16());
128 else if (d->node->colorSpace()->colorDepthId() == Float16BitsColorDepthID) {
129 dev =
new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha16f());
132 else if (d->node->colorSpace()->colorDepthId() == Float32BitsColorDepthID) {
133 dev =
new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha32f());
136 KisSequentialConstIterator srcIt(d->node->projection(), rect);
137 KisSequentialIterator dstIt(dev, rect);
139 while(srcIt.nextPixel() && dstIt.nextPixel()) {
140 const quint8 *srcPtr = srcIt.rawDataConst();
141 memcpy(dstIt.rawData(), srcPtr + d->channel->pos(), d->channel->size());
146 return dev->exactBounds();
156 if (!d->node || !d->channel)
return ba;
159 KisSequentialConstIterator srcIt(d->node->projection(), rect);
161 if (d->node->colorSpace()->colorDepthId() == Integer8BitsColorDepthID) {
162 while(srcIt.nextPixel()) {
164 memcpy(&v, srcIt.rawDataConst() + d->channel->pos(),
sizeof(v));
168 else if (d->node->colorSpace()->colorDepthId() == Integer16BitsColorDepthID) {
169 while(srcIt.nextPixel()) {
171 memcpy(&v, srcIt.rawDataConst() + d->channel->pos(),
sizeof(v));
176 else if (d->node->colorSpace()->colorDepthId() == Float16BitsColorDepthID) {
177 while(srcIt.nextPixel()) {
179 memcpy(&v, srcIt.rawDataConst() + d->channel->pos(),
sizeof(v));
184 else if (d->node->colorSpace()->colorDepthId() == Float32BitsColorDepthID) {
185 while(srcIt.nextPixel()) {
187 memcpy(&v, srcIt.rawDataConst() + d->channel->pos(),
sizeof(v));
198 if (!d->node || !d->channel || d->node->paintDevice() == 0)
return;
201 KisSequentialIterator dstIt(d->node->paintDevice(), rect);
203 if (d->node->colorSpace()->colorDepthId() == Integer8BitsColorDepthID) {
204 while (dstIt.nextPixel()) {
207 memcpy(dstIt.rawData() + d->channel->pos(), &v,
sizeof(v));
210 else if (d->node->colorSpace()->colorDepthId() == Integer16BitsColorDepthID) {
211 while (dstIt.nextPixel()) {
214 memcpy(dstIt.rawData() + d->channel->pos(), &v,
sizeof(v));
218 else if (d->node->colorSpace()->colorDepthId() == Float16BitsColorDepthID) {
219 while (dstIt.nextPixel()) {
223 memcpy(dstIt.rawData() + d->channel->pos(), &v,
sizeof(v));
228 else if (d->node->colorSpace()->colorDepthId() == Float32BitsColorDepthID) {
229 while (dstIt.nextPixel()) {
232 memcpy(dstIt.rawData() + d->channel->pos(), &v,
sizeof(v));
A Channel represents a single channel in a Node.
void setVisible(bool value)
setvisible set the visibility of the channel to the given value.
bool visible() const
visible checks whether this channel is visible in the node
void setPixelData(QByteArray value, const QRect &rect)
setPixelData writes the given data to the relevant channel in the Node.
QByteArray pixelData(const QRect &rect) const
Read the values of the channel into the a byte array for each pixel in the rect from the Node this ch...
bool fill(bool value, qsizetype size)
bool isEmpty() const const
bool testBit(qsizetype i) const const
qsizetype size() const const
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:00 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.