/* 
 * Thomas Pantzer: rle_bits.h, v0.1b  10.8.99 19:1 
 * 
 * 
 * Copyright 1999 by Thomas Pantzer
 * 
 * Permission to use, copy, modify, and distribute this software for noncommercial 
 * use and without fee is hereby granted, provided that the above copyright notice 
 * appear in all copies and that both that copyright notice and this permission 
 * notice appear in supporting documentation, and that the name of the Author not be 
 * used in advertising or publicity pertaining to distribution of the software 
 * without specific, written prior permission. The Author makes no representations about
 * the suitability of this software for any purpose.  It is provided "as is" 
 * without expressed or implied warranty. 
 * 
 * 
 * pantec@isys2.informatik.uni-leipzig.de   (Thomas Pantzer) 
 * 
 */



#ifndef RLE_BITS_H
#define RLE_BITS_H



typedef struct {
		unsigned char r,g,b;
               } t_color;


typedef  struct {
	         t_color Color;
	         unsigned char Pixel;
                 unsigned long Len;
               } t_rle_pixel;




class t_rle_object {
public:
	void Init(void);
	void Done(void);
	
//	void WriteToFile(char *filename, Pixmap *pixmap);
//	void WriteToFile(char *filename, XImage *ximage);

	void WriteHeader(int fd, int w, int h, t_color *Map); // 8bit pseudo
	void WriteHeader(int fd, int w, int h, int depth);    // 16..32bit true
	void WritePixel(unsigned char pix);
	void WritePixel(unsigned short pix);
	void WritePixel(unsigned int pix);
	void Sync();
	
	char ReadHeader(int &width, int &height); 
	char ReadPixel(); 
};


extern void rle_save_pixel(int fd, unsigned char C);
extern void rle_save_3dpixel(int fd, t_color *c);
extern void rle_save_header(int fd, int width, int height, t_color *map);
extern char rle_get_header(int fd, int &width, int &height);
extern char rle_get_pixel(int fd, unsigned char &C);
extern void rle_sync(int fd);
extern void rle_init();
extern void rle_done();


#ifdef MAIN_G
#define vextern
#else
#define vextern extern
#endif

vextern t_color *rle_Colormap;
vextern t_color *rle_Savemap;

vextern unsigned char *LINE;
vextern unsigned char *READLN;
vextern int read_ptr;
vextern int line_ptr;
vextern unsigned char ncolors_read;

vextern t_rle_pixel Last;

#undef vextern

#endif
