Я пытаюсь делать снимки с флаттером при максимальном разрешении моего Galaxy S7 (3024x4032 пикселей). Я написал этот минимальный фрагмент кода, который делает снимок и печатает полученное разрешение:
import 'dart:async';
import 'dart:io';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' show join;
import 'package:path_provider/path_provider.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final cameras = await availableCameras();
final firstCamera = cameras.first;
CameraController controller = CameraController(
firstCamera,
ResolutionPreset.max,
);
await controller.initialize();
final path = join((await getExternalStorageDirectory()).path, '${DateTime.now()}.png');
print(path);
await controller.takePicture(path);
File image = new File(path);
var decodedImage = await decodeImageFromList(image.readAsBytesSync());
print('Image size: ${decodedImage.width}x${decodedImage.height}');
controller.dispose();
return;
}
Несмотря на использование ResolutionPreset.max
при построении, я получаю только изображения 1080p, а это не то, что мне нужно.
Я пробовал разные версии флаттера и на разных телефонах Galaxy S7, и я никогда не получал лучшего результата.
Вот вывод flutter doctor -v
:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (1 available)
• No issues found!
(base) #### $ flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.5 at /soft/flutter_linux_v1.12.13+hotfix.5-stable/flutter
• Framework revision 27321ebbad (8 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at ####
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /soft/android-studio-ide-191.6010548-linux/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Android Studio (version 3.5)
• Android Studio at /soft/android-studio-ide-191.6010548-linux/android-studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.41.1)
• VS Code at /usr/share/code
• Flutter extension version 3.7.1
[✓] Connected device (1 available)
• SM G930F • ad051703b862e58240 • android-arm64 • Android 8.0.0 (API 26)