import { CameraPreview, CameraPreviewPictureOptions, CameraPreviewOptions, CameraPreviewDimensions } from '@awesome-cordova-plugins/camera-preview/ngx';
constructor(private cameraPreview: CameraPreview) { }
...
const cameraPreviewOpts: CameraPreviewOptions = {
x: 0,
y: 0,
width: window.screen.width,
height: window.screen.height,
camera: 'rear',
tapPhoto: true,
previewDrag: true,
toBack: true,
alpha: 1
}
this.cameraPreview.startCamera(cameraPreviewOpts).then(
(res) => {
console.log(res)
},
(err) => {
console.log(err)
});
this.cameraPreview.setOnPictureTakenHandler().subscribe((result) => {
console.log(result);
});
const pictureOpts: CameraPreviewPictureOptions = {
width: 1280,
height: 1280,
quality: 85
}
this.cameraPreview.takePicture(this.pictureOpts).then((imageData) => {
this.picture = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
console.log(err);
this.picture = 'assets/img/test.jpg';
});
this.cameraPreview.takeSnapshot(this.pictureOpts).then((imageData) => {
this.picture = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
console.log(err);
this.picture = 'assets/img/test.jpg';
});
this.cameraPreview.switchCamera();
this.cameraPreview.setColorEffect('negative');
this.cameraPreview.stopCamera();