Changeset 2246 for libpipi


Ignore:
Timestamp:
Feb 27, 2008, 1:41:29 AM (15 years ago)
Author:
Sam Hocevar
Message:
  • Fixed a bug in the naive resizing code.
Location:
libpipi/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/genethumb/genethumb.c

    r2245 r2246  
    99
    1010    i = pipi_load("irc.png");
    11     j = pipi_resize(i, 1000, 114);
     11    j = pipi_resize(i, 240, 240);
    1212    pipi_save(j, "irc.bmp");
    1313    pipi_free(i);
  • libpipi/trunk/pipi/resize.c

    r2245 r2246  
    2020#include "common.h"
    2121
     22#include <stdlib.h>
     23#include <string.h>
     24
    2225#include "pipi_internals.h"
    2326#include "pipi.h"
     
    2730    int *aline, *line;
    2831    pipi_image_t *dst;
    29     int x, y, x0, y0, sw, dw, sh, dh, remy = 0;
     32    int x, y, x0, y0, sw, dw, sh, dh, remy;
    3033
    3134    dst = pipi_new(w, h);
     
    3740    line = malloc(3 * dw * sizeof(int));
    3841
     42    memset(line, 0, 3 * dw * sizeof(int));
     43    remy = 0;
     44
    3945    for(y = 0, y0 = 0; y < dst->height; y++)
    4046    {
     
    4248
    4349        memset(aline, 0, 3 * dw * sizeof(int));
    44         memset(line, 0, 3 * dw * sizeof(int));
    4550
    4651        while(toty < sh)
     
    4853            if(remy == 0)
    4954            {
     55                int r = 0, g = 0, b = 0;
     56                int remx = 0;
     57
    5058                for(x = 0, x0 = 0; x < dst->width; x++)
    5159                {
    52                     int remx = 0, totx = 0, nx;
    5360                    int ar = 0, ag = 0, ab = 0;
    54                     int r = 0, g = 0, b = 0;
     61                    int totx = 0, nx;
    5562
    5663                    while(totx < sw)
     
    7279                    line[3 * x + 1] = ag;
    7380                    line[3 * x + 2] = ab;
    74 /* HACK */
    75 pipi_setpixel(dst, x, y, ar / sw, ag / sw, ab / sw);
    7681                }
    7782
    7883                y0++;
    7984                remy = dh;
    80 //printf("  remy is now %i\n", remy);
    8185            }
    8286
     
    9094            toty += ny;
    9195            remy -= ny;
    92 //printf("  remy-- %i\n", remy);
    9396        }
    94 //printf("pasting line %i (src line now %i)\n", y, y0);
    9597
    96 #if 0
    9798        for(x = 0; x < dst->width; x++)
    9899            pipi_setpixel(dst, x, y,
     
    100101                          aline[3 * x + 1] / (sw * sh),
    101102                          aline[3 * x + 2] / (sw * sh));
    102 #endif
    103103    }
    104104
Note: See TracChangeset for help on using the changeset viewer.