1 42 package org.jfree.chart.encoders; 43 44 import javax.imageio.ImageIO ; 45 import java.awt.image.BufferedImage ; 46 import java.io.OutputStream ; 47 import java.io.ByteArrayOutputStream ; 48 import java.io.IOException ; 49 50 57 public class SunPNGEncoderAdapter implements ImageEncoder { 58 59 64 public float getQuality() { 65 return 0.0f; 66 } 67 68 74 public void setQuality(float quality) { 75 } 77 78 83 public boolean isEncodingAlpha() { 84 return false; 85 } 86 87 94 public void setEncodingAlpha(boolean encodingAlpha) { 95 } 97 98 107 public byte[] encode(BufferedImage bufferedImage) throws IOException { 108 ByteArrayOutputStream outputStream = new ByteArrayOutputStream (); 109 encode(bufferedImage, outputStream); 110 return outputStream.toByteArray(); 111 } 112 113 120 public void encode(BufferedImage bufferedImage, OutputStream outputStream) 121 throws IOException { 122 if (bufferedImage == null) { 123 throw new IllegalArgumentException ("Null 'image' argument."); 124 } 125 if (outputStream == null) { 126 throw new IllegalArgumentException ("Null 'outputStream' argument."); 127 } 128 ImageIO.write(bufferedImage, ImageFormat.PNG, outputStream); 129 } 130 131 } 132 | Popular Tags |