This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera_platform_interface] Added imageFormatGroup to initialize #3364
Merged
mvanbeusekom
merged 14 commits into
flutter:master
from
Baseflow:image_stream_image_format_platform_interface
Jan 5, 2021
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a9ca829
Added imageFormatGroup to initialize
danielroek ec6aa45
Apply suggestions from code review
danielroek 56f77ec
Added period to sentence
danielroek ecea347
Moved ImageFormatGroup to platform_interface; Added extension to conv…
danielroek ac23632
Fixed test
danielroek 4eea926
Separated Android and iOS in name extension
danielroek 9a86d26
Clarified returns on name extension
danielroek cf6345c
Export image_format_group.dart in types.dart
danielroek 81799a7
Changed enum values to lowercase
danielroek ab15e89
Added ImageFormatGroup test
danielroek 098fd76
Fixed formatting
danielroek f8d9e4c
Removed target platform switch.
danielroek 8936a7f
Fixed formatting
danielroek b0d603c
Merge remote-tracking branch 'origin/master' into image_stream_image_…
danielroek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
50 changes: 50 additions & 0 deletions
50
packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/// Group of image formats that are comparable across Android and iOS platforms. | ||
enum ImageFormatGroup { | ||
/// The image format does not fit into any specific group. | ||
unknown, | ||
|
||
/// Multi-plane YUV 420 format. | ||
/// | ||
/// This format is a generic YCbCr format, capable of describing any 4:2:0 | ||
/// chroma-subsampled planar or semiplanar buffer (but not fully interleaved), | ||
/// with 8 bits per color sample. | ||
/// | ||
/// On Android, this is `android.graphics.ImageFormat.YUV_420_888`. See | ||
/// https://developer.android.com/reference/android/graphics/ImageFormat.html#YUV_420_888 | ||
/// | ||
/// On iOS, this is `kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange`. See | ||
/// https://developer.apple.com/documentation/corevideo/1563591-pixel_format_identifiers/kcvpixelformattype_420ypcbcr8biplanarvideorange?language=objc | ||
yuv420, | ||
|
||
/// 32-bit BGRA. | ||
/// | ||
/// On iOS, this is `kCVPixelFormatType_32BGRA`. See | ||
/// https://developer.apple.com/documentation/corevideo/1563591-pixel_format_identifiers/kcvpixelformattype_32bgra?language=objc | ||
bgra8888, | ||
|
||
/// 32-big RGB image encoded into JPEG bytes. | ||
/// | ||
/// On Android, this is `android.graphics.ImageFormat.JPEG`. See | ||
/// https://developer.android.com/reference/android/graphics/ImageFormat#JPEG | ||
jpeg, | ||
} | ||
|
||
/// Extension on [ImageFormatGroup] to stringify the enum | ||
extension ImageFormatGroupName on ImageFormatGroup { | ||
/// returns a String value for [ImageFormatGroup] | ||
/// returns 'unknown' if platform is not supported | ||
/// or if [ImageFormatGroup] is not supported for the platform | ||
String name() { | ||
switch (this) { | ||
case ImageFormatGroup.bgra8888: | ||
return 'bgra8888'; | ||
case ImageFormatGroup.yuv420: | ||
return 'yuv420'; | ||
case ImageFormatGroup.jpeg: | ||
return 'jpeg'; | ||
case ImageFormatGroup.unknown: | ||
default: | ||
return 'unknown'; | ||
} | ||
} | ||
} |
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
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
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
13 changes: 13 additions & 0 deletions
13
packages/camera/camera_platform_interface/test/types/image_group_test.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:camera_platform_interface/src/types/types.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('$ImageFormatGroup tests', () { | ||
test('ImageFormatGroupName extension returns correct values', () { | ||
expect(ImageFormatGroup.bgra8888.name(), 'bgra8888'); | ||
expect(ImageFormatGroup.yuv420.name(), 'yuv420'); | ||
expect(ImageFormatGroup.jpeg.name(), 'jpeg'); | ||
expect(ImageFormatGroup.unknown.name(), 'unknown'); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constraint is updated to be able to use extension methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should already be a constraint since the flutter version minimum is 1.22.0