Canvas - Combing two images, return one img html object?(Canvas - 组合两张图片,返回一个 img html 对象?)
问题描述
我有两个具有不同 src url 的 html img 对象.我想合并这两张图片(使用画布),并创建一个合并的 img 对象.
I have two html img objects with different src urls. I'd like to combine these two images (using canvas), and create one merged img object.
这可能吗?怎么样?
推荐答案
您可以在画布上绘制这两个图像,并将它们与您喜欢的任何叠加模式结合起来.要从画布中获取位图数据,您可以使用toDataURL".请注意,这两个图像应与页面来自同一域,否则出于安全原因,您对像素数据的访问将被阻止.
You can draw both images on the canvas and combine them with any overlay mode you like. To get the bitmap data from the canvas you can use 'toDataURL'. Only note that both images should come from the same domain as the page, otherwise your access to the pixel data is blocked for security reasons.
这篇关于Canvas - 组合两张图片,返回一个 img html 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Canvas - 组合两张图片,返回一个 img html 对象?
基础教程推荐
- 在 contenteditable 中精确拖放 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
