本文整理匯總了TypeScript中ionic-native.Camera類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Camera類的具體用法?TypeScript Camera怎麽用?TypeScript Camera使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Camera類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: takePicture
takePicture(){
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL,
targetWidth: 1000,
targetHeight: 1000
}).then((imageData) => {
// imageData is a base64 encoded string
this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
console.log(err);
});
}
示例2: takePhoto
takePhoto(){
Camera.getPicture({
quality: 100,
cameraDirection: Camera.Direction.FRONT,
destinationType: Camera.DestinationType.DATA_URL
}).then((imageData) => {
let base64Image = 'data:image/jpeg;base64,' + imageData;
this.image = base64Image;
}, (err) => {
});
}
示例3: openCamera
openCamera() {
var options = {
sourceType: Camera.PictureSourceType.CAMERA,
destinationType: Camera.DestinationType.DATA_URL
};
Camera.getPicture(options).then((imageData) => {
this.cameraData = 'data:image/jpeg;base64,' + imageData;
this.photoTaken = true;
this.photoSelected = false;
}, (err) => {
// Handle error
});
}
示例4: takePicture
takePicture(){
let options = {
destinationType: Camera.DestinationType.DATA_URL,
targetWidth: 1000,
targetHeight: 1000,
quality: 100
}
Camera.getPicture( options )
.then(imageData =>{
this.image = 'data:image/jpeg;base64,' + imageData;
});
}
示例5: selectFromGallery
selectFromGallery() {
var options = {
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
destinationType: Camera.DestinationType.FILE_URI
};
Camera.getPicture(options).then((imageData) => {
this.cameraUrl = imageData;
this.photoSelected = true;
this.photoTaken = false;
}, (err) => {
// Handle error
});
}
示例6: takePicture
takePicture(){
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL,
targetWidth: 1024,
targetHeight: 768,
correctOrientation: false,
quality: 80
}).then((imageData) => {
// imageData is a base64 encoded string
this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
console.log(err);
});
}
示例7: getPicture
getPicture(sourceType){
let options = {
destinationType: Camera.DestinationType.DATA_URL,
targetWidth: 1000,
targetHeight: 1000,
quality: 100,
correctOrientation: true,
saveToPhotoAlbum: false,
sourceType: (sourceType == 'picture') ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA
}
Camera.getPicture(options).then((imageData) => {
this.image = "data:image/jpeg;base64," + imageData;
}, (err) => {
});
}
示例8: takePicture
takePicture() {
Camera.getPicture({
destinationType: Camera.DestinationType.FILE_URI,
targetWidth: 1000,
targetHeight: 1000,
correctOrientation: true
}).then((imageURI) => {
// imageData is a base64 encoded string
console.log(imageURI);
this.image.src = imageURI;
// this.base64Image = "data:image/jpeg;base64," + imageURI;
}, (err) => {
console.log(err);
});
}
示例9: getPicture
getPicture (sourceType: number) {
// You can check the values here:
// https://github.com/driftyco/ionic-native/blob/master/src/plugins/camera.ts
Camera.getPicture({
quality: 100,
destinationType: 0, // DATA_URL
sourceType: sourceType,
allowEdit: true,
saveToPhotoAlbum: false,
correctOrientation: true
}).then(imageData => {
this.srcImage = `data:image/jpeg;base64,${imageData}`;
}, error => {
console.log(`ERROR -> ${JSON.stringify(error)}`);
});
}
示例10: takePicture
//add action take a picture
takePicture() {
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL
})
.then((image) => {
//image is a base64 encoded string
this.base64Image = "data:image/jpeg;base64," + image;
}, (error) => {
//display alert if error
let alert = Alert.create({
title: 'Ups. Error occurs!',
subTitle: 'Sorry, we have a error. Please try later or fix the bug.',
buttons: ['OK']
});
this.nav.present(alert);
});
}