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.
 
 
 
 
 
 

49 lines
1.0 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\n");
  17. fprintf(stderr, " 2 Direct binary search\n");
  18. return EXIT_FAILURE;
  19. }
  20. srcname = argv[1];
  21. dstname = argv[3];
  22. img = pipi_load(srcname);
  23. pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
  24. switch(atoi(argv[2]))
  25. {
  26. case 2:
  27. newimg = pipi_dbs(img); break;
  28. case 1:
  29. default:
  30. newimg = pipi_floydsteinberg(img); break;
  31. }
  32. pipi_free(img);
  33. pipi_getpixels(newimg, PIPI_PIXELS_RGBA_F);
  34. pipi_save(newimg, dstname);
  35. pipi_free(newimg);
  36. return 0;
  37. }