Krita Source Code Documentation
Loading...
Searching...
No Matches
KisFilterColorToAlpha Class Reference

#include <kis_color_to_alpha.h>

+ Inheritance diagram for KisFilterColorToAlpha:

Public Member Functions

KisConfigWidget * createConfigurationWidget (QWidget *parent, const KisPaintDeviceSP dev, bool useForMasks) const override
 
KisFilterConfigurationSP defaultConfiguration (KisResourcesInterfaceSP resourcesInterface) const override
 
 KisFilterColorToAlpha ()
 
void processImpl (KisPaintDeviceSP device, const QRect &rect, const KisFilterConfigurationSP config, KoUpdater *progressUpdater) const override
 
- Public Member Functions inherited from KisFilter
virtual QRect changedRect (const QRect &rect, const KisFilterConfigurationSP config, int lod) const
 
virtual bool configurationAllowedForMask (KisFilterConfigurationSP config) const
 
virtual void fixLoadedFilterConfigurationForMasks (KisFilterConfigurationSP config) const
 
 KisFilter (const KoID &id, const KoID &category, const QString &entry)
 
virtual QRect neededRect (const QRect &rect, const KisFilterConfigurationSP config, int lod) const
 
virtual bool needsTransparentPixels (const KisFilterConfigurationSP config, const KoColorSpace *cs) const
 
void process (const KisPaintDeviceSP src, KisPaintDeviceSP dst, KisSelectionSP selection, const QRect &applyRect, const KisFilterConfigurationSP config, KoUpdater *progressUpdater=0) const
 
void process (KisPaintDeviceSP device, const QRect &applyRect, const KisFilterConfigurationSP config, KoUpdater *progressUpdater=0) const
 
virtual bool supportsLevelOfDetail (const KisFilterConfigurationSP config, int lod) const
 
 ~KisFilter () override
 
- Public Member Functions inherited from KisBaseProcessor
KisBookmarkedConfigurationManager * bookmarkManager ()
 
const KisBookmarkedConfigurationManager * bookmarkManager () const
 
ColorSpaceIndependence colorSpaceIndependence () const
 
virtual KisFilterConfigurationSP factoryConfiguration (KisResourcesInterfaceSP resourcesInterface) const
 
QString id () const
 
 KisBaseProcessor (const KoID &id, const KoID &category, const QString &entry)
 
KoID menuCategory () const
 
QString menuEntry () const
 
QString name () const
 
 Private ()
 
QKeySequence shortcut () const
 
bool showConfigurationWidget ()
 If true, the filter wants to show a configuration widget.
 
bool supportsAdjustmentLayers () const
 This filter can be used in adjustment layers.
 
bool supportsPainting () const
 
bool supportsThreading () const
 
virtual ~KisBaseProcessor ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Static Public Member Functions

static KoID id ()
 

Additional Inherited Members

- Public Attributes inherited from KisBaseProcessor
KisBookmarkedConfigurationManager * bookmarkManager
 
KoID category
 
ColorSpaceIndependence colorSpaceIndependence
 
QString entry
 
KoID id
 
QKeySequence shortcut
 
bool showConfigurationWidget
 
bool supportsAdjustmentLayers
 
bool supportsPainting
 
bool supportsThreading
 
- Public Attributes inherited from Private
KisCanvas2 * canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Member Functions inherited from KisFilter
QString configEntryGroup () const
 
void setSupportsLevelOfDetail (bool value)
 
- Protected Member Functions inherited from KisBaseProcessor
void init (const QString &configEntryGroup)
 
void setColorSpaceIndependence (ColorSpaceIndependence v)
 
void setShortcut (const QKeySequence &shortcut)
 
void setShowConfigurationWidget (bool v)
 
void setSupportsAdjustmentLayers (bool v)
 
void setSupportsPainting (bool v)
 
void setSupportsThreading (bool v)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Detailed Description

Definition at line 14 of file kis_color_to_alpha.h.

Constructor & Destructor Documentation

◆ KisFilterColorToAlpha()

KisFilterColorToAlpha::KisFilterColorToAlpha ( )

Definition at line 29 of file kis_color_to_alpha.cpp.

30 : KisFilter(id(), FiltersCategoryColorId, i18n("&Color to Alpha..."))
31{
36}
@ FULLY_INDEPENDENT
void setSupportsLevelOfDetail(bool value)
KisFilter(const KoID &id, const KoID &category, const QString &entry)
Definition kis_filter.cc:22
const KoID FiltersCategoryColorId("color_filters", ki18nc("The category of color transfer filters, like color to alpha. Noun.", "Colors"))
void setSupportsAdjustmentLayers(bool v)
void setSupportsPainting(bool v)
void setColorSpaceIndependence(ColorSpaceIndependence v)

References FULLY_INDEPENDENT, KisBaseProcessor::setColorSpaceIndependence(), KisBaseProcessor::setSupportsAdjustmentLayers(), KisFilter::setSupportsLevelOfDetail(), and KisBaseProcessor::setSupportsPainting().

Member Function Documentation

◆ createConfigurationWidget()

KisConfigWidget * KisFilterColorToAlpha::createConfigurationWidget ( QWidget * parent,
const KisPaintDeviceSP dev,
bool useForMasks ) const
overridevirtual

Create the configuration widget for this processor.

Parameters
parentthe Qt owner widget of this widget
devthe paintdevice this filter will act on
useForMasksshown if the filer is going to be used in a mask. Some filters may provide limited options when applied as a mask (e.g. Gaussian Blur)

Reimplemented from KisBaseProcessor.

Definition at line 38 of file kis_color_to_alpha.cpp.

39{
40 return new KisWdgColorToAlpha(parent);
41}

◆ defaultConfiguration()

KisFilterConfigurationSP KisFilterColorToAlpha::defaultConfiguration ( KisResourcesInterfaceSP resourcesInterface) const
overridevirtual

Return the configuration set as the default by the user or the default configuration from the filter writer as returned by factoryConfiguration.

This configuration is used by default for the configuration widget and given to the process function if there is no configuration widget.

Returns
the default configuration of this widget

Reimplemented from KisBaseProcessor.

Definition at line 43 of file kis_color_to_alpha.cpp.

44{
45 KisFilterConfigurationSP config = factoryConfiguration(resourcesInterface);
46 config->setProperty("targetcolor", QColor(255, 255, 255));
47 config->setProperty("threshold", 100);
48 return config;
49}
virtual KisFilterConfigurationSP factoryConfiguration(KisResourcesInterfaceSP resourcesInterface) const

References KisBaseProcessor::factoryConfiguration().

◆ id()

static KoID KisFilterColorToAlpha::id ( )
inlinestatic

Definition at line 27 of file kis_color_to_alpha.h.

27 {
28 return KoID("colortoalpha", i18n("Color to Alpha"));
29 }
Definition KoID.h:30

◆ processImpl()

void KisFilterColorToAlpha::processImpl ( KisPaintDeviceSP device,
const QRect & applyRect,
const KisFilterConfigurationSP config,
KoUpdater * progressUpdater ) const
overridevirtual

Override this function with the implementation of your filter.

This is a low level function that expects all the conditions for the

Parameters
devicebe met. Use usual process() methods instead.
devicethe paint device to filter
applyRectthe rectangle where the filter is applied
configthe parameters of the filter
progressUpdaterto pass on the progress the filter is making

Implements KisFilter.

Definition at line 95 of file kis_color_to_alpha.cpp.

100{
101 Q_ASSERT(device != 0);
103
104 QVariant value;
105 QColor cTA = (config->getProperty("targetcolor", value)) ? value.value<QColor>() : QColor(255, 255, 255);
106 int threshold = (config->getProperty("threshold", value)) ? value.toInt() : 1;
107
108 const KoColorSpace * cs = device->colorSpace();
109
110 KisSequentialIteratorProgress it(device, rect, progressUpdater);
111 KoColor baseColor(cTA, cs);
112
113 QVector<int> channelIndex;
115
116 const QList<KoChannelInfo*> channels = cs->channels();
117
118 for (int i = 0; i < channels.size(); i++) {
119 const KoChannelInfo *info = channels[i];
120
121 if (info->channelType() != KoChannelInfo::COLOR) continue;
122
123 KoChannelInfo::enumChannelValueType currentValueType =
124 info->channelValueType();
125
126 if (valueType != KoChannelInfo::OTHER &&
127 valueType != currentValueType) {
128
129 warnKrita << "Cannot apply a Color-to-Alpha filter to a heterogeneous colorspace";
130 return;
131 } else {
132 valueType = currentValueType;
133 }
134
135 channelIndex.append(i);
136 }
137
138 switch (valueType) {
140 applyToIterator<quint8, qint16>(channelIndex.size(), channelIndex.data(),
141 it, baseColor,
142 threshold, cs);
143 break;
145 applyToIterator<quint16, qint32>(channelIndex.size(), channelIndex.data(),
146 it, baseColor,
147 threshold, cs);
148 break;
150 applyToIterator<quint32, qint64>(channelIndex.size(), channelIndex.data(),
151 it, baseColor,
152 threshold, cs);
153 break;
154
156 applyToIterator<float, float>(channelIndex.size(), channelIndex.data(),
157 it, baseColor,
158 threshold, cs);
159 break;
161 applyToIterator<double, double>(channelIndex.size(), channelIndex.data(),
162 it, baseColor,
163 threshold, cs);
164 break;
166#ifdef HAVE_OPENEXR
167#include <half.h>
168 applyToIterator<half, half>(channelIndex.size(), channelIndex.data(),
169 it, baseColor,
170 threshold, cs);
171 break;
172
173#endif
174 case KoChannelInfo::INT8: /* !UNSUPPORTED! */
175 case KoChannelInfo::INT16: /* !UNSUPPORTED! */
176
178 warnKrita << "Color To Alpha: Unsupported channel type:" << valueType;
179 }
180}
float value(const T *src, size_t ch)
const KoColorSpace * colorSpace() const
@ COLOR
The channel represents a color.
enumChannelValueType
enum to define the value of the channel
@ UINT8
use this for an unsigned integer 8bits channel
@ UINT16
use this for an integer 16bits channel
@ OTHER
Use this if the channel is neither an integer or a float.
@ INT16
use this for an integer 16bits channel
@ INT8
use this for an integer 8bits channel
@ FLOAT32
use this for a float 32bits channel
@ FLOAT16
use this for a float 16bits channel
@ UINT32
use this for an unsigned integer 21bits channel
@ FLOAT64
use this for a float 64bits channel
enumChannelType channelType() const
enumChannelValueType channelValueType() const
QList< KoChannelInfo * > channels
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define warnKrita
Definition kis_debug.h:94

References KoColorSpace::channels, KoChannelInfo::channelType(), KoChannelInfo::channelValueType(), KoChannelInfo::COLOR, KisPaintDevice::colorSpace(), KoChannelInfo::FLOAT16, KoChannelInfo::FLOAT32, KoChannelInfo::FLOAT64, KoChannelInfo::INT16, KoChannelInfo::INT8, KIS_SAFE_ASSERT_RECOVER_RETURN, KoChannelInfo::OTHER, KoChannelInfo::UINT16, KoChannelInfo::UINT32, KoChannelInfo::UINT8, value(), and warnKrita.


The documentation for this class was generated from the following files: