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

Last change on this file since 2709 was 2695, checked in by Sam Hocevar, 15 years ago
  • codec.c: support for stock images in pipi_load().
  • stock.c: start working on stock image generation; for instance:

pipi pipi:bayer64 -o image.png

will generate a 64x64 Bayer dithering pattern and save it to image.png.

File size: 1.6 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, "pipi:", 5))
32        return pipi_load_stock(name + 5);
33
34#if USE_IMLIB2
35    return pipi_load_imlib2(name);
36#elif USE_OPENCV
37    return pipi_load_opencv(name);
38#elif USE_SDL
39    return pipi_load_sdl(name);
40#else
41#   error "No imaging library"
42#endif
43}
44
45void pipi_free(pipi_image_t *img)
46{
47    int i;
48
49    for(i = 0; i < PIPI_PIXELS_MAX; i++)
50        if(i != img->codec_format && img->p[i].pixels)
51            free(img->p[i].pixels);
52
53    if(img->codec_priv)
54#if USE_IMLIB2
55        pipi_free_imlib2(img);
56#elif USE_OPENCV
57        pipi_free_opencv(img);
58#elif USE_SDL
59        pipi_free_sdl(img);
60#endif
61
62    free(img);
63}
64
65void pipi_save(pipi_image_t *img, const char *name)
66{
67#if USE_IMLIB2
68    return pipi_save_imlib2(img, name);
69#elif USE_OPENCV
70    return pipi_save_opencv(img, name);
71#elif USE_SDL
72    return pipi_save_sdl(img, name);
73#endif
74}
75
Note: See TracBrowser for help on using the repository browser.