- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
用前置摄像头录视频时屏幕变暗变窄我试了很多都没有办法解决
视频录制是全屏的,脸变得很窄很黑。我试过给出分辨率也很高但是后置摄像头工作正常
我正在使用相机插件,即:相机:^0.5.2+1
但后置摄像头工作正常
import 'dart:async';
import 'dart:io';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:video_player/video_player.dart';
class CameraExampleHome extends StatefulWidget {
@override
_CameraExampleHomeState createState() {
return _CameraExampleHomeState();
}
}
/// Returns a suitable camera icon for [direction].
IconData getCameraLensIcon(CameraLensDirection direction) {
switch (direction) {
case CameraLensDirection.back:
return Icons.camera_rear;
case CameraLensDirection.front:
return Icons.camera_front;
case CameraLensDirection.external:
return Icons.camera;
}
throw ArgumentError('Unknown lens direction');
}
void logError(String code, String message) =>
print('Error: $code\nError Message: $message');
class _CameraExampleHomeState extends State<CameraExampleHome>
with WidgetsBindingObserver {
CameraController controller;
String imagePath;
String videoPath;
VideoPlayerController videoController;
VoidCallback videoPlayerListener;
bool enableAudio = true;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.inactive) {
controller?.dispose();
} else if (state == AppLifecycleState.resumed) {
if (controller != null) {
onNewCameraSelected(controller.description);
}
}
}
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: const Text('Camera example'),
),
body: Column(
children: <Widget>[
Expanded(
child: Container(
child: Padding(
padding: const EdgeInsets.all(1.0),
child: Center(
child: _cameraPreviewWidget(),
),
),
decoration: BoxDecoration(
color: Colors.black,
border: Border.all(
color: controller != null && controller.value.isRecordingVideo
? Colors.redAccent
: Colors.grey,
width: 3.0,
),
),
),
),
_captureControlRowWidget(),
_toggleAudioWidget(),
Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_cameraTogglesRowWidget(),
_thumbnailWidget(),
],
),
),
],
),
);
}
/// Display the preview from the camera (or a message if the preview is not available).
Widget _cameraPreviewWidget() {
if (controller == null || !controller.value.isInitialized) {
return const Text(
'Tap a camera',
style: TextStyle(
color: Colors.white,
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
);
} else {
return AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: CameraPreview(controller),
);
}
}
/// Toggle recording audio
Widget _toggleAudioWidget() {
return Padding(
padding: const EdgeInsets.only(left: 25),
child: Row(
children: <Widget>[
const Text('Enable Audio:'),
Switch(
value: enableAudio,
onChanged: (bool value) {
enableAudio = value;
if (controller != null) {
onNewCameraSelected(controller.description);
}
},
),
],
),
);
}
/// Display the thumbnail of the captured image or video.
Widget _thumbnailWidget() {
return Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
videoController == null && imagePath == null
? Container()
: SizedBox(
child: (videoController == null)
? Image.file(File(imagePath))
: Container(
child: Center(
child: AspectRatio(
aspectRatio:
videoController.value.size != null
? videoController.value.aspectRatio
: 1.0,
child: VideoPlayer(videoController)),
),
decoration: BoxDecoration(
border: Border.all(color: Colors.pink)),
),
width: 64.0,
height: 64.0,
),
],
),
),
);
}
/// Display the control bar with buttons to take pictures and record videos.
Widget _captureControlRowWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
IconButton(
icon: const Icon(Icons.camera_alt),
color: Colors.blue,
onPressed: controller != null &&
controller.value.isInitialized &&
!controller.value.isRecordingVideo
? onTakePictureButtonPressed
: null,
),
IconButton(
icon: const Icon(Icons.videocam),
color: Colors.blue,
onPressed: controller != null &&
controller.value.isInitialized &&
!controller.value.isRecordingVideo
? onVideoRecordButtonPressed
: null,
),
IconButton(
icon: const Icon(Icons.stop),
color: Colors.red,
onPressed: controller != null &&
controller.value.isInitialized &&
controller.value.isRecordingVideo
? onStopButtonPressed
: null,
)
],
);
}
/// Display a row of toggle to select the camera (or a message if no camera is available).
Widget _cameraTogglesRowWidget() {
final List<Widget> toggles = <Widget>[];
if (cameras.isEmpty) {
return const Text('No camera found');
} else {
for (CameraDescription cameraDescription in cameras) {
toggles.add(
SizedBox(
width: 90.0,
child: RadioListTile<CameraDescription>(
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
groupValue: controller?.description,
value: cameraDescription,
onChanged: controller != null && controller.value.isRecordingVideo
? null
: onNewCameraSelected,
),
),
);
}
}
return Row(children: toggles);
}
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
void showInSnackBar(String message) {
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message)));
}
void onNewCameraSelected(CameraDescription cameraDescription) async {
if (controller != null) {
await controller.dispose();
}
controller = CameraController(
cameraDescription,
ResolutionPreset.high,
enableAudio: enableAudio,
);
// If the controller is updated then update the UI.
controller.addListener(() {
if (mounted) setState(() {});
if (controller.value.hasError) {
showInSnackBar('Camera error ${controller.value.errorDescription}');
}
});
try {
await controller.initialize();
} on CameraException catch (e) {
_showCameraException(e);
}
if (mounted) {
setState(() {});
}
}
void onTakePictureButtonPressed() {
takePicture().then((String filePath) {
if (mounted) {
setState(() {
imagePath = filePath;
videoController?.dispose();
videoController = null;
});
if (filePath != null) showInSnackBar('Picture saved to $filePath');
}
});
}
void onVideoRecordButtonPressed() {
startVideoRecording().then((String filePath) {
if (mounted) setState(() {});
if (filePath != null) showInSnackBar('Saving video to $filePath');
});
}
void onStopButtonPressed() {
stopVideoRecording().then((_) {
if (mounted) setState(() {});
showInSnackBar('Video recorded to: $videoPath');
});
}
Future<String> startVideoRecording() async {
if (!controller.value.isInitialized) {
showInSnackBar('Error: select a camera first.');
return null;
}
final Directory extDir = await getApplicationDocumentsDirectory();
final String dirPath = '${extDir.path}/Movies/flutter_test';
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}.mp4';
if (controller.value.isRecordingVideo) {
// A recording is already started, do nothing.
return null;
}
try {
videoPath = filePath;
await controller.startVideoRecording(filePath);
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
return filePath;
}
Future<void> stopVideoRecording() async {
if (!controller.value.isRecordingVideo) {
return null;
}
try {
await controller.stopVideoRecording();
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
await _startVideoPlayer();
}
Future<void> _startVideoPlayer() async {
final VideoPlayerController vcontroller =
VideoPlayerController.file(File(videoPath));
videoPlayerListener = () {
if (videoController != null && videoController.value.size != null) {
// Refreshing the state to update video player with the correct ratio.
if (mounted) setState(() {});
videoController.removeListener(videoPlayerListener);
}
};
vcontroller.addListener(videoPlayerListener);
await vcontroller.setLooping(true);
await vcontroller.initialize();
await videoController?.dispose();
if (mounted) {
setState(() {
imagePath = null;
videoController = vcontroller;
});
}
await vcontroller.play();
}
Future<String> takePicture() async {
if (!controller.value.isInitialized) {
showInSnackBar('Error: select a camera first.');
return null;
}
final Directory extDir = await getApplicationDocumentsDirectory();
final String dirPath = '${extDir.path}/Pictures/flutter_test';
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}.jpg';
if (controller.value.isTakingPicture) {
// A capture is already pending, do nothing.
return null;
}
try {
await controller.takePicture(filePath);
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
return filePath;
}
void _showCameraException(CameraException e) {
logError(e.code, e.description);
showInSnackBar('Error: ${e.code}\n${e.description}');
}
}
class CameraApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: CameraExampleHome(),
);
}
}
List<CameraDescription> cameras;
Future<void> main() async {
// Fetch the available cameras before initializing the app.
try {
cameras = await availableCameras();
} on CameraException catch (e) {
logError(e.code, e.description);
}
runApp(CameraApp());
}
最佳答案
我已经在 Nexus 6 模拟器中尝试了您的示例,输出如下:
看来前后摄像头都被拉长了。我找到了 this issue in GitHub你遇到了同样的问题。您可以尝试其他示例。此外,我还看到相机插件背后的团队 is working for a refactor在所述插件上。
我玩过你的代码并实现了我找到的解决方案 here .这可能是一些补救措施,但可能有更好的解决方案。
来自部分:
Widget _cameraPreviewWidget() {
if (controller == null || !controller.value.isInitialized) {
return const Text(
'Tap a camera',
style: TextStyle(
color: Colors.white,
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
);
} else {
return AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: CameraPreview(controller),
);
}
}
我已从引用的 SO post 中应用此修复程序:
Widget cameraWidget(context) {
var camera = _cameraController.value;
// fetch screen size
final size = MediaQuery.of(context).size;
// calculate scale depending on screen and camera ratios
// this is actually size.aspectRatio / (1 / camera.aspectRatio)
// because camera preview size is received as landscape
// but we're calculating for portrait orientation
var scale = size.aspectRatio * camera.aspectRatio;
// to prevent scaling down, invert the value
if (scale < 1) scale = 1 / scale;
return Transform.scale(
scale: scale,
child: Center(
child: CameraPreview(_cameraController),
),
);
}
因为我使用的是当前版本的 camera 0.8.0 ,我已经考虑了高于 0.7.0 版本的给定解决方案。
这里是示例代码:
import 'dart:async';
import 'dart:io';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:video_player/video_player.dart';
class CameraExampleHome extends StatefulWidget {
@override
_CameraExampleHomeState createState() {
return _CameraExampleHomeState();
}
}
/// Returns a suitable camera icon for [direction].
IconData getCameraLensIcon(CameraLensDirection direction) {
switch (direction) {
case CameraLensDirection.back:
return Icons.camera_rear;
case CameraLensDirection.front:
return Icons.camera_front;
case CameraLensDirection.external:
return Icons.camera;
}
throw ArgumentError('Unknown lens direction');
}
void logError(String code, String message) =>
print('Error: $code\nError Message: $message');
class _CameraExampleHomeState extends State<CameraExampleHome>
with WidgetsBindingObserver {
CameraController controller;
String imagePath;
String videoPath;
VideoPlayerController videoController;
VoidCallback videoPlayerListener;
bool enableAudio = true;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.inactive) {
controller?.dispose();
} else if (state == AppLifecycleState.resumed) {
if (controller != null) {
onNewCameraSelected(controller.description);
}
}
}
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: const Text('Camera example'),
),
body: Column(
children: <Widget>[
Expanded(
child: Container(
child: Padding(
padding: const EdgeInsets.all(1.0),
child: Center(
child: _cameraPreviewWidget(),
),
),
decoration: BoxDecoration(
color: Colors.black,
border: Border.all(
color: controller != null && controller.value.isRecordingVideo
? Colors.redAccent
: Colors.grey,
width: 3.0,
),
),
),
),
_captureControlRowWidget(),
_toggleAudioWidget(),
Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_cameraTogglesRowWidget(),
_thumbnailWidget(),
],
),
),
],
),
);
}
/// Display the preview from the camera (or a message if the preview is not available).
Widget _cameraPreviewWidget() {
var camera = controller.value;
final size = MediaQuery.of(context).size;
var scale = size.aspectRatio * camera.aspectRatio;
if (scale < 1) scale = 1 / scale;
if (controller == null || !controller.value.isInitialized) {
return const Text(
'Tap a camera',
style: TextStyle(
color: Colors.white,
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
);
} else {
return Transform.scale(
scale: scale,
child: Center(
child: CameraPreview(controller),
),
);
}
}
/// Toggle recording audio
Widget _toggleAudioWidget() {
return Padding(
padding: const EdgeInsets.only(left: 25),
child: Row(
children: <Widget>[
const Text('Enable Audio:'),
Switch(
value: enableAudio,
onChanged: (bool value) {
enableAudio = value;
if (controller != null) {
onNewCameraSelected(controller.description);
}
},
),
],
),
);
}
/// Display the thumbnail of the captured image or video.
Widget _thumbnailWidget() {
return Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
videoController == null && imagePath == null
? Container()
: SizedBox(
child: (videoController == null)
? Image.file(File(imagePath))
: Container(
child: Center(
child: AspectRatio(
aspectRatio:
videoController.value.size != null
? videoController.value.aspectRatio
: 1.0,
child: VideoPlayer(videoController)),
),
decoration: BoxDecoration(
border: Border.all(color: Colors.pink)),
),
width: 64.0,
height: 64.0,
),
],
),
),
);
}
/// Display the control bar with buttons to take pictures and record videos.
Widget _captureControlRowWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
IconButton(
icon: const Icon(Icons.camera_alt),
color: Colors.blue,
onPressed: controller != null &&
controller.value.isInitialized &&
!controller.value.isRecordingVideo
? onTakePictureButtonPressed
: null,
),
IconButton(
icon: const Icon(Icons.videocam),
color: Colors.blue,
onPressed: controller != null &&
controller.value.isInitialized &&
!controller.value.isRecordingVideo
? onVideoRecordButtonPressed
: null,
),
IconButton(
icon: const Icon(Icons.stop),
color: Colors.red,
onPressed: controller != null &&
controller.value.isInitialized &&
controller.value.isRecordingVideo
? onStopButtonPressed
: null,
)
],
);
}
/// Display a row of toggle to select the camera (or a message if no camera is available).
Widget _cameraTogglesRowWidget() {
final List<Widget> toggles = <Widget>[];
if (cameras.isEmpty) {
return const Text('No camera found');
} else {
for (CameraDescription cameraDescription in cameras) {
toggles.add(
SizedBox(
width: 90.0,
child: RadioListTile<CameraDescription>(
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
groupValue: controller?.description,
value: cameraDescription,
onChanged: controller != null && controller.value.isRecordingVideo
? null
: onNewCameraSelected,
),
),
);
}
}
return Row(children: toggles);
}
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
void showInSnackBar(String message) {
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message)));
}
void onNewCameraSelected(CameraDescription cameraDescription) async {
if (controller != null) {
await controller.dispose();
}
controller = CameraController(
cameraDescription,
ResolutionPreset.high,
enableAudio: enableAudio,
);
// If the controller is updated then update the UI.
controller.addListener(() {
if (mounted) setState(() {});
if (controller.value.hasError) {
showInSnackBar('Camera error ${controller.value.errorDescription}');
}
});
try {
await controller.initialize();
} on CameraException catch (e) {
_showCameraException(e);
}
if (mounted) {
setState(() {});
}
}
void onTakePictureButtonPressed() {
takePicture().then((String filePath) {
if (mounted) {
setState(() {
imagePath = filePath;
videoController?.dispose();
videoController = null;
});
if (filePath != null) showInSnackBar('Picture saved to $filePath');
}
});
}
void onVideoRecordButtonPressed() {
startVideoRecording().then((String filePath) {
if (mounted) setState(() {});
if (filePath != null) showInSnackBar('Saving video to $filePath');
});
}
void onStopButtonPressed() {
stopVideoRecording().then((_) {
if (mounted) setState(() {});
showInSnackBar('Video recorded to: $videoPath');
});
}
Future<String> startVideoRecording() async {
if (!controller.value.isInitialized) {
showInSnackBar('Error: select a camera first.');
return null;
}
final Directory extDir = await getApplicationDocumentsDirectory();
final String dirPath = '${extDir.path}/Movies/flutter_test';
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}.mp4';
if (controller.value.isRecordingVideo) {
// A recording is already started, do nothing.
return null;
}
try {
videoPath = filePath;
await controller.startVideoRecording();
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
return filePath;
}
Future<void> stopVideoRecording() async {
if (!controller.value.isRecordingVideo) {
return null;
}
try {
await controller.stopVideoRecording();
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
await _startVideoPlayer();
}
Future<void> _startVideoPlayer() async {
final VideoPlayerController vcontroller =
VideoPlayerController.file(File(videoPath));
videoPlayerListener = () {
if (videoController != null && videoController.value.size != null) {
// Refreshing the state to update video player with the correct ratio.
if (mounted) setState(() {});
videoController.removeListener(videoPlayerListener);
}
};
vcontroller.addListener(videoPlayerListener);
await vcontroller.setLooping(true);
await vcontroller.initialize();
await videoController?.dispose();
if (mounted) {
setState(() {
imagePath = null;
videoController = vcontroller;
});
}
await vcontroller.play();
}
Future<String> takePicture() async {
if (!controller.value.isInitialized) {
showInSnackBar('Error: select a camera first.');
return null;
}
final Directory extDir = await getApplicationDocumentsDirectory();
final String dirPath = '${extDir.path}/Pictures/flutter_test';
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}.jpg';
if (controller.value.isTakingPicture) {
// A capture is already pending, do nothing.
return null;
}
try {
await controller.takePicture();
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
return filePath;
}
void _showCameraException(CameraException e) {
logError(e.code, e.description);
showInSnackBar('Error: ${e.code}\n${e.description}');
}
}
class CameraApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: CameraExampleHome(),
);
}
}
List<CameraDescription> cameras;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Fetch the available cameras before initializing the app.
try {
cameras = await availableCameras();
} on CameraException catch (e) {
logError(e.code, e.description);
}
runApp(CameraApp());
}
实际输出:
我对你的代码做了一些调整,对比前后的相机预览,似乎它可以适用于你当前的场景。考虑到相机 aspectRatio
的计算,您只需要进行一些调整。
您还可以更新您的帖子并添加一些示例输出,以便我们检查此解决方案是否适合。
除了上述解决方案外,还有更灵活的解决方案,因为许多设备的分辨率和尺寸可能会有所不同。特别是当您尝试为 Android 和 iOS 构建时。
但是,如果相机插件仅提供 CameraPreview
小部件,这可能会更加困难。您可以通过从 Controller.buildPreview()
方法中提取 cameraId
创建您自己的 Texture
小部件来解决这个问题。
它可能类似于下面的代码。然而,我注意到相机插件仍然有只提供 4/5 分辨率的限制。因此,最接近 desiredRatio
的分辨率最终可能会变得非常低质量。
class CameraApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyCameraHome(),
);
}
}
class MyCameraHome extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return MyCameraHomeState();
}
}
class MyCameraHomeState extends State<MyCameraHome> {
static final double _desiredAspectRatio = 1.78;
late final CameraController _controller;
Widget _previewWidget = Container();
@override
void initState() {
super.initState();
print(_closestResolutionPreset());
_controller = CameraController(cameras[0], _closestResolutionPreset());
_controller.initialize().then((_) {
if (!mounted) {
return;
}
_buildPreviewWidget();
});
}
ResolutionPreset _closestResolutionPreset() {
final Map<ResolutionPreset, double> ratios = <ResolutionPreset, double>{
ResolutionPreset.low: defaultTargetPlatform == TargetPlatform.android
? 320 / 240
: 352 / 288,
ResolutionPreset.medium: defaultTargetPlatform == TargetPlatform.android
? 720 / 480
: 640 / 480,
ResolutionPreset.high: 1280 / 720,
ResolutionPreset.veryHigh: 1920 / 1080,
};
double smallestDifference = 1000;
late ResolutionPreset resultPreset;
for (MapEntry<ResolutionPreset, double> ratio in ratios.entries) {
final double newDifference = (ratio.value - _desiredAspectRatio).abs();
if (newDifference < smallestDifference) {
resultPreset = ratio.key;
smallestDifference = newDifference;
}
}
return resultPreset;
}
void _buildPreviewWidget() {
Widget previewWidget = _controller.buildPreview();
setState(() => _previewWidget = previewWidget);
}
Widget _buildPictureButton() {
return InkResponse(
onTap: () {
//_takePicture();
//_recordAVideo();
},
child: Container(
width: 65,
height: 65,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
border: Border.all(color: Colors.grey, width: 2)),
child: const Icon(
Icons.camera,
color: Colors.grey,
size: 60,
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Expanded(
child: Container(
decoration: const BoxDecoration(color: Colors.black),
child: _previewWidget,
),
),
Container(
decoration: const BoxDecoration(color: Colors.black),
padding: const EdgeInsets.only(
bottom: 30,
left: 10,
right: 10,
top: 15,
),
child: Stack(
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.centerLeft,
child: IconButton(
icon: const Icon(
Icons.switch_camera,
color: Colors.white,
size: 32,
),
onPressed: () {} //_toggleLensDirection,
),
),
Container(
alignment: Alignment.center,
child: _buildPictureButton(),
)
],
),
),
],
),
);
}
}
List<CameraDescription> cameras = [];
Future<void> main() async {
// Fetch the available cameras before initializing the app.
try {
WidgetsFlutterBinding.ensureInitialized();
cameras = await availableCameras();
} on CameraException catch (e) {
logError(e.code, e.description);
}
runApp(CameraApp());
}
关于flutter - 用前置摄像头录视频抖动屏幕变暗变窄,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56423364/
使用 Vanilla JS,我希望执行如下图所示的操作,其中除了特定部分(最好是椭圆形)之外,大部分 Canvas 都变暗。 我可以通过在前面绘制半透明颜色来轻松使 Canvas 变暗,但我不确定如何
我想将 UIView “变暗”一定程度。现在,我正在像这样进行变暗: UIView *overlay = [[UIView alloc] initWithFrame:mainView.bounds];
我有一个 TCard(TGraphicControl 组件)并且它有一个属性背景(TP图片) 我希望能够使背景变暗或变暗。因此,如果我可以在游戏中玩卡片,那么它是正常的。如果我不能在游戏中玩这张卡,那
如果您熟悉 iTerm2 应用程序,您就会知道您可以像 vim 一样 Split View,并且不活动的 View 会“变暗”。 我通常在 vim 中使用三个垂直 Split View,例如,通过将背
我正在尝试创建一些 jQuery 函数,将对象 bgcolor 更改为更亮或更暗(您将参数设置为色调差异)。我认为它应该可以工作,但是它破裂了。 $.fn.changeBg = function(di
我有两个 fragment ,其中一个具有完整 View 的大小。另一个 fragment 较小并放置在其上方。如何使第一个 fragment 变暗? 最佳答案 在 fragment XML 文件中,
我在一个 Pane 中使用 irssi 和 nicklist.pl在另一个中,每当我在 irssi Pane 中时,昵称列表 Pane 就会变暗: 如何阻止非事件 Pane 变暗? 最佳答案 找到了!
我试图做的是使 UIImageView 更暗,以便图像结果顶部的按钮和 View 。我想给它一个在 ios6 中用户使用 Facebook 分享时给出的效果。它后面的所有内容都变得更暗,但它是可见的。
在单击登录按钮后出现的进度条微调器中,我希望当微调器在屏幕上可见时微调器后面的元素变暗或变暗。我的布局文件目前看起来像这样:
在我的应用程序中,我有一个带有进度条的刷新功能。进度条位于应该刷新的 TextView 上。问题是:如果 textview 中有很多文本,你就看不到进度条了。是否可以在 onPreExcute/onP
操作表自然会使背景 View 稍微变灰,但并不明显。我想让它变得更暗。 还有,我要怎么做才能让您无法点击其他地方?现在,如果您在操作表外部单击,操作表就会消失。我希望这种情况不会发生 - 您必须按下“
我想创建一个主页,其背景图像填充整个页面高度。在此之上,我需要添加白色文本和其他元素。 This website是我想要实现的一个例子。 我想要的: 外观: 使用下面的 CSS,文本看起来非常模糊。
我一直在开发一款增强现实游戏,并且正在实现我的暂停菜单。我的暂停菜单完全可用,UIView 显示为 ARSKView 之上的另一层。但是,我想在显示暂停菜单时使 ARSKView 变暗,然后在关闭暂停
我在 View 的右上角有一个菜单按钮 (+),当按下按钮时,其他几个按钮会下拉供用户选择。 我想有效地调暗所有这些按钮下方的所有 View 。 我目前的做法是在所有内容之上设置一个透明 View ,
我是网络开发的半菜鸟,但我不是在使用错误的术语进行搜索,就是我不是一个非常熟练的 googler。 我正在制作一个单页网站,并且想要这样的效果,即当向下滚动新部分进入 View 时,新部分会变暗。我可
我的应用程序的背景是一个不透明的 UIImageView。在某些情况下,我想以动画方式将它从全亮度调暗到大约 50%。目前我降低了 View 的 alpha 属性并且效果很好。因为 View 后面没有
我需要向用户显示 alert 并且我希望它很漂亮。所以我使用 Bootstrap 的警报类,并像这样向用户显示 div: Some text 这段代码只显示了一个div。我想要的是将所有东
我需要在触摸 UIImageView 时使它变暗, 几乎就像跳板(主屏幕)上的图标一样。 我应该添加具有 0.5 alpha 和黑色背景的 UIView 吗?这看起来很笨拙。我应该使用图层还是其他东西
我正在将图像加载到 BitmapImage 中并将其转换为 PixelColor 的数组。我想要的是能够操纵这些像素中的一些,使它们更亮/更暗/透明,但我似乎无法让它工作。将其设置为某种颜色确实有效,
我找到了 change the opacity of a View 的方法,但我实际上需要使 View 变暗。我最好的办法是在上面放一个透明的黑色矩形,然后慢慢增加矩形的不透明度。 你知道更好的方法吗
我是一名优秀的程序员,十分优秀!