You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.4 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 (raster)\n");
  17. fprintf(stderr, " 2 Floyd-Steinberg (serpentine)\n");
  18. fprintf(stderr, " 3 Ostromoukhov (raster)\n");
  19. fprintf(stderr, " 4 Ostromoukhov (serpentine)\n");
  20. fprintf(stderr, " 5 Direct binary search\n");
  21. return EXIT_FAILURE;
  22. }
  23. srcname = argv[1];
  24. dstname = argv[3];
  25. img = pipi_load(srcname);
  26. switch(atoi(argv[2]))
  27. {
  28. case 5:
  29. newimg = pipi_dbs(img); break;
  30. case 4:
  31. newimg = pipi_ostromoukhov(img, PIPI_SCAN_SERPENTINE); break;
  32. case 3:
  33. newimg = pipi_ostromoukhov(img, PIPI_SCAN_RASTER); break;
  34. case 2:
  35. newimg = pipi_floydsteinberg(img, PIPI_SCAN_SERPENTINE); break;
  36. case 1:
  37. default:
  38. newimg = pipi_floydsteinberg(img, PIPI_SCAN_RASTER); break;
  39. }
  40. pipi_free(img);
  41. pipi_save(newimg, dstname);
  42. pipi_free(newimg);
  43. return 0;
  44. }