//将图片压缩并转变为base64
convertImgToBase64:function(url,callback, bili){ //path绝对路径
var _this = this;
var bitmap = new plus.nativeObj.Bitmap(“test”); //test标识谁便取
// 从本地加载Bitmap图片
// alert(JSON.stringify(bitmap))
bitmap.load(url,function(){
var base4=bitmap.toBase64Data();
var datastr=base4.split(’,’,3);
_this.pics = [];
if(datastr.length>1){
_this.pics.push(datastr[1]);
}else {
_this.pics.push(datastr[0]);
}
_this.srcimg = “data:image/png;base64,”+ _this.pics[0];
var str = _this.srcimg.replace(‘data:image/png;base64,’, ‘’);
var equalIndex = str.indexOf(’=’);
if (str.indexOf(’=’) > 0) {
str = str.substring(0, equalIndex);
}
var strLength = str.length;
var fileLength = parseInt(strLength - (strLength / 8) * 2);
// 由字节转换为KB
var size = “”;
size =