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

Last change on this file since 2767 was 2767, checked in by Sam Hocevar, 12 years ago
  • screen.c: add pipi_render_halftone() to create a 45-degree clustered dot halftoning pattern.
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 "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    if(!strncmp(name, "random:", 7) ||
32       !strncmp(name, "ediff:", 6) ||
33       !strncmp(name, "halftone:", 6) ||
34       !strncmp(name, "bayer:", 6))
35        return pipi_load_stock(name);
36
37#if USE_IMLIB2
38    return pipi_load_imlib2(name);
39#elif USE_OPENCV
40    return pipi_load_opencv(name);
41#elif USE_SDL
42    return pipi_load_sdl(name);
43#else
44#   error "No imaging library"
45#endif
46}
47
48void pipi_free(pipi_image_t *img)
49{
50    int i;
51
52    for(i = 0; i < PIPI_PIXELS_MAX; i++)
53        if(i != img->codec_format && img->p[i].pixels)
54            free(img->p[i].pixels);
55
56    if(img->codec_priv)
57#if USE_IMLIB2
58        pipi_free_imlib2(img);
59#elif USE_OPENCV
60        pipi_free_opencv(img);
61#elif USE_SDL
62        pipi_free_sdl(img);
63#endif
64
65    free(img);
66}
67
68void pipi_save(pipi_image_t *img, const char *name)
69{
70#if USE_IMLIB2
71    return pipi_save_imlib2(img, name);
72#elif USE_OPENCV
73    return pipi_save_opencv(img, name);
74#elif USE_SDL
75    return pipi_save_sdl(img, name);
76#endif
77}
78
Note: See TracBrowser for help on using the repository browser.