Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

histogram.c 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <pipi.h>
  6. int main(int argc, char *argv[])
  7. {
  8. char *srcname = NULL, *dstname = NULL;
  9. pipi_image_t *img, *newimg, *tmp;
  10. pipi_histogram_t* histogram;
  11. int ret = 0;
  12. if(argc < 2)
  13. {
  14. fprintf(stderr, "%s: too few arguments\n", argv[0]);
  15. fprintf(stderr, "Usage: %s <src> <dest>\n", argv[0]);
  16. return EXIT_FAILURE;
  17. }
  18. srcname = argv[1];
  19. dstname = argv[2];
  20. img = pipi_load(srcname);
  21. if(!img) {
  22. fprintf(stderr, "Can't open %s for reading\n", srcname);
  23. }
  24. newimg = pipi_copy(img);
  25. pipi_free(img);
  26. tmp = pipi_copy(newimg);
  27. histogram = pipi_new_histogram();
  28. pipi_get_image_histogram(tmp, histogram, PIPI_COLOR_R|PIPI_COLOR_G|PIPI_COLOR_B);
  29. pipi_render_histogram(tmp, histogram, PIPI_COLOR_R|PIPI_COLOR_G|PIPI_COLOR_B);
  30. pipi_save(tmp, dstname);
  31. pipi_free(newimg);
  32. return ret;
  33. }