Révision cda781e8 src/app/home/home.component.ts
src/app/home/home.component.ts | ||
---|---|---|
16 | 16 |
|
17 | 17 |
import * as dialogs from "tns-core-modules/ui/dialogs"; |
18 | 18 |
import * as app from "tns-core-modules/application"; |
19 |
import * as imagepicker from "nativescript-imagepicker"; |
|
19 | 20 |
|
20 | 21 |
declare var NSString: any; |
21 | 22 |
declare var NSUTF8StringEncoding: any; |
... | ... | |
53 | 54 |
} |
54 | 55 |
console.log("Your app's version is: " + this.appVersion); |
55 | 56 |
}); |
56 |
this.photoEditor = new PhotoEditor(); |
|
57 |
this.hasPicture = false; |
|
58 | 57 |
} |
59 | 58 |
|
60 | 59 |
ngOnInit(): void { |
61 | 60 |
// Init your component properties here. |
61 |
this.photoEditor = new PhotoEditor(); |
|
62 |
this.hasPicture = false; |
|
62 | 63 |
this.pseudo = getString("pseudo", ""); |
63 | 64 |
this.email = getString("email", ""); |
64 | 65 |
this.serverName = getString("serverName", "AbulEdu-FR"); |
... | ... | |
83 | 84 |
sideDrawer.showDrawer(); |
84 | 85 |
} |
85 | 86 |
|
86 |
onTakePictureTap(args: EventData) { |
|
87 |
let originalImage = new Image(); |
|
87 |
onGetPictureFromRollTap(args: EventData) { |
|
88 |
var that = this; |
|
89 |
let context = imagepicker.create({ |
|
90 |
mode: "single" // use "multiple" for multiple selection |
|
91 |
}); |
|
92 |
context |
|
93 |
.authorize() |
|
94 |
.then(function () { |
|
95 |
return context.present(); |
|
96 |
}) |
|
97 |
.then(function (selection) { |
|
98 |
selection.forEach(function (selected) { |
|
99 |
let imageSource = new ImageSource(); |
|
100 |
imageSource.fromAsset(selected).then((imageSource) => { |
|
101 |
console.log("ORIG IMAGE SIZE FROM ROLL: " + imageSource.height + " x " + imageSource.width); |
|
102 |
console.dir(imageSource); |
|
103 |
// console.log("un ter"); |
|
104 |
|
|
105 |
that.photoEditor.editPhoto({ |
|
106 |
imageSource: imageSource, |
|
107 |
hiddenControls: [ |
|
108 |
PhotoEditorControl.Draw, |
|
109 |
PhotoEditorControl.Text, |
|
110 |
PhotoEditorControl.Clear, |
|
111 |
], |
|
112 |
}).then((newImage: ImageSource) => { |
|
113 |
console.log("NEW IMAGE: ", newImage.height, newImage.width); |
|
114 |
that.imageCropped(newImage); |
|
115 |
// Here you can save newImage, send it to your backend or simply display it in your app |
|
116 |
// that.resultImage.imageSource = newImage; |
|
117 |
}).catch((e) => { |
|
118 |
console.log("erreur ES 1"); |
|
119 |
console.error(e); |
|
120 |
}); |
|
121 |
console.log("trois"); |
|
122 |
}); |
|
123 |
|
|
124 |
}); |
|
125 |
console.log("Selection des fichiers ", selection); |
|
126 |
}).catch(function (e) { |
|
127 |
console.log("Error ES: " + e); |
|
128 |
// process error |
|
129 |
}); |
|
88 | 130 |
|
131 |
} |
|
132 |
|
|
133 |
onTakePictureTap(args: EventData) { |
|
89 | 134 |
const options = { |
90 | 135 |
keepAspectRatio: true, |
91 | 136 |
saveToGallery: false |
... | ... | |
99 | 144 |
let imageSource = new ImageSource(); |
100 | 145 |
|
101 | 146 |
imageSource.fromAsset(imageAsset).then((imageSource) => { |
102 |
console.log("ORIG IMAGE: " + imageSource.height + " x " + imageSource.width); |
|
147 |
console.log("ORIG IMAGE SIZE: " + imageSource.height + " x " + imageSource.width);
|
|
103 | 148 |
console.dir(imageSource); |
104 |
console.log("ORIG IMAGE: ", imageSource.height, imageSource.width); |
|
105 | 149 |
// console.log("un ter"); |
106 | 150 |
|
107 |
// console.dir(this.originalImage); |
|
108 |
// console.log("un quater"); |
|
109 |
|
|
110 | 151 |
this.photoEditor.editPhoto({ |
111 | 152 |
imageSource: imageSource, |
112 | 153 |
hiddenControls: [ |
Formats disponibles : Unified diff