/* * libpipi Proper image processing implementation library * Copyright (c) 2004-2008 Sam Hocevar * 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 #include #include #include "pipi.h" #include "pipi_internals.h" pipi_image_t *pipi_load(char const *name) { if(!strncmp(name, "random:", 7) || !strncmp(name, "ediff:", 6) || !strncmp(name, "halftone:", 6) || !strncmp(name, "bayer:", 6)) return pipi_load_stock(name); #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 }