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.
 
 
 
 
 
 

76 lines
1.6 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, "pipi:", 5))
  27. return pipi_load_stock(name + 5);
  28. #if USE_IMLIB2
  29. return pipi_load_imlib2(name);
  30. #elif USE_OPENCV
  31. return pipi_load_opencv(name);
  32. #elif USE_SDL
  33. return pipi_load_sdl(name);
  34. #else
  35. # error "No imaging library"
  36. #endif
  37. }
  38. void pipi_free(pipi_image_t *img)
  39. {
  40. int i;
  41. for(i = 0; i < PIPI_PIXELS_MAX; i++)
  42. if(i != img->codec_format && img->p[i].pixels)
  43. free(img->p[i].pixels);
  44. if(img->codec_priv)
  45. #if USE_IMLIB2
  46. pipi_free_imlib2(img);
  47. #elif USE_OPENCV
  48. pipi_free_opencv(img);
  49. #elif USE_SDL
  50. pipi_free_sdl(img);
  51. #endif
  52. free(img);
  53. }
  54. void pipi_save(pipi_image_t *img, const char *name)
  55. {
  56. #if USE_IMLIB2
  57. return pipi_save_imlib2(img, name);
  58. #elif USE_OPENCV
  59. return pipi_save_opencv(img, name);
  60. #elif USE_SDL
  61. return pipi_save_sdl(img, name);
  62. #endif
  63. }