www.pudn.com > Success5.6.rar > 0211080239Dlg.cpp


// 0211080239Dlg.cpp : implementation file 
// 
#include 
#include 
 
#include 
#include 
 
 
#include "stdafx.h" 
#include "0211080239.h" 
#include "0211080239Dlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CMy0211080239Dlg dialog 
 
CMy0211080239Dlg::CMy0211080239Dlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CMy0211080239Dlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CMy0211080239Dlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
	 
     
 
	 
 	 
} 
 
void CMy0211080239Dlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CMy0211080239Dlg) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CMy0211080239Dlg, CDialog) 
	//{{AFX_MSG_MAP(CMy0211080239Dlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2) 
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3) 
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4) 
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6) 
//	ON_BN_CLICKED(IDC_BUTTON7, OnButton7) 
	ON_BN_CLICKED(IDC_BUTTON8, OnButton8) 
	ON_BN_CLICKED(IDC_BUTTON9, OnButton9) 
	ON_BN_CLICKED(IDC_BUTTON5, Onsave) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CMy0211080239Dlg message handlers 
 
BOOL CMy0211080239Dlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
	m_img=new BYTE[1000*1000*3]; 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
	RECT rect; 
	m_pDemoWnd=new CStaticWnd(IDC_0211080239_WND); 
	m_pDemoWnd->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rect,this,0,NULL); 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CMy0211080239Dlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CMy0211080239Dlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
void CMy0211080239Dlg::draw(int m_nhist[]) 
{ 
	    /*绘制直方图*/ 
	    int i; 
	    LONG max; 
		CPaintDC dc(this); 
		CWnd *pWnd=GetDlgItem(IDC_0211080239_WND); 
		CDC *pDC=pWnd->GetDC(); 
		pWnd->Invalidate(); 
		pWnd->UpdateWindow(); 
		pDC->Rectangle(0,0,330,330); 
		CPen *pRed=new CPen;////创建红色画笔 
		pRed->CreatePen(PS_SOLID,1,RGB(255,0,0)); 
		CPen *pPenold=pDC->SelectObject(pRed); 
		pDC->MoveTo(10,10);//坐标轴 
		pDC->LineTo(10,280);//y轴 
		pDC->LineTo(320,280);//x轴 
		 
		pDC->MoveTo(5,18);//y轴箭头 
		pDC->LineTo(10,10); 
		pDC->LineTo(15,18); 
 
		pDC->MoveTo(312,275);//x轴箭头 
		pDC->LineTo(320,280); 
		pDC->LineTo(312,285); 
     
		CString str; 
		for(i=0;i<6;i++){//坐标刻度 
			pDC->MoveTo(10+i*50,280); 
			pDC->LineTo(10+i*50,286); 
			str.Format("%d",50*i); 
			pDC->TextOut(8+i*50,288,str); 
		} 
 
		 
		for(i=0;i<256;i++) 
			if(m_nhist[i]>max)max=m_nhist[i]; 
        pDC->MoveTo(10,25); 
		pDC->LineTo(14,25); 
		str.Format("%d",max); 
		pDC->TextOut(11,26,str); 
		 
		CPen *pBlue=new CPen;//创建蓝色画笔 
		pBlue->CreatePen(PS_SOLID,1,RGB(0,0,255)); 
		pPenold=pDC->SelectObject(pBlue); 
		if(max>0) 
		{for(i=0;i<256;i++) 
			{ 
				pDC->MoveTo(i+10,280); 
				pDC->LineTo(i+10,281-(int)(m_nhist[i])*256/max); 
			} 
		} 
		pDC->SelectObject(pPenold); 
        str.Format("%s",PP); 
		pDC->TextOut(66,305,str); 
		delete pRed; 
		delete pBlue; 
 
} 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CMy0211080239Dlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
int writebmp(const char  * FileName,unsigned char *buf,int& X,int&Y) 
{ 
   BITMAPFILEHEADER	 bfheader; 
   BITMAPINFOHEADER   binfohead; 
   unsigned char *Data; 
   FILE*fp; 
   int i,j; 
 
 
   bfheader.bfType=0x4d42; 
   bfheader.bfReserved1=bfheader.bfReserved2=0; 
   bfheader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+3*X*Y; 
   bfheader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); 
 
   binfohead.biSize=sizeof(BITMAPINFOHEADER); 
   binfohead.biWidth=X; 
   binfohead.biHeight=Y; 
   binfohead.biPlanes=1; 
   binfohead.biBitCount=24; 
   binfohead.biCompression=BI_RGB; 
   binfohead.biSizeImage=3*X*Y; 
   binfohead.biXPelsPerMeter=0; 
   binfohead.biYPelsPerMeter=0; 
   binfohead.biClrUsed=0; 
   binfohead.biClrImportant=0; 
  
   fp=fopen(FileName,"wb"); 
   if(fp==NULL)  
   { 
		  AfxMessageBox("IDS_FILEOPENERR"); 
          return NULL; 
   } 
   fwrite(&bfheader,sizeof(BITMAPFILEHEADER),1,fp); 
   fwrite(&binfohead,sizeof(BITMAPINFOHEADER),1,fp); 
 
   Data=buf; 
   int foff=0; 
   if((3*X)%4!=0) 
	   foff=(4-(3*X)%4); 
   struct rgb 
   { 
	   BYTE r; 
	   BYTE g; 
	   BYTE b; 
   }; 
   rgb data; 
   if(Data==NULL) return 0; 
		for(i=Y-1;i>=0;i--) 
		{ 
			for(j=0;j24)  
        { 
          AfxMessageBox("IDS_NOT8OR24BITBMP"); 
          return NULL; 
		} 
   if(binfohead.biCompression!=0)  
        {    
         AfxMessageBox("IDS_BMPCOMPRESSED"); 
         return NULL; 
		} 
   Data=buf; 
   if(bufsize<3*X*Y) return 0; 
   if(Data==NULL) return 0; 
    
   if(binfohead.biBitCount==24)  
    { 
	   for(i=Y-1;i>=0;i--) 
        { 
		   fread(&(Data[i*X*3]),X,3,fp); 
		   if((3*X)%4!=0) 
			   fseek(fp,(4-(3*X)%4) ,SEEK_CUR ); 
        } 
    } 
   else  
   { 
	   temp=256*4; 
		Color=(RGBQUAD *)malloc(temp); 
		if (Color==NULL) return NULL; 
		fread(Color,temp,1,fp); 
 	    line=(unsigned char *) malloc(X); 
		if(line==NULL) return NULL; 
		for(i=Y-1;i>=0;i--) 
				{fread(line,X,1,fp); ///To Convert Image to Stand 
				 for(j=0;j=b)return a; 
	return b; 
} 
void CMy0211080239Dlg::OnButton1()  
{ 
	// TODO: Add your control notification handler code here 
	static BYTE img[256][256]; 
	int i,j; 
	for(i=0;i<256;i++) 
		for(j=0;j<256;j++)img[i][j]=i; 
	m_pDemoWnd->Set_GrayImage((BYTE *)img,0,0); 
	m_pDemoWnd->Invalidate(); 
} 
void CMy0211080239Dlg::OnButton2()  
{ 
	// TODO: Add your control notification handler code here 
	CFileDialog fdlg(TRUE); 
    int rtn; 
    fdlg.m_ofn.lpstrInitialDir="F:\\sample"; 
	fdlg.m_ofn.lpstrFilter="bmp文件\0*.bmp\0\0\0"; 
	fdlg.m_ofn.lpstrTitle="打开bmp文件"; 
 
	rtn=fdlg.DoModal(); 
	if(rtn==IDOK) 
	  { 
		int bufsize=1000*1000*3; 
		BYTE *img=new BYTE[bufsize]; 
		int X,Y; 
		LoadBitmapFile((LPCTSTR)fdlg.GetPathName(),img,bufsize,X,Y); 
		m_pDemoWnd->Set_Image(img,X,Y); 
		m_pDemoWnd->Invalidate(); 
		delete img; 
	  } 
 
} 
 
void CMy0211080239Dlg::OnButton3()  
{ 
	// TODO: Add your control notification handler code here 
	 
	CFileDialog fdlg(TRUE); 
    int rtn; 
    fdlg.m_ofn.lpstrInitialDir="f:\\sample"; 
	fdlg.m_ofn.lpstrFilter="bmp文件\0*.bmp\0\0\0"; 
	fdlg.m_ofn.lpstrTitle="打开bmp文件"; 
 
	rtn=fdlg.DoModal(); 
	if(rtn==IDOK) 
	  { 
		int bufsize=1000*1000*3; 
		BYTE *img=new BYTE[bufsize]; 
		int X,Y; 
		LoadBitmapFile((LPCTSTR)fdlg.GetPathName(),img,bufsize,X,Y); 
		Draw_TrueColor_Image(img,X,Y,0,0); 
		CClientDC dc(NULL); 
		//writebmp("new.bmp",img,X,Y); 
		delete img; 
	  }	 
} 
 
void ComputeHOS(int *a,int x,int y,double m4[]) 
{ 
	//计算HOS 
	double s,m,t; 
	double A; 
	int i,j,k,l; 
	for(i=y-2;i>=1;i--) 
	{ 
		for(j=1;j<=x-2;j++) 
		{    
			s=0; 
			for(k=i-1;k<=i+1;k++) 
			{ 
				for(l=j-1;l<=j+1;l++) 
				{ 
					s+=a[k*x+l]; 
				} 
			} 
			 
			m=int(s/9.+0.5); 
			A=0; 
			for(k=i-1;k<=i+1;k++) 
			{				 
				for(l=j-1;l<=j+1;l++) 
				{ 
					t=a[k*x+l]-m; 
					A=A+t*t*t*t; 
				} 
			} 
		    m4[(i*x+j)]=A/9; 
		} 
	} 
} 
 
void Computezaosheng(int *a,int x,int y,double &zs) 
{ 
	//计算噪声方差 
	double s[4],A,B,C,D; 
	double t[4]; 
	int i,j; 
	for(i=0;i<4;i++) 
		t[i]=0; 
	for(i=0;i<=9;i++) 
	{		 
		for(j=0;j<=9;j++) 
		{  
			t[0]+=a[i*x+j]; 
			t[1]+=a[(y-i-1)*x+j]; 
			t[2]+=a[i*x+x-j-1]; 
			t[3]+=a[(y-i-1)*x+x-j-1]; 
		} 
	} 
	for(i=0;i<4;i++) 
	{ 
		s[i]=t[i]/100; 
		t[i]=0; 
	} 
	for(i=0;i<=9;i++) 
	{		 
		for(j=0;j<=9;j++) 
		{ 
			A=a[i*x+j]-s[0]; 
			B=a[(y-i-1)*x+j]-s[1]; 
			C=a[i*x+x-j-1]-s[2]; 
			D=a[(y-i-1)*x+x-j-1]-s[3]; 
			t[0]+=A*A; 
			t[1]+=B*B; 
			t[2]+=C*C; 
			t[3]+=D*D; 
		} 
	} 
	for(i=0;i<4;i++) 
		for(j=i+1;j<4;j++) 
			if(t[j]=0;i--) 
	{ 
		for(j=0;j=1;i--) 
	{ 
		for(j=1;j(12*zs*zs)) 
			{ 
				m_img[(i*m_x+j)*3+0]=255;//img1[(i*m_x+j)*3+0]; 
				m_img[(i*m_x+j)*3+1]=255;//img1[(i*m_x+j)*3+1]; 
				m_img[(i*m_x+j)*3+2]=255;//img1[(i*m_x+j)*3+2]; 
			} 
			else 
			{ 
				m_img[(i*m_x+j)*3+0]=0;//max(0,min(255,m_img[(i*m_x+j)*3+0])); 
				m_img[(i*m_x+j)*3+1]=0;//max(0,min(255,m_img[(i*m_x+j)*3+1])); 
				m_img[(i*m_x+j)*3+2]=0;//max(0,min(255,m_img[(i*m_x+j)*3+2])); 
			} 
		} 
	} 
	Draw_TrueColor_Image(m_img,m_x,m_y,0,0); 
	delete []img1; 
	delete []m4; 
	delete []a; 
} 
 
void CMy0211080239Dlg::OnButton6()  
{ 
	// TODO: Add your control notification handler code here 
	CFileDialog fdlg(TRUE); 
    int rtn; 
    fdlg.m_ofn.lpstrInitialDir="f:\\sample"; 
	fdlg.m_ofn.lpstrFilter="bmp文件\0*.bmp\0\0\0"; 
	fdlg.m_ofn.lpstrTitle="打开bmp文件"; 
 
	rtn=fdlg.DoModal(); 
	if(rtn==IDOK) 
	{ 
		int bufsize=1000*1000*3; 
		BYTE *img=new BYTE[bufsize]; 
		int X,Y; 
		LoadBitmapFile((LPCTSTR)fdlg.GetPathName(),img,bufsize,X,Y); 
	} 
} 
 
#include 
void Rotate1(int X,int Y,int &w,int& h,float &th,double &n1,double &n2){ 
	double x1,x2,x3,x4; 
	double y1,y2,y3,y4; 
	double xx1,xx2,xx3,xx4; 
	double yy1,yy2,yy3,yy4; 
    // int i,j; 
	double cosa,sina; 
	th=3.141592657*th/180; 
	cosa=cos(th); 
	sina=sin(th); 
	// old 
	x1=(double)(-0.5*X); 
	y1=(double)(0.5*Y); 
	x2=(double)(0.5*X); 
	y2=(double)(0.5*Y); 
	x3=(double)(-0.5*X); 
	y3=(double)(-0.5*Y); 
	x4=(double)(0.5*X); 
	y4=(double)(-0.5*Y); 
	//new 
	xx1=cosa*x1+sina*y1; 
	yy1=-sina*x1+cosa*y1; 
	xx2=cosa*x2+sina*y2; 
	yy2=-sina*x2+cosa*y2; 
	xx3=cosa*x3+sina*y3; 
	yy3=-sina*x3+cosa*y3; 
	xx4=cosa*x4+sina*y4; 
	yy4=-sina*x4+cosa*y4; 
	 
	w=(int)(max(fabs(xx4-xx1),fabs(xx3-xx2))+0.5); 
	h=(int)(max(fabs(yy4-yy1),fabs(yy3-yy2))+0.5); 
	 
	n1=(double)(-0.5*w*cosa-0.5*h*sina+0.5*X); 
	n2=(double)(0.5*w*sina-0.5*h*cosa+0.5*Y); 
} 
 
void CMy0211080239Dlg::OnButton8()  
{ 
	// TODO: Add your control notification handler code here 
	CFileDialog fdlg(TRUE); 
    int rtn; 
    fdlg.m_ofn.lpstrInitialDir="f:\\sample"; 
	fdlg.m_ofn.lpstrFilter="bmp文件\0*.bmp\0\0\0"; 
	fdlg.m_ofn.lpstrTitle="打开bmp文件"; 
	rtn=fdlg.DoModal(); 
	if(rtn==IDOK) 
	{ 
	    int bufsize=2000*2000*3; 
	    BYTE *img=new BYTE[bufsize]; 
		Rotate dlg; 
		int rr; 
		rr=dlg.DoModal(); 
		if(rr=IDOK) 
		{ 
			float th=dlg.m_th; 
            int X,Y,w,h; 
			double n1,n2; 
			LoadBitmapFile((LPCTSTR)fdlg.GetPathName(),img,bufsize,X,Y); 
		    Rotate1(X,Y,w,h,th,n1,n2); 
	        BYTE *img1=new BYTE[w*h*3]; 
			memset(img1,(BYTE)255,w*h*3); 
		    double sina=sin(th),cosa=cos(th); 
		    int x0,y0; 
		    for(int k=0;k<3;k++) 
			{	 
				for(int i =0;i=0)&&(x0<=X)&&(y0>=0)&&(y0<=Y)) 
						{ 
				        img1[(i*w+j)*3+k]=img[3*(y0*X+x0)+k]; 
						} 
					} 
				} 
			} 
			Draw_TrueColor_Image(img1,w,h,10,10); 
			delete img1; 
		} 
		delete img; 
	} 
} 
 
void tmpl(BYTE *img,int w,int h,int th,int tw,int tx,int ty,float *a,float b){ 
	int i,j,k,l,m; 
	BYTE *temp=new BYTE[w*h*3]; 
	memcpy(temp,img,w*h*3); 
	float fr; 
	for(m=0;m<3;m++) 
	for(j=ty;j255) 
					temp[3*(j*w+i)+m]=255; 
				else 
					temp[3*(j*w+i)+m]=(int)(fr+0.5); 
		} 
	memcpy(img,temp,w*h*3); 
	delete temp; 
} 
void sobel(BYTE *img,int w,int h){ 
	int i,j; 
	int th,tw; 
	float b; 
	int tx,ty; 
	float aa[9]; 
	LPBYTE temp1=new BYTE[w*h*3]; 
    LPBYTE temp2=new BYTE[w*h*3]; 
	memcpy(temp1,img,w*h*3); 
	memcpy(temp2,img,w*h*3); 
	// 
	tw=3; 
	th=3; 
	b=1.0; 
	ty=1; 
	tx=1; 
	aa[0]=-1.0; 
	aa[1]=-2.0; 
	aa[2]=-1.0; 
	aa[3]=0.0; 
	aa[4]=0.0; 
	aa[5]=0.0; 
	aa[6]=1.0; 
	aa[7]=2.0; 
	aa[8]=1.0; 
	tmpl(temp1,w,h,th,tw,tx,ty,aa,b); 
 
	aa[0]=-1.0; 
	aa[1]=0.0; 
	aa[2]=1.0; 
	aa[3]=-2.0; 
	aa[4]=0.0; 
	aa[5]=2.0; 
	aa[6]=-1.0; 
	aa[7]=0.0; 
	aa[8]=1.0; 
	tmpl(temp2,w,h,th,tw,tx,ty,aa,b); 
 
	for(int k=0;k<3;k++) 
	for(j=0;jtemp1[3*(j*w+i)+k]) 
				temp1[3*(j*w+i)+k]=temp2[3*(j*w+i)+k]; 
	memcpy(img,temp1,w*h*3); 
	delete temp1; 
	delete temp2; 
} 
void CMy0211080239Dlg::OnButton9()  
{ 
	// TODO: Add your control notification handler code here 
    CFileDialog fdlg(TRUE); 
    int rtn; 
    fdlg.m_ofn.lpstrInitialDir="f:\\sample"; 
	fdlg.m_ofn.lpstrFilter="bmp文件\0*.bmp\0\0\0"; 
	fdlg.m_ofn.lpstrTitle="打开bmp文件"; 
 
	rtn=fdlg.DoModal(); 
	if(rtn==IDOK) 
	  { 
	    int bufsize=1000*1000*3; 
		BYTE *img=new BYTE[bufsize]; 
		int X,Y; 
     	LoadBitmapFile((LPCTSTR)fdlg.GetPathName(),img,bufsize,X,Y); 
		sobel(img,X,Y); 
		Draw_TrueColor_Image(img,X,Y,0,0); 
 
 
		CFileDialog fdlg2(FALSE); 
        fdlg2.m_ofn.lpstrInitialDir="f:\\sample"; 
	    fdlg2.m_ofn.lpstrFilter="bmp文件\0*.bmp\*.bmp\0\0"; 
		//dlg.Filter="bitmap files(*.bmp)|*.bmp|all files(*.*)|*.*"; 
	    fdlg2.m_ofn.lpstrTitle="保存bmp文件"; 
		int rtn1=fdlg2.DoModal(); 
		if(rtn1==IDOK) 
			writebmp((LPCTSTR)fdlg2.GetPathName(),img,X,Y); 
		delete img; 
	} 
 
	 
} 
 
 
#include  
 
void CMy0211080239Dlg::Onsave()  
{ 
	// TODO: Add your control notification handler code here 
	    CFileDialog fdlg1(FALSE); 
        int rtn1; 
        fdlg1.m_ofn.lpstrInitialDir="f:\\sample"; 
	    fdlg1.m_ofn.lpstrFilter="bmp文件\0*.bmp\0\0\0"; 
	    fdlg1.m_ofn.lpstrTitle="保存bmp文件"; 
		rtn1=fdlg1.DoModal(); 
		if(rtn1==IDOK) 
			writebmp((LPCTSTR)fdlg1.GetPathName(),m_img,m_x,m_y); 
		// 
		 
	 
} 
 
BOOL CMy0211080239Dlg::DestroyWindow()  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 delete m_img; 
	return CDialog::DestroyWindow(); 
}