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

📄 airimgdoc.cpp

📁 hough变换的代码
💻 CPP
字号:
// airImgDoc.cpp : implementation of the CAirImgDoc class
//

#include "stdafx.h"
#include "airImg.h"

#include "airImgDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAirImgDoc

IMPLEMENT_DYNCREATE(CAirImgDoc, CDocument)

BEGIN_MESSAGE_MAP(CAirImgDoc, CDocument)
	//{{AFX_MSG_MAP(CAirImgDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAirImgDoc construction/destruction

CAirImgDoc::CAirImgDoc()
{
	// TODO: add one-time construction code here

}

CAirImgDoc::~CAirImgDoc()
{
}

BOOL CAirImgDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CAirImgDoc serialization

void CAirImgDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
		BITMAPFILEHEADER BMPFileHeader;
		BITMAPINFOHEADER BMPInfoHeader;

		int BMPSize;
		int index;
		int i,j;

		ar.Read(&BMPFileHeader,sizeof(BITMAPFILEHEADER));
		ar.Read(&BMPInfoHeader,sizeof(BITMAPINFOHEADER));

		if(BMPInfoHeader.biBitCount!=24)
		{
			MessageBox(NULL,"必需是24位色图!","警告",MB_OK);
			return;
		}

		m_Width=BMPInfoHeader.biWidth;
		m_Height=BMPInfoHeader.biHeight;

		if(BMPInfoHeader.biBitCount==24)
		{
			if((m_Width*3)%4!=0)
			{
				m_LineLength=m_Width*3+(4-(m_Width*3)%4);
			}
			else
			{
				m_LineLength=m_Width*3;
			}
		}
		else
		{
			m_LineLength=m_Width*4;
		}

		BMPSize=BMPFileHeader.bfSize-BMPFileHeader.bfOffBits;
		m_ImageData=(unsigned char*)new BYTE[BMPSize];

		ar.Read(m_ImageData,BMPSize);
		unsigned char* tempImg = (unsigned char*)new BYTE[BMPSize];

		for (i=0;i<m_Height;i++)
			for (j=0;j<m_Width;j++)
			{
				index = i*m_Width*3+j*3;
				tempImg[index] = m_ImageData[index+2];
				tempImg[index+1] = m_ImageData[index+1];
				tempImg[index+2] = m_ImageData[index];
			}
		src_vlImage.vlImageCreate(RGB,m_Width,m_Height,tempImg);

		src_vlGrayImage.vlImageInit(&src_vlGrayImage, GRAY, m_Width, m_Height);
		dest_vlImage.vlImageInit(&dest_vlImage, RGB, m_Width, m_Height);
		dest_vlGrayImage.vlImageInit(&dest_vlGrayImage, GRAY, m_Width, m_Height);
		

		delete tempImg;
		
		SetTitle(GetPathName());
		UpdateAllViews(NULL);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CAirImgDoc diagnostics

#ifdef _DEBUG
void CAirImgDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CAirImgDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CAirImgDoc commands

⌨️ 快捷键说明

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