1 28 package net.sf.jasperreports.engine.util; 29 30 import java.awt.Image ; 31 import java.awt.MediaTracker ; 32 import java.awt.Panel ; 33 import java.awt.Toolkit ; 34 35 import net.sf.jasperreports.engine.JRException; 36 37 38 42 public class JRJdk13ImageReader implements JRImageReader 43 { 44 45 46 49 public Image readImage(byte[] bytes) throws JRException 50 { 51 Image image = Toolkit.getDefaultToolkit().createImage(bytes); 52 53 MediaTracker tracker = new MediaTracker (new Panel ()); 54 tracker.addImage(image, 0); 55 try 56 { 57 tracker.waitForID(0); 58 } 59 catch (Exception e) 60 { 61 throw new JRException(e); 63 } 64 65 if(tracker.isErrorID(0)) 66 { 67 throw new JRException("Image read failed."); 68 } 69 70 return image; 71 } 72 73 74 } 75 | Popular Tags |