www.pudn.com > RSImageManger.rar > GIFFILE.H


//////////////////////////////////////////////////////////////////////////////// 
// 
//	GIFFile - A C++ class to allow reading and writing of GIF Images 
// 
//	It is based on code from Programming for Graphics Files	by John Levine 
// 
//	This is free to use and modify provided proper credit is given 
// 
//	This reads GIF 87a and 89a, writes only 87a. 
//	This writes only 8-bit GIF files. 256 colors. 
//	You provide the palette and the palettized image.  
//	This does not do quantization. 
// 
// 
// use : 
// 
//	Reading: 
// 
//	GIFFile theGifObject; 
// 
//	BYTE * buf; 
//	buf=theGifObject.GIFReadFileToRGB(path,&width,&height); 
// 
//	if (buf!=NULL) { 
//		// you now have a buffer of width * height RGB pixels 
//		// do whatever you like with it 
//	}	else { 
//		// error text 
//		AfxMessageBox(theGifObject.m_GIFErrorText); 
//	} 
// 
//	//delete the buffer when you're done 
//	delete [] buf; 
// 
/////// 
// 
//	Writing : 
// 
//	GIFFile theGifThing; 
//	 
//	if (!theGifThing.GIFWriteFileFrom256Color(buffer,	// BYTE * of the 256-color buffer 
//							filename,					// name to save as 
//							m_width,					// pixels 
//							m_height,					// rows 
//							0,							// background color 
//							red, green, blue)) {		// arrays of 256 ints each that represent the 
//														// 256-color palette for this image. 
//		//Error! 
//		AfxMessageBox(theGifThing.m_GIFErrorText); 
//	} else { 
//		// success! 
//	} 
// 
//////////////////////////////////////////////////////////////////////////////// 
 
#ifndef GIFHDRH 
#define GIFHDRH 
 
////////// 
// 
// 
 
class GIFFile  
{ 
public: 
	GIFFile(); 
	~GIFFile(); 
 
public: 
	CString m_GIFErrorText; 
 
public: 
 
	// write a file 
	BOOL GIFWriteFileFrom256Color(BYTE  * buf, 
							CString name, 
							int GWidth,  
							int GHeight, 
							int BackGround, 
							int Red[], int Green[], int Blue[]); 
 
	// read to RGB 
	BYTE * GIFReadFileToRGB(CString path,  
							UINT *width,  
							UINT *height); 
 
	// find size of file 
	void GIFGetDimensions(CString path,  
							UINT *width,  
							UINT *height); 
}; 
 
#endif