多媒體技術(shù)實驗報告_第1頁
多媒體技術(shù)實驗報告_第2頁
多媒體技術(shù)實驗報告_第3頁
多媒體技術(shù)實驗報告_第4頁
多媒體技術(shù)實驗報告_第5頁
已閱讀5頁,還剩19頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、江蘇科技大學(xué)多媒體技術(shù)考核報告(2017/2018學(xué)年第1學(xué)期)課程名稱: 多 媒 體 技 術(shù) 指導(dǎo)教師: 景 國 良 實驗地點: 東校區(qū)外訓(xùn)樓軟件工程實驗室 學(xué)生姓名: 謝卉 學(xué)生學(xué)號: 1477965899 院 系: 計算機(jī)學(xué)院 專 業(yè): 計算機(jī)科學(xué)與技術(shù)專業(yè) 考核得分: 2017年 11 月 日實驗一 多媒體圖像文件轉(zhuǎn)換一、實驗?zāi)康?掌握多媒體靜態(tài)圖像的基本概念,技術(shù)和獲取過程。2掌握多媒體圖像文件基本格式種類。 3掌握不同圖像文件的數(shù)據(jù)結(jié)構(gòu)形式,了解不同格式圖像文件的具體類型區(qū)別。4運用高級語言編程實現(xiàn)不同圖像文件類型的相互轉(zhuǎn)換。二、實驗環(huán)境1、主流操作系統(tǒng);2、高級語言編程環(huán)境。三、

2、實驗內(nèi)容1、編寫程序?qū)崿F(xiàn)主流圖像文件格式之間的相互轉(zhuǎn)換;2、至少要實現(xiàn)jpg、bmp、gif、png圖像文件之間的轉(zhuǎn)換;3、編程語言不限;4、根據(jù)實驗內(nèi)容撰寫對應(yīng)的實驗報告。四、設(shè)計方案imageio 類的靜態(tài)方法可以執(zhí)行許多常見的圖像 i/o 操作。此包包含一些基本類和接口,有的用來描述圖像文件內(nèi)容(包括元數(shù)據(jù)和縮略圖)(iioimage);有的用來控制圖像讀取過程(imagereader、imagereadparam 和 imagetypespecifier)和控制圖像寫入過程(imagewriter 和 imagewriteparam);還有的用來執(zhí)行格式之間的代碼轉(zhuǎn)換 (imagetr

3、anscoder) 和報告錯誤 (iioexception)??商幚韴D像格式有:jpg,bmp,bmp,jpg,wbmp,jpeg,png,png,jpeg,wbmp,gif,gif。另外在加一些輸入代碼可實現(xiàn)簡單的格式轉(zhuǎn)換選擇。五、實驗代碼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(請輸入需要轉(zhuǎn)換的格式j(luò)pg, bmp, png, gif:); file out = new file(/users/14779/desktop/1.jpg); /將圖片寫入imageio流 try bufferedimage img = imageio.read(out); /將圖片寫出到指定位置(復(fù)制圖片) 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(轉(zhuǎn)換完成!); break; casejpg: casejpg: ops = new fileoutputstream(new file(/users/14779/desktop/1(1).jpg); imageio.write(img, jpg, ops); system.out.pr

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

7、intln(轉(zhuǎn)換完成!); break; default: system.out.println(請輸入正確格式!); break; catch (ioexception e) e.printstacktrace(); 實驗截圖六、實驗過程中的問題及對應(yīng)思考imageio是一個封裝好的圖像輸入輸出類, 使用 imageio 類的靜態(tài)方法可以執(zhí)行許多常見的圖像 i/o 操作。我將圖片路徑事先寫好放入程序里,可以通過鍵入轉(zhuǎn)換格式來達(dá)到想要轉(zhuǎn)換到的格式,為了避免鍵入出錯,我將主程序?qū)懺趖ry函數(shù)中。 實驗二 多媒體圖像文件壓縮一、實驗?zāi)康?、了解各種圖像文件格式之間的存儲方法和方式,了解其編碼的組織

8、方式;2、掌握運用高級編程語言編寫多媒體應(yīng)用程序的方法;3、運用高級編程語言實現(xiàn)對多媒體圖像文件的壓縮的方法。二、實驗環(huán)境1、主流操作系統(tǒng);2、高級語言編程環(huán)境。三、實驗內(nèi)容1、使用高級編程語言編寫良好的運行界面;2、運用高級編程語言編寫核心代碼實現(xiàn)對圖像文件的壓縮;3、了解壓縮過程中的順進(jìn)和累進(jìn)方法的運用提高壓縮比;4、合理的考慮壓縮算法壓縮和解壓的速度平衡;5、編程語言不限;6、根據(jù)實驗內(nèi)容撰寫對應(yīng)的實驗報告。四、設(shè)計方案使用imagioio的對圖片的壓縮處理來進(jìn)行此項實驗。五、實驗代碼package pany;import javax.imageio.imageio;imp

9、ort java.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); pressp

10、ic(c:users14779desktop, 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 outputw

11、idth = 100; / 默認(rèn)輸出圖片寬 private int outputheight = 100; / 默認(rèn)輸出圖片高 private boolean proportion = true; / 是否等比縮放標(biāo)記(默認(rèn)為等比縮放) public compresspicdemo() / 初始化變量 inputdir = ; outputdir = ; inputfilename = ; outputfilename = ; outputwidth = 100; outputheight = 100; public void setinputdir(string inputdir) this

12、.inputdir = inputdir; 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(in

13、t outputwidth) this.outputwidth = outputwidth; public void setoutputheight(int outputheight) this.outputheight = outputheight; public void setwidthandheight(int width, int height) this.outputwidth = width; this.outputheight = height; /* * 獲得圖片大小 * 傳入?yún)?shù) string path :圖片路徑 */ public long getpicsize(str

14、ing path) file = 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; el

15、se int newwidth; 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;/ 根據(jù)縮放比率大的進(jìn)行縮放控制 double rate = rate1 rate2 ? rate1 : rate2; ne

16、wwidth = (int) (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);/* im

17、age.scale_smooth 的縮略算法 生成縮略圖片的平滑度的* 優(yōu)先級比速度高 生成的圖片質(zhì)量比較好 但速度慢*/ tag.getgraphics().drawimage(img.getscaledinstance(newwidth, newheight, image.scale_smooth), 0, 0, null); string formatname = (outputdir + outputfilename).substring(outputdir + outputfilename).lastindexof(.) + 1);/ fileoutputstream out = n

18、ew fileoutputstream(outputdir + outputfilename);/ jpegimageencoder可適用于其他圖片類型的轉(zhuǎn)換/ jpegimageencoder encoder = jpegcodec.createjpegencoder(out);/ encoder.encode(tag); imageio.write(tag, formatname , new file(outputdir + outputfilename) );/ out.close(); catch (ioexception ex) ex.printstacktrace(); retur

19、n ok; public string compresspic (string inputdir, string outputdir, string inputfilename, string outputfilename) / 輸入圖路徑 this.inputdir = inputdir;/ 輸出圖路徑 this.outputdir = outputdir;/ 輸入圖文件名 this.inputfilename = inputfilename;/ 輸出圖文件名 this.outputfilename = outputfilename; return compresspic(); public

20、 string compresspic(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;/ 設(shè)置圖片長

21、寬 setwidthandheight(width, height);/ 是否是等比縮放 標(biāo)記 portion = gp; return compresspic(); 六、實驗過程中的問題及對應(yīng)思考實驗中出現(xiàn)了找不到輸出文件的問題,后考慮到可能是文件大小關(guān)系,所以換了一個小一些的圖片,完成實驗實驗三 超媒體開發(fā)設(shè)計一、實驗?zāi)康?、熟悉超文本和超文本系統(tǒng)的建立和典型的外部模型;2、熟練的運用超文本標(biāo)記語言的標(biāo)記方法展示超媒體;3、通過運用超文本標(biāo)記語言熟悉結(jié)點和鏈之間形成的超媒體結(jié)構(gòu)。二、實驗環(huán)境1、主流操作系統(tǒng)系統(tǒng);2、主流瀏覽器;3、系統(tǒng)有文本編輯器和網(wǎng)站開發(fā)工具。三、實驗內(nèi)

22、容1、運用超文本標(biāo)識語言和可擴(kuò)展語言架構(gòu)web站點的基本框架;2、練習(xí)超文本標(biāo)識語言進(jìn)行超媒體站點架構(gòu)時的合理布局及技巧;3、web站點主題內(nèi)容不限,但必須要有一明確主題體現(xiàn)超媒體;4、可以用記事本編寫實驗代碼;5、根據(jù)實驗內(nèi)容撰寫對應(yīng)的實驗報告;6、回答老師的對應(yīng)考核提問。四、設(shè)計方案使用canvas做出一個h5小游戲主要需要實現(xiàn)大魚吃果實大魚喂小魚小魚恢復(fù)體力還有一定的場景和界面的五、實驗代碼index.htmllovefish游戲規(guī)則鼠標(biāo)控制大魚吃果實吃到果實后喂給小魚若無及時投喂則小魚死亡紅色果實1分藍(lán)色果實兩分restartane.jsvar aneobj = function()t

23、his.rootx = ;this.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;/ 繪制??鸻neoto

24、type.draw = function()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,

25、canheight - 80,this.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=;/尾巴數(shù)組/ this.babyeye=;/眼睛數(shù)組this.babytailtimer=0;/計時器this.babytailcoun

26、t=0;/現(xiàn)在執(zhí)行到哪一幀this.babyeyetimer=0;/計時器this.babyeyecount=0;/現(xiàn)在執(zhí)行到哪一幀this.babybodytimer=0;/計時器this.babybodycount=0;/現(xiàn)在執(zhí)行到哪一幀this.babyeyeinterval;/這張圖片持續(xù)多久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+)/初始化小魚尾巴數(shù)組babytai

27、li=new image();babytaili.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

28、.random()*1500+2000;/如果睜著眼睛的狀態(tài)為1500-2000elsethis.babyeyeinterval=200;/閉眼狀態(tài)默認(rèn)200msif (this.babyeyetimerthis.babyeyeinterval) this.babyeyecount=(this.babyeyecount+1)%2;/取模實現(xiàn)循環(huán)this.babyeyetimer%=this.babyeyeinterval;/this.babybodytimer+=deltatime;if (this.babybodytimer300)this.babybodycount=this.babybo

29、dycount+1;this.babybodytimer%=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,-babytai

30、lbabytailcount.height*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.

31、5);ctx1.restore();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.

32、mombodycount=7;/ 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.fil

33、lstyle=rgba(255,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=;/圖片長度t

34、his.spd=;/速度this.fruittype=;/分辨果實類型this.orange = new image();this.blue = new image();/果實形態(tài)2fruitototype.num = 30;fruitototype.init=function()for (var i = 0; i this.num; i+) this.alivei=false;/初始化果實為激活狀態(tài)this.xi=0;this.yi=0;this.spdi=math.random()*0.017+0.003;/隨機(jī)生成速度在0.003,0.02之間this.fruit

35、typei=0;this.born(i);/console.log(this.yi); this.orange.src=./img/fruit.png;this.blue.src=./img/blue.png;/console.log(初始化執(zhí)行);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)/判斷成熟

36、this.li+=this.spdi*deltatime;/循環(huán)變大elsethis.yi-=this.spdi*5*deltatime;/當(dāng)成熟,y坐標(biāo)上移(果實上漂)ctx2.drawimage(pic, this.xi- this.li * 0.5,this.yi- this.li * 0.5,this.li,this.li);if (this.yi10) /當(dāng)果實飄出屏外時置果實為無任務(wù)this.alivei=false; /console.log(畫果實執(zhí)行);fruitototype.born=function(i)/果實坐標(biāo)依附在??蟰ar aneid =math.

37、floor(math.random()*ane.num);this.xi=ane.headxaneid;this.yi=ane.headyaneid;this.li=0;/長度從0開始this.alivei=true;var ran=math.random();/隨機(jī)數(shù)隨機(jī)決定藍(lán)色和黃色果實if (ran0.3) this.fruittypei=blue;elsethis.fruittypei=orange;/console.log(果實出生執(zhí)行);/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=fun

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論