本文整理汇总了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);
});
}