|
- /*
- * 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 <stdio.h>
- #include <stdlib.h>
-
- #include "config.h"
- #include "common.h"
-
- #include "pipi.h"
- #include "pipi_internals.h"
-
- pipi_image_t *pipi_load(const char *name)
- {
- #if USE_SDL
- return pipi_load_sdl(name);
- #elif USE_IMLIB2
- return pipi_load_imlib2(name);
- #elif USE_OPENCV
- return pipi_load_opencv(name);
- #else
- # error "No imaging library"
- #endif
- }
-
- pipi_image_t *pipi_new(int width, int height)
- {
- #if USE_SDL
- return pipi_new_sdl(width, height);
- #elif USE_IMLIB2
- return pipi_new_imlib2(width, height);
- #elif USE_OPENCV
- return pipi_new_opencv(width, height);
- #endif
- }
-
- pipi_image_t *pipi_copy(pipi_image_t const *img)
- {
- pipi_image_t *dst;
- int x, y;
- dst = pipi_new(img->width, img->height);
- for(y = 0; y < img->height; y++)
- {
- for(x = 0; x < img->width; x++)
- {
- double r, g, b;
- pipi_getpixel(img, x, y, &r, &g, &b);
- pipi_setpixel(dst, x, y, r, g, b);
- }
- }
- return dst;
- }
-
- void pipi_free(pipi_image_t *img)
- {
- #if USE_SDL
- return pipi_free_sdl(img);
- #elif USE_IMLIB2
- return pipi_free_imlib2(img);
- #elif USE_OPENCV
- return pipi_free_opencv(img);
- #endif
- }
-
- void pipi_save(pipi_image_t *img, const char *name)
- {
- #if USE_SDL
- return pipi_save_sdl(img, name);
- #elif USE_IMLIB2
- return pipi_save_imlib2(img, name);
- #elif USE_OPENCV
- return pipi_save_opencv(img, name);
- #endif
- }
|