1 30 31 package it.businesslogic.ireport.util; 32 33 import org.w3c.tools.codec.Base64Decoder; 34 import java.awt.*; 35 import java.io.*; 36 37 public class ImageLoader { 38 39 public static java.awt.Image loadFromBase64String( String imageSource ) throws net.sf.jasperreports.engine.JRException 40 { 41 Image _image = null; 42 try { 43 44 ByteArrayInputStream bais = new ByteArrayInputStream(imageSource.getBytes("UTF-8")); 45 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 46 47 Base64Decoder decoder = new Base64Decoder(bais, baos); 48 decoder.process(); 49 50 _image = Toolkit.getDefaultToolkit().createImage( baos.toByteArray() ); 51 52 MediaTracker traker = new MediaTracker(new Panel()); 53 traker.addImage(_image, 0); 54 55 traker.waitForID(0); 56 } 57 catch (Exception e) 58 { 59 e.printStackTrace(); 61 System.out.flush(); 62 throw new net.sf.jasperreports.engine.JRException(e); 63 } 64 65 return _image; 66 } 67 68 } 69 | Popular Tags |