BufferedImage outputImage = new BufferedImage(ire.getWidth(null), ire.getHeight(null), BufferedImage.TYPE_BYTE_BINARY);
outputImage.createGraphics().drawImage(ire, 0, 0, null);
TIFFEncodeParam param = new TIFFEncodeParam();
param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
FileOutputStream stream = new FileOutputStream(new File(path));
TIFFImageEncoder encoder = (TIFFImageEncoder) TIFFCodec.createImageEncoder("tiff", stream, param);
encoder.encode(outputImage);
//=====================================
ImageOutputStream out = ImageIO.createImageOutputStream(new File("c:\\temp\\ggg.tif"));
ImageWriter writer = ImageIO.getImageWritersByFormatName("tiff").next();
ImageWriteParam param2 = writer.getDefaultWriteParam();
param2.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param2.setCompressionType("CCITT T.4");
writer.setOutput(out);
writer.write(null,new IIOImage(ImageIO.read(new File(path)),null,null), param2);
writer.dispose();
out.close();
//=====================================
댓글 없음:
댓글 쓰기