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.
 
 
 
 
 
 

79 satır
1.7 KiB

  1. /*
  2. * libpipi Proper image processing implementation library
  3. * Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. /*
  15. * codec.c: image I/O functions
  16. */
  17. #include "config.h"
  18. #include "common.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include "pipi.h"
  23. #include "pipi_internals.h"
  24. pipi_image_t *pipi_load(char const *name)
  25. {
  26. if(!strncmp(name, "random:", 7) ||
  27. !strncmp(name, "ediff:", 6) ||
  28. !strncmp(name, "halftone:", 6) ||
  29. !strncmp(name, "bayer:", 6))
  30. return pipi_load_stock(name);
  31. #if USE_IMLIB2
  32. return pipi_load_imlib2(name);
  33. #elif USE_OPENCV
  34. return pipi_load_opencv(name);
  35. #elif USE_SDL
  36. return pipi_load_sdl(name);
  37. #else
  38. # error "No imaging library"
  39. #endif
  40. }
  41. void pipi_free(pipi_image_t *img)
  42. {
  43. int i;
  44. for(i = 0; i < PIPI_PIXELS_MAX; i++)
  45. if(i != img->codec_format && img->p[i].pixels)
  46. free(img->p[i].pixels);
  47. if(img->codec_priv)
  48. #if USE_IMLIB2
  49. pipi_free_imlib2(img);
  50. #elif USE_OPENCV
  51. pipi_free_opencv(img);
  52. #elif USE_SDL
  53. pipi_free_sdl(img);
  54. #endif
  55. free(img);
  56. }
  57. void pipi_save(pipi_image_t *img, const char *name)
  58. {
  59. #if USE_IMLIB2
  60. return pipi_save_imlib2(img, name);
  61. #elif USE_OPENCV
  62. return pipi_save_opencv(img, name);
  63. #elif USE_SDL
  64. return pipi_save_sdl(img, name);
  65. #endif
  66. }