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

📄 cdib.h

📁 数字图像处理的程序
💻 H
字号:
//--------------------------------------------------------------------------
//  cdib.h
//                       All copyrights reserved by ECNU
//--------------------------------------------------------------------------
//  Abstract:
//	图像类CDIB的定义
//--------------------------------------------------------------------------
//  Hostory:
//	ver1.0.0
//--------------------------------------------------------------------------
#ifndef _CDIB_H_
#define _CDIB_H_

#include <afxwin.h>
#include <afxtempl.h>
#include <iostream>

// 色彩模型宏
#define IMG_UNDEFINED	-1
#define IMG_GRAY	     1
#define IMG_RGB		     2


//==================================================================
//	存放图像实体和属性的结构体
typedef struct _impImage {
	long w;			// 图像宽度(pixel)
	long h;			// 图像高度(pixel)
	short nbit;		// 1个像素的bit数
	short band;		// 图像的band数
	long  x_len;	// 图像转折位置(DWORD边界)
	void  **buff;	// 指向图像data的先头位置的指针
} impImage;

//==================================================================
//	24bit
typedef struct _imptype24 {
	unsigned char B;	
	unsigned char G;	
	unsigned char R;
} imptype24;

//==================================================================
//	32bit
typedef struct _imptype32 {
	unsigned char B;
	unsigned char G;
	unsigned char R;
	unsigned char A;
} imptype32;



class CDIB
{
//--------------------------------------------------------------
//  data成员
private:
    CDC *m_dc;			    // 指向内存DC的指针
    LPBITMAPINFO m_bmi;		// 指向DIB头领域的指针
    impImage *m_img;		// DIB实体领域的存取结构体
    impImage *m_lut;		// DIB调色板领域的存取结构体
    HBITMAP m_hBMP;		    // 表示DIB实体领域的句柄
    HBITMAP m_orgbmp;		// m_dc最初的BITMAP对象的backup
    int m_color_type;		// 图像对象的色空间

//--------------------------------------------------------------
//  成员函数
public:
//  构造和析构函数
    CDIB();
    virtual ~CDIB();
    int create(int w, int h, int nbit, int lut_type=0);
    
//  图像信息的取得
    CDC *getCDC()		{return this ? m_dc : NULL;}
    impImage *getDIB()		{return this ? m_img : NULL;}
    impImage *getLUT()		{return this ? m_lut: NULL;}
    BITMAPINFO *getInfo()	{return this ? m_bmi : NULL;}
    HBITMAP getHBMP()		{return this ? m_hBMP : 0;}
    int colorType()		{return this ? m_color_type : IMG_UNDEFINED;}
    

//  图像像素存取函数
    unsigned char &pix8(int x, int y);
    imptype24 &pix24(int x, int y);
    imptype32 &pix32(int x, int y);

//  调色板check函数
    BOOL isGray();

//  文件I/O函数
    int readFile(CString &filename);
    int writeFile(CString &filename);

//
     CDIB &operator=(CDIB &src); 

private:
    int freeMember();
    int copyObject(CDIB &src);
 
};
#endif // _CDIB_H_

⌨️ 快捷键说明

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