希望可以支持一下
微信小程序支持blob文件吗dataURLToFile:function(dataurl, filename) { let arr = dataurl.split(','); console.log(arr[0]); let mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } return new File([u8arr], filename, { type: mime }); }, 这个是base转为blob文件对象,但是运行的时候File报错 File is not defined;at pages/singature/singature page dataURLToFile function ReferenceError: File is not defined 有没有大佬可以告知,是为什么啊?微信小程序支持blob文件对象吗?
2019-08-08我也用到了这个功能,但是我的程序一直都是失败的,根本获取不到能使用的base64编码,有没有其他的获取base64的方法啊
如何让onCameraFrame 获取的frame数据与相机控件显示范围一致[代码]<!--index.wxml-->[代码][代码]<view class=[代码][代码]"page"[代码][代码]>[代码][代码] [代码][代码]<camera device-position=[代码][代码]"back"[代码] [代码]flash=[代码][代码]"off"[代码] [代码]binderror=[代码][代码]"error"[代码] [代码]frame-size=[代码][代码]"large"[代码] [代码]class=[代码][代码]"mycamera"[代码][代码]>[代码][代码] [代码][代码]</camera>[代码][代码] [代码][代码]<canvas canvas-id=[代码][代码]"mycanvas"[代码] [代码]class=[代码][代码]"mycanvas"[代码][代码]> </canvas>[代码][代码]</view>[代码] [代码]/**index.wxss**/[代码] [代码]page{[代码][代码] [代码][代码]width: 100%;[代码][代码] [代码][代码]height: 100%;[代码][代码]}[代码] [代码].mycamera{[代码][代码] [代码][代码]top:0px;[代码][代码] [代码][代码]width: 100%;[代码][代码] [代码][代码]height: 50%;[代码][代码] [代码][代码]position: fixed;[代码][代码]}[代码] [代码].mycanvas{[代码][代码] [代码][代码]top:50%;[代码][代码] [代码][代码]width: 100%;[代码][代码] [代码][代码]height: 100%;[代码][代码] [代码][代码]background-color: black;[代码][代码] [代码][代码]position: fixed;[代码][代码]}[代码] [代码]//index.js[代码][代码]//获取应用实例[代码][代码]const app = getApp()[代码] [代码]var[代码] [代码]nCounter = 0[代码][代码]var[代码] [代码]listener[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]onReady: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]camera_ctx = wx.createCameraContext() [代码][代码] [代码][代码]listener = camera_ctx.onCameraFrame((frame) => { [代码][代码] [代码][代码]if[代码] [代码](nCounter == 0) {[代码][代码] [代码][代码]wx.canvasPutImageData({[代码][代码] [代码][代码]canvasId: [代码][代码]'mycanvas'[代码][代码],[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]width: frame.width,[代码][代码] [代码][代码]heihgt: frame.heihgt,[代码][代码] [代码][代码]data: [代码][代码]new[代码] [代码]Uint8ClampedArray(frame.data),[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log([代码][代码]'OK'[代码][代码])[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail(res) {[代码][代码] [代码][代码]console.log([代码][代码]'FAIL'[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]nCounter++[代码][代码] [代码][代码]if[代码] [代码](nCounter >= 10) {[代码][代码] [代码][代码]nCounter = 0[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]listener.start()[代码][代码] [代码][代码]}[代码] [代码]})[代码]- 当前 Bug 的表现(可附上截图) 上面为相机控件显示的内容,下面为canvas显示onCameraFrame获取的frame数据,可见内容并不一致,主要表现是图像显示内容的范围不一致 [图片] - 预期表现 - 复现路径 - 提供一个最简复现 Demo
2019-08-07