Skip to content

Commit 4543a53

Browse files
mvanbeusekomMinyewoo
authored andcommitted
Add implementation of didFinishProcessingPhoto callback (flutter#3337)
1 parent cda6a1a commit 4543a53

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

packages/camera/camera/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
## 0.6.3
34

45
* Adds auto exposure support for Android and iOS implementations.

packages/camera/camera/ios/Classes/CameraPlugin.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ - (void)captureOutput:(AVCapturePhotoOutput *)output
7676
UIImage *image = [UIImage imageWithCGImage:[UIImage imageWithData:data].CGImage
7777
scale:1.0
7878
orientation:[self getImageRotation]];
79+
7980
// TODO(sigurdm): Consider writing file asynchronously.
8081
bool success = [UIImageJPEGRepresentation(image, 1.0) writeToFile:_path atomically:YES];
8182
if (!success) {
@@ -85,6 +86,25 @@ - (void)captureOutput:(AVCapturePhotoOutput *)output
8586
_result(_path);
8687
}
8788

89+
- (void)captureOutput:(AVCapturePhotoOutput *)output
90+
didFinishProcessingPhoto:(AVCapturePhoto *)photo
91+
error:(NSError *)error API_AVAILABLE(ios(11.0)) {
92+
selfReference = nil;
93+
if (error) {
94+
_result(getFlutterError(error));
95+
return;
96+
}
97+
98+
NSData *photoData = [photo fileDataRepresentation];
99+
100+
bool success = [photoData writeToFile:_path atomically:YES];
101+
if (!success) {
102+
_result([FlutterError errorWithCode:@"IOError" message:@"Unable to write file" details:nil]);
103+
return;
104+
}
105+
_result(_path);
106+
}
107+
88108
- (UIImageOrientation)getImageRotation {
89109
float const threshold = 45.0;
90110
BOOL (^isNearValue)(float value1, float value2) = ^BOOL(float value1, float value2) {

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: camera
22
description: A Flutter plugin for getting information about and controlling the
33
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
44
and streaming image buffers to dart.
5+
56
version: 0.6.3
67
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera
78
dependencies:

0 commit comments

Comments
 (0)