java将多张图片合成一张tif图片
来源:互联网 发布:centos7 yum安装wine 编辑:程序博客网 时间:2024/05/16 01:56
public static void many2one(List<String> bookFilePaths, String toPath,String distFileName) {
if (bookFilePaths != null && bookFilePaths.size() > 0) {
File[] files = new File[bookFilePaths.size()];
for(int i = 0; i < bookFilePaths.size(); i++){
files[i] = new File(bookFilePaths.get(i));
}
if (files != null && files.length > 0) {
try {
ArrayList pages = new ArrayList(files.length - 1);
FileSeekableStream[] stream = new FileSeekableStream[files.length];
for (int i = 0; i < files.length; i++) {
stream[i] = new FileSeekableStream(
files[i].getCanonicalPath());
}
ParameterBlock pb = (new ParameterBlock());
PlanarImage firstPage = JAI.create("stream", stream[0]);
for (int i = 1; i < files.length; i++) {
PlanarImage page = JAI.create("stream", stream[i]);
pages.add(page);
}
TIFFEncodeParam param = new TIFFEncodeParam();
File f = new File(toPath);
if(!f.exists()){
f.mkdirs();
}
OutputStream os = new FileOutputStream(toPath + File.separator+ distFileName);
ImageEncoder enc = ImageCodec.createImageEncoder("tiff",
os, param);
param.setExtraImages(pages.iterator());
enc.encode(firstPage);
for (int i = 0; i < files.length; i++) {
stream[i].close();
if(files[i].isFile()&&files[i].exists()){
files[i].delete();
}
}
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
if (bookFilePaths != null && bookFilePaths.size() > 0) {
File[] files = new File[bookFilePaths.size()];
for(int i = 0; i < bookFilePaths.size(); i++){
files[i] = new File(bookFilePaths.get(i));
}
if (files != null && files.length > 0) {
try {
ArrayList pages = new ArrayList(files.length - 1);
FileSeekableStream[] stream = new FileSeekableStream[files.length];
for (int i = 0; i < files.length; i++) {
stream[i] = new FileSeekableStream(
files[i].getCanonicalPath());
}
ParameterBlock pb = (new ParameterBlock());
PlanarImage firstPage = JAI.create("stream", stream[0]);
for (int i = 1; i < files.length; i++) {
PlanarImage page = JAI.create("stream", stream[i]);
pages.add(page);
}
TIFFEncodeParam param = new TIFFEncodeParam();
File f = new File(toPath);
if(!f.exists()){
f.mkdirs();
}
OutputStream os = new FileOutputStream(toPath + File.separator+ distFileName);
ImageEncoder enc = ImageCodec.createImageEncoder("tiff",
os, param);
param.setExtraImages(pages.iterator());
enc.encode(firstPage);
for (int i = 0; i < files.length; i++) {
stream[i].close();
if(files[i].isFile()&&files[i].exists()){
files[i].delete();
}
}
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
- java将多张图片合成一张tif图片
- iOS开发图片合成,多张图片合成一张图片
- 用flex将两张图片合成一张图片
- 多张图片合成一张图片
- 三张jpg图片合成一张
- 多张UIImage图片合成一张
- pdf多页合成一张pdf图片
- ios两个图片合成为一张
- java图片处理——多张图片合成一张Gif图片并播放或Gif拆分成多张图片
- java图片处理——多张图片合成一张Gif图片并播放或Gif拆分成多张图片
- Java图片合成,压缩
- java合成图片
- java合成图片
- java 二维码图片合成
- JAVA图片合成
- java 图片合成
- java 图片合成
- java 图片合成
- android 9-patch
- 最核心4大NFC技术规范详解
- 64位win7下visual studio 10使用libcurl静态库的问题
- dede 留言簿 多个
- 文件下载,文件名乱码,XLS设置
- java将多张图片合成一张tif图片
- new和delete
- JDK中的URLConnection参数详解
- XA分布式事务处理
- C#笔记本
- C#中关于托管资源和非托管资源
- oracle中merge用法
- ios开发中测试设备不在身边,如何进行测试
- 一个前辈写的网络协议学习方法