你好,能给我demo吗
图片转画布,调用蓝牙打印机,打印出的照片很模糊不清晰(单色位图的解析),如何解决?单色位图的解析
04-25楼主找到解决办法了吗?我也碰到了,解决了给我个demo,谢谢
小程序打印图片,打印机打印出来是乱码 怎么办?求大佬解答,全网没有教程wx.createSelectorQuery() .select('#secondCanvas') .fields({ node: true, size: true }) .exec( (res) => { console.log('1111111111111111111') console.log(res) // Canvas 对象 const canvas = res[0].node // Canvas 画布的实际绘制宽高 const renderWidth = res[0].width const renderHeight = res[0].height // Canvas 绘制上下文 const ctx = canvas.getContext('2d') // 初始化画布大小 const dpr = wx.getSystemInfoSync().pixelRatio canvas.width = renderWidth * dpr canvas.height = renderHeight * dpr ctx.scale(dpr, dpr) // 若干绘制调用 // 这里绘制完成 console.log('draw done') const img = canvas.createImage() img.onload = () => { ctx.drawImage( img,0,0) } img.src='https://open.weixin.qq.com/zh_CN/htmledition/res/assets/res-design-download/icon64_wx_logo.png' wx.downloadFile({ url: 'https://open.weixin.qq.com/zh_CN/htmledition/res/assets/res-design-download/icon64_wx_logo.png', success: function(res) { // 下载成功后将文件转为临时路径 if (res.statusCode === 200) { wx.setStorageSync('tempFilePath', res.tempFilePath); } } }); this.setData({ img: wx.getStorageSync('tempFilePath'), canvasHeight: canvas.height, canvasWidth: canvas.width, }); const { canvasWidth, canvasHeight, deviceId, threshold } = this.data; const pix =res[0].node; const opt = { deviceId, ...this.character, onProgress: (percentage) => { console.log('percentage', percentage); this.setData({ percentage, }); }, lasterSuccess: () => { console.log('laster success'); this.setData({ printing: false, percentage: 0, }); wx.showModal({ title: '提示', content: '数据已发送完,请检查打印的内容是否正常', showCancel: false, confirmText: '好的', }); }, }; this.setData({ printing: true, }); console.log(threshold[0]) console.log(pix) console.log(opt) //打印图片 printImage( opt, overwriteImageData({ threshold: threshold[0], imageData: pix, width: canvasWidth, height: canvasHeight, }), ); }
04-25楼主找到解决办法了吗?我也碰到这个问题了,如果解决了,给我解决办法,谢谢
小程序连接蓝牙打印图片怎么打印?uni.canvasToTempFilePath({ canvasId: 'myCanvas', success: function(res) { // res.tempFilePath 是图片的临时文件路径 var imagePath = res.tempFilePath; } }), 现在界面里面有一个Canvas,这个把他转成图片,imagePath是图片的临时路径,现在怎么把他打印出来啊,在网上找了不少案例也不行,不是乱码 就是没反应,要么打印机滴滴的响
04-25