#ifndef _QUANT_H
#define _QUANT_H

#include "color.h"


#define MAX_GRAD   64
#define MAX_COLOR  256
#define MAX_REQ    20

#define FILE_BMP      1
#define FILE_LBM      2
#define FILE_UNKNOWN  3
#define FILE_DIR      4
#define FILE_LS       5


// list types
#define CTYPE_CLIST   1
#define CTYPE_OTREE   2


typedef unsigned char u_char;
typedef unsigned long u_long;


typedef struct {
	float r1, g1, b1;
	float r2, g2, b2;
} colorCube_t;



typedef struct {
	float r, g, b;
} cmapColor_t;


typedef struct {
	int gradCount;
	int colorCount;
	cmapColor_t **colors;
} cmap_t;


extern char  basedir[];
extern char  cmapname[];


// required colors and where they go

typedef struct {
    float r, g, b;
	int   index;
} cmapReq_t;



// main.c
void  Error(char *fmt, ...);
char *ggets(char *str, int len, FILE *f);
char *Sys_Argv(int i);
char *Sys_BaseDir(void);
char *Sys_Base(char *str);
int   Sys_CheckParm(char *parm);
void  Sys_SetBaseDir(char *str);

// median.c
// void Median_Reduce(colorList_t *clist, int reduce);
void Median_Reduce(colorList_t *clist, int depth, int useWeight);

// cmap.c
void Cmap_Load(cmap_t *cmap, char *pal_nm, char *cmap_nm);
void Cmap_Create(colorList_t *clist, cmap_t *cmap);
void Cmap_Reduce(cmap_t *cmap, colorList_t *pal);
void Cmap_Write(colorList_t *pal, cmap_t *cmap, char *dest);
void RGB_To_HSV(float r, float g, float b, float *h, float *s, float *v);

// cmap2.c
void Cmap2_Create(colorList_t *clist, cmap_t *cmap);
void Cmap2_CreateNone(colorList_t *clist, cmap_t *cmap);


// lump.c
int  Lump_FileType(char *file_nm);
void LoadMiptex(void *clist, char *file_nm, int sx, int sy, int w, int h, int fileWeight, int type);


// brute.c
void Brute_Reduce(colorList_t *clist, int reduce);

//loaddir.c
int LoadDir(void *clist, char *path, int type);


#endif