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

#include <kis_color_to_alpha.h>

+ Inheritance diagram for KisFilterColorToAlpha:

Public Member Functions

KisConfigWidgetcreateConfigurationWidget (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
KisBookmarkedConfigurationManagerbookmarkManager ()
 
const KisBookmarkedConfigurationManagerbookmarkManager () 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
KisBookmarkedConfigurationManagerbookmarkManager
 
KoID category
 
ColorSpaceIndependence colorSpaceIndependence
 
QString entry
 
KoID id
 
QKeySequence shortcut
 
bool showConfigurationWidget
 
bool supportsAdjustmentLayers
 
bool supportsPainting
 
bool supportsThreading
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
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 91 of file kis_color_to_alpha.cpp.

96{
97 Q_ASSERT(device != 0);
99
100 QVariant value;
101 QColor cTA = (config->getProperty("targetcolor", value)) ? value.value<QColor>() : QColor(255, 255, 255);
102 int threshold = (config->getProperty("threshold", value)) ? value.toInt() : 1;
103
104 const KoColorSpace * cs = device->colorSpace();
105
106 KisSequentialIteratorProgress it(device, rect, progressUpdater);
107 KoColor baseColor(cTA, cs);
108
109 QVector<int> channelIndex;
111
112 const QList<KoChannelInfo*> channels = cs->channels();
113
114 for (int i = 0; i < channels.size(); i++) {
115 const KoChannelInfo *info = channels[i];
116
117 if (info->channelType() != KoChannelInfo::COLOR) continue;
118
119 KoChannelInfo::enumChannelValueType currentValueType =
120 info->channelValueType();
121
122 if (valueType != KoChannelInfo::OTHER &&
123 valueType != currentValueType) {
124
125 warnKrita << "Cannot apply a Color-to-Alpha filter to a heterogeneous colorspace";
126 return;
127 } else {
128 valueType = currentValueType;
129 }
130
131 channelIndex.append(i);
132 }
133
134 switch (valueType) {
136 applyToIterator<quint8, qint16>(channelIndex.size(), channelIndex.data(),
137 it, baseColor,
138 threshold, cs);
139 break;
141 applyToIterator<quint16, qint32>(channelIndex.size(), channelIndex.data(),
142 it, baseColor,
143 threshold, cs);
144 break;
146 applyToIterator<quint32, qint64>(channelIndex.size(), channelIndex.data(),
147 it, baseColor,
148 threshold, cs);
149 break;
150
152 applyToIterator<float, float>(channelIndex.size(), channelIndex.data(),
153 it, baseColor,
154 threshold, cs);
155 break;
157 applyToIterator<double, double>(channelIndex.size(), channelIndex.data(),
158 it, baseColor,
159 threshold, cs);
160 break;
162#ifdef HAVE_OPENEXR
163#include <half.h>
164 applyToIterator<half, half>(channelIndex.size(), channelIndex.data(),
165 it, baseColor,
166 threshold, cs);
167 break;
168
169#endif
170 case KoChannelInfo::INT8: /* !UNSUPPORTED! */
171 case KoChannelInfo::INT16: /* !UNSUPPORTED! */
172
174 warnKrita << "Color To Alpha: Unsupported channel type:" << valueType;
175 }
176}
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:87

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: