画布 - 梳理两个图像,返回一个img html对象? [英] Canvas - Combing two images, return one img html object?

查看:113
本文介绍了画布 - 梳理两个图像,返回一个img html对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个带有不同src网址的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.

这篇关于画布 - 梳理两个图像,返回一个img html对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆