50 line
1.1 KiB

  1. #include "config.h"
  2. #include "common.h"
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <pipi.h>
  7. int main(int argc, char *argv[])
  8. {
  9. char *srcname = NULL, *dstname = NULL;
  10. pipi_image_t *img, *newimg;
  11. if(argc < 3)
  12. {
  13. fprintf(stderr, "%s: too few arguments\n", argv[0]);
  14. fprintf(stderr, "Usage: %s <src> <method> <dest>\n", argv[0]);
  15. fprintf(stderr, "Where <method> is one of:\n");
  16. fprintf(stderr, " 1 Floyd-Steinberg (serpentine)\n");
  17. fprintf(stderr, " 2 Ostromoukhov (serpentine)\n");
  18. fprintf(stderr, " 3 Direct binary search\n");
  19. return EXIT_FAILURE;
  20. }
  21. srcname = argv[1];
  22. dstname = argv[3];
  23. img = pipi_load(srcname);
  24. switch(atoi(argv[2]))
  25. {
  26. case 3:
  27. newimg = pipi_dbs(img); break;
  28. case 2:
  29. newimg = pipi_ostromoukhov(img); break;
  30. case 1:
  31. default:
  32. newimg = pipi_floydsteinberg(img); break;
  33. }
  34. pipi_free(img);
  35. pipi_save(newimg, dstname);
  36. pipi_free(newimg);
  37. return 0;
  38. }