[骗点,渣译]WindowsPhone和PhoneGap #12
原文
拍照
PhoneGap提供了camera.getPicture方法,让用户拍照。
实际上,只要调用navigator.camera.getPicture就可以了。
navigator.camera.getPicture接收3个参数。
1,成功后回调函数。
2,失败后回调函数。
3,可选,我们可以用来指定照片类型。默认是Camera.PictureSourceType.Camera,于是我们可以无视。![[骗点,渣译]WindowsPhone跟PhoneGap #12](http://img.reader8.net/uploadfile/jiaocheng/201401107/2958/2014012902582449060.jpg)
function Button1_onclick(){ navigator.camera.getPicture(onSuccess, onFail, {sourceType : Camera.PictureSourceType.CAMERA});}function onSuccess(data){ // image is a image control here var imageControl = document.getElementById('image'); imageControl.src = "data:image/jpeg;base64,"?+ data;}function onFail(message) { alert('Error taking picture'); }?
?