Hello, I still can't draw locally using downloadFile or getImageInfo.
well, I found the problem myself, and then the problem of the landlord did not appear in version 2.0.8. Maybe Tencent added the whitelist itself, that link, download does not draw on Synchronize, and pointing to the problem is that everyone's network pictures can not be drawn. I borrow the place where the landlord borrows the place to put a code to draw a network picture. Thank you.
drawPage: function () {
var that = this; // context.draw(true, that.getTempFilePath);
var context = wx.createCanvasContext('share');
var avatar = this.data.avatar;
this.setData({
canvasSwitcher: true
})
wx.downloadFile({
url: avatar,
success: function (res) {
if(res.tempFilePath) {
context.drawImage(res.tempFilePath, 150, 260, 30, 30);
context.draw(true, that.getTempFilePath);
}
}
})
var images = '../images/Bitmap.png';
context.setFillStyle('-sharpf2f2f2');
context.drawImage(images, 10, 10, 295, 250);
console.log(avatar)
context.setFontSize(20);
context.setFillStyle("-sharp666");
context.fillText('232', 230, 380);
context.fillText('', 200, 400);
context.fill();
context.draw(true, this.getTempFilePath);
},
getTempFilePath:function(){
console.log(121221)
wx.canvasToTempFilePath({
canvasId: 'share',
success: (res) => {
this.setData({
shareTempFilePath: res.tempFilePath
})
}
})
},
it should take time to download pictures on the Internet, so if you don't want to wait on Synchronize, please write true in the first parameter of another draw
.
Today, I revised it again. After I went online, I found that the picture could not be saved. I really wanted to add the avatar download address to the whitelist and was cheated.
above is your answer
can you share the source code?
excuse me: "configure https://wx.qlogo.cn into a secure domain name to ok. How to configure this?
Hello, I use canvas to draw Wechat's profile picture. It takes getImageInfo about 3 seconds to get url. Is it the same with yours?