Canvas.toTempFilePathSync(Object object)

Canvas.toTempFilePath 的同步版本

参数

Object object

属性 类型 默认值 必填 说明
x number 0 截取 canvas 的左上角横坐标
y number 0 截取 canvas 的左上角纵坐标
width number canvas 的宽度 截取 canvas 的宽度
height number canvas 的高度 截取 canvas 的高度
destWidth number canvas 的宽度 目标文件的宽度,会将截取的部分拉伸或压缩至该数值
destHeight number canvas 的高度 目标文件的高度,会将截取的部分拉伸或压缩至该数值
fileType string png 目标文件的类型
quality number 1.0 jpg图片的质量,仅当 fileType 为 jpg 时有效。取值范围为 0.0(最低)- 1.0(最高),不含 0。不在范围内时当作 1.0

object.fileType 的合法值

说明 最低版本
jpg jpg 文件
png png 文件

示例代码

Canvas.toTempFilePath

canvas.toTempFilePath({
  x: 10,
  y: 10,
  width: 200,
  height: 150,
  destWidth: 400,
  destHeight: 300,
  success: (res) => {
    wx.shareAppMessage({
      imageUrl: res.tempFilePath
    })
  }
})

Canvas.toTempFilePathSync

const tempFilePath = canvas.toTempFilePathSync({
  x: 10,
  y: 10,
  width: 200,
  height: 150,
  destWidth: 400,
  destHeight: 300
})
wx.shareAppMessage({
  imageUrl: tempFilePath
})

个结果 ""

    没有找到相关内容 ""