Version 0.3
[colorize.git] / gui / colorize.c
index 61d396d..61e6345 100644 (file)
@@ -56,7 +56,7 @@ static void save_event(gpointer *priv)
        struct colorize_priv *cp = (struct colorize_priv *) priv;
        guchar *data;
        int rs, i, j;
-       unsigned char *buffer;
+       unsigned short *buffer;
        GtkWidget *dialog;
        char *filename = NULL;
 
@@ -80,13 +80,13 @@ static void save_event(gpointer *priv)
 
        data = gdk_pixbuf_get_pixels(cp->pixbuf);
         rs = gdk_pixbuf_get_rowstride(cp->pixbuf);
-       buffer = malloc(cp->width*cp->height*3);
+       buffer = malloc(cp->width*cp->height*3*sizeof(unsigned short));
 
        for (i = 0; i < cp->height; i++) {
                for (j = 0; j < cp->width; j++) {
-                       buffer[(i*cp->width+j)*3+0] = data[i*rs+j*3+0];
-                       buffer[(i*cp->width+j)*3+1] = data[i*rs+j*3+1];
-                       buffer[(i*cp->width+j)*3+2] = data[i*rs+j*3+2];
+                       buffer[(i*cp->width+j)*3+0] = data[i*rs+j*3+0] << 8;
+                       buffer[(i*cp->width+j)*3+1] = data[i*rs+j*3+1] << 8;
+                       buffer[(i*cp->width+j)*3+2] = data[i*rs+j*3+2] << 8;
                }
        }