Commit 1c343a45 authored by 和慭琛's avatar 和慭琛

水印图片下载

parent 3e6c8074
......@@ -48,12 +48,14 @@
icon_live_mark:'https://qn-static.banshouhui.com/live_mark.png',
width:'',
height:'',
markPath:'',
}
},
onLoad(e) {
this.ctx = uni.createCameraContext();
this.date = '时间:' + this.getTime()
this.getLocation()
this.getMarkPath()
uni.setNavigationBarColor({
frontColor:'#FFFFFF',
......@@ -63,10 +65,7 @@
},
methods: {
//切换前后
switchClick(){
},
//返回 点击
backClick: function () {
......@@ -90,6 +89,25 @@
});
},
//获取 水印 本地缓存路径
getMarkPath: function (){
let that = this
uni.downloadFile({
url: this.icon_live_mark, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
console.log('水印图片 下载成功')
that.markPath = res.tempFilePath
console.log('markPath:'+ that.markPath)
}
},
fail() {
console.log('水印图片 下载失败')
}
})
},
//第一步: 拍照
takePhoto(){
let that = this
......@@ -117,8 +135,8 @@
success(res) {
console.log('获取图片信息成功')
//that.saveToLocal(res.)
that.width = res.width/3+'px';
that.height = res.height/3+'px';
that.width = res.width+'px';
that.height = res.height+'px';
that.drawCanvas(tempImagePath,res)
}
......@@ -131,12 +149,23 @@
this.showImage = true
//将原图画到canvas上面
this.canvas = uni.createCanvasContext("canvas", this)
this.canvas.drawImage(tempImagePath, 0, 0, res.width / 3 , res.height / 3)
this.canvas.drawImage(tempImagePath, 0, 0, res.width , res.height)
this.canvas.draw()
//加入 水印文字
this.canvas.setFontSize(18)
this.canvas.setFillStyle('#8a2929')
this.canvas.rotate(30 * Math.PI / 180);
let textToWidth = res.width * 0.5;
let textToHeight = res.height * 0.3;
this.canvas.fillText('我是水印', textToWidth, textToHeight)
//加入 水印图片
this.canvas.drawImage(this.markPath, 50, 50, 200, 40)
uni.showLoading({
title: '数据处理中...',
icon: 'loading',
duration: 10000
icon: 'loading'
})
//that.canvas.draw()
this.exportCanvasTempFilePath(res.width,res.height)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment