This commit is contained in:
tiago.kayaya
2021-11-09 16:38:26 +01:00
parent 3a46b77e36
commit becc9796a1
4 changed files with 51 additions and 34 deletions
+3 -3
View File
@@ -2031,9 +2031,9 @@
"dev": true
},
"@capacitor/android": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@capacitor/android/-/android-3.3.0.tgz",
"integrity": "sha512-dzbzdN7KjjwpUbg7mZKVkgAVytEwGyXUL4Z1t9c12UhViJaNjU7/nSlTXjb+IiauwVg9oI2LHtSVrp1NIjUycw=="
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/@capacitor/android/-/android-3.3.1.tgz",
"integrity": "sha512-TB9UJh6/e6CV6KDpu/lNHKhgVvnDL2d3crNYtfKzp64CzeZhttQGIQShXSdMb3DG4kk7Zi/qBlfSaWBBD95NhQ=="
},
"@capacitor/app": {
"version": "1.0.5",
+1 -1
View File
@@ -31,7 +31,7 @@
"@angular/platform-browser": "~12.1.2",
"@angular/platform-browser-dynamic": "~12.1.2",
"@angular/router": "~12.1.2",
"@capacitor/android": "^3.3.0",
"@capacitor/android": "^3.3.1",
"@capacitor/app": "^1.0.5",
"@capacitor/camera": "^1.2.0",
"@capacitor/core": "^3.3.0",
@@ -118,7 +118,28 @@ async takePicture() {
});
laodPicture() {
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
@@ -133,30 +154,10 @@ async takePicture() {
console.log(this.capturedImage)
};
}
/* getPicture() {
const options: CameraOptions = {
quality: 90,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
targetWidth: 720,
targetHeight: 720,
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
let base64Image = 'data:image/jpeg;base64,' + imageData;
this.capturedImage = imageData;
this.capturedImageTitle = new Date().getTime() + '.jpeg';
}, (err) => {
console.log(err);
});
} */
runValidation() {
this.validateFrom = true
}
@@ -94,7 +94,6 @@ export class NewPublicationPage implements OnInit {
// allowEditing: true,
resultType: CameraResultType.Uri,
source: CameraSource.Camera
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
@@ -103,12 +102,9 @@ export class NewPublicationPage implements OnInit {
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
//console.log(this.capturedImage);
}
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
@@ -120,7 +116,28 @@ export class NewPublicationPage implements OnInit {
reader.readAsDataURL(blob);
});
laodPicture() {
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
@@ -132,8 +149,7 @@ export class NewPublicationPage implements OnInit {
this.capturedImage = imageData;
this.capturedImageTitle = file.name
};
}
} */
runValidation() {