Bibliothèque de traitements d'images en virgule flottante. http://la.buvette.org/photos/cumul/
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.

107 lines
2.2 KiB

  1. /*
  2. SINGLE
  3. experimental and/or testing code, do not use in
  4. production.
  5. */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <sys/stat.h>
  9. #include "../floatimg.h"
  10. #include "sfx.h"
  11. #include "filterstack.h"
  12. #include "crapulator.h"
  13. #include "single.h"
  14. /* -------------------------------------------------------------- */
  15. /*
  16. * singleton/private variables
  17. */
  18. static int nextpng, counter;
  19. static char *destination;
  20. static int chainfilter;
  21. /* -------------------------------------------------------------- */
  22. int single_init(int next, char *dest, int fxchain)
  23. {
  24. int foo;
  25. struct stat stbuf;
  26. #if DEBUG_LEVEL
  27. fprintf(stderr, ">>> %s ( %d '%s' %d )\n", __func__,
  28. next, dest, fxchain);
  29. #endif
  30. nextpng = next;
  31. chainfilter = fxchain;
  32. foo = stat(dest, &stbuf);
  33. if (foo) {
  34. perror("stat dest dir");
  35. return -2;
  36. }
  37. if (S_IFDIR != (stbuf.st_mode & S_IFMT)) {
  38. fprintf(stderr, "! %s must be a directory\n", dest);
  39. return -3;
  40. }
  41. destination = strdup(dest); /* have a static copy */
  42. return 0;
  43. }
  44. /* -------------------------------------------------------------- */
  45. int single_push_picture(FloatImg *pimg)
  46. {
  47. int foo;
  48. char line[1000], buff[100];
  49. #if DEBUG_LEVEL
  50. fprintf(stderr, ">>> %s ( %p )\n", __func__, pimg);
  51. #endif
  52. strncpy(line, destination, 100);
  53. if ('/' != line[strlen(line)-1]) {
  54. // fprintf(stderr, "adding '/'\n");
  55. strcat(line, "/");
  56. }
  57. // fprintf(stderr, " destdir = '%s'\n", line);
  58. sprintf(buff, "%05d.png", nextpng);
  59. strcat(line, buff);
  60. // fprintf(stderr, "writing %p to '%s'\n", pimg, line);
  61. foo = fimg_export_picture(pimg, line, 0);
  62. if (foo) {
  63. fprintf(stderr, "%s: err %d on export\n", __func__, foo);
  64. return foo;
  65. }
  66. nextpng++; counter++;
  67. return 0;
  68. }
  69. /* -------------------------------------------------------------- */
  70. int single_print_state(char *title, int k)
  71. {
  72. #if DEBUG_LEVEL
  73. fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, title, k);
  74. #endif
  75. fprintf(stderr, "%s : %s\n", __FILE__, title);
  76. fprintf(stderr, " nextpng %d\n", nextpng);
  77. fprintf(stderr, " counter %d\n", counter);
  78. fprintf(stderr, " chainfilter %d\n", chainfilter);
  79. fprintf(stderr, " destination %s\n", destination);
  80. if (k) {
  81. /* XXX */
  82. }
  83. return -1;
  84. }
  85. /* -------------------------------------------------------------- */