|
|
@@ -0,0 +1,48 @@ |
|
|
|
#include "config.h" |
|
|
|
#include "common.h" |
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include <pipi.h> |
|
|
|
|
|
|
|
int main(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
char *srcname = NULL, *dstname = NULL; |
|
|
|
pipi_image_t *img, *newimg; |
|
|
|
|
|
|
|
if(argc < 3) |
|
|
|
{ |
|
|
|
fprintf(stderr, "%s: too few arguments\n", argv[0]); |
|
|
|
fprintf(stderr, "Usage: %s <src> <method> <dest>\n", argv[0]); |
|
|
|
fprintf(stderr, "Where <method> is one of:\n"); |
|
|
|
fprintf(stderr, " 1 Floyd-Steinberg\n"); |
|
|
|
fprintf(stderr, " 2 Direct binary search\n"); |
|
|
|
return EXIT_FAILURE; |
|
|
|
} |
|
|
|
|
|
|
|
srcname = argv[1]; |
|
|
|
dstname = argv[3]; |
|
|
|
|
|
|
|
img = pipi_load(srcname); |
|
|
|
pipi_getpixels(img, PIPI_PIXELS_RGBA_F); |
|
|
|
|
|
|
|
switch(atoi(argv[2])) |
|
|
|
{ |
|
|
|
case 2: |
|
|
|
newimg = pipi_dbs(img); break; |
|
|
|
case 1: |
|
|
|
default: |
|
|
|
newimg = pipi_floydsteinberg(img); break; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_free(img); |
|
|
|
|
|
|
|
pipi_getpixels(newimg, PIPI_PIXELS_RGBA_F); |
|
|
|
pipi_save(newimg, dstname); |
|
|
|
pipi_free(newimg); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|