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

Last change on this file since 2897 was 2897, checked in by Jean-Yves Lamoureux, 11 years ago
  • Added preliminary support of CoreImage? (Cocoa/Mac? OS X) Changed default hidden unicode glyph to 'x' in The Pimp to fix a compilation problem
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#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    pipi_image_t *ret = NULL;
32
33    if(!strncmp(name, "random:", 7) ||
34       !strncmp(name, "ediff:", 6) ||
35       !strncmp(name, "halftone:", 6) ||
36       !strncmp(name, "bayer:", 6))
37        ret = pipi_load_stock(name);
38
39    if(!ret)
40        ret = pipi_load_oric(name);
41
42#if USE_IMLIB2
43    if(!ret)
44        ret = pipi_load_imlib2(name);
45#endif
46#if USE_OPENCV
47    if(!ret)
48        ret = pipi_load_opencv(name);
49#endif
50#if USE_SDL
51    if(!ret)
52        ret = pipi_load_sdl(name);
53#endif
54#if USE_GDI
55    if(!ret)
56        ret = pipi_load_gdi(name);
57#endif
58#if USE_COCOA
59    if(!ret)
60        ret = pipi_load_coreimage(name);
61#endif
62    return ret;
63}
64
65void pipi_free(pipi_image_t *img)
66{
67    int i;
68
69    for(i = 0; i < PIPI_PIXELS_MAX; i++)
70        if(i != img->codec_format && img->p[i].pixels)
71            free(img->p[i].pixels);
72
73    if(img->codec_priv)
74        img->codec_free(img);
75
76    free(img);
77}
78
79int pipi_save(pipi_image_t *img, const char *name)
80{
81    int ret = -1;
82
83    if(ret < 0)
84        ret = pipi_save_oric(img, name);
85
86#if USE_IMLIB2
87    if(ret < 0)
88        ret = pipi_save_imlib2(img, name);
89#endif
90#if USE_OPENCV
91    if(ret < 0)
92        ret = pipi_save_opencv(img, name);
93#endif
94#if USE_SDL
95    if(ret < 0)
96        ret = pipi_save_sdl(img, name);
97#endif
98#if USE_GDI
99    if(ret < 0)
100        ret = pipi_save_gdi(img, name);
101#endif
102
103    return ret;
104}
105
Note: See TracBrowser for help on using the repository browser.