13#include <klocalizedstring.h>
14#include <QGlobalStatic>
24 Q_UNUSED(weightsPositionScale);
27 if (t < 1.0)
return((2.0 * t - 3.0) * t * t + 1.0);
33 Q_UNUSED(weightsPositionScale);
37 t = (2 * t - 3 * 256) * t * t + (256 << 16);
40 t = (t + 0x8000) >> 16;
52 Q_UNUSED(weightsPositionScale);
56 t = (3 * t - 5 * 256) * t * t / 2 + (256 << 16);
59 t = (t + 0x8000) >> 16;
68 t = ((-t + 5 * 256) * t / 2 - 4 * 256 * 256) * t + (2 * 256 << 16);
71 t = (t + 0x8000) >> 16;
83 if ((t >= -0.5 * weightsPositionScale) && (t < 0.5 * weightsPositionScale))
return(1.0);
90 if ((t >= -128 * weightsPositionScale) && (t < 128 * weightsPositionScale))
108 Q_UNUSED(weightsPositionScale);
110 if (t < 1.0)
return(1.0 - t);
116 Q_UNUSED(weightsPositionScale);
121 if (t >= 128)
return 256 - t;
130 Q_UNUSED(weightsPositionScale);
132 if (t < .5)
return(.75 - (t * t));
142 Q_UNUSED(weightsPositionScale);
148 return((.5 * tt * t) - tt + (2.0 / 3.0));
151 return((1.0 / 6.0) *(t * t * t));
158 Q_UNUSED(weightsPositionScale);
160 if (t < 3.0)
return(
sinc(t) *
sinc(t / 3.0));
166 const qreal pi = 3.1415926535897932385;
168 if (x != 0)
return(sin(x) / x);
174 Q_UNUSED(weightsPositionScale);
175 const qreal
B = 1.0 / 3.0;
176 const qreal
C = 1.0 / 3.0;
182 t = (((12.0 - 9.0 *
B - 6.0 *
C) * (t * tt)) + ((-18.0 + 12.0 *
B + 6.0 *
C) * tt) + (6.0 - 2 *
B));
184 }
else if (t < 2.0) {
185 t = (((-1.0 *
B - 6.0 *
C) * (t * tt)) + ((6.0 *
B + 30.0 *
C) * tt) + ((-12.0 *
B - 48.0 *
C) * t) + (8.0 *
B + 24 *
C));
197 Q_FOREACH (
const QString &
id,
keys()) {
200 dbgRegistry <<
"deleting KisFilterStrategyRegistry";
205 if (!s_instance.exists()) {
207 s_instance->addAlias(
"Box",
"NearestNeighbor");
223 Q_FOREACH (
const QString key,
keys()) {
224 answer.append(
KoID(key,
get(key)->name()));
232 QString formatedDescription(
"<html><head/><body>");
234 Q_FOREACH (
const QString key,
keys()) {
238 if (!description.isEmpty()) {
239 formatedDescription.append(
"<p><span style=\"font-weight:600;\">");
240 formatedDescription.append(strategy->
name());
241 formatedDescription.append(
"</span>: ");
242 formatedDescription.append(description);
243 formatedDescription.append(
"</p>");
246 formatedDescription.append(
"</body></html>");
248 return formatedDescription;
254 const int pixelArtThreshold = 256;
255 if (originalSize.width() <= pixelArtThreshold ||
256 originalSize.height() <= pixelArtThreshold) {
260 const float xScaleFactor = (float)desiredSize.width() / originalSize.width();
261 const float yScaleFactor = (float)desiredSize.height() / originalSize.height();
263 if (xScaleFactor > 1.f || yScaleFactor > 1.f) {
265 }
else if (xScaleFactor < 1.f || yScaleFactor < 1.f) {
Q_GLOBAL_STATIC(KisStoragePluginRegistry, s_instance)
qreal valueAt(qreal t, qreal weightsPositionScale) const override
qreal valueAt(qreal t, qreal weightsPositionScale) const override
qint32 intValueAt(qint32 t, qreal weightsPositionScale) const override
qint32 intValueAt(qint32 t, qreal weightsPositionScale) const override
qreal valueAt(qreal t, qreal weightsPositionScale) const override
qreal valueAt(qreal t, qreal weightsPositionScale) const override
virtual qint32 intSupport(qreal weightsPositionScale) override
virtual qreal support(qreal weightsPositionScale) override
qint32 intValueAt(qint32 t, qreal weightsPositionScale) const override
static KisFilterStrategyRegistry * instance()
~KisFilterStrategyRegistry() override
KisFilterStrategyRegistry()
KisFilterStrategy * autoFilterStrategy(QSize originalSize, QSize desiredSize) const
QString formattedDescriptions() const
QList< KoID > listKeys() const
virtual QString description()
qint32 intValueAt(qint32 t, qreal weightsPositionScale) const override
qreal valueAt(qreal t, qreal weightsPositionScale) const override
qreal sinc(qreal x) const
qreal valueAt(qreal t, qreal weightsPositionScale) const override
const T value(const QString &id) const
KisFilterStrategy * get(const QString &id) const
QList< QString > keys() const