Index: /libpipi/trunk/genethumb/genethumb.c
===================================================================
--- /libpipi/trunk/genethumb/genethumb.c	(revision 2245)
+++ /libpipi/trunk/genethumb/genethumb.c	(revision 2246)
@@ -9,5 +9,5 @@
 
     i = pipi_load("irc.png");
-    j = pipi_resize(i, 1000, 114);
+    j = pipi_resize(i, 240, 240);
     pipi_save(j, "irc.bmp");
     pipi_free(i);
Index: /libpipi/trunk/pipi/resize.c
===================================================================
--- /libpipi/trunk/pipi/resize.c	(revision 2245)
+++ /libpipi/trunk/pipi/resize.c	(revision 2246)
@@ -20,4 +20,7 @@
 #include "common.h"
 
+#include <stdlib.h>
+#include <string.h>
+
 #include "pipi_internals.h"
 #include "pipi.h"
@@ -27,5 +30,5 @@
     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);
@@ -37,4 +40,7 @@
     line = malloc(3 * dw * sizeof(int));
 
+    memset(line, 0, 3 * dw * sizeof(int));
+    remy = 0;
+
     for(y = 0, y0 = 0; y < dst->height; y++)
     {
@@ -42,5 +48,4 @@
 
         memset(aline, 0, 3 * dw * sizeof(int));
-        memset(line, 0, 3 * dw * sizeof(int));
 
         while(toty < sh)
@@ -48,9 +53,11 @@
             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)
@@ -72,11 +79,8 @@
                     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);
             }
 
@@ -90,9 +94,6 @@
             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,
@@ -100,5 +101,4 @@
                           aline[3 * x + 1] / (sw * sh),
                           aline[3 * x + 2] / (sw * sh));
-#endif
     }
 
