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.
 
 
 
 
 
 

72 lines
1.5 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 <stdio.h>
  18. #include <stdlib.h>
  19. #include "config.h"
  20. #include "common.h"
  21. #include "pipi.h"
  22. #include "pipi_internals.h"
  23. pipi_image_t *pipi_load(const char *name)
  24. {
  25. #if USE_IMLIB2
  26. return pipi_load_imlib2(name);
  27. #elif USE_OPENCV
  28. return pipi_load_opencv(name);
  29. #elif USE_SDL
  30. return pipi_load_sdl(name);
  31. #else
  32. # error "No imaging library"
  33. #endif
  34. }
  35. void pipi_free(pipi_image_t *img)
  36. {
  37. int i;
  38. for(i = 0; i < PIPI_PIXELS_MAX; i++)
  39. if(i != img->codec_format && img->p[i].pixels)
  40. free(img->p[i].pixels);
  41. if(img->codec_priv)
  42. #if USE_IMLIB2
  43. pipi_free_imlib2(img);
  44. #elif USE_OPENCV
  45. pipi_free_opencv(img);
  46. #elif USE_SDL
  47. pipi_free_sdl(img);
  48. #endif
  49. free(img);
  50. }
  51. void pipi_save(pipi_image_t *img, const char *name)
  52. {
  53. #if USE_IMLIB2
  54. return pipi_save_imlib2(img, name);
  55. #elif USE_OPENCV
  56. return pipi_save_opencv(img, name);
  57. #elif USE_SDL
  58. return pipi_save_sdl(img, name);
  59. #endif
  60. }