uni.getImageInfo({
src: this.authorbackpic,
success: res => {
// 异步调用方式, 跨平台写法
uni.createCanvasContextAsync({
id: 'bgcolor',
component: this,
success: (context : CanvasContext) => {
this.renderingContext = context.getContext('2d')!
}
})
const context = this.renderingContext!
console.log('context',context)
const image = new Image(100, 100);
image.src = 'https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode.png'
image.onload = () => {
context.drawImage(image, 0, 0, 100, 100)
context.save()
let datadots = context.getImageData(0,0,100,100)
console.log('datadots',datadots)
}
console.log('-------context',context)
console.log('---',res)
}
})
返回数据如下
//[io.dcloud.canvas.ImageDataImpl]
{
"data":
//[io.dcloud.uts.Uint8ClampedArray]
{},
"height":
//[Int]
100,
"width":
//[Int]
100
}
为啥data是空对象呢
0 个回复