标签:
1
|
cordova plugin add cordova-plugin-camera |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<!DOCTYPE html> <html> <head> <title>Capture Photo</title> <meta http-equiv= "Content-type" content= "text/html; charset=utf-8" > <script type= "text/javascript" charset= "utf-8" src= "cordova.js" ></script> <script type= "text/javascript" charset= "utf-8" > var pictureSource; var destinationType; document.addEventListener( "deviceready" ,onDeviceReady, false ); //Cordova加载完成会触发 function onDeviceReady() { pictureSource=navigator.camera.PictureSourceType; destinationType=navigator.camera.DestinationType; } //获取照片 function getPhoto(source) { //quality : 图像的质量,范围是[0,100] navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType: destinationType.FILE_URI, sourceType: source }); } //获取照片成功 function onPhotoURISuccess(imageURI) { //打印出照片路径 console.log(imageURI); var largeImage = document.getElementById( ‘largeImage‘ ); largeImage.style.display = ‘block‘ ; largeImage.src = imageURI; } //获取照片是吧 function onFail(message) { alert( ‘获取失败: ‘ + message); } </script> </head> <body style= "padding-top:50px" > <button style= "font-size:23px;" onclick= "getPhoto(pictureSource.PHOTOLIBRARY);" > 从“相簿”中获取照片 </button> <br> <img style= "display:none;" id= "largeImage" src= "" /> </body> </html> |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<!DOCTYPE html> <html> <head> <title>Capture Photo</title> <meta http-equiv= "Content-type" content= "text/html; charset=utf-8" > <script type= "text/javascript" charset= "utf-8" src= "cordova.js" ></script> <script type= "text/javascript" charset= "utf-8" > var pictureSource; var destinationType; document.addEventListener( "deviceready" ,onDeviceReady, false ); //Cordova加载完成会触发 function onDeviceReady() { pictureSource=navigator.camera.PictureSourceType; destinationType=navigator.camera.DestinationType; } //获取照片 function getPhoto(source) { //quality : 图像的质量,范围是[0,100] navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType: destinationType.FILE_URI, sourceType: source }); } //获取照片成功 function onPhotoURISuccess(imageURI) { //打印出照片路径 console.log(imageURI); var largeImage = document.getElementById( ‘largeImage‘ ); largeImage.style.display = ‘block‘ ; largeImage.src = imageURI; } //获取照片是吧 function onFail(message) { alert( ‘获取失败: ‘ + message); } </script> </head> <body style= "padding-top:50px" > <button style= "font-size:23px;" onclick= "getPhoto(pictureSource.SAVEDPHOTOALBUM);" > 从“时刻”中获取照片 </button> <br> <img style= "display:none;" id= "largeImage" src= "" /> </body> </html> |
Cordova - 使用Cordova开发iOS应用实战5(获取手机里照片,并编辑)
标签:
原文地址:http://www.cnblogs.com/huazai/p/5415584.html