/*
 *  libpipi       Proper image processing implementation library
 *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
 *                All Rights Reserved
 *
 *  $Id$
 *
 *  This library is free software. It comes without any warranty, to
 *  the extent permitted by applicable law. You can redistribute it
 *  and/or modify it under the terms of the Do What The Fuck You Want
 *  To Public License, Version 2, as published by Sam Hocevar. See
 *  http://sam.zoy.org/wtfpl/COPYING for more details.
 */

/*
 *  pipi_internals.h: internal types
 */

#ifndef __PIPI_INTERNALS_H__
#define __PIPI_INTERNALS_H__

/* pipi_image_t: the image structure. This is probably going to be the most
 * complex structure in the library, but right now it only has fairly normal
 * stuff, like width and height and pointers to pixel areas. */
struct pipi_image
{
    int w, h, pitch;

    /* A list of internal image flags.
     *  wrap: should filters wrap around at edges?
     *  u8: are the image samples still 8-bit per channel? */
    int wrap, u8;

    /* Translation vectors for wrap around and tiling. */
    int wrapx1, wrapy1, wrapx2, wrapy2;

    /* List of all possible pixel formats and the last active one. */
    pipi_pixels_t p[PIPI_PIXELS_MAX];
    pipi_format_t last_modified;

    /* Private data used by the codec */
    pipi_format_t codec_format;
    void *codec_priv;
};

struct pipi_context
{
    int nimages;
    pipi_image_t *images[1024]; /* FIXME: do dynamic allocation */
};

#ifdef USE_IMLIB2
pipi_image_t *pipi_load_imlib2(const char *name);
pipi_image_t *pipi_new_imlib2(int width, int height);
void pipi_free_imlib2(pipi_image_t *img);
void pipi_save_imlib2(pipi_image_t *img, const char *name);
#endif

#ifdef USE_OPENCV
pipi_image_t *pipi_load_opencv(const char *name);
pipi_image_t *pipi_new_opencv(int width, int height);
void pipi_free_opencv(pipi_image_t *img);
void pipi_save_opencv(pipi_image_t *img, const char *name);
#endif

#ifdef USE_SDL
pipi_image_t *pipi_load_sdl(const char *name);
pipi_image_t *pipi_new_sdl(int width, int height);
void pipi_free_sdl(pipi_image_t *img);
void pipi_save_sdl(pipi_image_t *img, const char *name);
#endif

#endif /* __PIPI_INTERNALS_H__ */