www.pudn.com > wavelet-vc++6.rar > CS91.cpp


// CS91.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "wavelet.h" 
#include "MainFrm.h" 
#include "waveletView.h" 
#include "CS91.h" 
#include"math.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CCS91 dialog 
 
 
CCS91::CCS91(CWnd* pParent /*=NULL*/) 
	: CDialog(CCS91::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CCS91) 
	m_outfile = _T(""); 
	N = 0; 
	//}}AFX_DATA_INIT 
} 
 
 
void CCS91::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CCS91) 
	DDX_Text(pDX, IDC_OUTFILEEDIT91, m_outfile); 
	DDX_Text(pDX, IDC_DATALENGTH, N); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CCS91, CDialog) 
	//{{AFX_MSG_MAP(CCS91) 
		// NOTE: the ClassWizard will add message map macros here 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CCS91 message handlers 
 
void CCS91::mainprogram() 
{ 
   CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->GetMainWnd(); 
   CWaveletView* pView=(CWaveletView*)pFrame->GetActiveView(); 
   CDC* dc=pView->GetDC(); 
   CFile output; 
   CPen pen(PS_SOLID,2,RGB(250,200,0)); 
   CPen* pOldPen; 
   int j; 
   float *image; 
   CFileException e; 
   image=new float[N*sizeof(float)]; 
   if(!image) 
   { 
	   AfxMessageBox("Memory Error!"); 
	   return; 
   } 
   pOldPen=dc->SelectObject(&pen); 
   dc->TextOut(200,0,"Using the MFC Library!",22); 
   if(!output.Open(m_outfile,CFile::modeCreate|CFile::modeWrite,&e)) 
     { 
      AfxMessageBox("打不开文件!"); 
       return; 
	} 
   for(j=0;jMoveTo(200,300); 
   for(j=0;jLineTo(200+j,300-(int)image[j]); 
   output.Write((unsigned char*)image,sizeof(float)*N); 
   delete(image); 
   output.Close(); 
   dc->SelectObject(pOldPen); 
   dc->DeleteDC(); 
   pen.DeleteObject(); 
}