PhoneGap-安卓系统-如何将相机拍摄的图像保存在sd卡中

PhoneGap - Android - how to save the capture image from camera in the sd card

本文关键字:图像 保存 存在 卡中 sd 相机 系统 PhoneGap-      更新时间:2023-09-26

我是PhoneGap Android开发人员的新手。我正在使用phonegap在android中制作一个应用程序。我想从设备摄像头拍摄照片,然后在从设备拍摄图像后将其显示在屏幕上,并将拍摄的图像存储在SD卡中。你能告诉我怎么做吗。

Gurpeet singh

用于保存在SD卡中。。。。。。

function save(){
    document.addEventListener("deviceready", onDeviceReady, false);
}

    // PhoneGap is ready
    //
    function onDeviceReady() {
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }
    function gotFS(fileSystem) {
        fileSystem.root.getFile("pic.jpg", {create: true, exclusive: false}, gotFileEntry, fail);
    }
    function gotFileEntry(fileEntry) {
        fileEntry.createWriter(gotFileWriter, fail);
    }
    function gotFileWriter(writer) {
        var photo = document.getElementById("image");
        writer.write(photo.value);
    }
    function fail(error) {
        console.log(error.code);
    }

参考以下要点,该要点在数据和文件模式下都可以从相机捕获图像。

相机捕获样品Gist

参考

捕获相机图像-Phonegap Doc