本文整理汇总了Java中javax.imageio.ImageWriteParam.getCompressionMode方法的典型用法代码示例。如果您正苦于以下问题:Java ImageWriteParam.getCompressionMode方法的具体用法?Java ImageWriteParam.getCompressionMode怎么用?Java ImageWriteParam.getCompressionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.ImageWriteParam
的用法示例。
在下文中一共展示了ImageWriteParam.getCompressionMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
@Override
public void write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param) throws IOException {
RenderedImage img = image.getRenderedImage();
if (stream == null) {
throw new IOException("Set an output first!");
}
if (param == null) {
param = getDefaultWriteParam();
}
Rectangle sourceRegion = new Rectangle(0, 0, img.getWidth(), img.getHeight());
if (param.getSourceRegion() != null) {
sourceRegion = sourceRegion.intersection(param.getSourceRegion());
}
Raster raster = img.getData(sourceRegion);
int quality = 85;
if (param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
quality = (int) (param.getCompressionQuality() * 100);
}
try {
stream.write(lib.encode(raster, quality).array());
} catch (TurboJpegException e) {
throw new IOException(e);
}
}
示例2: TIFFDeflater
import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
public TIFFDeflater(String compressionType,
int compressionTagValue,
ImageWriteParam param,
int predictorValue) {
super(compressionType, compressionTagValue, true);
this.predictor = predictorValue;
// Set the deflate level.
int deflateLevel;
if(param != null &&
param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
float quality = param.getCompressionQuality();
deflateLevel = (int)(1 + 8*quality);
} else {
deflateLevel = Deflater.DEFAULT_COMPRESSION;
}
this.deflater = new Deflater(deflateLevel);
}
示例3: getDefaultImageMetadata
import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType,
ImageWriteParam param) {
BMPMetadata meta = new BMPMetadata();
meta.bmpVersion = VERSION_3;
meta.compression = getPreferredCompressionType(imageType);
if (param != null
&& param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
meta.compression = BMPCompressionTypes.getType(param.getCompressionType());
}
meta.bitsPerPixel = (short)imageType.getColorModel().getPixelSize();
return meta;
}