Last active
March 2, 2019 14:47
-
-
Save maneeshaindrachapa/f1ce9b57f497a99b33339d18075925dd to your computer and use it in GitHub Desktop.
This file contains 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
import { Component } from '@angular/core'; | |
import { NavController, Platform } from 'ionic-angular'; | |
import {Camera,CameraOptions} from '@ionic-native/camera/ngx'; | |
import { ImageProvider } from '../../providers/image/image'; | |
@Component({ | |
selector: 'page-home', | |
templateUrl: 'home.html' | |
}) | |
export class HomePage { | |
base64img:string=''; | |
constructor(public imgpov:ImageProvider, public nav: NavController,private platform: Platform,private camera:Camera) { | |
} | |
imageCaptured(){ | |
const options:CameraOptions={ | |
quality:70, | |
destinationType:this.camera.DestinationType.DATA_URL, | |
encodingType:this.camera.EncodingType.JPEG, | |
mediaType:this.camera.MediaType.PICTURE | |
} | |
this.camera.getPicture(options).then((ImageData=>{ | |
this.base64img="data:image/jpeg;base64,"+ImageData; | |
}),error=>{ | |
console.log(error); | |
}) | |
} | |
imageCapturedGallery(){ | |
const options:CameraOptions={ | |
quality:70, | |
destinationType:this.camera.DestinationType.DATA_URL, | |
sourceType:this.camera.PictureSourceType.PHOTOLIBRARY, | |
saveToPhotoAlbum:false | |
} | |
this.camera.getPicture(options).then((ImageData=>{ | |
this.base64img="data:image/jpeg;base64,"+ImageData; | |
}),error=>{ | |
console.log(error); | |
}) | |
} | |
nextPage(){ | |
this.imgpov.setImage(this.base64img); | |
this.nav.push('IdentifyphotoPage'); | |
} | |
clear(){ | |
this.base64img=''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment