jquery canvas图像下载 [英] jquery canvas image download
本文介绍了jquery canvas图像下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的canvas元素和一些div,点击后我希望打开下载画布快照。现在我有:
I have my canvas element and some div, which after clicking I wish open downloading the "canvas snapshot". Over now I have:
$("#save").live('click', function(e)
{
var image = canvas.toDataURL("image/png", true);
var imageElement = document.getElementById("myPics");
imageElement.src = image;
});
什么显示图像 - 所以没关系,但我想要的是会导致自动下载的公式点击#save div后,这张图片给用户电脑。
What displays the Image - so it is ok, but what I want is formula which will cause automatic download of this picture to users computer, after clicking #save div.
推荐答案
使用HTML5 blob可以保存图像。
The saving of the image can be done using HTML5 blobs.
http://www.html5rocks.com/en/教程/文件/文件系统/ #toc文件写入
你可以从< canvas>中获取Blob
就像在这段代码中完成一样:
You can get Blob out of the <canvas>
like done in this code:
https://github.com/miohtama/Krusovice/blob/master/src/tools/resizer.js
这篇关于jquery canvas图像下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文