Here you can find the source of base64StringToImage(String imageString)
Parameter | Description |
---|---|
imageString | The string to decode |
public static BufferedImage base64StringToImage(String imageString)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Open Door Logistics (www.opendoorlogistics.com) * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at http://www.gnu.org/licenses/lgpl.txt ******************************************************************************/ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import javax.imageio.ImageIO; import sun.misc.BASE64Decoder; public class Main { /**// w w w . ja v a2s. com * Decode string to image * * @param imageString * The string to decode * @return decoded image */ public static BufferedImage base64StringToImage(String imageString) { BufferedImage ret = null; byte[] imageByte; try { BASE64Decoder decoder = new BASE64Decoder(); imageByte = decoder.decodeBuffer(imageString); ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); ret = ImageIO.read(bis); bis.close(); } catch (Throwable e) { } return ret; } }