当前位置:网站首页>Canvastotempfilepath of wechat
Canvastotempfilepath of wechat
2022-06-22 07:40:00 【A Huang Junhui a】
When canvas After drawing the picture , We want to save it locally , Or upload to the server ,
In two ways , One is to save pictures base64 Image information
The other is Save the binary data of the picture to the local , The default is png Format
The first method , have access to canvas Object's toDataURL(); Get one base64 Encoded picture information
canvas.toDataURL
Here's a reminder it is to be noted that canvas.getContext();
Let's draw a picture , Writing is used convas.getContext() The object of acquisition , and toDataURL It is used. canvas object ,
There are pictures to prove 
The second method , You can upload pictures to the server in wechat programs , We won't upload here , Use wechat ready-made api Save it locally
wx.canvasToTempFilePath({
canvasId: "canvas",
canvas:that.data.canvasobj,
x:0,
y:0,
success(res){
console.log(res.tempFilePath);
wx.saveImageToPhotosAlbum({
filePath:res.tempFilePath,
success(res1){
wx.showToast({
title: ' Saved successfully ',
duration: 1000,
});
}
})
},
fail(e){
console.log(e);
}
},that)
above filepath:res.tempFilePath Value Something like this http://tmp/Q7HOHsK5uM3v9a28c4b4cfd44850fa422994a8ab457f.png
You can open... In wechat developer tool , But it can't be opened in Google
The above code can see , It is saved to the local picture library
边栏推荐
猜你喜欢

Wx applet vant UI call interface to realize two-level cascade

Detr3d model source code Guide & mmdetection3d construction process

How to backup the treasures in the store and upload them to multiple stores

Crmeb open source version, a free mall worth trying

Open version - order delivery

The pit on the school recruitment Road

Chromedriver所有版本下載

Taobao assistant can not be used. How to export the baby in the warehouse to backup the data package

Qualcomm platform LCM summary
![[standard version 4.3] marketing activities (group bargaining second kill) error reporting under orders](/img/44/2e7789a97fa43d196ef770e8b3c4d4.jpg)
[standard version 4.3] marketing activities (group bargaining second kill) error reporting under orders
随机推荐
Device tree failed to add SPI device node
网站是否要修改标题
MTK platform execution disable_ Interrupt signals masked during IRQ will be enabled when I execute enable_ Continue triggering after IRQ
Backup the method of uploading babies in Taobao stores to multiple stores
Wechat games (3)
6、 Scrollview component
How to import and upload a CSV generated by a third-party platform to a Taobao store
[common template problems in graph theory] four shortest path solutions and two minimum spanning tree solutions
[usecols parameter of pd.read\u excel ((), list error reason]
Crmeb open version 4.3
2 lines of text on the right of the left Avatar
EditText and Scrollview focus grabbing
Unity AssetBundle packaging
Crmeb mall distribution function
chrome浏览器查看cookie方法
Crmeb open source version, a free mall worth trying
Detr3d model source code Guide & mmdetection3d construction process
Solution to the problem of "brand abuse such as brand inconsistency and stacking in the published product information" prompted by copying and uploading
How to solve 'webdriver' object has no attribute 'switch_ to_ window‘
微信小游戏(四)