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

Last change on this file since 3018 was 3018, checked in by Jean-Yves Lamoureux, 12 years ago
  • Finally made the CoreImage? save function available
  • Removed annoying xcode project files from svn
File size: 2.1 KB
Line 
1/*
2 *  libpipi       Pathetic image processing interface 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
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include "pipi.h"
26#include "pipi_internals.h"
27
28pipi_image_t *pipi_load(char const *name)
29{
30    pipi_image_t *ret = NULL;
31
32    if(!strncmp(name, "random:", 7) ||
33       !strncmp(name, "ediff:", 6) ||
34       !strncmp(name, "halftone:", 6) ||
35       !strncmp(name, "bayer:", 6))
36        ret = pipi_load_stock(name);
37
38    if(!ret)
39        ret = pipi_load_oric(name);
40
41#if USE_IMLIB2
42    if(!ret)
43        ret = pipi_load_imlib2(name);
44#endif
45#if USE_OPENCV
46    if(!ret)
47        ret = pipi_load_opencv(name);
48#endif
49#if USE_SDL
50    if(!ret)
51        ret = pipi_load_sdl(name);
52#endif
53#if USE_GDI
54    if(!ret)
55        ret = pipi_load_gdi(name);
56#endif
57#if USE_COCOA
58    if(!ret)
59        ret = pipi_load_coreimage(name);
60#endif
61    return ret;
62}
63
64void pipi_free(pipi_image_t *img)
65{
66    int i;
67
68    for(i = 0; i < PIPI_PIXELS_MAX; i++)
69        if(i != img->codec_format && img->p[i].pixels)
70            free(img->p[i].pixels);
71
72    if(img->codec_priv)
73        img->codec_free(img);
74
75    free(img);
76}
77
78int pipi_save(pipi_image_t *img, const char *name)
79{
80    int ret = -1;
81
82    if(ret < 0)
83        ret = pipi_save_oric(img, name);
84
85#if USE_IMLIB2
86    if(ret < 0)
87        ret = pipi_save_imlib2(img, name);
88#endif
89#if USE_OPENCV
90    if(ret < 0)
91        ret = pipi_save_opencv(img, name);
92#endif
93#if USE_SDL
94    if(ret < 0)
95        ret = pipi_save_sdl(img, name);
96#endif
97#if USE_GDI
98    if(ret < 0)
99        ret = pipi_save_gdi(img, name);
100#endif
101#if USE_COCOA
102    if(ret < 0)
103        ret = pipi_save_coreimage(img, name);
104#endif
105   
106    return ret;
107}
108
Note: See TracBrowser for help on using the repository browser.