|
|
@@ -19,6 +19,9 @@ |
|
|
|
#include "config.h" |
|
|
|
#include "common.h" |
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include "pipi_internals.h" |
|
|
|
#include "pipi.h" |
|
|
|
|
|
|
@@ -26,7 +29,7 @@ pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h) |
|
|
|
{ |
|
|
|
int *aline, *line; |
|
|
|
pipi_image_t *dst; |
|
|
|
int x, y, x0, y0, sw, dw, sh, dh, remy = 0; |
|
|
|
int x, y, x0, y0, sw, dw, sh, dh, remy; |
|
|
|
|
|
|
|
dst = pipi_new(w, h); |
|
|
|
|
|
|
@@ -36,22 +39,26 @@ pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h) |
|
|
|
aline = malloc(3 * dw * sizeof(int)); |
|
|
|
line = malloc(3 * dw * sizeof(int)); |
|
|
|
|
|
|
|
memset(line, 0, 3 * dw * sizeof(int)); |
|
|
|
remy = 0; |
|
|
|
|
|
|
|
for(y = 0, y0 = 0; y < dst->height; y++) |
|
|
|
{ |
|
|
|
int toty = 0, ny; |
|
|
|
|
|
|
|
memset(aline, 0, 3 * dw * sizeof(int)); |
|
|
|
memset(line, 0, 3 * dw * sizeof(int)); |
|
|
|
|
|
|
|
while(toty < sh) |
|
|
|
{ |
|
|
|
if(remy == 0) |
|
|
|
{ |
|
|
|
int r = 0, g = 0, b = 0; |
|
|
|
int remx = 0; |
|
|
|
|
|
|
|
for(x = 0, x0 = 0; x < dst->width; x++) |
|
|
|
{ |
|
|
|
int remx = 0, totx = 0, nx; |
|
|
|
int ar = 0, ag = 0, ab = 0; |
|
|
|
int r = 0, g = 0, b = 0; |
|
|
|
int totx = 0, nx; |
|
|
|
|
|
|
|
while(totx < sw) |
|
|
|
{ |
|
|
@@ -71,13 +78,10 @@ pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h) |
|
|
|
line[3 * x] = ar; |
|
|
|
line[3 * x + 1] = ag; |
|
|
|
line[3 * x + 2] = ab; |
|
|
|
/* HACK */ |
|
|
|
pipi_setpixel(dst, x, y, ar / sw, ag / sw, ab / sw); |
|
|
|
} |
|
|
|
|
|
|
|
y0++; |
|
|
|
remy = dh; |
|
|
|
//printf(" remy is now %i\n", remy); |
|
|
|
} |
|
|
|
|
|
|
|
ny = (toty + remy <= sh) ? remy : sh - toty; |
|
|
@@ -89,17 +93,13 @@ pipi_setpixel(dst, x, y, ar / sw, ag / sw, ab / sw); |
|
|
|
} |
|
|
|
toty += ny; |
|
|
|
remy -= ny; |
|
|
|
//printf(" remy-- %i\n", remy); |
|
|
|
} |
|
|
|
//printf("pasting line %i (src line now %i)\n", y, y0); |
|
|
|
|
|
|
|
#if 0 |
|
|
|
for(x = 0; x < dst->width; x++) |
|
|
|
pipi_setpixel(dst, x, y, |
|
|
|
aline[3 * x] / (sw * sh), |
|
|
|
aline[3 * x + 1] / (sw * sh), |
|
|
|
aline[3 * x + 2] / (sw * sh)); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
free(aline); |
|
|
|