Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_math_toolbox.h
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 *
4 * SPDX-FileCopyrightText: 2005 Cyrille Berger <cberger@cberger.net>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KIS_MATH_TOOLBOX_H
10#define KIS_MATH_TOOLBOX_H
11
12#include <QObject>
13#include <QRect>
14
15#include <new>
16
17#include <KoColorSpace.h>
18
19#include "kis_types.h"
20#include "kis_paint_device.h"
21
22#ifdef _MSC_VER
23#pragma warning(disable: 4290) // disable "C++ exception specification ignored" warning
24#endif
25
26#if !defined _MSC_VER
27#pragma GCC diagnostic ignored "-Wcast-align"
28#endif
29
30typedef double(*PtrToDouble)(const quint8*, int);
31typedef void (*PtrFromDouble)(quint8*, int, double);
32typedef void (*PtrFromDoubleCheckNull)(quint8*, int, double, bool*);
33
34class KRITAIMAGE_EXPORT KisMathToolbox
35{
36
37public:
38
40
42 : coeffs(new float[nsize*nsize*ndepth])
43 , size(nsize)
44 , depth(ndepth) {
45 // XXX: Valgrind shows that these are being used without being initialised.
46 for (quint32 i = 0; i < nsize * nsize * ndepth; ++i) {
47 coeffs[i] = 0;
48 }
49 }
50
52 if (coeffs) delete[] coeffs;
53 }
54
55 float* coeffs;
58 };
59
61
67 inline KisWavelet* initWavelet(KisPaintDeviceSP lay, const QRect&);
68
69 inline uint fastWaveletTotalSteps(const QRect&);
70
80 KisWavelet* fastWaveletTransformation(KisPaintDeviceSP src, const QRect&, KisWavelet* buff = 0);
81
92 void fastWaveletUntransformation(KisPaintDeviceSP dst, const QRect&, KisWavelet* wav, KisWavelet* buff = 0);
93
94 bool getToDoubleChannelPtr(QList<KoChannelInfo *> cis, QVector<PtrToDouble>& f);
95 bool getFromDoubleChannelPtr(QList<KoChannelInfo *> cis, QVector<PtrFromDouble>& f);
96 bool getFromDoubleCheckNullChannelPtr(QList<KoChannelInfo *> cis, QVector<PtrFromDoubleCheckNull>& f);
97
98 double minChannelValue(KoChannelInfo *);
99 double maxChannelValue(KoChannelInfo *);
100
101private:
102
103 void wavetrans(KisWavelet* wav, KisWavelet* buff, uint halfsize);
104 void waveuntrans(KisWavelet* wav, KisWavelet* buff, uint halfsize);
105
110 void transformToFR(KisPaintDeviceSP src, KisFloatRepresentation*, const QRect&);
111
116 void transformFromFR(KisPaintDeviceSP dst, KisFloatRepresentation*, const QRect&);
117
118};
119
121{
122 int size;
123 int maxrectsize = (rect.height() < rect.width()) ? rect.width() : rect.height();
124 for (size = 2; size < maxrectsize; size *= 2) ;
125 qint32 depth = src->colorSpace()->colorChannelCount();
126 return new KisWavelet(size, depth);
127}
128
130{
131 int size, steps;
132 int maxrectsize = (rect.height() < rect.width()) ? rect.width() : rect.height();
133 steps = 0;
134 for (size = 2; size < maxrectsize; size *= 2) steps += size / 2; ;
135 return steps;
136}
137
138#endif
unsigned int uint
uint fastWaveletTotalSteps(const QRect &)
KisWavelet * initWavelet(KisPaintDeviceSP lay, const QRect &)
KisFloatRepresentation KisWavelet
double(* PtrToDouble)(const quint8 *, int)
void(* PtrFromDoubleCheckNull)(quint8 *, int, double, bool *)
void(* PtrFromDouble)(quint8 *, int, double)
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
KisFloatRepresentation(uint nsize, uint ndepth)