How can I save div as image at client side where div contains one or more than one HTML5 canvas elements?(如何在 div 包含一个或多个 HTML5 画布元素的客户端将 div 保存为图像?)
问题描述
Div 'canvasesdiv' 元素包含三个 HTML5 画布.
如何使用 JavaScript 保存在客户端的 div 'canvasesdiv' 中包含所有画布的图像?
解决方案 这和我之前回答的一个问题非常相似:save-many-canvas-element-as-image
总而言之:将所有画布绘制到其中之一,然后通过 toDataURL()
获取图像Div 'canvasesdiv' element contains three HTML5 canvases.
<div style="position: relative; width: 400px; height: 300px;" id="canvasesdiv">
<canvas width="400" height="300px" style="z-index: 1; position: absolute; left: 0px; top: 0px;" id="layer1" />
<canvas width="400" height="300px" style="z-index: 2; position: absolute; left: 0px; top: 0px;" id="layer2"/>
<canvas width="400" height="300px" style="z-index: 3; position: absolute; left: 0px; top: 0px;" id="layer3"/>
</div>
How can I save an image combining all canvases present inside the div 'canvasesdiv' at client side using JavaScript?
解决方案 This is very similar to a previous question that I answered:
save-many-canvas-element-as-image
In summary: draw all of the canvases to one of them and then get the image via toDataURL()
这篇关于如何在 div 包含一个或多个 HTML5 画布元素的客户端将 div 保存为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 div 包含一个或多个 HTML5 画布元素的客户端将 div 保存为图像?
基础教程推荐
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
