20 #include "../parallelism.h"
21 #include "../geometry.h"
39 srcW =
src.width(), srcH =
src.height(),
49 for (
int y = sliceStart;
y < sliceStop; ++
y) {
51 const int sy =
src.a.y + (
y * srcH + shiftY) / dstH;
53 for (
int x = 0;
x < dstW; ++
x) {
54 const int sx =
src.a.x + (
x * srcW + shiftX) / dstW;
78 srcW =
src.width(), srcH =
src.height(),
86 int x0, y0,
x1,
y1 =
src.a.y + (sliceStart) * srcH / dstH;
88 typename in_t::pixtype acc;
89 for (
int y = sliceStart;
y < sliceStop; ++
y) {
92 y1 =
src.a.y + (
y + 1) * srcH / dstH;
94 for (
int x = 0;
x < dstW; ++
x) {
96 x1 =
src.a.x + (
x + 1) * srcW / dstW;
133 srcW =
src.width(), srcH =
src.height(),
135 shiftX = (srcW - dstW) / 2,
136 shiftY = (srcH - dstH) / 2;
143 for (
int y = sliceStart;
y < sliceStop; ++
y) {
145 const float fsy = (float)(
y * srcH + shiftY) / dstH;
146 const int isy = (int)fsy;
147 const float fy = fsy - (float)isy, _fy = 1 - fy;
148 const int sy =
src.a.y + isy;
151 lineJump = sy < srcH - 1 ? srcW - 1 : -1,
154 typename out_t::pixtype acc;
155 for (
int x = 0;
x < dstW; ++
x) {
157 const float fsx = (float)(
x * srcW + shiftX) / dstW;
158 const int isx = (int)fsx;
159 const float fx = fsx - (float)isx;
160 const int sx =
src.a.x + isx;
164 acc = in() * (1 - fx) * _fy;
166 acc = acc + in() * fx * _fy;
168 acc = acc + in() * (1 - fx) * fy;
170 acc = acc + in() * fx * fy;
175 acc = acc + in() * fy;
196 float c0[2], c1[2], c2[3];
208 c2[1] = 2 * alpha + 3;
216 const float xx =
x *
x, xxx = xx *
x;
217 coeff[0] = c0[0] * (xxx +
x) + c0[1] * xx;
218 coeff[1] = c1[1] * xxx + c1[0] * xx + 1;
219 coeff[2] = c2[2] * xxx + c2[1] * xx + c2[0] *
x;
220 coeff[3] = 1 - coeff[0] - coeff[1] - coeff[2];
237 srcW =
src.width(), srcH =
src.height(),
239 shiftX = (srcW - dstW) / 2,
240 shiftY = (srcH - dstH) / 2;
249 for (
int y = sliceStart;
y < sliceStop; ++
y) {
251 const float fsy = (float)(
y * srcH + shiftY) / dstH;
252 const int isy = (int)fsy;
253 const float fy = fsy - (float)isy;
254 const int sy =
src.a.y + isy;
256 const int lineJump[3] = {
258 sy < srcH - 1 ? srcW : 0,
259 sy < srcH - 2 ? srcW : 0
265 typename out_t::pixtype acc;
266 for (
int x = 0;
x < dstW; ++
x) {
268 const float fsx = (float)(
x * srcW + shiftX) / dstW;
269 const int isx = (int)fsx;
270 const float fx = fsx - (float)isx;
271 const int sx =
src.a.x + isx;
275 const int pixJump[3] = {
277 sx < srcW - 1 ? +1 : 0,
278 sx < srcW - 2 ? +2 : 0
281 in.goTo(sx, sy > 0 ? sy - 1 : 0);
282 acc = in[pixJump[0]] * kx[0] * ky[0] + in() * kx[1] * ky[0] + in[pixJump[1]] * kx[2] * ky[0] + in[pixJump[2]] * kx[3] * ky[0];
284 acc = acc + in[pixJump[0]] * kx[0] * ky[1] + in() * kx[1] * ky[1] + in[pixJump[1]] * kx[2] * ky[1] + in[pixJump[2]] * kx[3] * ky[1];
286 acc = acc + in[pixJump[0]] * kx[0] * ky[2] + in() * kx[1] * ky[2] + in[pixJump[1]] * kx[2] * ky[2] + in[pixJump[2]] * kx[3] * ky[2];
288 acc = acc + in[pixJump[0]] * kx[0] * ky[3] + in() * kx[1] * ky[3] + in[pixJump[1]] * kx[2] * ky[3] + in[pixJump[2]] * kx[3] * ky[3];
A very basic class for any image.
virtual ThreadIndex numThreads() const =0
ThreadIndex currentThread() const
virtual bool isTaskAborted() const =0
Returns true if the task is asked to stop from outside.
Precomputes kernel coefficients in function of bicubic kernel parameter.
void operator()(float x)
Computes the kernel itself for a given phase.
BicubicKernel(const float alpha)
const float operator[](const int i) const
static void process(AbstractBitmap &input, AbstractBitmap &output, IntRectangle &src, IntRectangle &dst, const float alpha, const TaskThread &tt)
Resamples a rectangle from an input bitmap to a rectangle in an output bitmap applying a bicubic kern...
static void process(AbstractBitmap &input, AbstractBitmap &output, IntRectangle &src, IntRectangle &dst, const TaskThread &tt)
Resamples a rectangle from an input bitmap to a rectangle in an output bitmap by bilinear interpolati...
static void process(AbstractBitmap &input, AbstractBitmap &output, IntRectangle &src, IntRectangle &dst, const TaskThread &tt)
Resamples a rectangle from an input bitmap to a rectangle in an output bitmap applying a box filter.
static void process(AbstractBitmap &input, AbstractBitmap &output, IntRectangle &src, IntRectangle &dst, const TaskThread &tt)
Resamples a rectangle from an input bitmap to a rectangle in an output bitmap by nearest neighbor int...
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
JNIEnv jlong jint jint jint y1
jobject jlong jint jint y
return(jlong) new Beatmup jlong jstring src