⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dib.h

📁 该程序实现各种小波提升分解
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////

// dib.h

#ifndef _INC_DIB
#define _INC_DIB

/* DIB constants */
#define PALVERSION   0x300

/* Dib Header Marker - used in writing DIBs to files */
#define DIB_HEADER_MARKER   ((WORD) ('M' << 8) | 'B')

/* DIB Macros*/
#define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top)

// WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.

#define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)

class CDib : public CObject
{
	DECLARE_DYNAMIC(CDib)

// Constructors
public:
	CDib();

// Attributes
protected:

	LPBITMAPINFO m_pBMI;
public:	
	CPalette* m_pPalette;
	LPBYTE m_pBits;
	LPBYTE pBits1;
	LPBYTE pBits2;
public:
	DWORD Width()     const;
	DWORD Height()    const;
	WORD  NumColors() const;
	BOOL  IsValid()   const { return (m_pBMI != NULL); }

// Operations
public:
	BOOL  Paint(HDC hDC, LPRECT lpDCRect= NULL, LPRECT lpDIBRect=NULL) const;
	HGLOBAL CopyToHandle()           const;
	DWORD Save(CFile& file)          const;
	DWORD Read(CFile& file);
	DWORD ReadFromHandle(HGLOBAL hGlobal);
	void Invalidate() { Free(); }

	virtual void Serialize(CArchive& ar);

// Implementation
public:
	virtual ~CDib();

protected:
	BOOL  CreatePalette();
	WORD  PaletteSize() const;

	void Free();
	// 逆序置乱
public:
	int GETXY_Y(int x,int y);
	int GETXY_U(int x,int y);
	int GETXY_V(int x,int y);
	int YUV_R(float Y,float U,float V);
	int YUV_G(float Y,float U,float V);
	int YUV_B(float Y,float U,float V);
	float RGB_Y(int R,int G,int B);
	float RGB_U(int R,int G,int B);
	float RGB_V(int R,int G,int B);
	void SetXYR(int x,int y,int val);
	void SetXYG(int x,int y,int val);
	void SetXYB(int x,int y,int val);
	int GetXYR(int x,int y);
	int GetXYG(int x,int y);
	int GetXYB(int x,int y);
	DWORD Save(LPCSTR filename);
	DWORD Read(LPCSTR filename);
	CDib& operator =(CDib &dib);
	void ConvertToRGB();
	void Copy(CDib& dib );


	void ToGray();
	void SetXY8(int x, int y, int val);
	int GetXY8(int x, int y);
	BOOL IsGray();
#ifdef _DEBUG
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

};

#endif //!_INC_DIB

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -