Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.14.0

* Adds `rgba8888` to `ImageFormatGroup` enum.
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

## 2.13.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ ImageFormatGroup _imageFormatGroupFromPlatformData(dynamic data) {
return ImageFormatGroup.yuv420;
case 256: // android.graphics.ImageFormat.JPEG
return ImageFormatGroup.jpeg;
case 1: // android.graphics.PixelFormat.RGBA_8888
return ImageFormatGroup.rgba8888;
Comment thread
Mairramer marked this conversation as resolved.
}
}

Expand All @@ -47,6 +49,9 @@ ImageFormatGroup _imageFormatGroupFromPlatformData(dynamic data) {

case 1111970369: // kCVPixelFormatType_32BGRA
return ImageFormatGroup.bgra8888;

case 1380401729: // kCVPixelFormatType_32RGBA
return ImageFormatGroup.rgba8888;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ enum ImageFormatGroup {
/// On Android, this is `android.graphics.ImageFormat.NV21`. See
/// https://developer.android.com/reference/android/graphics/ImageFormat#NV21
nv21,

/// 32-bit RGBA.
///
/// On Android, this is `android.graphics.PixelFormat.RGBA_8888`. See
/// https://developer.android.com/reference/android/graphics/PixelFormat#RGBA_8888
///
/// On iOS, this is `kCVPixelFormatType_32RGBA`. See
/// https://developer.apple.com/documentation/corevideo/1563591-pixel_format_identifiers/kcvpixelformattype_32rgba?language=objc
rgba8888,
}

/// Extension on [ImageFormatGroup] to stringify the enum
Expand All @@ -54,6 +63,8 @@ extension ImageFormatGroupName on ImageFormatGroup {
return 'jpeg';
case ImageFormatGroup.nv21:
return 'nv21';
case ImageFormatGroup.rgba8888:
return 'rgba8888';
case ImageFormatGroup.unknown:
return 'unknown';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.13.0
version: 2.14.0

environment:
sdk: ^3.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,54 @@ void main() {
);
expect(cameraImage.format.group, ImageFormatGroup.yuv420);
});

test('$CameraImageData has ImageFormatGroup.rgba8888 for Android', () {
debugDefaultTargetPlatformOverride = TargetPlatform.android;

final CameraImageData cameraImage = cameraImageFromPlatformData(
<dynamic, dynamic>{
'format': 1,
'height': 1,
'width': 4,
'lensAperture': 1.8,
'sensorExposureTime': 9991324,
'sensorSensitivity': 92.0,
'planes': <dynamic>[
<dynamic, dynamic>{
'bytes': Uint8List.fromList(<int>[1, 2, 3, 4]),
'bytesPerPixel': 1,
'bytesPerRow': 4,
'height': 1,
'width': 4,
},
],
},
);
expect(cameraImage.format.group, ImageFormatGroup.rgba8888);
});

test('$CameraImageData has ImageFormatGroup.rgba8888 for iOS', () {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;

final CameraImageData cameraImage = cameraImageFromPlatformData(
<dynamic, dynamic>{
'format': 1380401729,
'height': 1,
'width': 4,
'lensAperture': 1.8,
'sensorExposureTime': 9991324,
'sensorSensitivity': 92.0,
'planes': <dynamic>[
<dynamic, dynamic>{
'bytes': Uint8List.fromList(<int>[1, 2, 3, 4]),
'bytesPerPixel': 1,
'bytesPerRow': 4,
'height': 1,
'width': 4,
},
],
},
);
expect(cameraImage.format.group, ImageFormatGroup.rgba8888);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void main() {
expect(ImageFormatGroup.yuv420.name(), 'yuv420');
expect(ImageFormatGroup.jpeg.name(), 'jpeg');
expect(ImageFormatGroup.nv21.name(), 'nv21');
expect(ImageFormatGroup.rgba8888.name(), 'rgba8888');
expect(ImageFormatGroup.unknown.name(), 'unknown');
});
});
Expand Down