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.
 
 
 
 
 
 

68 lines
1.7 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 random dithering\n");
  17. fprintf(stderr, " 2 Floyd-Steinberg (raster)\n");
  18. fprintf(stderr, " 3 Floyd-Steinberg (serpentine)\n");
  19. fprintf(stderr, " 4 Ostromoukhov (raster)\n");
  20. fprintf(stderr, " 5 Ostromoukhov (serpentine)\n");
  21. fprintf(stderr, " 6 Direct binary search\n");
  22. return EXIT_FAILURE;
  23. }
  24. srcname = argv[1];
  25. dstname = argv[3];
  26. img = pipi_load(srcname);
  27. switch(atoi(argv[2]))
  28. {
  29. case 7:
  30. newimg = pipi_dither_dbs(img);
  31. break;
  32. case 6:
  33. newimg = pipi_dither_ostromoukhov(img, PIPI_SCAN_SERPENTINE);
  34. break;
  35. case 5:
  36. newimg = pipi_dither_ostromoukhov(img, PIPI_SCAN_RASTER);
  37. break;
  38. case 4:
  39. newimg = pipi_dither_floydsteinberg(img, PIPI_SCAN_SERPENTINE);
  40. break;
  41. case 3:
  42. newimg = pipi_dither_floydsteinberg(img, PIPI_SCAN_RASTER);
  43. break;
  44. case 2:
  45. newimg = pipi_dither_ordered(img);
  46. break;
  47. case 1:
  48. default:
  49. newimg = pipi_dither_random(img);
  50. break;
  51. }
  52. pipi_free(img);
  53. pipi_save(newimg, dstname);
  54. pipi_free(newimg);
  55. return 0;
  56. }