收藏 分销(赏)

多媒体编程基础课程综合作业说明书.docx

上传人:pc****0 文档编号:8842097 上传时间:2025-03-04 格式:DOCX 页数:94 大小:1.32MB
下载 相关 举报
多媒体编程基础课程综合作业说明书.docx_第1页
第1页 / 共94页
多媒体编程基础课程综合作业说明书.docx_第2页
第2页 / 共94页
点击查看更多>>
资源描述
南京工程学院 多媒体编程基础课程 综合作业说明书 题 目 多媒体处理综合应用设计 班 级 学 生 姓 名 刘土豪 学 号 2021003 20一三 年 06 月 07 日 一、 程序功能与设计思路 设计目标与具有的功能: 必须含有文字处理、绘图、图像、音频视频四部分内容各3种以上功能,界面及应用方法自己根据软件的特色综合考虑,每位同学必须自己设计一个动画标志,放在【帮助】对话框中,或者窗口界面上 设计思路: 1) 图形处理: Ø 可以选择直线,矩形,椭圆,涂鸦进行绘画 Ø 可以选择线的形状:实线,虚线,点线 Ø 可以改变线条的颜色 Ø 可以改变线条的宽度 Ø 可以进行多边形填充颜色并可以改变颜色 2) 图片处理: Ø 可以打开BMP格式的图片 Ø 可以进行锐化,浮雕,反色等图片处理效果 Ø 可以显示鼠标在图片上坐标处的颜色值和颜色 3) 文字处理: Ø 实现至少少三种文字特效,比如:文字渐变,旋转体,3D,文字倾斜,下划线,空心字等 4) 音乐播放器: Ø 可以打开mp3,wma,wvi格式的歌曲 Ø 可以控制音乐的播放、暂停、停止 Ø 可以指定播放当前音乐的上一个或下一个音乐 Ø 在列表中随意选择要播放的音乐 Ø 在播放时,可以获取并显示当前播放音乐的信息 Ø 可以调节音乐的音量 5)视频播放器: Ø 可以打开MP3,WMA,WMV,AVI,RM,RMVB,FLV,MP4等格式 Ø 在列表中随意选择要播放的媒体文件 Ø 控制媒体文件的播放、暂停、停止、快进、快退 Ø 指定播放当前文件的上一个或下一个媒体文件 Ø 在播放时,可以获取并显示当前播放媒体的文件信息 Ø 播放模式可以进行进行选择 Ø 可以对播放列表或列表中的选项进行删除操作 二、 相关原理知识介绍 (1) 图形处理:画笔和画刷是绘图中最基本的元素 1.画笔(Pen):用于在设备环境中绘制直线,曲线和多边形边框。 创建画笔: (1) CPen(); (2) CPen(int nPenStyle, int nWidth, COLORREF crColor); nPenStyle:画笔的样式PS_SOLID 创建一个实线画笔,PS_DASH 创建一个虚线画笔,PS_DOT 创建一个点线画笔 nWidth:画笔的宽度 crColor:画笔的颜色(颜色用RGB值来描述) 2.画刷(CBrush):常用于填充个区域诸如多边形,椭圆和路径等图形内部区域 创建画刷: (1) CreateSolidBrush 用指定的颜色初始化画刷 (2) CreateHatchBrush 用指定的阴影线初始化画刷。 (3) CreateBrushIndirect用结构LOGBRUSH中指定的风格、颜色和模式初始化画刷。 3.画直线:LineTo(int x,int y) 画椭圆:Ellipse(int x1,int y1, int x2,int y2) 画矩形:Rectangle(int x1,int y1,int x2,int y2)//x1,y1为边界矩形左上角的坐标,x2,y2为边界矩形右下角的坐标 (2) 图片处理: BitBlt,用于从源设备中复制位图到目标设备中, BOOL BitBlt(HDC hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,HDC hdcSrc,int nXSrc,int nYSrc,DWORD dwRop) hdcDest:指向目标设备环境的句柄。 nXDest:指定目标矩形区域左上角的X轴逻辑坐标。 nYDest:指定目标矩形区域左上角的Y轴逻辑坐标。 nWidth:指定源和目标矩形区域的逻辑宽度。 nHeight:指定源和目标矩形区域的逻辑高度。 hdcSrc:指向源设备环境的句柄。 nXSrc:指定源矩形区域左上角的X轴逻辑坐标。 nYSrc:指定源矩形区域左上角的Y轴逻辑坐标。 dwRop:指定光栅操作代码。这些代码将定义源矩形区域的颜色数据,如何与目标矩形区域的颜色数据组合以完成最后的颜色。 (3) 文字处理: 输出文字Textout():用当前字体在指定位置处写一个字符串 TextOut(int x,int y,Cstring string):文本起点的x坐标和y坐标以及要绘制的字符串 创建字体LOGFONT{ }结构 (4) 音频播放器: 使用VC++6.0强大的MFC、AppWizard、Class Wizard和其中的多种控件可以很方便地建立各种应用程序。同时想要实现更高级更复杂的功能,也可以借助ActiveX控件资源,用这些现有的控件资源,可以省去自己编程的复杂过程,从而实现更高级的功能。本次课程设计要使用VC++6.0自带的一个ActiveX控件——Windows Media Player控件,建立自己的多媒体播放器 三、 界面设计和功能实现 1. 主界面设计结构框架图: 主界面 音频播放器 音乐播放器 图形处理 图片处理 文字效果 2. 打开VC 6.0,新建MFC工程,基于对话框,名称为多媒体课设 3. 向主窗口拖一个Tab控件,并调整大小使之占据2/3主窗口大小,并为Tab添加类向导, 添加IDC_TAB1的变量:m_tab 完成后在 “多媒体课设Dlg.cpp”中的OnInitDialog添加如下代码: // 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 m_tab.InsertItem(0,"图形处理"); m_tab.InsertItem(1,"图片处理"); m_tab.InsertItem(2,"文字处理"); m_tab.InsertItem(3,"音乐播放"); m_tab.InsertItem(4,"音频播放"); RECT rc; m_tab.GetClientRect(&rc); m_draw.Create(IDD_DRAW_DIALOG,&m_tab); m_draw.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_SHOWWINDOW); m_picture.Create(IDD_PICTURE_DIALOG,&m_tab); m_picture.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_music.Create(IDD_MUSIC_DIALOG,&m_tab); m_music.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_movie.Create(IDD_MOVIE_DIALOG,&m_tab); m_movie.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_word.Create(IDD_WORD_DIALOG,&m_tab); m_word.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); return TRUE; // return TRUE unless you set the focus to a control 在添加类向导OnSelchangeTab1()中添加代码: void CMyDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CRect rc; m_tab.GetClientRect(&rc); switch(m_tab.GetCurSel()) { case 0: m_movie.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_music.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_word.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_picture.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_draw.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_SHOWWINDOW); break; case 1: m_movie.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_music.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_word.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_draw.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_picture.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_SHOWWINDOW); break; case 2: m_movie.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_music.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_picture.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_draw.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_word.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_SHOWWINDOW); break; case 3: m_movie.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_word.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_picture.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_draw.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_music.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_SHOWWINDOW); break; case 4: m_music.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_word.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_picture.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_draw.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_HIDEWINDOW); m_movie.SetWindowPos(NULL,5,20,rc.right,rc.bottom,SWP_SHOWWINDOW); break; } *pResult = 0; } 4. 本作业分为5个部分:图形处理,图片处理,文字处理,音乐播放,音频播放 (1)分别建立5个资源: 选择菜单栏的“插入”,选择窗体,窗体名称分别为:DRAW,Picture,Word,MUSIC,MOVIE 并将窗体的样式改为如下: (2)分别为5个窗体创建变量名称: 在 “多媒课设Dlg.h”中添加变量: 另外将5个部分的头文件全部加到“多媒体课设Dlg.h”中,才能调用哦 (3)插入背景图片: 菜单栏选择“插入”,选择“资源”,选择“Bitmap”,点击“引入”,选择BMP格式的图片 名称为IDB_BITMAP4,在OnPaint()添加如下代码: else { // CDialog::OnPaint(); CPaintDC dc(this); CRect rect; GetClientRect(&rect); CDC dcMem; dcMem.CreateCompatibleDC(&dc); CBitmap bmpBackground; bmpBackground.LoadBitmap(IDB_BITMAP4); BITMAP bitmap; bmpBackground.GetBitmap(&bitmap); CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground); dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY); } 二.各个板块设计: (1)图形处理: 图形处理设计框架图: 图形处理界面 选择图形 清空面板 改变填充颜色 选择线型 改变画笔颜色 输入线宽 实线 点线 虚线 椭圆 直线 矩形 涂鸦 设计如图: 插件名称 ID 直线 IDC_Line 矩形 IDC_Rect 椭圆 IDC_Elipse 涂鸦 IDC_Tuya 线型 IDC_Linestyle 线宽 IDC_Linewidth 画笔颜色 IDC_Pen color 填充颜色 IDC_Brushcolor 清空面板 IDC_clear 绘画区域 IDC_Show 功能实现: 在Draw.h添加变量: 设置默认值: DRAW::DRAW(CWnd* pParent) : CDialog(DRAW::IDD, pParent) { //{{AFX_DATA_INIT(DRAW) m_linewidth = 0; f_move=0; color_pen=RGB(255,0,0); color_brush=RGB(255,255,255); Hcursor=AfxGetApp()->LoadStandardCursor(IDC_CROSS); //}}AFX_DATA_INIT } 在OnInitDialog()中设置线型的选择和默认值,代码如下: BOOL DRAW::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here CheckRadioButton(IDC_Line,IDC_Tuya,IDC_Rect);//默认选择画矩形 m_linestyle.AddString("实线"); m_linestyle.AddString("虚线"); m_linestyle.AddString("点线"); m_linestyle.SetCurSel(0);//默认画实线 return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } 在OnPaint添加如下代码: void DRAW::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here UpdateData(TRUE); CRect rect; GetDlgItem(IDC_SHOW)->GetWindowRect(&rect); ScreenToClient(&rect); CBrush brush(RGB(255,255,255)); dc.FillRect(CRect(rect.left,rect.top+8,rect.right,rect.bottom),&brush); // Do not call CDialog::OnPaint() for painting messages } 添加LButtonDown函数响应: void DRAW::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default UpdateData(TRUE); m_BeginPoint = point; m_EndPoint = point; SetCapture();//执行这条语句后,当鼠标移动到本窗口以外时,鼠标消息仍然被发送给本窗口; f_move = 1; CRect rect; GetClientRect(&rect); ClientToScreen(&rect); CDialog::OnLButtonDown(nFlags, point); } 添加LButtonUp函数响应: void DRAW::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDC *dc=GetDC(); if(f_move) { ::ReleaseCapture();//停止捕获鼠标消息 draw(point,1); f_move = 0; } CDialog::OnLButtonUp(nFlags, point); } 添加MouseMove函数响应: void DRAW::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default draw(point,0); CDialog::OnMouseMove(nFlags, point); } 给“线型按钮”添加CBN_SELCHANCE响应函数,代码如下: void DRAW::OnSelchangeLinestyle() { // TODO: Add your control notification handler code here CString str; m_linestyle.GetLBText(m_linestyle.GetCurSel(),str); if(0 == strxpare("实线")) { type = PS_SOLID; } if(0 == strxpare("虚线")) { type = PS_DASH; } if(0 == strxpare("点线")) { type = PS_DOT; } } 添加draw()函数,实现各种功能的绘图: void DRAW::draw(CPoint point, int k) { CPen pen(type,m_linewidth,color_pen); CClientDC ClientDC(this); ClientDC.SelectObject(&pen); CBrush brush(color_brush); ClientDC.SelectObject(&brush); int j; j = GetCheckedRadioButton(IDC_Line,IDC_Tuya); if(f_move) { switch(j) { case IDC_Rect: ClientDC.SetROP2(R2_NOT); ClientDC.MoveTo(m_BeginPoint); ClientDC.Rectangle(m_BeginPoint.x,m_BeginPoint.y,m_EndPoint.x,m_EndPoint.y); if(k==1) ClientDC.SetROP2(R2_COPYPEN); ClientDC.MoveTo(m_BeginPoint); ClientDC.Rectangle(m_BeginPoint.x,m_BeginPoint.y,point.x,point.y); m_EndPoint=point; break; case IDC_Line: ClientDC.SetROP2(R2_NOT); ClientDC.MoveTo(m_BeginPoint); ClientDC.LineTo(point); if(k == 1) ClientDC.SetROP2(R2_COPYPEN); ClientDC.MoveTo(m_BeginPoint); ClientDC.LineTo(point); m_EndPoint=point; break; case IDC_Ellipse: ClientDC.SetROP2(R2_NOT); ClientDC.MoveTo(m_BeginPoint); ClientDC.Ellipse(m_BeginPoint.x,m_BeginPoint.y,m_EndPoint.x,m_EndPoint.y); if(k==1) ClientDC.SetROP2(R2_COPYPEN); ClientDC.MoveTo(m_BeginPoint); ClientDC.Ellipse(m_BeginPoint.x,m_BeginPoint.y,point.x,point.y); m_EndPoint=point; break; case IDC_Tuya: ClientDC.MoveTo(m_BeginPoint); ClientDC.LineTo(point); m_BeginPoint = point; break; } } } 给“填充颜色”按钮添加单击响应: void DRAW::OnBrushcolor() { // TODO: Add your control notification handler code here CColorDialog m_pColorDlg; m_pColorDlg.m_cc.Flags = CC_ANYCOLOR|CC_ENABLEHOOK; if(m_pColorDlg.DoModal() == IDOK) { color_brush = m_pColorDlg.GetColor(); } } 给“画笔颜色”按钮添加单击响应: void DRAW::OnPencolor() { // TODO: Add your control notification handler code here CColorDialog m_pColorDlg; m_pColorDlg.m_cc.Flags = CC_ANYCOLOR|CC_ENABLEHOOK; if(m_pColorDlg.DoModal() ==IDOK) { color_pen = m_pColorDlg.GetColor(); } } 添加“情况面板”按钮单击响应: void DRAW::Onclear() { // TODO: Add your control notification handler code here Invalidate(); } (2)图片处理: 图形处理设计框架图: 图片处理界面 打开图片 轮廓 杂色 反色 浮雕 锐化 鼠标处的RGB和颜色 蓝 绿 颜色 红 设计如图: 控件名称 ID 图形显示区域 IDC_DRAW 打开 IDC_OPEN 锐化 IDC_sharp 浮雕 IDC_fudiao 反色 IDC_fanse 轮廓 IDC_lunkuo 杂色 IDC_zase (编辑框)红 IDC_RED (编辑框)蓝 IDC_GREEN (编辑框)绿 IDC_BLUE (编辑框)显示颜色 IDC_COLOR 实现功能: 在Picture.h中添加变量: 在OnPaint()添加代码如下: void Picture::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CDialog::OnPaint(); CWnd*pWnd=GetDlgItem(IDC_DRAW); pWnd->UpdateWindow(); DrawPhoto(); // Do not call CDialog::OnPaint() for painting messages } 添加DrawPhoto()函数,代码如下: void Picture::DrawPhoto() { if(!m_hBitmap) return; CBitmap m_bmp; m_bmp.Attach(m_hBitmap); BITMAP bm; m_bmp.GetObject(sizeof(BITMAP),&bm); float fScale; fScale=(float)bm.bmHeight/(float)bm.bmWidth; CWnd*pWnd=GetDlgItem(IDC_DRAW); CDC*pDC=pWnd->GetDC(); CRect reClient; int nWidth,nHeight,nX=0,nY=0; pWnd->GetClientRect(reClient); nWidth=reClient.Width(); nHeight=(int)((float)nWidth*fScale); nX=0; nY=(reClient.Height()-nHeight)/2; if(nHeight>reClient.Height()) { nHeight=reClient.Height(); nWidth=(int)((float)nHeight/fScale); nX=(reClient.Width()-nWidth)/2; nY=0; } CDC dcMem; dcMem.CreateCompatibleDC(pDC); CBitmap *pOldbmp=dcMem.SelectObject(&m_bmp); reClient.DeflateRect(0,0); pDC->Rectangle(reClient); pDC->StretchBlt(nX,nY,nWidth,nHeight,&dcMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY); dcMem.SelectObject(pOldbmp); } 给“打开”按钮添加单击响应,代码如下: void Picture::OnOpen() { // TODO: Add your control notification handler code here static char BASED_CODE szFilter[]="图片文件(*.bmp)|*.bmp||"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter); if(IDOK!=dlg.DoModal()) return; m_hBitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),dlg.GetPathName(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); GetDlgItem(IDC_sharp)->EnableWindow(TRUE); Invalidate(); } 给“锐化”按钮添加单击响应,代码如下: void Picture::Onsharp() { // TODO: Add your control notification handler code here int sharpLaplacian[9]={-1,-1,-1,-1,9,-1,-1,-1,-1}; CWnd*pWnd=GetDlgItem(IDC_DRAW); CDC*pDC=pWnd->GetDC(); pWnd->UpdateWindow(); CRect reClient; pWnd->GetClientRect(reClient); int nWidth=reClient.Width(); int nHeight=reClient.Height(); COLORREF bkPixel[400][300]; for(int bi=0;bi<nWidth;bi++) for(int bj=0;bj<nHeight;bj++) bkPixel[bi][bj]=pDC->GetPixel(bi,bj); int i,j; for(i=1;i<nWidth-1;i++) { for(j=1;j<nHeight-1;j++) { int rr=0,gg=0,bb=0,index=0; for(int col=-1;col<=1;col++) { for(int row=-1;row<=1;row++) { COLORREF clr=bkPixel[i+row][j+col]; rr+=GetRValue(clr)*sharpLaplacian[index]; gg+=GetGValue(clr)*sharpLaplacian[index]; bb-=GetBValue(clr)*sharpLaplacian[index]; index++; } } if(rr>255) rr=255; else if(rr<0) rr=-rr; if(gg>255) gg=255; else if(gg<0) gg=-gg; if(bb>255) bb=255; else if(bb<0) bb=-bb; pDC->SetPixelV(i,j,RGB(rr,gg,bb)); } } } 给“浮雕”按钮添加单击响应,代码如下: void Picture::Onfudiao() { // TODO: Add your control notification handl
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服