Changeset View
Changeset View
Standalone View
Standalone View
plugins/tools/basictools/kis_tool_colorpicker.cc
Context not available. | |||||
57 | #include "kis_wrapped_rect.h" | 57 | #include "kis_wrapped_rect.h" | ||
---|---|---|---|---|---|
58 | #include "kis_tool_utils.h" | 58 | #include "kis_tool_utils.h" | ||
59 | 59 | | |||
60 | | ||||
61 | namespace | 60 | namespace | ||
62 | { | 61 | { | ||
63 | // The location of the sample all visible layers in the combobox | 62 | // The location of the sample all visible layers in the combobox | ||
Context not available. | |||||
113 | m_colorPickerDelayTimer.start(100); | 112 | m_colorPickerDelayTimer.start(100); | ||
114 | } | 113 | } | ||
115 | 114 | | |||
116 | | ||||
117 | QScopedPointer<boost::lock_guard<KisImage> > imageLocker; | 115 | QScopedPointer<boost::lock_guard<KisImage> > imageLocker; | ||
118 | 116 | | |||
119 | KisPaintDeviceSP dev; | 117 | KisPaintDeviceSP dev; | ||
Context not available. | |||||
126 | imageLocker.reset(new boost::lock_guard<KisImage>(*currentImage())); | 124 | imageLocker.reset(new boost::lock_guard<KisImage>(*currentImage())); | ||
127 | dev = currentImage()->projection(); | 125 | dev = currentImage()->projection(); | ||
128 | } | 126 | } | ||
129 | 127 | | |||
128 | // Color sampling radius. | ||||
130 | if (m_config->radius == 1) { | 129 | if (m_config->radius == 1) { | ||
131 | QPoint realPos = pos.toPoint(); | 130 | QPoint realPos = pos.toPoint(); | ||
132 | if (currentImage()->wrapAroundModePermitted()) { | 131 | if (currentImage()->wrapAroundModePermitted()) { | ||
Context not available. | |||||
136 | dev->pixel(realPos.x(), realPos.y(), &m_pickedColor); | 135 | dev->pixel(realPos.x(), realPos.y(), &m_pickedColor); | ||
137 | } | 136 | } | ||
138 | else { | 137 | else { | ||
139 | | ||||
140 | const KoColorSpace* cs = dev->colorSpace(); | 138 | const KoColorSpace* cs = dev->colorSpace(); | ||
141 | int pixelSize = cs->pixelSize(); | 139 | int pixelSize = cs->pixelSize(); | ||
142 | 140 | | |||
Context not available. | |||||
161 | } | 159 | } | ||
162 | } | 160 | } | ||
163 | 161 | | |||
164 | | ||||
165 | const quint8** cpixels = const_cast<const quint8**>(pixels.constData()); | 162 | const quint8** cpixels = const_cast<const quint8**>(pixels.constData()); | ||
166 | cs->mixColorsOp()->mixColors(cpixels, pixels.size(), dstColor); | 163 | cs->mixColorsOp()->mixColors(cpixels, pixels.size(), dstColor); | ||
167 | 164 | | |||
Context not available. | |||||
170 | delete[] dstColor; | 167 | delete[] dstColor; | ||
171 | } | 168 | } | ||
172 | 169 | | |||
170 | // Color blending. | ||||
171 | if(m_config->blend < 255){ | ||||
172 | KoColor previousColor = canvas()->resourceManager()->foregroundColor(); | ||||
173 | | ||||
174 | const quint8* colors[2]; | ||||
175 | colors[0] = previousColor.data(); | ||||
176 | colors[1] = m_pickedColor.data(); | ||||
177 | qint16 weights[2]; | ||||
178 | weights[0] = 255-m_config->blend; | ||||
179 | weights[1] = m_config->blend; | ||||
180 | | ||||
181 | const KoMixColorsOp * mixOp = dev->colorSpace()->mixColorsOp(); | ||||
182 | mixOp->mixColors(colors, weights, 2, m_pickedColor.data()); | ||||
183 | } | ||||
184 | | ||||
173 | m_pickedColor.convertTo(dev->compositionSourceColorSpace()); | 185 | m_pickedColor.convertTo(dev->compositionSourceColorSpace()); | ||
174 | 186 | | |||
175 | if (m_config->updateColor && | 187 | if (m_config->updateColor && | ||
Context not available. | |||||
204 | } | 216 | } | ||
205 | 217 | | |||
206 | QPoint pos = convertToImagePixelCoordFloored(event); | 218 | QPoint pos = convertToImagePixelCoordFloored(event); | ||
207 | // the color picking has to start in the visible part of the layer | 219 | // Color picking has to start in the visible part of the layer | ||
208 | if (!currentImage()->bounds().contains(pos) && | 220 | if (!currentImage()->bounds().contains(pos) && | ||
209 | !currentImage()->wrapAroundModePermitted()) { | 221 | !currentImage()->wrapAroundModePermitted()) { | ||
210 | event->ignore(); | 222 | event->ignore(); | ||
Context not available. | |||||
305 | SLOT(slotSetAddPalette(bool))); | 317 | SLOT(slotSetAddPalette(bool))); | ||
306 | connect(m_optionsWidget->radius, SIGNAL(valueChanged(int)), | 318 | connect(m_optionsWidget->radius, SIGNAL(valueChanged(int)), | ||
307 | SLOT(slotChangeRadius(int))); | 319 | SLOT(slotChangeRadius(int))); | ||
320 | connect(m_optionsWidget->blend, SIGNAL(valueChanged(int)), | ||||
321 | SLOT(slotChangeBlend(int))); | ||||
308 | connect(m_optionsWidget->cmbSources, SIGNAL(currentIndexChanged(int)), | 322 | connect(m_optionsWidget->cmbSources, SIGNAL(currentIndexChanged(int)), | ||
309 | SLOT(slotSetColorSource(int))); | 323 | SLOT(slotSetColorSource(int))); | ||
310 | 324 | | |||
Context not available. | |||||
335 | m_optionsWidget->cmbSources->setCurrentIndex(SAMPLE_MERGED + !m_config->sampleMerged); | 349 | m_optionsWidget->cmbSources->setCurrentIndex(SAMPLE_MERGED + !m_config->sampleMerged); | ||
336 | m_optionsWidget->cbPalette->setChecked(m_config->addPalette); | 350 | m_optionsWidget->cbPalette->setChecked(m_config->addPalette); | ||
337 | m_optionsWidget->radius->setValue(m_config->radius); | 351 | m_optionsWidget->radius->setValue(m_config->radius); | ||
352 | m_optionsWidget->blend->setValue(m_config->blend); | ||||
338 | } | 353 | } | ||
339 | 354 | | |||
340 | void KisToolColorPicker::setToForeground(bool newValue) | 355 | void KisToolColorPicker::setToForeground(bool newValue) | ||
Context not available. | |||||
370 | m_config->radius = value; | 385 | m_config->radius = value; | ||
371 | } | 386 | } | ||
372 | 387 | | |||
388 | void KisToolColorPicker::slotChangeBlend(int value) | ||||
389 | { | ||||
390 | m_config->blend = value; | ||||
391 | } | ||||
392 | | ||||
373 | void KisToolColorPicker::slotSetColorSource(int value) | 393 | void KisToolColorPicker::slotSetColorSource(int value) | ||
374 | { | 394 | { | ||
375 | m_config->sampleMerged = value == SAMPLE_MERGED; | 395 | m_config->sampleMerged = value == SAMPLE_MERGED; | ||
Context not available. | |||||
383 | m_palettes.append(palette); | 403 | m_palettes.append(palette); | ||
384 | } | 404 | } | ||
385 | } | 405 | } | ||
386 | | ||||
Context not available. |