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.
 
 
 
 
 
 

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