本文整理汇总了TypeScript中ionic-native.Camera.getPicture方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Camera.getPicture方法的具体用法?TypeScript Camera.getPicture怎么用?TypeScript Camera.getPicture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.Camera
的用法示例。
在下文中一共展示了Camera.getPicture方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPhoto
getPhoto() {
this.options = {
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 400,
targetHeight: 400
};
this.options.quality = this.cameraOpt.quality;
this.options.allowEdit = this.cameraOpt.allowEdit;
this.options.saveToPhotoAlbum = this.cameraOpt.saveToPhotoAlbum;
this.options.correctOrientation = this.cameraOpt.correctOrientation;
console.log(this.onDevice);
if (this.onDevice) {
Camera.getPicture(this.options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
this.display.displayToast("CamĂŠra erreur : "+err);
});
} else {
this.display.displayToast("CamĂŠra non disponible en mode WEB");
}
}
示例2: constructor
constructor() {
Camera.getPicture({}).then((imageData) => {
console.log(imageData);
}, (error) => {
console.log('camera error:', error);
});
}
示例3: takePhoto
takePhoto(){
let options = {
quality: 80,
destinationType: window["Camera"].DestinationType.FILE_URI,
encodingType: window["Camera"].EncodingType.JPEG,
correctOrientation: true
};
Camera.getPicture(options).then(fileUrl => {
let currentFileName = fileUrl.replace(/^.*[\\\/]/, "");
let pathMinusFileName = fileUrl.replace(currentFileName, "");
let newfileName = `${(new Date()).getTime()}.jpg`;
return File.moveFile(pathMinusFileName, currentFileName, window["cordova"].file.dataDirectory, newfileName);
}).then(fileDescriptor => {
return fileDescriptor.nativeURL;
}).then(fileUrl => {
let photo = new Photo();
photo.filePath = fileUrl;
console.log("fileUrl: ", fileUrl);
this.ngZone.run( () => {
this.photos.push(photo);
});
}).catch(error => {
alert(`Failed to take photo and persist to app storage - ${error.message}`);
});
}
示例4: take_photo
take_photo(source_type: number = 1) {
var options = {
quality:100,
destinationType: 1, // 0:DATA_URL ; 1: FILE_URI ; 2: NATIVE_URI
sourceType: source_type, // 0: PHOTO_ALBUM ; 1: CAMERA ; 2: SAVEDPHOTOALBUM
allowEdit: false,
};
console.log("CHECKPOINT 001");
this.app_storage.set_current_geolocation();
this.app_storage.current_time = (new Date()).toISOString();
Camera.getPicture(options).then(
(camera_data) => {
console.log("Raw Image Data", camera_data);
//var imgdata = "data:image/jpeg;base64," + results[0];
var imgdata = camera_data;
this.zone.run(
() => {
this.app_storage.current_photo.src = imgdata;
localStorage.setItem('cover_photo_src', imgdata)
console.log("Image Data Captured", imgdata);
}
);
},
(camera_error) => {
let modal = Modal.create(AppModalBox, { title: "Access to Image Source Denied", content: "Sorry, we are unable to use Image Files.<br>" + JSON.stringify(camera_error) })
this.nav.present(modal);
}
);
}
示例5: addPhoto
/**
* try and add a photo to the database
*
* @param _callback {Function} called when the process is complete
*
* @memberOf ToDoService
*/
addPhoto(_callback) {
let that = this
let options = {
quality: 50,
destinationType: 1, // Camera.DestinationType.FILE_URI,
sourceType: 0, // Camera.PictureSourceType.PHOTOLIBRARY,
encodingType: 1 // Camera.EncodingType.PNG
};
Camera.getPicture(options).then((imageURI) => {
window.resolveLocalFileSystemURL(imageURI,
(_file) => {
this._readImageFileFromCamera(_file, this, _callback)
},
(_error) => {
_callback({
success: false,
result: _error
})
});
}).catch((message) => {
alert('Failed because: ' + message);
_callback({
success: false,
result: message
})
})
}
示例6: scanImage
scanImage(){
console.log('console working');
let options = {
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
quality: 75,
allowEdit: false,
saveToPhotoAlbum: false
}
Camera.getPicture(options).then((fileUrl)=>{
console.log(fileUrl);
this.fileTransfer.upload(fileUrl, 'http://terry.jasperyap.com').then( (results)=>{
alert(JSON.stringify(results));
});
},(err) => {
if(err === 'cordova_not_available'){
// switch out to normal
let modal = Modal.create(CameraPage);
this.nav.present(modal);
}
});
}
示例7:
}).then(buttonIndex => {
if (buttonIndex < 3) {
Camera.getPicture({
sourceType: buttonIndex - 1
})
}
console.log('Button pressed:' + buttonLabels[buttonIndex - 1])
})
示例8: takePicture
takePicture(){
Camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
let base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
});
}
示例9: getPicture
private getPicture(opts: CameraOptions): void {
console.log('gittin da pic');
Camera.getPicture(opts)
.then((imgData) => {
this.photo = 'data:image/jpeg;base64,' + imgData;
}, (er) => {
console.error(er);
});
}
示例10: addPhoto
addPhoto(mode:number){
Camera.getPicture({'sourceType':mode}).then((imageData) => {
let base64Image= "data:image/jpeg;base64," + imageData;
if(imageData.startsWith("file"))
base64Image=imageData;
this.notes.push(new Note(null,base64Image,null,Date.now()))
this.save();
})
}