/Report errors if unable to do so.Adjust the Scroller to the new //bitmap dimensions TBmpViewWindow::LoadBitmapResource(WORD resId) TDib*newDib: newDib =new TDib(*GetModule(),TResId(resId)): SetupFromDib(newDib) return TRUE; /Test if the passed file is a Windows 3.0 DI (or PM 1.x)bitmap /and if so read it. /Report errors if unable to do so.Adiust the Scroller to the new /bitmap dimensions. bool TBmpViewwindow:LoadBitmapFile(const char*name) TDib*newDib: newDib=new TDib(name): SetupFromDib(newDib): return TRUE; 1- class TBmpViewApp public TApplication public: TBmpViewApp(const char far*name):TApplication(name)() void InitMainWindow( MainWindow new TFrameWindow(0,Name,new TBmpViewWindow): MainWindow->AssignMenu("MainMenu"): MainWindow->SetIcon(this,"MainIcon"); 11-
// Report errors if unable to do so. Adjust the Scroller to the new // bitmap dimensions. // bool TBmpViewWindow::LoadBitmapResource(WORD resId) { TDib* newDib; newDib = new TDib(*GetModule(), TResId(resId)); SetupFromDib(newDib); return TRUE; } // // Test if the passed file is a Windows 3.0 DI (or PM 1.x) bitmap // and if so read it. // Report errors if unable to do so. Adjust the Scroller to the new // bitmap dimensions. // bool TBmpViewWindow::LoadBitmapFile(const char* name) { TDib* newDib; newDib = new TDib(name); SetupFromDib(newDib); return TRUE; } //- class TBmpViewApp : public TApplication { public: TBmpViewApp(const char far* name) : TApplication(name) {} void InitMainWindow() { MainWindow = new TFrameWindow(0, Name, new TBmpViewWindow); MainWindow->AssignMenu("MainMenu"); MainWindow->SetIcon(this, "MainIcon"); } }; //-
int OwlMain(int /*argc*/,char*/*argv*/[] return TBmpViewApp(AppName).Run(: 附录五、直方图均衡处理程序实例” .月 /histdlg.h:header file头文件 LLKKKKKKK1141111411111441444111451444 /∥CHistDlg dialog class CHistDlg public CDialog /∥Construction public: CHistDlg(CWnd*pParent NULL)://standard constructor BYTE rhist[256],ghist[256],bhist[256]: private void DrawAxs(: int color: /Dialog Data //((AFX_DATA(CHistDlg) enum IDD IDD_DIALOG6} /NOTE:the Classwizard will add data members here //}AFX_DATA /Implementation protected virtual void DoDataExchange(CDataExchange*pDX);/DDX/DDV support /Generated message map functions //AFX MSG (CHistDlg) afx_msg void OnBlueBut(;
int OwlMain(int /*argc*/, char* /*argv*/ []) { return TBmpViewApp(AppName).Run(); } 附录五、直方图均衡处理程序实例 // histdlg.h : header file 头文件 // ///////////////////////////////////////////////////////////////////////////// // CHistDlg dialog class CHistDlg : public CDialog { // Construction public: CHistDlg(CWnd* pParent = NULL); // standard constructor BYTE rhist[256],ghist[256],bhist[256]; private: void DrawAxs(); int color; // Dialog Data //{{AFX_DATA(CHistDlg) enum { IDD = IDD_DIALOG6 }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // Implementation protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Generated message map functions //{{AFX_MSG(CHistDlg) afx_msg void OnBlueBut();
afx msg void OnGreenBut () afx_msg void OnRedBut virtual BOOL OnInitDialog( afx_msg void OnPaint () //AFX MSG DECLARE_MESSAGE MAPO /histdlg.cpp:implementation file处理程序 #include "stdafx.h" #include picture.h" #include《w1 ndowsx.h #include "pictudoc.h" #include "histdlg.h" const int x=50 const int y=265; #ifdef DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[]=_FILE_: #endif IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII /CHistDlg dialog CHistDlg::CHistDlg(CWnd*pParent /*=NULL*/) CDialog(CHistDlg:IDD,pParent) //AFX DATA INIT(CHistDlg) /NOTE:the ClassWizard will add member initialization here //}}AFX_DATA_INIT 1 void CHistDIg:DoDataExchange (CDataExchange*pDX) CDialog::DoDataExchange(pDX): //AFX DATA MAP(CHistDlg) /NOTE:the ClassWizard will add DDX and DDV calls here //}AFX_DATA_MAP
afx_msg void OnGreenBut(); afx_msg void OnRedBut(); virtual BOOL OnInitDialog(); afx_msg void OnPaint(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; // histdlg.cpp : implementation file 处理程序 // #include "stdafx.h" #include "picture.h" #include <windowsx.h> #include "pictudoc.h" #include "histdlg.h" const int x=50; const int y=265; #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = _FILE_; #endif ///////////////////////////////////////////////////////////////////////////// // CHistDlg dialog CHistDlg::CHistDlg(CWnd* pParent /*=NULL*/) : CDialog(CHistDlg::IDD, pParent) { //{{AFX_DATA_INIT(CHistDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CHistDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CHistDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP }
BEGIN MESSAGE MAP(CHistDIg.CDialog) //((AFX_MSG _MAP(CHistDg) ON_BN_CLICKED(IDC_BLUE_BUT,OnBlueBut ON_BN_CLICKED(IDC_GREEN_BUT,OnGreenBut) ON_BN_CLICKED(IDC_RED_BUT,OnRedBut) ON WM PAINTO //}AFX MSG_MAP END_MESSAGE_MAP( LLAKEKKKKKA414100110001011141111 //CHistDlg message handlers void CHistDIg::OnBlueBut() /TODO:Add your control notification handler code here CPen*pPen=new CPen pPen->CreatePen(PS_SOLID,0,RGB(0,0,255)); CClientDC dc(this): dc.Rectang1e(45,50,320,270) CPen*poldPen=dc.Selectobject (pPen): for(int i=0:i<256:i++) dc.MoveTo(x+i,y) dc.LineTo(x+i,y-bhist[i]) delete dc.Selectobject(poldPen): color=3; void CHistDIg::OnGreenBut() /TODO:Add your control notification handler code here CPen*pPen=new CPen pPen->CreatePen(PS_SOLID,O,RGB(0,255,0)); CClientDC dc(this): dc.Rectangle(45.50.320.270)
BEGIN_MESSAGE_MAP(CHistDlg, CDialog) //{{AFX_MSG_MAP(CHistDlg) ON_BN_CLICKED(IDC_BLUE_BUT, OnBlueBut) ON_BN_CLICKED(IDC_GREEN_BUT, OnGreenBut) ON_BN_CLICKED(IDC_RED_BUT, OnRedBut) ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CHistDlg message handlers void CHistDlg::OnBlueBut() { // TODO: Add your control notification handler code here CPen* pPen=new CPen; pPen->CreatePen(PS_SOLID,0,RGB(0,0,255)); CClientDC dc(this); dc.Rectangle(45,50,320,270); DrawAxs(); CPen* pOldPen=dc.SelectObject(pPen); for(int i=0;i<256;i++) { dc.MoveTo(x+i,y); dc.LineTo(x+i,y-bhist[i]); } delete dc.SelectObject(pOldPen); color=3; } void CHistDlg::OnGreenBut() { // TODO: Add your control notification handler code here CPen* pPen=new CPen; pPen->CreatePen(PS_SOLID,0,RGB(0,255,0)); CClientDC dc(this); dc.Rectangle(45,50,320,270);
DrawAxs(); CPen*poldPen=dc.SelectObject(pPen) for(int i=0:i<56;i++) de.MoveTo(xti y): dc.LineTo(x+i,y-ghist[i]) delete dc.SelectObject(poldPen) c010r=2: /TODO:Add your control notification handler code here CPen*pPensnew CPen pPen->CreatePen(PS_SOLID,0,RGB(255,0,O)): CClientDC de(this) dc.Rectangle(45,50,320,270): DrawAxs(): CPen*poldPen=dc.SelectObject(pPen); for(int i=0:i56:i++) dc.MoveTo(x+i,y): dc.LineTo(x+i.y-rhist[il) delete dc.SelectObject(poldPen) color=1; CDialog:OnInitDialogO: /TODO:Add extra initialization here MoveWindow(1OO,100,375,325,TRUE): color=1 return TRUE:/return TRUE unless you set the focus to a control
DrawAxs(); CPen* pOldPen=dc.SelectObject(pPen); for(int i=0;i<256;i++) { dc.MoveTo(x+i,y); dc.LineTo(x+i,y-ghist[i]); } delete dc.SelectObject(pOldPen); color=2; } void CHistDlg::OnRedBut() { // TODO: Add your control notification handler code here CPen* pPen=new CPen; pPen->CreatePen(PS_SOLID,0,RGB(255,0,0)); CClientDC dc(this); dc.Rectangle(45,50,320,270); DrawAxs(); CPen* pOldPen=dc.SelectObject(pPen); for(int i=0;i<256;i++) { dc.MoveTo(x+i,y); dc.LineTo(x+i,y-rhist[i]); } delete dc.SelectObject(pOldPen); color=1; } BOOL CHistDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here MoveWindow(100,100,375,325,TRUE); color=1; return TRUE; // return TRUE unless you set the focus to a control }