Foros del Web » Creando para Internet » HTML »

Apoyo tomar foto phonegap

Estas en el tema de Apoyo tomar foto phonegap en el foro de HTML en Foros del Web. Hola tengo un gran y urgente problema no he podido hacer que la camara tome la foto y la guarde desde phonegap para android, este ...
  #1 (permalink)  
Antiguo 21/04/2012, 11:41
 
Fecha de Ingreso: marzo-2012
Mensajes: 28
Antigüedad: 12 años, 1 mes
Puntos: 1
Apoyo tomar foto phonegap

Hola tengo un gran y urgente problema no he podido hacer que la camara tome la foto y la guarde desde phonegap para android, este es un codigo que uso pero solo activa la camara toma la foto y al momento de querer guardarla para procesarla no permite


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

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

Hechenme la mano porfa me urge resolver el problema

Etiquetas: css, foto, jquery, phonegap, tomar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:43.