showdataimagedoc.cpp
来自「该算法用来显示数据图像」· C++ 代码 · 共 115 行
CPP
115 行
// ShowDataImageDoc.cpp : implementation of the CShowDataImageDoc class
//
#include "stdafx.h"
#include "ShowDataImage.h"
#include "ShowDataImageDoc.h"
#include "ImageSize.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShowDataImageDoc
IMPLEMENT_DYNCREATE(CShowDataImageDoc, CDocument)
BEGIN_MESSAGE_MAP(CShowDataImageDoc, CDocument)
//{{AFX_MSG_MAP(CShowDataImageDoc)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CShowDataImageDoc construction/destruction
CShowDataImageDoc::CShowDataImageDoc()
{
// TODO: add one-time construction code here
}
CShowDataImageDoc::~CShowDataImageDoc()
{
}
BOOL CShowDataImageDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CShowDataImageDoc serialization
void CShowDataImageDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CShowDataImageDoc diagnostics
#ifdef _DEBUG
void CShowDataImageDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CShowDataImageDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CShowDataImageDoc commands
BOOL CShowDataImageDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
CImageSize opt;
if(opt.DoModal() == IDCANCEL)
return false;
nImageHeight = opt.m_Height;
nImageWidth = opt.m_Width;
DataImageFile = fopen(lpszPathName,"rb");
if(DataImageFile == NULL)
return false;
mImageData = (unsigned char*)malloc(nImageHeight*nImageWidth);
if(mImageData == NULL)
return false;
if(fread(mImageData,1,nImageHeight*nImageWidth,DataImageFile) != nImageHeight*nImageWidth)
return false;
bImageFileIsLoad = true;
return TRUE;
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?