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

Last change on this file since 2607 was 2607, checked in by Sam Hocevar, 12 years ago
  • Free surfaces allocated by pipi_getpixels() in pipi_free().
File size: 1.7 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 <stdio.h>
20#include <stdlib.h>
21
22#include "config.h"
23#include "common.h"
24
25#include "pipi.h"
26#include "pipi_internals.h"
27
28pipi_image_t *pipi_load(const char *name)
29{
30#if USE_SDL
31    return pipi_load_sdl(name);
32#elif USE_IMLIB2
33    return pipi_load_imlib2(name);
34#elif USE_OPENCV
35    return pipi_load_opencv(name);
36#else
37#   error "No imaging library"
38#endif
39}
40
41pipi_image_t *pipi_new(int width, int height)
42{
43#if USE_SDL
44    return pipi_new_sdl(width, height);
45#elif USE_IMLIB2
46    return pipi_new_imlib2(width, height);
47#elif USE_OPENCV
48    return pipi_new_opencv(width, height);
49#endif
50}
51
52void pipi_free(pipi_image_t *img)
53{
54    unsigned int i;
55
56    for(i = 0; i < PIPI_PIXELS_MAX; i++)
57        if(i != img->codec_format && img->p[i].pixels)
58            free(img->p[i].pixels);
59
60#if USE_SDL
61    return pipi_free_sdl(img);
62#elif USE_IMLIB2
63    return pipi_free_imlib2(img);
64#elif USE_OPENCV
65    return pipi_free_opencv(img);
66#endif
67}
68
69void pipi_save(pipi_image_t *img, const char *name)
70{
71#if USE_SDL
72    return pipi_save_sdl(img, name);
73#elif USE_IMLIB2
74    return pipi_save_imlib2(img, name);
75#elif USE_OPENCV
76    return pipi_save_opencv(img, name);
77#endif
78}
79
Note: See TracBrowser for help on using the repository browser.