java中两个vector合并,如何在JAVA中将两个或多个tiff图像文件合并到一个多页tiff图像中...

I have 5 single page tiff images.

I want to combine all these 5 tiff images in to one multipage tiff image.

I am using Java Advanced Imaging API.

I have read the JAI API documentation and tutorials given by SUN.

I am new to JAI. I know the basic core java.

I dont understand those documentation and turorial by SUN.

So friends Please tell me how to combine 5 tiff image file in to one multipage tiff image.

Please give me some guidence on above topic.

I have been searching internet for above topic but not getting any single clue.

So please guide me friends.

Thanks in advance.

解决方案

I hope you have the computer memory to do this. TIFF image files are large.

You're correct in that you need to use the

First, you have to convert the TIFF images to a

BufferedImage image[] = new BufferedImage[numImages];

for (int i = 0; i < numImages; i++) {

SeekableStream ss = new FileSeekableStream(input_dir + file[i]);

ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", ss, null);

PlanarImage op = new NullOpImage(decoder.decodeAsRenderedImage(0), null, null, OpImage.OP_IO_BOUND);

image[i] = op.getAsBufferedImage();

}

Then, you convert the BufferedImage array back into a multiple TIFF image. I haven't tested this code either.

TIFFEncodeParam params = new TIFFEncodeParam();

OutputStream out = new FileOutputStream(output_dir + image_name + ".tif");

ImageEncoder encoder = ImageCodec.createImageEncoder("tiff", out, params);

Vector vector = new Vector();

for (int i = 0; i < numImages; i++) {

vector.add(image[i]);

}

params.setExtraImages(vector.listIterator(1)); // this may need a check to avoid IndexOutOfBoundsException when vector is empty

encoder.encode(image[0]);

out.close();

Good luck.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值