ZBLOG

rotat(e) { // this.isRotatShow = true // this.showCanvas = true let rotatCtx = uni.createCanvasContext('rotatCanvas', this); //创建绘图对象 // 重新定位中心点 rotatCtx.translate(0, (this.screenWidth * this.screenWidth) / this.screenHeight); ...

要不旋转图片,只需要将以下两行代码注释掉即可:

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助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=15945

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?