|
- /*
- * libpipi Proper image processing implementation library
- * Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
- * All Rights Reserved
- *
- * $Id$
- *
- * This library is free software. It comes without any warranty, to
- * the extent permitted by applicable law. You can redistribute it
- * and/or modify it under the terms of the Do What The Fuck You Want
- * To Public License, Version 2, as published by Sam Hocevar. See
- * http://sam.zoy.org/wtfpl/COPYING for more details.
- */
-
- /*
- * codec.c: image I/O functions
- */
-
- #include "config.h"
- #include "common.h"
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "pipi.h"
- #include "pipi_internals.h"
-
- pipi_image_t *pipi_load(char const *name)
- {
- if(!strncmp(name, "pipi:", 5))
- return pipi_load_stock(name + 5);
-
- #if USE_IMLIB2
- return pipi_load_imlib2(name);
- #elif USE_OPENCV
- return pipi_load_opencv(name);
- #elif USE_SDL
- return pipi_load_sdl(name);
- #else
- # error "No imaging library"
- #endif
- }
-
- void pipi_free(pipi_image_t *img)
- {
- int i;
-
- for(i = 0; i < PIPI_PIXELS_MAX; i++)
- if(i != img->codec_format && img->p[i].pixels)
- free(img->p[i].pixels);
-
- if(img->codec_priv)
- #if USE_IMLIB2
- pipi_free_imlib2(img);
- #elif USE_OPENCV
- pipi_free_opencv(img);
- #elif USE_SDL
- pipi_free_sdl(img);
- #endif
-
- free(img);
- }
-
- void pipi_save(pipi_image_t *img, const char *name)
- {
- #if USE_IMLIB2
- return pipi_save_imlib2(img, name);
- #elif USE_OPENCV
- return pipi_save_opencv(img, name);
- #elif USE_SDL
- return pipi_save_sdl(img, name);
- #endif
- }
|