CameraRoll image to canvas using Phonegap

落花浮王杯 提交于 2019-12-05 07:14:48

问题


I'm trying (aka getting mad) to get an image from camera roll/album's iphone and putting onto a canvas over phonegap, and specifically, using the Camera Plugin but I can't do it. Here is the function that should show the image in an tag, but I want to put it in canvas due to edit and then save it:

function onPhotoURISuccess(imageURI) {
      var largeImage = document.getElementById('largeImage');
      largeImage.style.display = 'block';
      largeImage.src = imageURI;
}

Any ideas?

Thanks in advance, DGM.-


回答1:


And this is the solution : )

function onPhotoURISuccess(imageURI) {
    var cambas = document.getElementById('canvas_1');
    var ctx = cambas.getContext("2d");
    var imagen = new Image();
    imagen.onload = function(){
        cambas.width = imagen.width;
        cambas.height = imagen.height;
        ctx.drawImage(imagen, 0, 0, imagen.width, imagen.height);
    }

    imagen.src = imageURI;
}


来源:https://stackoverflow.com/questions/9893741/cameraroll-image-to-canvas-using-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!