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.
 
 
 
 
 
 

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