source: libpipi/trunk/pipi/codec.c @ 2757

Last change on this file since 2757 was 2757, checked in by Sam Hocevar, 12 years ago
  • Do not prefix stock image names with "pipi:", it's redundant.
File size: 1.6 KB
Line 
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/*
16 * codec.c: image I/O functions
17 */
18
19#include "config.h"
20#include "common.h"
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25
26#include "pipi.h"
27#include "pipi_internals.h"
28
29pipi_image_t *pipi_load(char const *name)
30{
31    if(!strncmp(name, "random:", 7) ||
32       !strncmp(name, "bayer:", 6))
33        return pipi_load_stock(name);
34
35#if USE_IMLIB2
36    return pipi_load_imlib2(name);
37#elif USE_OPENCV
38    return pipi_load_opencv(name);
39#elif USE_SDL
40    return pipi_load_sdl(name);
41#else
42#   error "No imaging library"
43#endif
44}
45
46void pipi_free(pipi_image_t *img)
47{
48    int i;
49
50    for(i = 0; i < PIPI_PIXELS_MAX; i++)
51        if(i != img->codec_format && img->p[i].pixels)
52            free(img->p[i].pixels);
53
54    if(img->codec_priv)
55#if USE_IMLIB2
56        pipi_free_imlib2(img);
57#elif USE_OPENCV
58        pipi_free_opencv(img);
59#elif USE_SDL
60        pipi_free_sdl(img);
61#endif
62
63    free(img);
64}
65
66void pipi_save(pipi_image_t *img, const char *name)
67{
68#if USE_IMLIB2
69    return pipi_save_imlib2(img, name);
70#elif USE_OPENCV
71    return pipi_save_opencv(img, name);
72#elif USE_SDL
73    return pipi_save_sdl(img, name);
74#endif
75}
76
Note: See TracBrowser for help on using the repository browser.