赞
踩
// 合并2张图片
function mergeImage(base1, base2, width, height) {
return new Promise((resolve, reject) => {
const canvas = document.createElement("canvas")
canvas.width = width
canvas.height = height
const ctx = canvas.getContext("2d")
const image = new Image() // MAP图片
image.crossOrigin = "Anonymous" // 支持跨域图片
image.onload = () => {
ctx.drawImage(image, 0, 0, width, height)
const image2 = new Image() // div图片
image2.crossOrigin = "Anonymous" // 支持跨域图片
image2.onload = () => {
ctx.drawImage(image2, 0, 0, width, height)
// 合并后的图片
const base64 = canvas.toDataURL("image/png")
resolve(base64)
}
image2.src = base2
}
image.src = base1
})
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。