Here you can find the source of decodeToImage(String imageString)
Parameter | Description |
---|---|
imageString | The string to decode |
public static BufferedImage decodeToImage(String imageString)
//package com.java2s; //License from project: Open Source License import sun.misc.BASE64Decoder; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import javax.imageio.ImageIO; public class Main { /**//from w w w . ja v a 2s . c o m * Decode string to image * @param imageString The string to decode * @return decoded image */ public static BufferedImage decodeToImage(String imageString) { BufferedImage image = null; byte[] imageByte; try { BASE64Decoder decoder = new BASE64Decoder(); imageByte = decoder.decodeBuffer(imageString); ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); image = ImageIO.read(bis); bis.close(); } catch (Exception e) { e.printStackTrace(); } return image; } }