0

我一直在使用以下代码来抓取照片并以 html 显示效果很好。

function takePicture() {

navigator.camera.getPicture(
    function(uri) {
        var img = document.getElementById('camera_image1');
        img.style.visibility = "visible";
        img.style.display = "block";
        img.src = uri;
        document.getElementById('camera_status').innerHTML = "Success";

    },

    { quality: 50, allowEdit: true, destinationType: navigator.camera.DestinationType.FILE_URI});
   };

以后的html

 <img style="width:144px;height:144px;" id="camera_image1" src="nophoto.jpg"/>

但是我想同时将图像保存到用户库中,非常感谢任何指针。

我曾尝试使用 captureImage 但这给了我更少的选项,比如编辑,并且没有将图像内嵌在 html 中。

再次感谢

电话间隙 1.3

4

2 回答 2

1

使用 Phonegap 2.2,您可以将图像保存到本地设备。

添加"saveToPhotoAlbum : true"cameraOptions

function takePicture() {

navigator.camera.getPicture(
    function(uri) {
        var img = document.getElementById('camera_image1');
        img.style.visibility = "visible";
        img.style.display = "block";
        img.src = uri;
        document.getElementById('camera_status').innerHTML = "Success";

    }, { 
       quality: 50, 
       allowEdit: true, 
       destinationType: navigator.camera.DestinationType.FILE_URI,
       saveToPhotoAlbum : true
    });

};
于 2012-11-05T20:11:31.177 回答
0

您必须稍微更改一下phonegap 代码。它不会将图像保存在当前的实现中。告诉我你是否正在使用phonegap android。也许可以帮助你。

于 2012-02-08T05:42:02.210 回答