Java BufferedImage from String decodeToImage(String imageString)

Here you can find the source of decodeToImage(String imageString)

Description

decode To Image

License

Open Source License

Declaration

public static java.awt.image.BufferedImage decodeToImage(String imageString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static java.awt.image.BufferedImage decodeToImage(String imageString) {

        java.awt.image.BufferedImage image = null;
        try {/*from  w ww.  j  a v  a  2 s . c  om*/
            String imgString = imageString.startsWith("data:image/")
                    ? imageString.substring(imageString.indexOf(',') + 1)
                    : imageString;
            java.io.InputStream stream = new java.io.ByteArrayInputStream(
                    java.util.Base64.getDecoder().decode(imgString));
            image = javax.imageio.ImageIO.read(stream);
            stream.close();
        } catch (Exception e) {
        }
        return image;
    }
}

Related

  1. base64ToImage(String base64)
  2. base64ToImg(String base64Strings)
  3. decodeImage(String encoded)
  4. decodeImage(String imageString)
  5. decodeToImage(String imageString)
  6. decodeToImage(String imageString, String pathFile)