
//		Revamp into OO and beautification 2000, Robert

#ifndef __BMP_LIB__
#define __BMP_LIB__

#include <afxwin.h>
#include <stdio.h>

typedef struct tagBitmapDesc {		// bitmap descriptor
		int		w;					// width of bitmap
		int		sl;					// scanline width to nearest LONG (4 unsigned chars)		
		int		h;					// height of bitmap
		int		bpp;				// bits-per-pixel
		int		cc;					// colour count 
		WORD	cd;					// colour descriptor
} bitmapDesc_t;

typedef struct tagRGB {
	unsigned char	ch[3];		// r,g,b channels
} BMPRGB_t ;

class BMP {
//private:
public:
	BITMAPFILEHEADER	fileHdr;
	BITMAPINFOHEADER	infoHdr;
	unsigned char		*bmp8bpp;
	BMPRGB_t			*bmp24bpp;
	RGBQUAD				*colTable;
	bitmapDesc_t		bmpDesc ;
	unsigned char		bmpLoaded ;
	unsigned char		bmpInit ;
	FILE				*bmpPtr ;

public:
	BMP() ;
	~BMP() ;

	//--------- BMP Input functions -----------------------------------
	WORD LoadBMP( char *filename );
	WORD GetBMPDesc( bitmapDesc_t *desc );
	WORD GetBMP( unsigned char *image, RGBQUAD *cList );	// return 8bpp image + color list
	WORD GetBMP( BMPRGB_t *image );							// return 24bpp image
	//--------- BMP Output functions ----------------------------------
	WORD IniBMP( bitmapDesc_t *desc );
	WORD DefBMP( unsigned char *image, RGBQUAD *cList );
	WORD DefBMP( BMPRGB_t *image );
	WORD SaveBMP( char *filename );
	//--------- BMP Misc functions ------------------------------------
	WORD FreeBMP();
	WORD FormatImage( unsigned char *image );
	WORD FormatImage( BMPRGB_t *image );
};

#endif //__BMP_LIB__