25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

histogram.c 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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, *tmp;
  11. pipi_histogram_t* histogram;
  12. int ret = 0;
  13. if(argc < 2)
  14. {
  15. fprintf(stderr, "%s: too few arguments\n", argv[0]);
  16. fprintf(stderr, "Usage: %s <src> <dest>\n", argv[0]);
  17. return EXIT_FAILURE;
  18. }
  19. srcname = argv[1];
  20. dstname = argv[2];
  21. img = pipi_load(srcname);
  22. if(!img) {
  23. fprintf(stderr, "Can't open %s for reading\n", srcname);
  24. }
  25. newimg = pipi_copy(img);
  26. pipi_free(img);
  27. tmp = pipi_copy(newimg);
  28. histogram = pipi_new_histogram();
  29. pipi_get_image_histogram(tmp, histogram, PIPI_COLOR_R|PIPI_COLOR_G|PIPI_COLOR_B);
  30. pipi_render_histogram(tmp, histogram, PIPI_COLOR_R|PIPI_COLOR_G|PIPI_COLOR_B);
  31. pipi_save(tmp, dstname);
  32. pipi_free(newimg);
  33. return ret;
  34. }