Created
June 4, 2018 12:17
-
-
Save Sampath-Lokuge/6d896433740f309759f40e4213e43c23 to your computer and use it in GitHub Desktop.
Photo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//take Photo | |
takePhoto(sourceType: number) { | |
const options: CameraOptions = { | |
quality: 50, | |
destinationType: this.camera.DestinationType.DATA_URL, | |
encodingType: this.camera.EncodingType.JPEG, | |
mediaType: this.camera.MediaType.PICTURE, | |
correctOrientation: true, | |
sourceType: sourceType, | |
} | |
this.camera.getPicture(options).then((imageData) => { | |
let base64Image = 'data:image/jpeg;base64,' + imageData; | |
let photo = new Photo(); | |
let id = random(1, 12); | |
photo.id = id; | |
photo.url = base64Image; | |
if (this.data == null) this.data = []; | |
this.data.push(photo); | |
}, (err) => { | |
// Handle error | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment