www.pudn.com > ±ÏÒµÁôÄî²á.rar > Jpeg.h


#include "MidDib.h" 
 
class CJpeg   
{ 
public: 
	CJpeg(); 
	CJpeg(CMidDib *pDib); 
	virtual ~CJpeg(); 
 
 
public: 
	CMidDib * GetDib() 
	{ 
		return m_pDib; 
	} 
	BOOL SetDib(CMidDib *pDib) 
	{ 
		if (pDib == NULL) 
			return FALSE; 
 
		if (m_pDib != NULL) 
			delete m_pDib; 
 
		m_pDib = pDib->Clone(); 
 
		return (m_pDib != NULL); 
	} 
	BOOL Load(LPCSTR lpstrFileName); 
	BOOL Save(LPCSTR lpstrFileName,  
			  CMidDib* pDib = NULL, 
			  BOOL bColor = TRUE, 
			  int nQuality = 75); 
	CString GetErrorString(); 
 
private: 
	BYTE* ReadJPEGFile(LPCSTR lpstrFileName, UINT *uWidth, UINT *uHeight); 
	BOOL WriteJPEGFile(LPCTSTR lpstrFileName,	 
					   BYTE *dataBuf,		 
					   UINT width,		 
					   UINT height,			 
					   BOOL color,		 
											 
    				   int quality);	 
 
	BYTE* MakeDwordAlign(BYTE *dataBuf,		 
						 UINT widthPix,			 
						 UINT height,			 
						 UINT *uiOutWidthBytes); 
 
 
	void FreeBuffer(BYTE *Buffer); 
 
	BYTE *ClearDwordAlign(BYTE *inBuf,			 
						UINT widthPix,			 
						UINT widthBytes,		 
						UINT height); 
	BOOL VertFlipBuf(BYTE * inbuf,					 
				   UINT widthBytes,						 
				   UINT height);						 
	BOOL BGRFromRGB(BYTE *buf,						 
					UINT widthPix,							 
					UINT height);							 
 
	CString m_strJPEGError; 
 
private: 
	CMidDib*	m_pDib; 
};