要不旋转图片,只需要将以下两行代码注释掉即可:
rotatCtx.translate(0, (this.screenWidth * this.screenWidth) / this.screenHeight);
rotatCtx.rotate((270 * Math.PI) / 180);
修改后的代码如下所示:
rotat(e) {
// this.isRotatShow = true
// this.showCanvas = true
let rotatCtx = uni.createCanvasContext('rotatCanvas', this); //创建绘图对象
// 将签字图片绘制进入Canvas
rotatCtx.drawImage(e, 0, 0, (this.screenWidth * this.screenWidth) / this.screenHeight, this.screenWidth);
// 保存绘图结果
rotatCtx.draw(true);
setTimeout(() => {
// 生成图片并回调
uni.canvasToTempFilePath({
canvasId: 'rotatCanvas',
success: val => {
console.log('tempFilePath', val.tempFilePath)
this.showCanvas = false
this.$emit('savesign', {
tempFilePath: val.tempFilePath,
flag: true
});
setTimeout(() => {
this.hide();
}, 500);
},
complete: com => {
console.log(com);
}
}, this);
}, 500);
}
这样修改之后,图片就不会进行旋转操作了。记得在使用该函数之前确保rotatCanvas
存在且可见。
内容由零声教学AI助手提供,问题来源于学员提问