PhoneGap- Android-如何从SD卡中的相机中保存捕获图像[英] PhoneGap - Android - how to save the capture image from camera in the sd card

本文是小编为大家收集整理的关于PhoneGap- Android-如何从SD卡中的相机中保存捕获图像的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我是PhoneGap Android开发人员的新手.我正在使用PhoneGap在Android中制作应用程序.我想从设备摄像头拍摄照片,然后我想在从设备中获取图像以及在SD卡中捕获图像的存储后将其显示在屏幕上.你能告诉我我如何做.

gurpreet 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 doc

本文地址:https://www.itbaoku.cn/post/102641.html

问题描述

I'm new in PhoneGap Android developer. I'm making an application in android using the phonegap. I want to take picture from the device camera and then i want to display it on the screen after taking the image from device and as well as store that captured image in the SD Card. Can you please tell me how i can do this.

Gurpreet singh

推荐答案

For saving in the SD card......

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);
    }

其他推荐答案

Refer the following gist which does capture the image from camera in both data and file mode.

Camera Capture Sample Gist

Reference from

Capture camera image - Phonegap Doc