多媒体技术实验报告

上传人:汽*** 文档编号:497327309 上传时间:2022-09-28 格式:DOCX 页数:23 大小:98.97KB
返回 下载 相关 举报
多媒体技术实验报告_第1页
第1页 / 共23页
多媒体技术实验报告_第2页
第2页 / 共23页
多媒体技术实验报告_第3页
第3页 / 共23页
多媒体技术实验报告_第4页
第4页 / 共23页
多媒体技术实验报告_第5页
第5页 / 共23页
点击查看更多>>
资源描述

《多媒体技术实验报告》由会员分享,可在线阅读,更多相关《多媒体技术实验报告(23页珍藏版)》请在金锄头文库上搜索。

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

2、写程序实现主流图像文件格式之间的相互转换;2、至少要实现JPG、BMP、GIF、PNG图像文件之间的转换;3、编程语言不限;4、根据实验内容撰写对应的实验报告。四、设计方案ImageIO 类的静态方法可以执行许多常见的图像 I/O 操作。此包包含一些基本类和接口,有的用来描述图像文件内容(包括元数据和缩略图)(IlOImage); 有的用来控制图像读取过程(ImageReader、ImageReadParam和ImageTypeSpecifier)和控制 图像写入过程(ImageWriter和ImageWriteParam);还有的用来执行格式之间的代码转换 (ImageTranscoder)

3、 和报告错误 (IIOException)。可处理图像格式有:jpg,BMRbmp,JPG,wbmp,jpeg,png,PNG,JPEG,WBMPGIgif。 另外在加一些输入代码可实现简单的格式转换选择。五、实验代码import javax.imagei o.I mageIO;import java.awt.image.Bufferedlmage;import java.io.File;import java.io.FileOutputStream;import java.i o.IO Excepti on;import java.io.OutputStream;import java.ut

4、il.Sca nn er;public class Main public static void main(String args) Scanner scan = new Scanner(System.in);System.out.prntln(请输入需要转换的格式jpg, bmp, png, gif:);File out = new File(/Users/14779/Desktop/1jpg);/将图片写入/mage/O流try BufferedImage img = ImagelO.read(out);/将图片写出到指定位置(复制图片)switch (scan.next()casepn

5、g: casePNG:OutputStream ops = new FileOutputStream(newFile(7Users/14779/Desktop/1(1) png);lmagelO.write(img, png, ops);System.ouf.println(转换完成!); break;casejpg: caseJPG:ops = new FileOutputStream(new File(/Users/14779/Desktop/1(1).jpg);lmagelO.write(img, jpg, ops);System.out.println(转换完成!);break;cas

6、ebmp: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.println(转换完成!); break;default:Syste

7、m.out.println(请输入正确格式!); break; catch (IOException e) e.pri ntStackTrace();实验截图lilMbmp 转撫完成!illC: Pr0gr3m Fi lesJa V3jdk-9. 0.1 VbinKjava* 八*请输入需要丰专换的格式Zjpg, bnip, png, gif:Process finished with 总工it code 0六、实验过程中的问题及对应思考ImagelO是一个封装好的图像输入输出类,使用ImagelO类的静态方法可以执行许多常见 的图像I/O操作。我将图片路径事先写好放入程序里,可以通过键入转换

8、格式来达到想要转换 到的格式,为了避免键入出错,我将主程序写在try函数中。实验二多媒体图像文件压缩一、实验目的1、了解各种图像文件格式之间的存储方法和方式,了解其编码的组织方式;2、掌握运用高级编程语言编写多媒体应用程序的方法;3、运用高级编程语言实现对多媒体图像文件的压缩的方法。二、实验环境1、主流操作系统;2、高级语言编程环境。三、实验内容1、使用高级编程语言编写良好的运行界面;2、运用高级编程语言编写核心代码实现对图像文件的压缩;3、了解压缩过程中的顺进和累进方法的运用提高压缩比;4、合理的考虑压缩算法压缩和解压的速度平衡;5、编程语言不限;6、根据实验内容撰写对应的实验报告。四、设计

9、方案使用imagiolO的对图片的压缩处理来进行此项实验。五、实验代码package .compa ny;import javax.imagei o.I magelO;import java.awt.*;import java.awt.image.Bufferedlmage;import java.io.File;import java.i o.IO Excepti on; public class Main public static void main(String args) CompressPicDemo mypic = new CompressPicDemo();System. ou

10、 t. pr in tl n(输入的图片大小:+ mypic.getPicSize(C:Users14779Desktop2.jpg)/1024 + KB);pressPic(C:Users14779Desktop, C:Users14779Desktop, 2.jpg, 2(2).jpg, 120, 120, false);class CompressPicDemo private File file = null; II 文件对象 private String inputDir; II 输入图路径 private String outputDir; II 输出图路径 private Str

11、ing inputFileName; II 输入图文件名 private String outputFileName; II 输出图文件名 private int outputwidth = 100; II 默认输出图片宽 private int outputHeight = 100; II 默认输出图片高 private boolean proportion = true; II是否等比缩放标记默认为等比缩放 public CompressPicDemo() II 初始化变量inp utDir =; outputDir =; inputFileName =; outputFileName =

12、; outputWidth = 100; outputHeight = 100;public void set In putDir(Stri ng in putDir) this.i nputDir = in putDir;public void setOutputDir(String outputDir) this. outputDir = outputDir;public void setInputFileName(String inputFileName) this.i nputFileName = in putFileName;public void setOutputFileName

13、(String outputFileName) this. outputFileName = outputFileName;public void setOutputWidth(int outputWidth) this. outputWidth = outputWidth;public void setOutputHeight(int outputHeight) this. outputHeight = outputHeight; public void setWidthAndHeight(int width, int height) this. outputWidth = width; t

14、his. outputHeight = height;I*获得图片大小*传入参数String path :图片路径*/public long getPicSize(Stri ng path) file = new File(path);return file.length();/图片处理public String compressPic() try /获得源文件file = new File(inputDir + inputFileName);if (!file.exists() return;Image img = ImagelO.read(file);/判断图片格式是否正确if (img.getWidth(null) = -1) System. out.pri ntl n( cant read,retry! + );return no; else int newWidth; int newHeight;/判断是否是等比缩放if (this.proportion = true) /为等比缩放计算输出的图片宽度及高度double rate1 = (double) img.getWidth(null) / (double) outputwidth + 0.1; doub

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号