#ifndef _IMAGE_H_
# define _IMAGE_H_
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <errno.h>
# include <config.h>
# include "raster.h"
# define IMAGE_CMYK -4
# define IMAGE_CMY -3
# define IMAGE_BLACK -1
# define IMAGE_WHITE 1
# define IMAGE_RGB 3
# define IMAGE_RGB_CMYK 4
# define TILE_SIZE 256
# define TILE_MINIMUM 10
#ifndef max
# define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef abs
# define abs(a) ((a) < 0 ? -(a) : (a))
#endif
typedef unsigned char ib_t;
typedef struct ic_str
{
struct ic_str *prev,
*next;
void *tile;
ib_t *pixels;
} ic_t;
typedef struct
{
int dirty;
long pos;
ic_t *ic;
} itile_t;
typedef struct
{
int colorspace;
unsigned xsize,
ysize,
xppi,
yppi,
num_ics,
max_ics;
itile_t **tiles;
ic_t *first,
*last;
FILE *cachefile;
char cachename[256];
} image_t;
typedef struct
{
image_t *img;
unsigned xorig,
yorig,
width,
height,
depth,
rotated,
xsize,
ysize,
xmax,
ymax,
xmod,
ymod;
int xstep,
xincr,
instep,
inincr,
ystep,
yincr,
row;
ib_t *rows[2],
*in;
} izoom_t;
extern image_t *ImageOpen(char *filename, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern void ImageClose(image_t *img);
extern void ImageSetColorSpace(cups_cspace_t cs);
extern void ImageSetMaxTiles(image_t *img, int max_tiles);
extern void ImageSetProfile(float d, float g, float matrix[3][3]);
#define ImageGetDepth(img) ((img)->colorspace < 0 ? -(img)->colorspace : (img)->colorspace)
extern int ImageGetCol(image_t *img, int x, int y, int height, ib_t *pixels);
extern int ImageGetRow(image_t *img, int x, int y, int width, ib_t *pixels);
extern int ImagePutCol(image_t *img, int x, int y, int height, const ib_t *pixels);
extern int ImagePutRow(image_t *img, int x, int y, int width, const ib_t *pixels);
extern int ImageReadBMP(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadFPX(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadGIF(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadJPEG(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadPIX(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadPNG(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadPNM(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadPhotoCD(image_t *img, FILE *fp, int primary,
int secondary, int saturation, int hue,
const ib_t *lut);
extern int ImageReadSGI(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern int ImageReadSunRaster(image_t *img, FILE *fp, int primary,
int secondary, int saturation, int hue,
const ib_t *lut);
extern int ImageReadTIFF(image_t *img, FILE *fp, int primary, int secondary,
int saturation, int hue, const ib_t *lut);
extern void ImageWhiteToWhite(const ib_t *in, ib_t *out, int count);
extern void ImageWhiteToRGB(const ib_t *in, ib_t *out, int count);
extern void ImageWhiteToBlack(const ib_t *in, ib_t *out, int count);
extern void ImageWhiteToCMY(const ib_t *in, ib_t *out, int count);
extern void ImageWhiteToCMYK(const ib_t *in, ib_t *out, int count);
extern void ImageRGBToWhite(const ib_t *in, ib_t *out, int count);
extern void ImageRGBToRGB(const ib_t *in, ib_t *out, int count);
extern void ImageRGBToBlack(const ib_t *in, ib_t *out, int count);
extern void ImageRGBToCMY(const ib_t *in, ib_t *out, int count);
extern void ImageRGBToCMYK(const ib_t *in, ib_t *out, int count);
extern void ImageCMYKToWhite(const ib_t *in, ib_t *out, int count);
extern void ImageCMYKToRGB(const ib_t *in, ib_t *out, int count);
extern void ImageCMYKToBlack(const ib_t *in, ib_t *out, int count);
extern void ImageCMYKToCMY(const ib_t *in, ib_t *out, int count);
extern void ImageCMYKToCMYK(const ib_t *in, ib_t *out, int count);
extern void ImageRGBAdjust(ib_t *pixels, int count, int saturation, int hue);
extern void ImageLut(ib_t *pixels, int count, const ib_t *lut);
extern izoom_t *ImageZoomAlloc(image_t *img, int x0, int y0, int x1, int y1,
int xsize, int ysize, int rotated);
extern void ImageZoomFill(izoom_t *z, int iy);
extern void ImageZoomQFill(izoom_t *z, int iy);
extern void ImageZoomFree(izoom_t *z);
#endif