CloudDoc.cpp
资源名称:08.zip [点击查看]
上传用户:ynjin1970
上传日期:2014-10-13
资源大小:6438k
文件大小:3k
源码类别:
中间件编程
开发平台:
Visual C++
- // CloudDoc.cpp : implementation of the CCloudDoc class
- //
- #include "stdafx.h"
- #include "Cloud.h"
- #include "CloudDoc.h"
- #include "math.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CCloudDoc
- IMPLEMENT_DYNCREATE(CCloudDoc, CDocument)
- BEGIN_MESSAGE_MAP(CCloudDoc, CDocument)
- //{{AFX_MSG_MAP(CCloudDoc)
- ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
- ON_COMMAND(ID_CHANGE_BRIGHTNESS, OnChangeBrightness)
- ON_COMMAND(ID_CLOSE_FILE, OnCloseFile)
- ON_COMMAND(ID_GRAY_STRETCH, OnGrayStretch)
- ON_COMMAND(ID_CHANGE_GRAY, OnChangeGray)
- ON_COMMAND(ID_HISTOGRAM_EQUALIZE, OnHistogramEqualize)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CCloudDoc construction/destruction
- CCloudDoc::CCloudDoc()
- {
- m_Dib=NULL;
- }
- CCloudDoc::~CCloudDoc()
- {
- m_Dib=NULL;
- }
- BOOL CCloudDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- // TODO: add reinitialization code here
- // (SDI documents will reuse this document)
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCloudDoc serialization
- void CCloudDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCloudDoc diagnostics
- #ifdef _DEBUG
- void CCloudDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CCloudDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CCloudDoc commands
- void CCloudDoc::OnFileOpen()
- {
- CString FileName;
- char szFilters[]=
- "MyType Files (*.bmp)|*.bmp|jpeg (*.jpg)|*.jpg|All Files (*.*)|*.*||";
- CFileDialog fileDlg (TRUE, "bmp", "*.bmp",
- OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, szFilters, NULL);
- CDib* t_Dib=NULL;
- if(fileDlg.DoModal()==IDOK)
- {
- FileName=fileDlg.GetPathName();
- if(m_Dib)
- {
- CDib* t_Dib=m_Dib;
- }
- m_Dib=new CDib();
- delete t_Dib;
- LPSTR lpfileName=(LPSTR)((LPCSTR)FileName);
- m_Dib->LoadDIB(lpfileName);
- UpdateAllViews(NULL);
- }
- }
- void CCloudDoc::OnChangeBrightness()
- {
- if(m_Dib)
- {
- int bitCount=m_Dib->bmpInfo->bmiHeader.biBitCount;
- if(bitCount<24)
- {
- AfxMessageBox("只能改变真彩色图像");
- return;
- }
- m_Dib->OnChangeBrightness(1,30.0);
- UpdateAllViews(NULL);
- }
- }
- void CCloudDoc::OnCloseFile()
- {
- UpdateAllViews(NULL);
- }
- void CCloudDoc::OnGrayStretch()
- {
- if(m_Dib)
- {
- int bitCount=m_Dib->bmpInfo->bmiHeader.biBitCount;
- if(bitCount<24)
- {
- AfxMessageBox("只能改变真彩色图像");
- return;
- }
- m_Dib->OnGrayStretch(20,200,0,230);
- UpdateAllViews(NULL);
- }
- }
- void CCloudDoc::OnChangeGray()
- {
- if(m_Dib)
- {
- int bitCount=m_Dib->bmpInfo->bmiHeader.biBitCount;
- if(bitCount<24)
- {
- AfxMessageBox("只能改变真彩色图像");
- return;
- }
- m_Dib->OnChangeToGray();
- UpdateAllViews(NULL);
- }
- }
- void CCloudDoc::OnHistogramEqualize()
- {
- if(m_Dib)
- {
- int bitCount=m_Dib->bmpInfo->bmiHeader.biBitCount;
- if(bitCount<24)
- {
- AfxMessageBox("只能改变真彩色图像");
- return;
- }
- m_Dib->OnHistogramEqualize();
- UpdateAllViews(NULL);
- }
- }