Phonegap: The image object is camera. This object has only one method, getpicture (). The method parameters are as follows:
Quality: an integer between 0 and. Set the image quality. If the local image is loaded as an address, this parameter is invalid.
Destinationtype: Camera. destinationtype. file_url | camera. destinationtype. data_url
If it is file_url, the image is returned in the form of a local address. If it is data_url, the image is returned in the form of base64. the src attribute of IMG needs to be spliced with the base64 prefix "data: image/JPEG; base64 ,"
For example, image. src = "data: image/JPEG; base64," + imagedata;
Sourcetype: Camera. picturesourcetype. savedphotoalbum | camera. picturesourcetype. photolibrary | camera. picturesourcetype. Camera
There is no difference between savedphotoalbum and photolibrary on Android devices. They both show the same photo gallery. Camera indicates that images are taken using cameras.
Example:
1 Document. addeventlistener ("deviceready", function () {2 try {3 Init (); 4} catch (e) {alert (e) ;}5}, false ); 6 7 function Init () {8 // var Options = {quality: 40, destinationtype: Camera. destinationtype. file_url, sourcetype: Camera. picturesourcetype. savedphotoalbum}; // select 9 var Options = {quality: 40, destinationtype: camera from the album. destinationtype. file_url, sourcetype: Camera. picturesourcetype. camera, allowedit: true}; // use camera 10 navigator. camera. getpicture (onsuccess, onerror, options); 11} 12 function onsuccess (imgurl) {13 MSG. innerhtml = imgurl; 14 IMG. src = imgurl; 15} 16 function onerror (Message) {17 MSG. innerhtml = message; 18}
Phonegap Study Notes (4) Local images and cameras