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 对象?
基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
