Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/04/2012, 11:37
merchell
 
Fecha de Ingreso: marzo-2012
Mensajes: 28
Antigüedad: 12 años
Puntos: 1
Pregunta Apoyo Phonegap tomar foto

Hola tengo un gran problema, he intentado de mil formas y no he podido tomar las fotos correctamente desde el telefono android activo la camara pero al momento de tomar la foto no permite aceptarla para guardarla este es mi codigo


function startCamera() {

var onSuccess = function(uri) {
console.log("camera successfully started");
document.getElementById('camera-image').style.backgroundImage="url('"+uri+"')";
document.getElementById('camera-image').style.width="100%";
console.log(uri);
};

var onFail = function() {
console.log('Failed to get an image');
};

navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI
});
}

function selectFileFromGallery() {

var onSuccess = function(uri) {
console.log("camera successfully started");
document.getElementById('camera-image').style.backgroundImage="url('"+uri+"')";
document.getElementById('camera-image').style.width="100%";
console.log(uri);
};

var onFail = function() {
console.log('Failed to get an image');
};

navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
});
}

Tambien trate con este codigo y nada

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/appmobi.js"></script>
<script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/phonegap.js"></script>
<script src="js/jquery.js"></script>
<style type="text/css">
body { font-family: 'lucida grande',sans-serif; text-align:center; }
h1 { margin:5px;font-size:1.5em; letter-spacing:-1px; }
.xsend { font-size:1.1em; }
.wait { display:none; }
</style>
</head>

<body>
<div id="content">
<h1>Subir imagen</h1>
<div id="info"><img class="wait" src="../wait.gif"> <span>Elija la fuente</span></div>
<p align="center">
<input type="button" class="xsend" data-source="library" value="Biblioteca" />
<input type="button" class="xsend" data-source="camera" value="Cámara" />
</p>
<a href="http://clubnono.tumblr.com">http://clubnono.tumblr.com</a>
</div>
<script type="text/javascript">
$(".xsend").click(function() {
$(".xsend").attr('readonly','true');
$("#info SPAN").html("procesando, espere... &raquo; "+ $(this).val());
var source = ($(this).attr('data-source') == 'library') ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA;
//obtiene imagen
navigator.camera.getPicture(procesaImagen, fail, {quality: 45, sourceType: source, destinationType: Camera.DestinationType.FILE_URI});
$(".wait").show();
})
function fail(message) {
$("#info SPAN").html(message); $(".wait").hide();
$(".xsend").removeAttr('readonly');
}
function procesaImagen(imageURI) {
$(".xsend").attr('disable','disable');
$(".wait").show();
$("#info SPAN").html('<br />subiendo, espere...');
var options = new FileUploadOptions();
options.fileKey="archivo";
options.fileName=imageURI.substr(imageURI.lastInde xOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.device = device.platform;
options.params = params;
var ft = new FileTransfer();
ft.upload(imageURI, "http://www.trueware.mx/eduardo/mybiometrics_online/upload.php", sube, falla, options);
}
function sube(r) {
t = jQuery.parseJSON(r.response);
var img = $("<img />").attr('src',t.img).load(function(){
$(".wait").hide();
$("#info SPAN").html('').append('<img src="'+t.img+'" />').append("<br />"+t.txt);
$(".xsend").removeAttr('readonly');
});
}
function falla(error) {
alert("Error: "+ error.code);
}

Por favor hechenme la mano me urge