1 28 package net.sf.jasperreports.engine.util; 29 30 import java.awt.Image ; 31 import java.io.ByteArrayInputStream ; 32 import java.io.IOException ; 33 import java.io.InputStream ; 34 35 import javax.imageio.ImageIO ; 36 37 import net.sf.jasperreports.engine.JRException; 38 39 40 44 public class JRJdk14ImageReader implements JRImageReader 45 { 46 47 48 51 public Image readImage(byte[] bytes) throws JRException 52 { 53 InputStream bais = new ByteArrayInputStream (bytes); 54 55 Image image = null; 56 try 57 { 58 image = ImageIO.read(bais); 59 } 60 catch (IOException e) 61 { 62 throw new JRException(e); 63 } 64 finally 65 { 66 try 67 { 68 bais.close(); 69 } 70 catch (IOException e) 71 { 72 } 73 } 74 75 if (image == null) 76 { 77 throw new JRException("Image read failed."); 78 } 79 80 return image; 81 } 82 83 84 } 85 | Popular Tags |