@@ -64,39 +64,6 @@ class TakePictureScreenState extends State<TakePictureScreen> {
64
64
super .dispose ();
65
65
}
66
66
67
- Future <File > fixExifRotation (String imagePath) async {
68
- final originalFile = File (imagePath);
69
- List <int > imageBytes = await originalFile.readAsBytes ();
70
-
71
- final originalImage = img.decodeImage (imageBytes);
72
- final height = originalImage.height;
73
- final width = originalImage.width;
74
-
75
- if (height >= width) {
76
- return originalFile;
77
- }
78
-
79
- final exifData = await readExifFromBytes (imageBytes);
80
- img.Image fixedImage;
81
-
82
- if (height < width) {
83
- if (exifData['Image Orientation' ].printable.contains ('Horizontal' )) {
84
- fixedImage = img.copyRotate (originalImage, 90 );
85
- } else if (exifData['Image Orientation' ].printable.contains ('180' )) {
86
- fixedImage = img.copyRotate (originalImage, - 90 );
87
- } else if (exifData['Image Orientation' ].printable.contains ('CCW' )) {
88
- fixedImage = img.copyRotate (originalImage, 180 );
89
- } else {
90
- fixedImage = img.copyRotate (originalImage, 0 );
91
- }
92
- }
93
-
94
- final fixedFile =
95
- await originalFile.writeAsBytes (img.encodeJpg (fixedImage));
96
-
97
- return fixedFile;
98
- }
99
-
100
67
@override
101
68
Widget build (BuildContext context) {
102
69
return Scaffold (
@@ -128,8 +95,6 @@ class TakePictureScreenState extends State<TakePictureScreen> {
128
95
// Take an picture with the best resolution
129
96
await _controller.takePicture (path);
130
97
// await FlutterExifRotation.rotateAndSaveImage(path: path);
131
- await fixExifRotation (path);
132
-
133
98
Navigator .push (
134
99
context,
135
100
MaterialPageRoute (
@@ -155,6 +120,7 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
155
120
final GlobalKey <ScaffoldState > key2 = GlobalKey <ScaffoldState >();
156
121
Color _acceptButtonColor = Colors .green;
157
122
Color _declineButtonColor = Colors .red;
123
+ double _progress = 0.0 ;
158
124
ProgressDialog pr;
159
125
160
126
bool _isButtonDisabled;
@@ -167,25 +133,59 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
167
133
_isButtonDisabled = false ;
168
134
}
169
135
136
+ Future <File > fixExifRotation (String imagePath) async {
137
+ final originalFile = File (imagePath);
138
+ List <int > imageBytes = await originalFile.readAsBytes ();
139
+
140
+ final originalImage = img.decodeImage (imageBytes);
141
+ final height = originalImage.height;
142
+ final width = originalImage.width;
143
+
144
+ if (height >= width) {
145
+ return originalFile;
146
+ }
147
+
148
+ final exifData = await readExifFromBytes (imageBytes);
149
+ img.Image fixedImage;
150
+
151
+ if (height < width) {
152
+ if (exifData['Image Orientation' ].printable.contains ('Horizontal' )) {
153
+ fixedImage = img.copyRotate (originalImage, 90 );
154
+ } else if (exifData['Image Orientation' ].printable.contains ('180' )) {
155
+ fixedImage = img.copyRotate (originalImage, - 90 );
156
+ } else if (exifData['Image Orientation' ].printable.contains ('CCW' )) {
157
+ fixedImage = img.copyRotate (originalImage, 180 );
158
+ } else {
159
+ fixedImage = img.copyRotate (originalImage, 0 );
160
+ }
161
+ }
162
+
163
+ final fixedFile =
164
+ await originalFile.writeAsBytes (img.encodeJpg (fixedImage));
165
+
166
+ return fixedFile;
167
+ }
168
+
170
169
@override
171
170
Widget build (BuildContext context) {
172
- pr = ProgressDialog (
173
- context,
174
- type: ProgressDialogType .Normal ,
175
- textDirection: TextDirection .ltr,
176
- isDismissible: false ,
177
- );
171
+ pr = ProgressDialog (context,
172
+ type: ProgressDialogType .Download ,
173
+ isDismissible: false ,
174
+ showLogs: true );
178
175
179
176
pr.style (
180
- message:
181
- 'Parsing image using tesseract. This takes some time.' ,
182
- borderRadius: 10.0 ,
183
- backgroundColor: Colors .white,
184
- elevation: 10.0 ,
185
- insetAnimCurve: Curves .easeInCirc,
186
- messageTextStyle: TextStyle (
187
- color: Colors .black, fontSize: 15.0 , fontWeight: FontWeight .w600),
188
- );
177
+ message: 'Downloading file...' ,
178
+ borderRadius: 10.0 ,
179
+ backgroundColor: Colors .white,
180
+ progressWidget: CircularProgressIndicator (),
181
+ elevation: 10.0 ,
182
+ insetAnimCurve: Curves .easeInOut,
183
+ progress: 0.0 ,
184
+ maxProgress: 100.0 ,
185
+ progressTextStyle: TextStyle (
186
+ color: Colors .black, fontSize: 13.0 , fontWeight: FontWeight .w400),
187
+ messageTextStyle: TextStyle (
188
+ color: Colors .black, fontSize: 19.0 , fontWeight: FontWeight .w600));
189
189
190
190
return Scaffold (
191
191
appBar: AppBar (title: Text ('Display the Picture' )),
@@ -231,11 +231,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
231
231
await SharedPreferences .getInstance ();
232
232
String ip = sharedPrefs.get ("ipv4" );
233
233
234
- pr. show ( );
234
+ await fixExifRotation (imagePath );
235
235
await NetworkClient .sendImage (
236
236
File (imagePath), ip, context, key2);
237
-
238
- pr.hide ();
237
+ _progress = _progress + 80.0 ;
239
238
})))),
240
239
],
241
240
)
0 commit comments