- BufferedImage转base64
BufferedImage image=null;
// ByteArrayOutputStream stream = new ByteArrayOutputStream();
// ImageIO.write(image, "png", stream);
// base64 = Base64.encode(stream.toByteArray());
- base64前缀:data:image/png;base64,
- 显示在网页:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<img src="data:image/png;base64,base64码" />
</body>
</html>