We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
手机型号:redmi note 10 pro 当画图尺寸设置喂某些值的时候会出现这个问题,比图width: 392, height: 66 发现手机dpr是2.75 生成图的时候: wx.canvasToTempFilePath({ canvasId: 'photo', canvas: that.properties.use2D ? that.canvasNode : null, destWidth: that.canvasWidthInPx * getApp().systemInfo.pixelRatio, destHeight: that.canvasHeightInPx * getApp().systemInfo.pixelRatio, success: function (res) { that.getImageInfo(res.tempFilePath); }, fail: function (error) { console.error(canvasToTempFilePath failed, ${JSON.stringify(error)}); that.triggerEvent('imgErr', { error: error }); }, }, this); destWidth:是1078,destHeight:是181.5 wx.getImageInfo({ src: filePath, success: (infoRes) => { if (that.paintCount > MAX_PAINT_COUNT) { const error =The result is always fault, even we tried ${MAX_PAINT_COUNT} times; console.error(error); that.triggerEvent('imgErr', { error: error }); return; } // 比例相符时才证明绘制成功,否则进行强制重绘制 if (Math.abs((infoRes.width * that.canvasHeightInPx - that.canvasWidthInPx * infoRes.height) / (infoRes.height * that.canvasHeightInPx)) < 0.01) { that.triggerEvent('imgOK', { path: filePath }); } else { console.log('比例不同,重新绘制') that.startPaint(); } that.paintCount++; }, fail: (error) => { console.error(getImageInfo failed, ${JSON.stringify(error)}); that.triggerEvent('imgErr', { error: error }); }, }); wx.getImageInfo出来的图会精度丢失, infoRes.height是181, Math.abs((infoRes.width * that.canvasHeightInPx - that.canvasWidthInPx * infoRes.height) / (infoRes.height * that.canvasHeightInPx)) 这个算出来偏差有0.016几,就会继续重绘
wx.canvasToTempFilePath({ canvasId: 'photo', canvas: that.properties.use2D ? that.canvasNode : null, destWidth: that.canvasWidthInPx * getApp().systemInfo.pixelRatio, destHeight: that.canvasHeightInPx * getApp().systemInfo.pixelRatio, success: function (res) { that.getImageInfo(res.tempFilePath); }, fail: function (error) { console.error(
); that.triggerEvent('imgErr', { error: error }); }, }, this);
wx.getImageInfo({ src: filePath, success: (infoRes) => { if (that.paintCount > MAX_PAINT_COUNT) { const error =
; console.error(error); that.triggerEvent('imgErr', { error: error }); return; } // 比例相符时才证明绘制成功,否则进行强制重绘制 if (Math.abs((infoRes.width * that.canvasHeightInPx - that.canvasWidthInPx * infoRes.height) / (infoRes.height * that.canvasHeightInPx)) < 0.01) { that.triggerEvent('imgOK', { path: filePath }); } else { console.log('比例不同,重新绘制') that.startPaint(); } that.paintCount++; }, fail: (error) => { console.error(
); that.triggerEvent('imgErr', { error: error }); }, });
Math.abs((infoRes.width * that.canvasHeightInPx - that.canvasWidthInPx * infoRes.height) / (infoRes.height * that.canvasHeightInPx))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
手机型号:redmi note 10 pro
当画图尺寸设置喂某些值的时候会出现这个问题,比图width: 392, height: 66
发现手机dpr是2.75
生成图的时候:
wx.canvasToTempFilePath({ canvasId: 'photo', canvas: that.properties.use2D ? that.canvasNode : null, destWidth: that.canvasWidthInPx * getApp().systemInfo.pixelRatio, destHeight: that.canvasHeightInPx * getApp().systemInfo.pixelRatio, success: function (res) { that.getImageInfo(res.tempFilePath); }, fail: function (error) { console.error(
canvasToTempFilePath failed, ${JSON.stringify(error)}); that.triggerEvent('imgErr', { error: error }); }, }, this);
destWidth:是1078,destHeight:是181.5
wx.getImageInfo({ src: filePath, success: (infoRes) => { if (that.paintCount > MAX_PAINT_COUNT) { const error =
The result is always fault, even we tried ${MAX_PAINT_COUNT} times; console.error(error); that.triggerEvent('imgErr', { error: error }); return; } // 比例相符时才证明绘制成功,否则进行强制重绘制 if (Math.abs((infoRes.width * that.canvasHeightInPx - that.canvasWidthInPx * infoRes.height) / (infoRes.height * that.canvasHeightInPx)) < 0.01) { that.triggerEvent('imgOK', { path: filePath }); } else { console.log('比例不同,重新绘制') that.startPaint(); } that.paintCount++; }, fail: (error) => { console.error(
getImageInfo failed, ${JSON.stringify(error)}); that.triggerEvent('imgErr', { error: error }); }, });
wx.getImageInfo出来的图会精度丢失, infoRes.height是181,
Math.abs((infoRes.width * that.canvasHeightInPx - that.canvasWidthInPx * infoRes.height) / (infoRes.height * that.canvasHeightInPx))
这个算出来偏差有0.016几,就会继续重绘
The text was updated successfully, but these errors were encountered: