JPEG TIFF编码 [英] JPEG in TIFF encoding

查看:196
本文介绍了JPEG TIFF编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行以下步骤:

TIFFEncodeParam tep = new TIFFEncodeParam();

tep.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2);

BufferedImage buff = new BufferedImage(newimage.getWidth(null),
                                                   newimage.getHeight(null),
                                                   BufferedImage.TYPE_BYTE_BINARY);
//newimage is an awt image

buff.createGraphics().drawImage(newimage, 0,0,null);

ParameterBlock outPB = new ParameterBlock();

outPB.addSource(buff);
outPB.add("myjpegfile.jpg");
outPB.add("tiff");
outPB.add(tep);

PlanarImage outPI = JAI.create("filestore",outPB);

在这里我得到:java.lang.Error:仅8位sampl支持JPEG-in-TIFF编码 es,每个像素1个(灰度)或3个(RGB或YCbCr)样本.

Here I get:java.lang.Error: JPEG-in-TIFF encoding supported only for 8-bit sampl es and either 1 (grayscale) or 3 (RGB or YCbCr) samples per pixel.

这是因为我需要在jpeg文件中对单色图像进行最大程度的压缩. 我可以写tiff(24Kb)和jpeg(212Kb)(A4页面大小200dpi BW),但是jpeg太大.

This because I need to have maximum compression in jpeg file for monochromatic image. I'm able to write tiff (24Kb), and jpeg (212Kb) (A4 page size 200dpi BW) but jpeg is too huge.

此错误是什么意思?什么是8位样本?

What does it mean this error? What is 8-bit samples?

谢谢.

推荐答案

这意味着JPEG--in-TIFF仅支持8位灰度(= 1个样本,每个像素8位)或24位彩色图像(= 3个样本(每个像素8位).

This means that JPEG--in-TIFF only supports 8-bit greyscale (= 1 sample with 8 bits per pixel) or 24-bit color images (= 3 samples with 8 bits per pixels).

TYPE_BYTE_BINARY代表黑白图片(= 1个样本,每个像素1位).您想改用TYPE_BYTE_GRAY.

TYPE_BYTE_BINARY represents a black/white picture (= 1 sample with 1 bit per pixel). You'd want to use TYPE_BYTE_GRAY instead.

这篇关于JPEG TIFF编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆