|
|
@@ -37,6 +37,7 @@ pipi_image_t *pipi_resize(pipi_image_t *src, int w, int h) |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
int x, y, x0, y0, sw, dw, sh, dh, remy; |
|
|
|
float invswsh; |
|
|
|
|
|
|
|
srcp = pipi_get_pixels(src, PIPI_PIXELS_RGBA_F32); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
@@ -47,6 +48,7 @@ pipi_image_t *pipi_resize(pipi_image_t *src, int w, int h) |
|
|
|
|
|
|
|
sw = src->w; sh = src->h; |
|
|
|
dw = dst->w; dh = dst->h; |
|
|
|
invswsh = 1.0f / (sw * sh); |
|
|
|
|
|
|
|
aline = malloc(4 * dw * sizeof(float)); |
|
|
|
line = malloc(4 * dw * sizeof(float)); |
|
|
@@ -114,10 +116,10 @@ pipi_image_t *pipi_resize(pipi_image_t *src, int w, int h) |
|
|
|
|
|
|
|
for(x = 0; x < dw; x++) |
|
|
|
{ |
|
|
|
dstdata[(y * dw + x) * 4] = aline[4 * x] / (sw * sh); |
|
|
|
dstdata[(y * dw + x) * 4 + 1] = aline[4 * x + 1] / (sw * sh); |
|
|
|
dstdata[(y * dw + x) * 4 + 2] = aline[4 * x + 2] / (sw * sh); |
|
|
|
dstdata[(y * dw + x) * 4 + 3] = aline[4 * x + 3] / (sw * sh); |
|
|
|
dstdata[(y * dw + x) * 4] = aline[4 * x] * invswsh; |
|
|
|
dstdata[(y * dw + x) * 4 + 1] = aline[4 * x + 1] * invswsh; |
|
|
|
dstdata[(y * dw + x) * 4 + 2] = aline[4 * x + 2] * invswsh; |
|
|
|
dstdata[(y * dw + x) * 4 + 3] = aline[4 * x + 3] * invswsh; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|