Source code: http://download.csdn.net/detail/nuptboyzhb/3961698
Alpha Fusion menu item
1. Add the Alpha Fusion menu item, modify the corresponding properties, create a Class Wizard, and edit the message processing function.
2. Add the following code to the message processing function:
Void ccvmfcview: onalphamix ()
{
// Todo: add your command handler code here
// Todo: add your command handler code here
Iplimage * src1, * src2;
Cstringcsavi = "src1 files(lena.bmp) | *. BMP | ";
Cstring csfilter = csavi;
Cstringcsfilter2 = "src2 files(gs76.bmp) | *. BMP | ";
Cstringname [] = {"", "BMP ",""};
Cstringstrfilename;
Cstringstrextension;
Cfiledialogfiledlg (true, null, null, ofn_hidereadonly, csfilter );
If (filedlg. domodal () = idok) {// select the file name
Strfilename = filedlg. m_ofn.lpstrfile;
If (filedlg. m_ofn.nfileextension = 0) {// No file suffix
Strextension = Name [filedlg. m_ofn.nfilterindex];
Strfilename = strfilename + '.' + strextension;
// Add the file suffix
}
Src1 = cvloadimage (strfilename );
If (src1)
{
MessageBox ("You also need to open an image! ");
}
Cfiledialog filedlg (true, null, null, ofn_hidereadonly, csfilter2 );
If (filedlg. domodal () = idok) {// select the file name
Strfilename = filedlg. m_ofn.lpstrfile;
If (filedlg. m_ofn.nfileextension = 0) {// No file suffix
Strextension = Name [filedlg. m_ofn.nfilterindex];
Strfilename = strfilename + '.' + strextension;
// Add the file suffix
}
Src2 = cvloadimage (strfilename );
Cvnamedwindow ("src1", cv_window_autosize );
Cvmovewindow ("src1", 300,300 );
Cvshowimage ("src1", src1 );
Cvnamedwindow ("src2", cv_window_autosize );
Cvmovewindow ("src2", 300 + src1-> width, 300 );
Cvshowimage ("src2", src2 );
Intx= 112;
Int y= 123;
Int width = src2-> width;
Int Height = src2-> height;
Double alpha = 0.5;
Double Beta = 1-alpha;
Cvsetimageroi (src1, cvrect (X, Y, width, height ));
Cvsetimageroi (src2, cvrect (0, 0, width, height ));
Cvaddweighted (src1, Alpha, src2, beta, 0.0, src1 );
Cvresetimageroi (src1 );
Cvnamedwindow ("alpha_blend", cv_window_autosize );
Cvmovewindow ("alpha_blend", 350 + src1-> width + src2-> width, 300 );
Cvshowimage ("alpha_blend", src1 );
Cvwaitkey (0 );
Cvreleaseimage (& src1 );
Cvreleaseimage (& src2 );
}
}
}
Play wav music
1. Insert a resource (insert-> resource-> Custom-> (enter Wava ))
2. Find the "Wava" file in resources and open an idr_wava1 file.
3. Right-click and choose import from the shortcut menu to view audio files suffixed with .wav.
4. Add the following in the constructor of cxxxxview:
Playsound (makeintresource (Idr_taobao_sent_sound), Afxgetresourcehandle (), snd_async | snd_resource );
5. Add the header file # include "mmsystem. H" at the top of the file"
6. Project-> Settings-> connection-> library template Add "winmm. lib"