问题描述
我是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); }
其他推荐答案
请参阅以下要点,该要点确实在数据和文件模式下从相机捕获图像.
问题描述
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.
Reference from