12 Mart 2017 Pazar

ImageWriter Sınıfı

getDefaultWriteParam metodou
Şöyle yaparız
ImageWriteParam iwp = writer.getDefaultWriteParam();
setOutput meetodu
Şöyle yaparız.
ImageOutputStream os = new FileImageOutputStream(new File(filenamepath));

ImageWriter jpgWriter = ImageIO.getImageWritersByFormatName("jpg").next();
ImageWriteParam jpgWriteParam = jpgWriter.getDefaultWriteParam();
jpgWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
jpgWriteParam.setCompressionQuality(1f);
jpgWriter.setOutput(os);
write metodu
Şöyle yaparız
BufferedImage bi = ...;

ImageWriter writer = ...;
ImageWriteParam iwp = ...;

ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new java.io.BufferedOutputStream(baos);
ImageOutputStream ios = ImageIO.createImageOutputStream(bos);
writer.setOutput(ios);

IIOImage optimizedImage = new IIOImage(bi, null, null);
writer.write(null, optimizedImage, iwp);
writer.dispose();
baos.flush();

Hiç yorum yok:

Yorum Gönder