Changeset View
Changeset View
Standalone View
Standalone View
plugins/paintops/libpaintop/kis_pressure_sharpness_option.cpp
Context not available. | |||||
42 | void KisPressureSharpnessOption::readOptionSetting(const KisPropertiesConfigurationSP setting) | 42 | void KisPressureSharpnessOption::readOptionSetting(const KisPropertiesConfigurationSP setting) | ||
---|---|---|---|---|---|
43 | { | 43 | { | ||
44 | KisCurveOption::readOptionSetting(setting); | 44 | KisCurveOption::readOptionSetting(setting); | ||
45 | m_threshold = setting->getInt(SHARPNESS_THRESHOLD, 4); | 45 | m_threshold = quint32(setting->getInt(SHARPNESS_THRESHOLD)); | ||
46 | 46 | | |||
47 | // backward compatibility: test for a "sharpness factor" property | 47 | // backward compatibility: test for a "sharpness factor" property | ||
48 | // and use this value if it does exist | 48 | // and use this value if it does exist | ||
Context not available. | |||||
81 | } | 81 | } | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | void KisPressureSharpnessOption::applyThreshold(KisFixedPaintDeviceSP dab) | 84 | void KisPressureSharpnessOption::applyThreshold(KisFixedPaintDeviceSP dab, const KisPaintInformation & info) | ||
85 | { | 85 | { | ||
86 | if (!isChecked()) return; | 86 | if (!isChecked()) return; | ||
87 | const KoColorSpace * cs = dab->colorSpace(); | 87 | const KoColorSpace * cs = dab->colorSpace(); | ||
Context not available. | |||||
91 | quint8* dabPointer = dab->data(); | 91 | quint8* dabPointer = dab->data(); | ||
92 | QRect rc = dab->bounds(); | 92 | QRect rc = dab->bounds(); | ||
93 | 93 | | |||
94 | int pixelSize = dab->pixelSize(); | 94 | qreal threshold = computeSizeLikeValue(info); | ||
95 | | ||||
96 | quint32 pixelSize = dab->pixelSize(); | ||||
95 | int pixelCount = rc.width() * rc.height(); | 97 | int pixelCount = rc.width() * rc.height(); | ||
96 | 98 | | |||
99 | quint32 tolerance = quint32(OPACITY_OPAQUE_U8 - (threshold * OPACITY_OPAQUE_U8)); | ||||
100 | | ||||
97 | for (int i = 0; i < pixelCount; i++) { | 101 | for (int i = 0; i < pixelCount; i++) { | ||
98 | quint8 alpha = cs->opacityU8(dabPointer); | 102 | quint8 opacity = cs->opacityU8(dabPointer); | ||
99 | 103 | | |||
100 | if (alpha < (m_threshold * OPACITY_OPAQUE_U8) / 100) { | 104 | // Check what pixel goes sharp | ||
101 | cs->setOpacity(dabPointer, OPACITY_TRANSPARENT_U8, 1); | 105 | if (opacity > (tolerance) ) { | ||
102 | } | | |||
103 | else { | | |||
104 | cs->setOpacity(dabPointer, OPACITY_OPAQUE_U8, 1); | 106 | cs->setOpacity(dabPointer, OPACITY_OPAQUE_U8, 1); | ||
107 | } else { | ||||
108 | // keep original value if in soft range | ||||
109 | if (opacity <= (100 - m_threshold) * tolerance / 100) { | ||||
110 | cs->setOpacity(dabPointer, OPACITY_TRANSPARENT_U8, 1); | ||||
111 | } | ||||
105 | } | 112 | } | ||
106 | | ||||
107 | dabPointer += pixelSize; | 113 | dabPointer += pixelSize; | ||
108 | } | 114 | } | ||
109 | } | 115 | } | ||
Context not available. |