/*
 *  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.h: the full libpipi public API
 */

#ifndef __PIPI_H__
#define __PIPI_H__

#include <stdio.h>

#ifdef __cplusplus
extern "C"
{
#endif

/* pipi_scan_t: this enum is a list of all possible scanning methods when
 * parsing an image’s pixels. Not all functions support all scanning paths. */
typedef enum
{
    PIPI_SCAN_RASTER = 0,
    PIPI_SCAN_SERPENTINE = 1
}
pipi_scan_t;

/* pipi_format_t: this enum is a list of all possible pixel formats for
 * our internal images. RGBA32 is the most usual format when an image has
 * just been loaded, but RGBA_F is a lot better for complex operations. */
typedef enum
{
    PIPI_PIXELS_UNINITIALISED = -1,

    PIPI_PIXELS_RGBA32 = 0,
    PIPI_PIXELS_BGR24 = 1,
    PIPI_PIXELS_RGBA_F = 2,
    PIPI_PIXELS_Y_F = 3,

    PIPI_PIXELS_MAX = 4
}
pipi_format_t;

/* pipi_pixels_t: this structure stores a pixel view of an image. */
typedef struct
{
    void *pixels;
    int w, h, pitch, bpp;
    size_t bytes;
}
pipi_pixels_t;

/* pipi_image_t: the main image type */
typedef struct pipi_image pipi_image_t;

/* pipi_context_t: the processing stack */
typedef struct pipi_context pipi_context_t;


extern pipi_context_t *pipi_create_context(void);
extern void pipi_destroy_context(pipi_context_t *);
extern int pipi_command(pipi_context_t *, char const *, ...);

extern pipi_image_t *pipi_load(char const *);
extern pipi_image_t *pipi_load_stock(char const *);
extern pipi_image_t *pipi_new(int, int);
extern pipi_image_t *pipi_copy(pipi_image_t *);
extern void pipi_free(pipi_image_t *);
extern void pipi_save(pipi_image_t *, const char *);

extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);

extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);

extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);

extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);

extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
                                            float, float, float, float);
extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
extern pipi_image_t *pipi_autocontrast(pipi_image_t *);

extern int pipi_flood_fill(pipi_image_t *,
                           int, int, float, float, float, float);

extern pipi_image_t *pipi_dither_floydsteinberg(pipi_image_t *, pipi_scan_t);
extern pipi_image_t *pipi_dither_jajuni(pipi_image_t *, pipi_scan_t);
extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
extern pipi_image_t *pipi_dither_random(pipi_image_t *);
extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
extern void pipi_dither_24to16(pipi_image_t *);

#ifdef __cplusplus
}
#endif

#endif /* __PIPI_H__ */