Small speedup for bilinear resize (used for thumbnails)
This commit is contained in:
parent
c63cd8dd76
commit
f885b17439
@ -818,33 +818,21 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (interp == TI_Bilinear) {
|
} else if (interp == TI_Bilinear) {
|
||||||
for (int i = 0; i < nh; i++) {
|
float heightByNh = float(height) / float(nh);
|
||||||
int sy = i * height / nh;
|
float widthByNw = float(width) / float(nw);
|
||||||
|
float syf = 0.f;
|
||||||
|
|
||||||
if (sy >= height) {
|
for (int i = 0; i < nh; i++, syf += heightByNh) {
|
||||||
sy = height - 1;
|
int sy = syf;
|
||||||
}
|
float dy = syf - float(sy);
|
||||||
|
int ny = sy < height - 1 ? sy + 1 : sy;
|
||||||
|
|
||||||
float dy = float(i) * float(height) / float(nh) - float(sy);
|
float sxf = 0.f;
|
||||||
int ny = sy + 1;
|
|
||||||
|
|
||||||
if (ny >= height) {
|
for (int j = 0; j < nw; j++, sxf += widthByNw) {
|
||||||
ny = sy;
|
int sx = sxf;
|
||||||
}
|
float dx = sxf - float(sx);
|
||||||
|
int nx = sx < width - 1 ? sx + 1 : sx;
|
||||||
for (int j = 0; j < nw; j++) {
|
|
||||||
int sx = j * width / nw;
|
|
||||||
|
|
||||||
if (sx >= width) {
|
|
||||||
sx = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
float dx = float(j) * float(width) / float(nw) - float(sx);
|
|
||||||
int nx = sx + 1;
|
|
||||||
|
|
||||||
if (nx >= width) {
|
|
||||||
nx = sx;
|
|
||||||
}
|
|
||||||
|
|
||||||
convertTo(r(sy, sx) * (1.f - dx) * (1.f - dy) + r(sy, nx)*dx * (1.f - dy) + r(ny, sx) * (1.f - dx)*dy + r(ny, nx)*dx * dy, imgPtr->r(i, j));
|
convertTo(r(sy, sx) * (1.f - dx) * (1.f - dy) + r(sy, nx)*dx * (1.f - dy) + r(ny, sx) * (1.f - dx)*dy + r(ny, nx)*dx * dy, imgPtr->r(i, j));
|
||||||
convertTo(g(sy, sx) * (1.f - dx) * (1.f - dy) + g(sy, nx)*dx * (1.f - dy) + g(ny, sx) * (1.f - dx)*dy + g(ny, nx)*dx * dy, imgPtr->g(i, j));
|
convertTo(g(sy, sx) * (1.f - dx) * (1.f - dy) + g(sy, nx)*dx * (1.f - dy) + g(ny, sx) * (1.f - dx)*dy + g(ny, nx)*dx * dy, imgPtr->g(i, j));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user