简体   繁体   English

将Canvas下载为没有.toDataUrl()的图像

[英]Download Canvas as Image without .toDataUrl()

Is it possible to download the (edited) Image of a Canvas Element in HTML without using the .toDataUrl() function? 是否可以在不使用.toDataUrl()函数的情况下以HTML下载Canvas元素的(已编辑)图像? I tested some frameworks but they still use this function. 我测试了一些框架,但他们仍然使用这个功能。

In newer browsers, you can get MUCH larger images and faster performance with the async method canvas.toBlob(callback, mimeType, qualityArgument); 在较新的浏览器中,使用async方法canvas.toBlob(callback, mimeType, qualityArgument);可以获得更大的图像和更快的性能canvas.toBlob(callback, mimeType, qualityArgument);

see the mdc article for details and compat (basically IE10+) 有关详细信息和compat(基本上是IE10 +),请参阅mdc文章

the blob doesn't have the same size limits that dataURL realistically face in many browsers and devices, so where supported, it leads to a much better user experience. blob没有dataURL在许多浏览器和设备中实际面临的相同大小限制,因此在支持的情况下,它会带来更好的用户体验。

if you later want to turn the blob into a dataURL, use FileReader.readAsDataURL(blob) 如果您以后想要将blob转换为dataURL,请使用FileReader.readAsDataURL(blob)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM