使用PhoneGap的图像到Base64

时间:2014-03-04 18:43:32

标签: javascript android jquery cordova

我从相机拍摄照片后使用了这个功能。 它总是控制我相同的数据。数据:图像/ PNG; BASE64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAEsCAYAAACG + VY + AAAABHNCSVQICAgIfAhkiAAAAQBJREFUeJztwTEBAAAAwqD1T20LL6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIcBqtkAAcZpLS4AAAAASUVORK5CYII =

 function onPhotoURISuccess(imageURI) {
      var imageObj = new Image();
      imageObj.src=imageURI;


      var canvas = document.createElement("canvas");
      canvas.setAttribute('width',200);
      canvas.setAttribute('height',300);

      var ctx = canvas.getContext("2d");
      ctx.drawImage(imageObj, 29, 0, 142, 300);
      var dataURL = canvas.toDataURL();

console.log(dataURL);
    }

0 个答案:

没有答案