www.pudn.com > pccode_2006910124551680.rar > Bmpfile.h


 
 
#define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4) 
#define BMP_HEADERSIZE (3 * 2 + 4 * 12) 
#define BMP_BYTESPERLINE (width, bits) ((((width) * (bits) + 31) / 32) * 4) 
#define BMP_PIXELSIZE(width, height, bits) (((((width) * (bits) + 31) / 32) * 4) * height) 
 
 
class BMPFile 
{ 
public: 
	// parameters 
	CString m_errorText; 
	DWORD m_bytesRead; 
 
public: 
	void CopyToMapFile(CString filename,BYTE* pData,int width,int height,int bitcount=24); 
	BYTE* AttachMapFile(CString filename,int& width,int& height,int& bitcount,int& widthbytes); 
	BYTE* AttachMemory(LPVOID lpvMem,int& width,int& height,int& bitcount,int& widthbytes); 
	BYTE* LoadImage(CString filename,int& width,int& height,int& bitcount,int& widthbytes); 
 
	void DisplayBMP(CDC* pDC, BYTE* buffer,int width,int height,int x, int y, int dstWidth, int dstHeight); 
 
	void RGB2Gray(int width, int height, BYTE *pInput, BYTE *pOutput); 
	void Gray2RGB(int width, int height, BYTE *pInput, BYTE *pOutput); 
 
	void SaveBMP(CString fileName,		// output path 
				BYTE * buf,				// RGB buffer 
				int width,				// size 
				int height); // save as 24 bit-per-pixel bmp file 
 
	void SaveBMP(CString fileName, 			         // output path 
				BYTE * colormappedbuffer,	         // one BYTE per pixel colomapped image 
				int width, 
				int height, 
 				int bitsperpixel,			          // 1, 4, 8 
				int colors,				              // number of colors (number of RGBQUADs) 
				RGBQUAD *colormap);			          // array of RGBQUADs  
 
	BMPFile(); 
	~BMPFile(); 
};