image - 来自 Flutter Widget 的高分辨率图像
问题描述
在我的应用程序中,我需要从屏幕上显示的小部件创建图像。
我使用以下代码使用RepaintBoundary
.
但我得到的图像是 72 PPI。有什么方法可以获得更高分辨率的图像吗?
Future<void> takePicture() async {
RenderRepaintBoundary boundary = genKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage();
final directory = (await getApplicationDocumentsDirectory()).path;
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
File imgFile = new File('$directory/photo.png');
imgFile.writeAsBytes(pngBytes);
}
解决方案
使用这条线将提高“boundary.toImage(pixelRatio:10.0)”pixelRatio 使用双倍来提高你想要的质量。
推荐阅读
- spring-boot - 将 Spring Boot 连接到多个 Artemis 代理
- javascript - javascript无法对复杂数组进行排序
- c# - XAML - WPF StringFormat dd/MM/yyyy 不能通过相同的 StringFormat 以两种方式工作
- sql - 我想在临时表中执行存储过程,但它给了我一个错误你必须指定一个表来进行选择
- html - 完全隐藏按钮上的环绕文本
- powershell - Powershell - 尝试 Catch - 非 Powershell 错误
- java - 如何在主菜单android中以隐藏图标模式启动应用程序
- python - 将 N、S、E、W 角度系统系统映射到 360° 角度系统
- c++ - 我想将 char* 更改为浮动而不会丢失
- python - 'NoneType' 对象在 kivy 环境中没有属性 'size'