江苏科技大学
多媒体技术考核报告
( 2 0 1 7 / 2 0 1 8 学 年 第 1 学 期 )
课程名称: 多 媒 体 技 术
指导教师: 景 国 良
实验地点: 东校区外训楼软件工程实验室
学生姓名: 谢卉
学生学号: 1477965899
院 系: 计算机学院
专 业: 计算机科学与技术专业
考核得分:
2017 年 11 月 日
实验一 多媒体图像文件转换
一、实验目的
1.掌握多媒体静态图像的基本概念,技术和获取过程。
2.掌握多媒体图像文件基本格式种类。
3.掌握不同图像文件的数据结构形式,了解不同格式图像文件的具体类型区别。
4.运用高级语言编程实现不同图像文件类型的相互转换。
二、实验环境
1、主流操作系统;
2、高级语言编程环境。
三、实验内容
1、编写程序实现主流图像文件格式之间的相互转换;
2、至少要实现 JPG、BMP 、GIF 、PNG 图像文件之间的转换;
3、编程语言不限;
4、根据实验内容撰写对应的实验报告。
四、设计方案
ImageIO 类的静态方法可以执行许多常见的图像 I/O 操作。
此包包含一些基本类和接口,有的用来描述图像文件内容(包括元数据和缩略图) (IIOImage) ;
有的用来控制图像读取过程( ImageReader、ImageReadParam 和 ImageTypeSpecifier )和控制
图像写入过程( ImageWriter 和 ImageWriteParam );还有的用来执行格式之间的代码转换
(ImageTranscoder) 和报告错误 (IIOException) 。
可处理图像格式有: jpg,BMP,bmp,JPG,wbmp,jpeg,png,PNG,JPEG,WBMP,GIF,gif 。
另外在加一些输入代码可实现简单的格式转换选择。
五、实验代码
import ;
import ;
import ;
import ;
import ;
import ;
import ;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System. in );
System. ( " 请输入需要转换的格式 [jpg, bmp, png, gif]:" );
File out = new File( "/Users/14779/Desktop/" );
// 将图片写入 ImageIO流 try {
BufferedImage img = ImageIO. read(out);
// 将图片写出到指定位置(复制图片) switch (()){
case "png" :
case "PNG":
OutputStream ops = new FileOutputStream( new
File( "/Users/14779/Desktop/1(1).png" ));
ImageIO. write (img, "png" , ops); System. ( " 转换完成! " );
break ;
case "jpg" :
case "JPG" :
ops = new FileOutputStream( new File( "/Users/14779/Desktop/1(1).jpg" ));
ImageIO. write (img, "jpg" , ops); System. ( " 转换完成! " );
break ;
case "bmp" :
case "BMP":
ops = new FileOutputStream( new File( "/Users/14779/Desktop/1(1).bmp" ));
ImageIO. write (img, "bmp" , ops); System. ( " 转换完成! " );
break ;
case "GIF" :
case "gif" :
ops = new FileOutputStream( new File( "/Users/14779/Des
多媒体技术实验报告 来自淘豆网www.taodocs.com转载请标明出处.