小睿睿cc
小睿睿cc
  • 发布:2020-04-02 01:06
  • 更新:2022-02-23 13:14
  • 阅读:1141

native bitmap.save保存图片png是黑色的

分类:Native.js

init(){
var t= this
t.ws = plus.webview.currentWebview();
t.bitmap = new plus.nativeObj.Bitmap('drawImage');
// 将webview内容绘制到Bitmap对象中
t.ws.draw(t.bitmap,function(){
console.log('截屏绘制图片成功');
},e => {
console.log('截屏绘制图片失败:' + JSON.stringify(e));
uni.hideLoading()
},{
bit:'ARGB',
check: false, // 设置为检测白屏
clip: {top:'0px',left:'0px',width:'100%',height:'100%'} // 设置截屏区域
}
);
},

save_img(){
var t = this
t.bitmap.save( "_doc/13453.png",{
overwrite:true,
format:'png',
quality:100,
clip:{top:'0px',left:'0px',width:'100%',height:'100%'}
}
,function(i){

                t.save_img_path = i.target  
                uni.hideLoading()  
                plus.gallery.save(i.target, function () {  
                    console.log('保存图片成功:'+JSON.stringify(i))  
                    uni.showToast({  
                        title: "成功保存图片到相册",  
                        icon:'none'  
                    })  
                });  
                t.bitmap.clear()  

            }  
            ,function(e){  
                console.log('保存图片失败:'+JSON.stringify(e))  
                t.bitmap.clear()  
                uni.hideLoading()  
            });  

        },
2020-04-02 01:06 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com

我也遇到这问题了

x***@foxmail.com

x***@foxmail.com

t.ws = plus.webview.currentWebview();
替换为
let pages = getCurrentPages();
let page = pages[pages.length - 1];
let currentWebview = page.$getAppWebview();
就是用uniapp自身提供的页面栈,未实际多次测试,手上手机这么改了一下就正常截图了,暂时还在调整ios截图无法正确裁剪的问题

该问题目前已经被锁定, 无法添加新回复