source: libpipi/trunk/pipi/pipi.c @ 2865

Last change on this file since 2865 was 2865, checked in by Sam Hocevar, 12 years ago

pipi.c: add pipi_get_version().

File size: 2.0 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 * pipi.c: core library routines
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
29/** \brief Return the \e libpipi version.
30 *
31 *  Return a read-only string with the \e libpipi version information.
32 *
33 *  This function never fails.
34 *
35 *  \return The \e libpipi version information.
36 */
37char const * pipi_get_version(void)
38{
39    return PACKAGE_VERSION;
40}
41
42/*
43static int init = 0;
44
45void _pipi_init(void)
46{
47    if(init)
48        return;
49
50    _pipi_init_pixels();
51}
52*/
53
54pipi_image_t *pipi_new(int w, int h)
55{
56    pipi_image_t *img;
57
58    img = malloc(sizeof(pipi_image_t));
59    memset(img, 0, sizeof(pipi_image_t));
60
61    img->w = w;
62    img->h = h;
63    img->last_modified = PIPI_PIXELS_UNINITIALISED;
64    img->codec_format = PIPI_PIXELS_UNINITIALISED;
65
66    img->wrap = 0;
67    img->u8 = 1;
68
69    return img;
70}
71
72pipi_image_t *pipi_copy(pipi_image_t *src)
73{
74    pipi_image_t *dst = pipi_new(src->w, src->h);
75
76    /* Copy properties */
77    dst->wrap = src->wrap;
78    dst->u8 = src->u8;
79
80    /* Copy pixels, if any */
81    if(src->last_modified != PIPI_PIXELS_UNINITIALISED)
82    {
83        pipi_pixels_t *srcp, *dstp;
84
85        srcp = &src->p[src->last_modified];
86        dstp = &dst->p[src->last_modified];
87
88        memcpy(dstp, srcp, sizeof(pipi_pixels_t));
89        dstp->pixels = malloc(dstp->bytes);
90        memcpy(dstp->pixels, srcp->pixels, dstp->bytes);
91
92        dst->last_modified = src->last_modified;
93    }
94
95    return dst;
96}
97
Note: See TracBrowser for help on using the repository browser.