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
RevLine 
[2261]1/*
[2844]2 *  libpipi       Pathetic image processing interface library
[2261]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
[2695]19#include "config.h"
20
[2261]21#include <stdio.h>
22#include <stdlib.h>
[2695]23#include <string.h>
[2261]24
25#include "pipi.h"
26#include "pipi_internals.h"
27
[2695]28pipi_image_t *pipi_load(char const *name)
[2261]29{
[2837]30    pipi_image_t *ret = NULL;
31
[2757]32    if(!strncmp(name, "random:", 7) ||
[2759]33       !strncmp(name, "ediff:", 6) ||
[2767]34       !strncmp(name, "halftone:", 6) ||
[2757]35       !strncmp(name, "bayer:", 6))
[2837]36        ret = pipi_load_stock(name);
[2695]37
[2842]38    if(!ret)
39        ret = pipi_load_oric(name);
40
[2632]41#if USE_IMLIB2
[2837]42    if(!ret)
43        ret = pipi_load_imlib2(name);
[2261]44#endif
[2837]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
[2840]53#if USE_GDI
54    if(!ret)
55        ret = pipi_load_gdi(name);
56#endif
[2897]57#if USE_COCOA
58    if(!ret)
59        ret = pipi_load_coreimage(name);
60#endif
[2837]61    return ret;
[2261]62}
63
64void pipi_free(pipi_image_t *img)
65{
[2629]66    int i;
[2607]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
[2631]72    if(img->codec_priv)
[2837]73        img->codec_free(img);
[2629]74
75    free(img);
[2261]76}
77
[2837]78int pipi_save(pipi_image_t *img, const char *name)
[2261]79{
[2837]80    int ret = -1;
81
[2845]82    if(ret < 0)
83        ret = pipi_save_oric(img, name);
84
[2632]85#if USE_IMLIB2
[2837]86    if(ret < 0)
87        ret = pipi_save_imlib2(img, name);
[2261]88#endif
[2837]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
[2840]97#if USE_GDI
98    if(ret < 0)
99        ret = pipi_save_gdi(img, name);
100#endif
[3018]101#if USE_COCOA
102    if(ret < 0)
103        ret = pipi_save_coreimage(img, name);
104#endif
105   
[2837]106    return ret;
[2261]107}
108
Note: See TracBrowser for help on using the repository browser.