//撮影写真を利用する
takePicture() {
let cameraOptions: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation: true,
};
this.camera.getPicture(cameraOptions).then((imageURI) => {
//イメージの表示
this.image.style.display = 'block';
//イメージ表示完了
this.image.onload = this.ImageLoadFunc;
//イメージのセット
this.image.src = "data:image/jpeg;base64," + imageURI;
}, (
err)
=> {
console.log(err);
});
}
selectPicture() {
let cameraOptions: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation: true,
sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
};
this.camera.getPicture(cameraOptions).then((imageURI) => {
//イメージの表示
this.image.style.display = 'block';
//イメージ表示完了
this.image.onload = this.ImageLoadFunc;
//イメージのセット
console.log("imageURI:", imageURI)
this.image.src = "data:image/jpeg;base64," + imageURI;
}, (
err)
=> {
console.log(err);
});
}
//アクションシートの表示(ここから写真から
presentActionSheet() {
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: '写真を撮る',
handler: () => {
console.log('Destructive clicked');
this.takePicture();
}
},
{
text: '写真から選択',
handler: () => {
console.log('Archive clicked');
this.selectPicture();
}
},
{
text: '取り消し',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
]
});
actionSheet.present();
}