多媒体技术实验报告骄阳教育_第1页
多媒体技术实验报告骄阳教育_第2页
多媒体技术实验报告骄阳教育_第3页
多媒体技术实验报告骄阳教育_第4页
多媒体技术实验报告骄阳教育_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

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

文档简介

1、江苏科技大学多媒体技术考核报告(2017/2018学年第1学期)课程名称: 多 媒 体 技 术 指导教师: 景 国 良 实验地点: 东校区外训楼软件工程实验室 学生姓名: 谢卉 学生学号: 1477965899 院 系: 计算机学院 专 业: 计算机科学与技术专业 考核得分: 2017年 11 月 日实验一 多媒体图像文件转换一、实验目的1掌握多媒体静态图像的基本概念,技术和获取过程。2掌握多媒体图像文件基本格式种类。 3掌握不同图像文件的数据结构形式,了解不同格式图像文件的具体类型区别。4运用高级语言编程实现不同图像文件类型的相互转换。二、实验环境1、主流操作系统;2、高级语言编程环境。三、

2、实验内容1、编写程序实现主流图像文件格式之间的相互转换;2、至少要实现jpg、bmp、gif、png图像文件之间的转换;3、编程语言不限;4、根据实验内容撰写对应的实验报告。四、设计方案imageio 类的静态方法可以执行许多常见的图像 i/o 操作。此包包含一些基本类和接口,有的用来描述图像文件内容(包括元数据和缩略图)(iioimage);有的用来控制图像读取过程(imagereader、imagereadparam 和 imagetypespecifier)和控制图像写入过程(imagewriter 和 imagewriteparam);还有的用来执行格式之间的代码转换 (imagetr

3、anscoder) 和报告错误 (iioexception)。可处理图像格式有:jpg,bmp,bmp,jpg,wbmp,jpeg,png,png,jpeg,wbmp,gif,gif。另外在加一些输入代码可实现简单的格式转换选择。五、实验代码import javax.imageio.imageio;import java.awt.image.bufferedimage;import java.io.file;import java.io.fileoutputstream;import java.io.ioexception;import java.io.outputstream;import

4、java.util.scanner;public class main public static void main(string args) scanner scan = new scanner(system.in); system.out.println(请输入需要转换的格式jpg, bmp, png, gif:); file out = new file(/users/14779/desktop/1.jpg); /将图片写入imageio流 try bufferedimage img = imageio.read(out); /将图片写出到指定位置(复制图片) switch (scan

5、.next() casepng: casepng: outputstream ops = new fileoutputstream(new file(/users/14779/desktop/1(1).png); imageio.write(img, png, ops); system.out.println(转换完成!); break; casejpg: casejpg: ops = new fileoutputstream(new file(/users/14779/desktop/1(1).jpg); imageio.write(img, jpg, ops); system.out.pr

6、intln(转换完成!); break; casebmp: casebmp: ops = new fileoutputstream(new file(/users/14779/desktop/1(1).bmp); imageio.write(img, bmp, ops); system.out.println(转换完成!); break; casegif: casegif: ops = new fileoutputstream(new file(/users/14779/desktop/1(1).gif); imageio.write(img, gif, ops); system.out.pr

7、intln(转换完成!); break; default: system.out.println(请输入正确格式!); break; catch (ioexception e) e.printstacktrace(); 实验截图六、实验过程中的问题及对应思考imageio是一个封装好的图像输入输出类, 使用 imageio 类的静态方法可以执行许多常见的图像 i/o 操作。我将图片路径事先写好放入程序里,可以通过键入转换格式来达到想要转换到的格式,为了避免键入出错,我将主程序写在try函数中。 实验二 多媒体图像文件压缩一、实验目的1、了解各种图像文件格式之间的存储方法和方式,了解其编码的组织

8、方式;2、掌握运用高级编程语言编写多媒体应用程序的方法;3、运用高级编程语言实现对多媒体图像文件的压缩的方法。二、实验环境1、主流操作系统;2、高级语言编程环境。三、实验内容1、使用高级编程语言编写良好的运行界面;2、运用高级编程语言编写核心代码实现对图像文件的压缩;3、了解压缩过程中的顺进和累进方法的运用提高压缩比;4、合理的考虑压缩算法压缩和解压的速度平衡;5、编程语言不限;6、根据实验内容撰写对应的实验报告。四、设计方案使用imagioio的对图片的压缩处理来进行此项实验。五、实验代码package pany;import javax.imageio.imageio;import jav

9、a.awt.*;import java.awt.image.bufferedimage;import java.io.file;import java.io.ioexception;public class main public static void main(string args) compresspicdemo mypic = new compresspicdemo(); system.out.println(输入的图片大小: + mypic.getpicsize(c:users14779desktop2.jpg)/1024 + kb); presspic(c:users14779d

10、esktop, c:users14779desktop, 2.jpg, 2(2).jpg, 120, 120, false); class compresspicdemo private file file = null; / 文件对象 private string inputdir; / 输入图路径 private string outputdir; / 输出图路径 private string inputfilename; / 输入图文件名 private string outputfilename; / 输出图文件名 private int outputwidth = 100; / 默认

11、输出图片宽 private int outputheight = 100; / 默认输出图片高 private boolean proportion = true; / 是否等比缩放标记(默认为等比缩放) public compresspicdemo() / 初始化变量 inputdir = ; outputdir = ; inputfilename = ; outputfilename = ; outputwidth = 100; outputheight = 100; public void setinputdir(string inputdir) this.inputdir = inpu

12、tdir; public void setoutputdir(string outputdir) this.outputdir = outputdir; public void setinputfilename(string inputfilename) this.inputfilename = inputfilename; public void setoutputfilename(string outputfilename) this.outputfilename = outputfilename; public void setoutputwidth(int outputwidth) t

13、his.outputwidth = outputwidth; public void setoutputheight(int outputheight) this.outputheight = outputheight; public void setwidthandheight(int width, int height) this.outputwidth = width; this.outputheight = height; /* * 获得图片大小 * 传入参数 string path :图片路径 */ public long getpicsize(string path) file =

14、 new file(path); return file.length(); / 图片处理 public string compresspic() try /获得源文件 file = new file(inputdir + inputfilename); if (!file.exists() return ; image img = imageio.read(file);/ 判断图片格式是否正确 if (img.getwidth(null) = -1) system.out.println( cant read,retry! + ); return no; else int newwidth;

15、 int newheight;/ 判断是否是等比缩放 if (portion = true) / 为等比缩放计算输出的图片宽度及高度 double rate1 = (double) img.getwidth(null) / (double) outputwidth + 0.1; double rate2 = (double) img.getheight(null) / (double) outputheight + 0.1;/ 根据缩放比率大的进行缩放控制 double rate = rate1 rate2 ? rate1 : rate2; newwidth = (int) (

16、double) img.getwidth(null) / rate); newheight = (int) (double) img.getheight(null) / rate); else newwidth = img.getwidth(null); / 输出的图片宽度 newheight = img.getheight(null); / 输出的图片高度 bufferedimage tag = new bufferedimage(int) newwidth, (int) newheight, bufferedimage.type_int_rgb);/* image.scale_smooth

17、 的缩略算法 生成缩略图片的平滑度的* 优先级比速度高 生成的图片质量比较好 但速度慢*/ tag.getgraphics().drawimage(img.getscaledinstance(newwidth, newheight, image.scale_smooth), 0, 0, null); string formatname = (outputdir + outputfilename).substring(outputdir + outputfilename).lastindexof(.) + 1);/ fileoutputstream out = new fileoutputstr

18、eam(outputdir + outputfilename);/ jpegimageencoder可适用于其他图片类型的转换/ jpegimageencoder encoder = jpegcodec.createjpegencoder(out);/ encoder.encode(tag); imageio.write(tag, formatname , new file(outputdir + outputfilename) );/ out.close(); catch (ioexception ex) ex.printstacktrace(); return ok; public str

19、ing compresspic (string inputdir, string outputdir, string inputfilename, string outputfilename) / 输入图路径 this.inputdir = inputdir;/ 输出图路径 this.outputdir = outputdir;/ 输入图文件名 this.inputfilename = inputfilename;/ 输出图文件名 this.outputfilename = outputfilename; return compresspic(); public string compress

20、pic(string inputdir, string outputdir, string inputfilename, string outputfilename, int width, int height, boolean gp) / 输入图路径 this.inputdir = inputdir;/ 输出图路径 this.outputdir = outputdir;/ 输入图文件名 this.inputfilename = inputfilename;/ 输出图文件名 this.outputfilename = outputfilename;/ 设置图片长宽 setwidthandhei

21、ght(width, height);/ 是否是等比缩放 标记 portion = gp; return compresspic(); 六、实验过程中的问题及对应思考实验中出现了找不到输出文件的问题,后考虑到可能是文件大小关系,所以换了一个小一些的图片,完成实验实验三 超媒体开发设计一、实验目的1、熟悉超文本和超文本系统的建立和典型的外部模型;2、熟练的运用超文本标记语言的标记方法展示超媒体;3、通过运用超文本标记语言熟悉结点和链之间形成的超媒体结构。二、实验环境1、主流操作系统系统;2、主流浏览器;3、系统有文本编辑器和网站开发工具。三、实验内容1、运用超文本标识语言和可扩展

22、语言架构web站点的基本框架;2、练习超文本标识语言进行超媒体站点架构时的合理布局及技巧;3、web站点主题内容不限,但必须要有一明确主题体现超媒体;4、可以用记事本编写实验代码;5、根据实验内容撰写对应的实验报告;6、回答老师的对应考核提问。四、设计方案使用canvas做出一个h5小游戏主要需要实现大鱼吃果实大鱼喂小鱼小鱼恢复体力还有一定的场景和界面的五、实验代码index.htmllovefish游戏规则鼠标控制大鱼吃果实吃到果实后喂给小鱼若无及时投喂则小鱼死亡红色果实1分蓝色果实两分restartane.jsvar aneobj = function()this.rootx = ;thi

23、s.headx=;this.heady=;this.amp=;this.alpha=0;this.num = 50;/ 初始化aneototype.init = function()for (var i = 0; i this.num; i+) this.rootxi = i * 20 + math.random()*20;this.headxi=this.rootxi;this.headyi=canheight-200+math.random()*50;this.ampi=math.random()*50+50;/ 绘制海葵aneototype.draw = func

24、tion()this.alpha+=deltatime*0.001;var l=math.sin(this.alpha);/ctx2.save();ctx2.globalalpha = 0.6;ctx2.strokestyle = #3b154e;ctx2.linewidth = 20;ctx2.linecap = round;for (var i = 0; i this.num; i+) /ctx2.beginpath();ctx2.moveto(this.rootxi,canheight);ctx2.quadraticcurveto(this.rootxi,canheight - 80,t

25、his.headxi+l*this.ampi,this.headyi);ctx2.stroke();ctx2.restore();baby.jsvar babyobj=function()this.x;this.y;this.angle;/this.babyeye=new image();/this.babybody=new image();/this.babytail=new image();/ this.babytail=;/尾巴数组/ this.babyeye=;/眼睛数组this.babytailtimer=0;/计时器this.babytailcount=0;/现在执行到哪一帧thi

26、s.babyeyetimer=0;/计时器this.babyeyecount=0;/现在执行到哪一帧this.babybodytimer=0;/计时器this.babybodycount=0;/现在执行到哪一帧this.babyeyeinterval;/这张图片持续多久babyototype.init=function()this.x=canwidth*0.5-50;this.y=canheight*0.5+50;this.angle=0;/console.log(this.y);for(var i=0;i8;i+)/初始化小鱼尾巴数组babytaili=new image();b

27、abytaili.src=./img/babytail+i+.png;for (var i = 0; i 2; i+) babyeyei=new image();babyeyei.src=./img/babyeye+i+.png;for (var i = 0; i 50) this.babytailcount=(this.babytailcount+1)%8;this.babytailtimer%=50;/this.babyeyetimer+=deltatime;if (this.babyeyecount=0) this.babyeyeinterval=math.random()*1500+2

28、000;/如果睁着眼睛的状态为1500-2000elsethis.babyeyeinterval=200;/闭眼状态默认200msif (this.babyeyetimerthis.babyeyeinterval) this.babyeyecount=(this.babyeyecount+1)%2;/取模实现循环this.babyeyetimer%=this.babyeyeinterval;/this.babybodytimer+=deltatime;if (this.babybodytimer300)this.babybodycount=this.babybodycount+1;this.b

29、abybodytimer%=300;if(this.babybodycount19)this.babybodycount=19;data.gameover=true;ctx1.save();/属性仅适用于小鱼ctx1.translate(this.x,this.y);/指定相对原点值ctx1.rotate(this.angle);var babytailcount=this.babytailcount;ctx1.drawimage(babytailbabytailcount,-babytailbabytailcount.width*0.5+23,-babytailbabytailcount.h

30、eight*0.5);var babybodycount=this.babybodycount;ctx1.drawimage(babybodybabybodycount,-babybodybabybodycount.width*0.5,-babybodybabybodycount.height*0.5);var babyeyecount=this.babyeyecount;ctx1.drawimage(babyeyebabyeyecount,-babyeyebabyeyecount.width*0.5,-babyeyebabyeyecount.height*0.5);ctx1.restore(

31、);background.jsfunction drawbackground()ctx2.drawimage(bgpic,0,0,canwidth,canheight);collision.js/碰撞检测/判断大鱼和果实的距离function momfruitscollision()if (data.gameover) return;for (var i = 0; i fruit.num; i+) if (fruit.alivei) /距离的平方var l=callength2(fruit.xi,fruit.yi,mom.x,mom.y);if (l7)mom.mombodycount=7;/

32、 console.log(data.fruitnum);else if(fruit.fruittypei=blue)data.double=2;elsedata.double=1;wave.born(fruit.xi,fruit.yi);/ console.log(mom.mombodycount);function mombabycollision()if(data.fruitnum0&!data.gameover)var l=callength2(mom.x,mom.y,baby.x,baby.y);if (l1) this.alpha=1;ctx1.fillstyle=rgba(255,

33、255,255,+ this.alpha +);/添加样式的颜色 白色 +alphactx1.filltext(gameover,w*0.5,h*0.5);ctx1.restore();dataototype.addscore=function()this.score+=this.fruitnum*this.double;this.fruitnum=0;this.double=1;fruit.jsvar fruitobj=function()this.alive = ;/boolthis.x = ;/this.y = ;/this.l=;/图片长度this.spd=;/速度this

34、.fruittype=;/分辨果实类型this.orange = new image();this.blue = new image();/果实形态2fruitototype.num = 30;fruitototype.init=function()for (var i = 0; i this.num; i+) this.alivei=false;/初始化果实为激活状态this.xi=0;this.yi=0;this.spdi=math.random()*0.017+0.003;/随机生成速度在0.003,0.02之间this.fruittypei=0;this.bor

35、n(i);/console.log(this.yi); this.orange.src=./img/fruit.png;this.blue.src=./img/blue.png;/console.log(初始化执行);fruitototype.draw=function()/画果实for (var i = 0; i this.num; i+) if (this.alivei) if (this.fruittypei=blue) var pic =this.blue;elsevar pic=this.orange;if(this.li=15)/判断成熟this.li+=this.sp

36、di*deltatime;/循环变大elsethis.yi-=this.spdi*5*deltatime;/当成熟,y坐标上移(果实上漂)ctx2.drawimage(pic, this.xi- this.li * 0.5,this.yi- this.li * 0.5,this.li,this.li);if (this.yi10) /当果实飘出屏外时置果实为无任务this.alivei=false; /console.log(画果实执行);fruitototype.born=function(i)/果实坐标依附在海葵上var aneid =math.floor(math.rando

37、m()*ane.num);this.xi=ane.headxaneid;this.yi=ane.headyaneid;this.li=0;/长度从0开始this.alivei=true;var ran=math.random();/随机数随机决定蓝色和黄色果实if (ran0.3) this.fruittypei=blue;elsethis.fruittypei=orange;/console.log(果实出生执行);/console.log(canheight)fruitototype.dead=function(i)/消失this.alivei=false;function fruitmonitor()/保证屏幕中至少有15个果实var num=0;for (var i = 0; i fruit.num; i+) if (fruit.alivei) num+;if (num15) /如果活跃的果实小于15,则送入新的果实sendfruit();return;function sendfruit()/送果实for (var i = 0; i fruit.num; i+) if (!fruit.alivei) fruit.born(i);return;halo.jsvar haloobj=fu

温馨提示

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

评论

0/150

提交评论