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.
 
 
 
 
 
 

91 lines
1.9 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. pipi_image_t *pipi_copy(pipi_image_t const *img)
  46. {
  47. pipi_image_t *dst;
  48. int x, y;
  49. dst = pipi_new(img->width, img->height);
  50. for(y = 0; y < img->height; y++)
  51. {
  52. for(x = 0; x < img->width; x++)
  53. {
  54. double r, g, b;
  55. pipi_getpixel(img, x, y, &r, &g, &b);
  56. pipi_setpixel(dst, x, y, r, g, b);
  57. }
  58. }
  59. return dst;
  60. }
  61. void pipi_free(pipi_image_t *img)
  62. {
  63. #if USE_SDL
  64. return pipi_free_sdl(img);
  65. #elif USE_IMLIB2
  66. return pipi_free_imlib2(img);
  67. #elif USE_OPENCV
  68. return pipi_free_opencv(img);
  69. #endif
  70. }
  71. void pipi_save(pipi_image_t *img, const char *name)
  72. {
  73. #if USE_SDL
  74. return pipi_save_sdl(img, name);
  75. #elif USE_IMLIB2
  76. return pipi_save_imlib2(img, name);
  77. #elif USE_OPENCV
  78. return pipi_save_opencv(img, name);
  79. #endif
  80. }