Changeset 2605 for libpipi/trunk/pipi/resize.c
- Timestamp:
- Jul 29, 2008, 1:01:29 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/resize.c
r2260 r2605 26 26 #include "pipi_internals.h" 27 27 28 pipi_image_t *pipi_resize(pipi_image_t const*src, int w, int h)28 pipi_image_t *pipi_resize(pipi_image_t *src, int w, int h) 29 29 { 30 double*aline, *line;30 float *srcdata, *dstdata, *aline, *line; 31 31 pipi_image_t *dst; 32 pipi_pixels_t *srcp, *dstp; 32 33 int x, y, x0, y0, sw, dw, sh, dh, remy; 33 34 35 srcp = pipi_getpixels(src, PIPI_PIXELS_RGBA_F); 36 srcdata = (float *)srcp->pixels; 37 34 38 dst = pipi_new(w, h); 39 dstp = pipi_getpixels(dst, PIPI_PIXELS_RGBA_F); 40 dstdata = (float *)dstp->pixels; 35 41 36 sw = src->w idth; sh = src->height;37 dw = dst->w idth; dh = dst->height;42 sw = src->w; sh = src->h; 43 dw = dst->w; dh = dst->h; 38 44 39 aline = malloc(3 * dw * sizeof( double));40 line = malloc(3 * dw * sizeof( double));45 aline = malloc(3 * dw * sizeof(float)); 46 line = malloc(3 * dw * sizeof(float)); 41 47 42 memset(line, 0, 3 * dw * sizeof( double));48 memset(line, 0, 3 * dw * sizeof(float)); 43 49 remy = 0; 44 50 45 for(y = 0, y0 = 0; y < d st->height; y++)51 for(y = 0, y0 = 0; y < dh; y++) 46 52 { 47 53 int toty = 0, ny; 48 54 49 memset(aline, 0, 3 * dw * sizeof( double));55 memset(aline, 0, 3 * dw * sizeof(float)); 50 56 51 57 while(toty < sh) … … 53 59 if(remy == 0) 54 60 { 55 doubler = 0, g = 0, b = 0;61 float r = 0, g = 0, b = 0; 56 62 int remx = 0; 57 63 58 for(x = 0, x0 = 0; x < d st->width; x++)64 for(x = 0, x0 = 0; x < dw; x++) 59 65 { 60 doublear = 0, ag = 0, ab = 0;66 float ar = 0, ag = 0, ab = 0; 61 67 int totx = 0, nx; 62 68 … … 65 71 if(remx == 0) 66 72 { 67 pipi_getpixel(src, x0, y0, &r, &g, &b); 73 r = srcdata[(y0 * sw + x0) * 4]; 74 g = srcdata[(y0 * sw + x0) * 4 + 1]; 75 b = srcdata[(y0 * sw + x0) * 4 + 2]; 68 76 x0++; 69 77 remx = dw; … … 86 94 87 95 ny = (toty + remy <= sh) ? remy : sh - toty; 88 for(x = 0; x < d st->width; x++)96 for(x = 0; x < dw; x++) 89 97 { 90 98 aline[3 * x] += ny * line[3 * x]; … … 96 104 } 97 105 98 for(x = 0; x < dst->width; x++) 99 pipi_setpixel(dst, x, y, 100 aline[3 * x] / (sw * sh), 101 aline[3 * x + 1] / (sw * sh), 102 aline[3 * x + 2] / (sw * sh)); 106 for(x = 0; x < dw; x++) 107 { 108 dstdata[(y * dw + x) * 4] = aline[3 * x] / (sw * sh); 109 dstdata[(y * dw + x) * 4 + 1] = aline[3 * x + 1] / (sw * sh); 110 dstdata[(y * dw + x) * 4 + 2] = aline[3 * x + 2] / (sw * sh); 111 } 103 112 } 104 113
Note: See TracChangeset
for help on using the changeset viewer.