我正在开发一个使用相机包摄像头预览的颤振应用程序。
我正在初始化摄像机控制器,如:
final controller = CameraController(
_cameras[0],
ResolutionPreset.ultraHigh,
enableAudio: false,
imageFormatGroup: ImageFormatGroup.bgra8888,
);
ResolutionPreset
枚举有以下选项:
enum ResolutionPreset {
/// 352x288 on iOS, 240p (320x240) on Android
low,
/// 480p (640x480 on iOS, 720x480 on Android)
medium,
/// 720p (1280x720)
high,
/// 1080p (1920x1080)
veryHigh,
/// 2160p (3840x2160)
ultraHigh,
/// The highest resolution available.
max,
}
分辨率必须是4032x2034
。如何使用自定义分辨率?
发布于 2022-07-19 15:22:48
ResolutionPreset枚举没有提供设置自定义解析的选项。作为解决办法,您可以使用ResolutionPreset.max
然后调整图像的大小。使用图像包,您可以将映像调整为所需的width
和height
,并将其写入存储中。
// Read a jpeg image from file path
Image image = decodeImage(File('image path').readAsBytesSync());
// Resize the image
Image resizedImage = copyResize(image, width: 4032, height: 2034);
// Save the image as jpg
File('out/image-resized.jpg')
..writeAsBytesSync(encodeJpg(resizedImage, quality: 100));
https://stackoverflow.com/questions/68717264
复制相似问题