移动端H5截屏

移动端截屏

时间隔得久远了,忘记是哪位大佬的了,再次感谢。

参数具体格式查看方法内。成功函数为必填。function successCB()     

var save = function(successCB, errorCB, fileName, imgID, overwrite, format, quality, clip) {
errorCB = errorCB || function() {};
fileName = fileName || Date.parse(new Date());
imgID = imgID || String(Date.parse(new Date()));
overwrite = overwrite || true;
format = format || ‘png‘;
quality = quality || 100;
clip = clip || {
top: ‘9%‘,
left: ‘0px‘,
width: ‘100%‘,
height: ‘90%‘
};

var self = plus.webview.currentWebview();
var bitmap = new plus.nativeObj.Bitmap(imgID);

//绘制截图
self.draw(bitmap, function() {
// 保存Bitmap图片
bitmap.save(‘_doc/‘ + fileName + ‘.‘ + format, {
overwrite: overwrite,
format: format,
quality: quality,
clip: clip
}, function(i) {
//保存到系统相册
plus.gallery.save(i.target, function(d) {
//销毁Bitmap图片
bitmap.clear();
success({
success: ‘success‘,
details: d
});
plus.io.resolveLocalFileSystemURL(d function(entry) {
UpladFile(entry);
}, function(e) {
console.log(‘读取影像材料失败!‘);
});
}, function(e) {
//销毁Bitmap图片
bitmap.clear();
errorCB({
error: ‘图片保存至相册失败‘,
details: e
});
});
}, function(e) {
bitmap.clear();
errorCB({
error: ‘图片保存失败‘,
details: e
});
});

}, function(e) {
errorCB({
error: ‘截屏绘制失败‘,
details: e
});
});
}

移动端H5截屏

上一篇:Steam一键领取90多款免费游戏 武装突袭3 狙击精英


下一篇:appium+python自动化45-夜神模拟器连不上(adb server version (36) doesn't match this client (39); killing...)