基于WINCE的图片播放器设计_第1页
基于WINCE的图片播放器设计_第2页
基于WINCE的图片播放器设计_第3页
基于WINCE的图片播放器设计_第4页
基于WINCE的图片播放器设计_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、嵌入式计算机系统大作业 题目: 图片播放器 院系: 电子与信息工程学院 专业年级: 电工理论与新技术 学生姓名: # 学号 #同组学生: # 学号 # 2013年12月29日目录一、需求分析11.1 意义11.2 发展情况11.3 开发技术目的2二、系统开发思想和开发环境32.1 系统开发思想32.2 开发环境32.3 采用的技术及特点3三、开发模块划分和说明43.1 模块及功能43.2 模块说明4四、核心代码及其说明4五、程序运行及测试135.1 运行配置135.2 运行界面135.3 程序测试14六、遇到的问题与解决方案及系统特点156.1 遇到的问题与解决方案156.2 系统整体特色15

2、七、心得体会16I嵌入式系统与优化大作业图片播放器一、需求分析1.1 意义图像是现代信息社会中最基本的信息,它使信息变得栩栩如生,更加符合人们的日常交流习惯,因此它成为人类获取和交换信息的主要来源。如今数字图像处理的应用日益广泛,逐步成为信息科学、工程学、医学等许多学科的重要基础,同时作为一种实用技术广泛应用于军事、气象、交通、探矿、水利、农业甚至娱乐等领域。尤其是价格低廉的高性能计算机和诸如数码相机及扫描仪这样的图像采集设备出现后,数字图像处理技术被大量的应用到影视、游戏等公众及娱乐领域,与人类的生活密切相关。处理信息量巨大,要求处理速度极高,实时产生高质量的图形图像是我们不断的追求目标。因

3、此本选题具有较好好的实用价值和意义。 1.2 发展情况目前图像处理的主流应用是图像的压缩,即通过互联网进行传递或在可视电话和视频会议中进行动态视频图像的压缩。可视电话是当今结合计算机图像和传统图像处理的技术,以期产生很高压缩比的交叉领域之一。所有这一切都是图像的“数字表达”这一不可抗拒的发展趋势的组成部分。事实上,20世纪最强大、应用最广泛的图像形式电视图像,也将不可避免的融入数字领域。  数字图像及其处理技术之所以发展的如此迅速并获得广泛的应用,与其自身的优点是息息相关的。 1.再现性好  数字图像处理与模拟图像处理的根本不同在于,它不会因图像的存储、传输或复制

4、等一系列变换操作而导致图像质量的退化。只要图像在数字化时准确地表现了原稿,则数字图像处理过程始终能保持图像的再现。 2.处理精度高  按目前的技术,几乎可将一幅模拟图像数字化为任意大小的二维数组,这主要取决于图像数字化设备的能力。现代扫描仪可以把每个像素的灰度等级量化为16位甚至更高,这意味着图像的数字化精度可以达到满足任一应用需求。对计算机而言,不论数组大小,也不论每个像素的位数多少,其处理程序几乎是一样的。换言之,从原理上讲不论图像的精度有多高,处理总是能实现的,只要在处理时改变程序中的数组参数就可以了。回想一下图像的模拟处理,为了要把处理精度提高一个数量级,就要大幅度

5、地改进处理装置,这在经济上是极不合算的。3. 适用面宽  图像可以来自于多种信息源,它们可以是可见光图像,也可以是不可见的波谱图像(例如X射线图像、射线图像、超声波图像或红外图像等)。从图像反映的客观实体尺度看,可以小到电子显微镜图像,大到航空照片、遥感图像甚至天文望远镜图像。这些来自不同信息源的图像只要被变换为数字编码形式后,均是用二维数组表示的灰度图像(彩色图像也是由灰度图像组合成的,例如RGB图像由红、绿、蓝三个灰度图像组合而成),因而均可用计算机来处理。即只要针对不同的图像信息源,采取相应的图像信息采集措施,图像的数字处理方法可适用于任何一种图像。 4.&

6、#160; 灵活性高  图像处理大体上可分为图像的像质改善、图像分析和图像重建三大部分,每一部分均包含丰富的内容。由于图像的光学处理从原理上讲只能进行线性运算,这极大地限制了光学图像处理能实现的目标。而数字图像处理不仅能完成线性运算,而且能实现非线性处理,即凡是可以用数学公式或逻辑关系来表达的一切运算均可用数字图像处理实现。1.3 开发技术目的随着多媒体和互联网的快速发展,图片浏览功能成了绝大部分计算机必不可少的基本功能之一。比如Windows操作系统自带的Windows图片浏览器、ACDSee看图软件等,都是为了方便用户查看、浏览及处理图片的优秀软件。同样,在相关嵌入式系统(如手机

7、、MP4、数码相机等)中,图片浏览也成为了不可或缺的功能。为此,我们专门开发了一款基于WINCE系统的图片浏览器,主要实现在WINCE系统上对图片进行显示、翻页、缩放、旋转以及简单的效果处理等。我们知道,图片浏览器作为一种常用的应用程序,其基本功能都是差不多的,比如显示一张图片,放大,缩小,旋转等等,因此我们实地亲自使用了在桌面环境下的一些图片应用程序,总结出一些比较基础的常用功能,来作为我们的程序的需求。二、系统开发思想和开发环境2.1 系统开发思想我们通过对一些桌面图片处理浏览程序进行研究,总结了它们的一些基本特征,从而构想出我们的设计方案。开发环境:Windows7开发工具:Micros

8、oft Visual studio 2005硬件环境:计算机、嵌入式处理器运行环境:Windows7、Microsoft Visual studio 2005、WindowsCE 5.0(不包含图片浏览组件)、亿道嵌入式开发板EELiod270教学开发平台。2.2 开发环境由于本软件为单机软件,不需进行大量的数据读写和数据交换,故对系统硬件配置的要求并不高,只要能够平稳运行Windows操作系统的硬件平台,都能够使用本软件。本软件运行平台为Microsoft Windows 98/Me/NT/2000/XP/2003/7。 2.3 采用的技术及特点本软件采用C#来进行图像编程。其主要特点是:1

9、、C#代码被编译成汇编语言,可以直接在处理器上运行,效率很高。2、C#直接控制内存的分配和释放,这虽繁琐,加大了编程的负担,但却能有效地控制内存的使用。3、使用C#进行图像处理编程具有更大的灵活性。而在以C#为核心语言的可视化编程工具中,Microsoft Visual Studio以其自身许多优异的特性而获得了最为广泛的应用。鉴于以上的特点,本设计使用Microsoft Visual Studio 2005作为软件的开发平台。三、开发模块划分和说明3.1 模块及功能程序主要实现四大部分功能,叙述如下:(1) 图片显示模块:包括“打开”“删除”功能,主要把JPG、PNG、JPEG、GIF、TI

10、F、BMP等格式的图片打开并显示在指定位置,或者删除已经打开的图片。(2) 图片浏览模块:包括“上一张”“下一张”“关闭”功能,可以对文件夹里面的图片进行翻页浏览,以及关闭浏览模式。(3) 图片缩放模块:包括“放大”“缩小”功能,对图片进行缩放。(4) 图片旋转模块:包括“左旋转”“右选择”功能,每次旋转90度。3.2 模块说明模块的框图如下:四、核心代码及其说明using System;/using System.Linq;using System.Collections.Generic;using System.ComponentModel;using System.Data;using

11、System.Drawing;using System.Text;using System.Windows.Forms;using System.Collections;using System.IO;using System.Drawing.Imaging;namespace PictureBrowser1 public partial class Form1 : Form private String dirPath;/文件所在文件夹路径 private ArrayList fileInDir;/用ArrayList存储文件夹中图片文件 private int index;/图片文件索引,

12、用以实现上一张、下一张浏览 private String curFile;/当前文件夹路径 private Bitmap curBmp;/当前文件夹位图 public Form1() InitializeComponent(); panel2.AutoScroll = true; /文件打开函数 private void open()if(this.openFileDialog1.ShowDialog() =DialogResult.OK)if(this.pictureBox1.Image != null)this.pictureBox1.Image.Dispose();this.pictur

13、eBox1.Image = null;String filename = this.openFileDialog1.FileName;trycurFile = filename;curBmp = new Bitmap(curFile);this.pictureBox1.Image = curBmp;displayImage();dirPath = filename.Substring(0,filename.LastIndexOf("");System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(dirPath

14、);System.IO.FileInfo fileInfo = dirInfo.GetFiles();fileInDir = new ArrayList();if(fileInDir.Count > 0) fileInDir.Clear();foreach(FileInfo fi in fileInfo)if(fi.Extension = ".JPG" | fi.Extension = ".jpg" | fi.Extension = ".jpeg" | fi.Extension = ".tif" | fi.E

15、xtension = ".png" | fi.Extension = ".bmp" | fi.Extension = ".Bmp" | fi.Extension = ".gif" | fi.Extension = ".GIF")fileInDir.Add(fi.FullName.ToString();for(index = 0;index< fileInDir.Count;index+)if(fileInDirindex.ToString() = filename)break;catch(

16、Exception excep)Console.WriteLine(excep);MessageBox.Show("请选择后缀名为”JPG/PNG/JPEG/GIF/TIF/BMP”的图片!", "温馨提醒!");elseMessageBox.Show("请先选择一张图片!", "温馨提醒!"); /文件关闭函数private void close()if(this.pictureBox1.Image != null) this.pictureBox1.Image.Dispose();this.pictureBox

17、1.Image = null;curFile = " "curBmp = null; /下一张private void next()tryif(index = fileInDir.Count - 1)MessageBox.Show("这已经是最后一张了.", "温馨提醒!");elsethis.pictureBox1.Image.Dispose();curFile = fileInDir+index.ToString();curBmp = new Bitmap(curFile);this.pictureBox1.Image = cur

18、Bmp;displayImage();catch (NullReferenceException)MessageBox.Show("请先打开一张图片!", "温馨提醒!");/上一张private void previous() try if (index = 0) MessageBox.Show("这已经是第一张了.", "温馨提醒!");elsethis.pictureBox1.Image.Dispose();curFile = fileInDir-index.ToString();curBmp = new B

19、itmap(curFile);this.pictureBox1.Image = curBmp;displayImage();catch (NullReferenceException)MessageBox.Show("请先打开一张图片!", "温馨提醒!"); /放大函数private void max()tryint w = (int)(this.pictureBox1.Image.Width * 1.1);int h = (int)(this.pictureBox1.Image.Height * 1.1);Bitmap bmpo = curBmp;B

20、itmap bmpn = new Bitmap(w, h);Graphics g = Graphics.FromImage(bmpn); g.DrawImage(bmpo,new Rectangle(0, 0, w, h),new Rectangle(0, 0, bmpo.Width, bmpo.Height), GraphicsUnit.Pixel);g.Dispose();curBmp = bmpn;this.pictureBox1.Image.Dispose();this.pictureBox1.Image = curBmp;displayImage();catch(NullRefere

21、nceException)MessageBox.Show("请先打开一张图片!", "温馨提醒!"); 缩小函数private void min()tryint w = (int)(this.pictureBox1.Image.Width * 0.9);int h = (int)(this.pictureBox1.Image.Height * 0.9);Bitmap bmpo = curBmp;Bitmap bmpn = new Bitmap(w, h);Graphics g = Graphics.FromImage(bmpn); g.DrawImage

22、(bmpo, new Rectangle(0, 0, w, h), new Rectangle(0, 0, bmpo.Width, bmpo.Height), GraphicsUnit.Pixel);g.Dispose();curBmp = bmpn;this.pictureBox1.Image.Dispose();this.pictureBox1.Image = curBmp;displayImage();catch(NullReferenceException)MessageBox.Show("请先打开一张图片!", "温馨提醒!");/左旋转pri

23、vate void left()tryBitmap originalBitmap = curBmp;int rotationAngle = 270;int newWidth = originalBitmap.Height;int newHeight = originalBitmap.Width;Bitmap rotatedBitmap = new Bitmap(newWidth, newHeight);#if ALLOW_UNSAFE_CODEinternalRotateImage(rotationAngle, originalBitmap, rotatedBitmap);#elseinter

24、nalRotateImage(rotationAngle, originalBitmap, rotatedBitmap);#endifthis.pictureBox1.Image = rotatedBitmap;curBmp = rotatedBitmap;displayImage();catch(NullReferenceException)MessageBox.Show("请先打开一张图片!", "温馨提醒!");/右旋转private void right()tryBitmap originalBitmap = curBmp;int rotatio

25、nAngle = 90;int newWidth = originalBitmap.Height;int newHeight = originalBitmap.Width;Bitmap rotatedBitmap = new Bitmap(newWidth, newHeight);#if ALLOW_UNSAFE_CODEinternalRotateImage(rotationAngle, originalBitmap, rotatedBitmap);#elseinternalRotateImage(rotationAngle, originalBitmap, rotatedBitmap);#

26、endifthis.pictureBox1.Image = rotatedBitmap;curBmp = rotatedBitmap;displayImage();catch(NullReferenceException)MessageBox.Show("请先打开一张图片!", "温馨提醒!");/调用函数,实现图片旋转#if ALLOW_UNSAFE_CODEprivate static void InternalRotateImage(int rotationAngle, Bitmap originaBitmap, Bitmap rotatedBit

27、map)int newWidth = rotatedBitmap.Width;int newHeight = rotatedBitmap.Height; int orignalWidth = orignalBitmap.Width;int orignalHeigth = orignalBitmap.Heigth;int newWidthMinusOne = newWidth-1;int newHeightMinusOne = newHeight-1;BitmapData originalData = originalBitmap.LockBits(new Rectangle(0,0,origi

28、nalWidth, originalHeight), ImageLockMode.ReadOnly, PixelFormat32bppRgb);BitmapData rotatedData = rotatedBitmap.LockBits(new Rectangle(0,0,rotatedBitmap.Width, rotatedBitmap.Height),ImageLockMode.WriteOnly,PixelFormat.Format32bppRgb);unsafeint* originalPoiner = (int*)orignalData.Scan0.ToPointer();int

29、* rotatedPointer = (int*)rotatedData.Scan0.ToPointer();switch(rotationAngle)case 90:for(int y = 0; y < originalHeight; +y)int destinationX = newWidthMinusOne - y;for (int x =0; x < originalWidth; +x)int sourcePosition = (x+y * originalWidth);int destinationY = x;int destinationPosition = (dest

30、inationX + detinationY * nowWidth);rotatedPointordestinationPosition = originalPointorsourcePosition;break;case 270:for (int y=0; y< originalHeight; +y)int destinationX = y;for (int x = 0; x < originalWidth; +x)int sourcePosition = (x+y*originalWidth);int destinationY = newHeightMinusOne - x;i

31、nt destinationPosition = (destinationX + destinationY * newWidth);rotatedPointerdestinationPosition = originalPointorsourcePosition;break;originalBitmap.UnlockBits(originalData);rotatedBitmap.UnlockBits(rotatedData);#else/图片选择实现函数private static void internalRotateImage(int rotationAngle, Bitmap orig

32、inalBitmap, Bitmap rotatedBitmap) int rotatedWidthMinusOne = rotatedBitmap.Width - 1; int rotatedHeightMinusOne = rotatedBitmap.Height - 1; int originalWidth = originalBitmap.Width; int originalHeight = originalBitmap.Height; switch (rotationAngle) case 90: for (int y = 0; y < originalHeight; +y)

33、 for (int x = 0; x < originalWidth; +x) rotatedBitmap.SetPixel(rotatedWidthMinusOne - y, x, originalBitmap.GetPixel(x, y); break; case 270: for (int y = 0; y < originalHeight; +y) for (int x = 0; x < originalWidth; +x) rotatedBitmap.SetPixel(y, rotatedHeightMinusOne - x, originalBitmap.GetP

34、ixel(x, y); break; #endif /图片删除private void delete()DialogResult dlgResult = MessageBox.Show("您确定要删除此图片?", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);if(dlgResult = DialogResult.OK)File.Delete(fileInDirindex.ToString();fileInDiri

35、ndex = fileInDir+index;curFile = fileInDirindex.ToString();curBmp = new Bitmap(curFile);this.pictureBox1.Image = curBmp; /图片显示自定义private void displayImage()this.pictureBox1.Height = curBmp.Height;this.pictureBox1.Width = curBmp.Width;pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;if (picture

36、Box1.Width < panel2.Width)pictureBox1.Left = (panel2.Width - pictureBox1.Width)/2;elsepictureBox1.Left = 0;if (pictureBox1.Height < panel2.Height)pictureBox1.Top = (panel2.Height - (pictureBox1.Height)/2);elsepictureBox1.Top = 0;点击界面中的各个按钮(如打开、上一张、下一张等),将下面对应的程序输入进去。 private void button1_Click

37、(object sender, EventArgs e) open(); private void button2_Click(object sender, EventArgs e) previous(); private void button3_Click(object sender, EventArgs e) next(); private void button4_Click(object sender, EventArgs e) delete(); private void button5_Click(object sender, EventArgs e) max(); private void button6_Click(object sender, EventArgs e) min(); private void button7_Click(object sender, EventArgs e) right(); private void button8_Click(object sender, EventArgs e) left(); private void button9_Click(o

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论