16#include <klocalizedstring.h>
19#include <kpluginfactory.h>
67 const QRect& applyRect,
71 Q_ASSERT(!device.
isNull());
73 const int threshold = config->getInt(
"threshold");
98 config->setProperty(
"threshold", 128);
113 m_page.thresholdGradient->setThreshold(0.5);
114 m_page.intThreshold->setValue(128);
117 connect(
m_page.intThreshold, QOverload<int>::of(&QSpinBox::valueChanged),
120 KisSignalsBlocker blocker(m_page.thresholdGradient);
121 m_page.thresholdGradient->setThreshold(static_cast<qreal>(value) / 255.0);
128 KisSignalsBlocker blocker(m_page.intThreshold);
129 m_page.intThreshold->setValue(static_cast<int>(qRound(value * 255.0)));
138 m_page.histview->resize(288,100);
149 int wHeight =
m_page.histview->height();
150 int wHeightMinusOne = wHeight - 1;
151 int wWidth =
m_page.histview->width();
162 QPalette appPalette = QApplication::palette();
163 QPixmap pix(wWidth-100, wHeight);
165 pix.fill(QColor(appPalette.color(QPalette::Base)));
168 p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
170 double highest = (double)
m_histogram->calculations().getHighest();
171 qint32 bins =
m_histogram->producer()->numberOfBins();
175 double factor = (double)(wHeight - wHeight / 5.0) / highest;
176 for (
int i = 0; i < wWidth; i++) {
177 int binNo = qRound((
double)i / wWidth * (bins - 1));
179 p.drawLine(i, wHeightMinusOne, i, wHeightMinusOne - (
int)
m_histogram->getValue(binNo) * factor);
182 double factor = (double)(wHeight - wHeight / 5.0) / (double)log(highest);
183 for (
int i = 0; i < wWidth; i++) {
184 int binNo = qRound((
double)i / wWidth * (bins - 1)) ;
186 p.drawLine(i, wHeightMinusOne, i, wHeightMinusOne - log((
double)
m_histogram->getValue(binNo)) * factor);
190 m_page.histview->setPixmap(pix);
195 m_page.intThreshold->setMaximum(limit - 1);
201 config->setProperty(
"threshold",
m_page.intThreshold->value());
208 if (config->getProperty(
"threshold",
value)) {
211 m_page.thresholdGradient->setThreshold(
static_cast<qreal
>(
value.toUInt()) / 255.0);
217#include "threshold.moc"
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void add(KisFilterSP item)
static KisFilterRegistry * instance()
KisConfigWidget * createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, bool useForMasks) const override
KisFilterConfigurationSP defaultConfiguration(KisResourcesInterfaceSP resourcesInterface) const override
void processImpl(KisPaintDeviceSP device, const QRect &applyRect, const KisFilterConfigurationSP config, KoUpdater *progressUpdater) const override
void setSupportsLevelOfDetail(bool value)
static KisResourcesInterfaceSP instance()
QRect exactBounds() const
const KoColorSpace * colorSpace() const
ALWAYS_INLINE quint8 * rawData()
ALWAYS_INLINE const quint8 * oldRawData() const
void thresholdChanged(qreal newThreshold)
Signal emitted when the threshold value changes.
virtual quint8 intensity8(const quint8 *src) const =0
virtual quint32 pixelSize() const =0
virtual quint8 opacityU8(const quint8 *pixel) const =0
void setOpacity(quint8 alpha)
~KritaThreshold() override
KritaThreshold(QObject *parent, const QVariantList &)
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL
const KoID FiltersCategoryAdjustId("adjust_filters", ki18nc("The category of color adjustment filters, like levels. Verb.", "Adjust"))
void setSupportsThreading(bool v)
void setShowConfigurationWidget(bool v)
virtual KisFilterConfigurationSP factoryConfiguration(KisResourcesInterfaceSP resourcesInterface) const
void setSupportsAdjustmentLayers(bool v)
void setSupportsPainting(bool v)
void setColorSpaceIndependence(ColorSpaceIndependence v)