Canvas.toTempFilePath

2020-02-14 11:29 更新

string Canvas.toTempFilePath(Object object)

將當(dāng)前 Canvas 保存為一個(gè)臨時(shí)文件,并生成相應(yīng)的臨時(shí)文件路徑。


輸入

繼承標(biāo)準(zhǔn)對象輸入,擴(kuò)展屬性描述:

屬性類型默認(rèn)值是否必填說明
xnumber0截取 canvas 的左上角橫坐標(biāo)
ynumber0截取 canvas 的左上角縱坐標(biāo)
widthnumbercanvas 的寬度截取 canvas 的寬度
heightnumbercanvas 的高度截取 canvas 的高度
destWidthnumbercanvas 的寬度目標(biāo)文件的寬度,會(huì)將截取的部分拉伸或壓縮至該數(shù)值
destHeightnumbercanvas 的高度目標(biāo)文件的高度,會(huì)將截取的部分拉伸或壓縮至該數(shù)值
fileTypestringpng目標(biāo)文件的類型
qualitynumber1.0jpg 圖片的質(zhì)量,僅當(dāng) fileType 為 jpg 時(shí)有效。取值范圍為 0.0(最低)- 1.0(最高),不含 0。不在范圍內(nèi)時(shí)當(dāng)作 1.0
說明
jpgjpg 文件
pngpng 文件


輸出

string

canvas 生成的臨時(shí)文件路徑


示例代碼

canvas.toTempFilePath({
    x: 20,
    y: 20,
    width: 200,
    height: 150,
    destWidth: 400,
    destHeight: 300
    success: (res) => {
        console.log(res.tempFilePath)
    }
})
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)