70{
72
73 if (dlg.exec() == QDialog::Accepted) {
74
76 dlg.hide();
77
79 if (!image) return;
80
82 if (!node) return;
83
84
85 if (node->inherits("KisColorizeMask")) {
87 node = convertedNode.get();
88 }
89
90 if (!node) return;
91
92 KisImageBarrierLock lock(image);
93
95 if (!projection) return;
96
98
100 QRect rc = image->
bounds();
101
103
104 KisCursorOverrideLock cursorLock(Qt::WaitCursor);
105
107 if( modeToLayer){
108 updater =
viewManager()->createUnthreadedUpdater(i18n(
"Split into Layers"));
109 }
110 else {
111 updater =
viewManager()->createUnthreadedUpdater(i18n(
"Split into Masks"));
112 }
113
114 updater->setProgress(0);
115
117
118 for (int row = rc.y(); row < rc.height(); ++row) {
119
120 for (int col = rc.x(); col < rc.width(); ++col) {
121
123
126
128 continue;
129 }
130
133 }
134
135 bool found = false;
136 Q_FOREACH (
const Layer &l, colorMap) {
137 if (fuzziness == 0) {
138
139 found = (l.
color == c);
140 }
141 else {
143 found = (match <= fuzziness);
144 }
145 if (found) {
149 const_cast<Layer*
>(&l)->pixelsWritten++;
150 break;
151 }
152 }
153
154 if (!found) {
157 name = dlg.
palette()->getClosestSwatchInfo(c).swatch.name();
158 }
159
160 if (
name.toLower() ==
"untitled" ||
name.toLower() ==
"none" ||
name.toLower() ==
"") {
162 }
170 colorMap << l;
171 }
172 }
173
174 if (updater->interrupted()) {
175 return;
176 }
177
178 updater->setProgress((row - rc.y()) * 100 / rc.height() - rc.y());
179 }
180
181 updater->setProgress(100);
182
183 dbgKrita <<
"Created" << colorMap.size() <<
"layers";
184
185
186
187
189 std::sort(colorMap.begin(), colorMap.end());
190 }
191
195
196 if(modeToLayer){
198 if (!baseGroup) {
199
201 }
202
205 }
206
209 adapter.addNode(grp, baseGroup, 1);
210 baseGroup = grp;
211 }
212
213 Q_FOREACH (
const Layer &l, colorMap) {
217 adapter.addNode(grp, baseGroup, 1);
218 }
220 adapter.addNode(paintLayer, grp, 0);
222 }
223 }
224 else{
226 Q_FOREACH (
const Layer &l, colorMap) {
229
232 adapter.addNode(mask, baseGroup,0);
234 }
235 }
236
238 }
239}
const quint8 OPACITY_TRANSPARENT_U8
const quint8 OPACITY_OPAQUE_U8
KoColorSetSP palette() const
bool disregardOpacity() const
bool createSeparateGroups() const
bool hideOriginal() const
bool createBaseGroup() const
QPointer< KisViewManager > viewManager() const
virtual quint8 * rawData()=0
virtual const quint8 * rawDataConst() const =0
KisUndoAdapter * undoAdapter() const
QRect bounds() const override
KisRandomConstAccessorSP createRandomConstAccessorNG() const
const KoColorSpace * colorSpace() const
KisRandomAccessorSP createRandomAccessorNG()
static KisPaintDeviceSP convertToAlphaAsPureAlpha(KisPaintDeviceSP src)
virtual void moveTo(qint32 x, qint32 y)=0
virtual quint32 pixelSize() const =0
virtual quint8 difference(const quint8 *src1, const quint8 *src2) const =0
static QString toQString(const KoColor &color)
toQString create a user-visible string of the channel names and the channel values
KUndo2MagicString kundo2_i18n(const char *text)
QAction * undo(const QObject *recvr, const char *slot, QObject *parent)
const char * name(StandardAction id)
std::future< KisNodeSP > convertToPaintLayer(KisImageSP image, KisNodeSP src)
virtual KisPaintDeviceSP projection() const =0
virtual void setVisible(bool visible, bool loading=false)
void setName(const QString &name)
void initSelection(KisSelectionSP copyFrom, KisLayerSP parentLayer)
initSelection initializes the selection for the mask from the given selection's projection.
void setAlphaLocked(bool lock)
void setActive(bool active)
KisRandomAccessorSP accessor