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