1.利用canva可以转成base64码
var canvas = $chart.find("canvas")[0];
var data = canvas.toDataURL('image/png');
var b64 = data.split(",")[1];
2.将截取后的base64码上传到后端,生成图片
//base64字符串转化成图片
public static Boolean GenerateImage(String imgStr,String desPath)
{ //对字节数组字符串进行Base64解码并生成图片
BASE64Decoder decoder = new BASE64Decoder();
byte[] b;
try {
b = decoder.decodeBuffer(imgStr);
ByteArrayInputStream bais = new ByteArrayInputStream(b);
BufferedImage bi1 = ImageIO.read(bais);
File w2 = new File(desPath);
ImageIO.write(bi1, "png", w2);
return true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}