flutter - Using nearest neighbour interpolation for flutter image
问题描述
How do I get flutter to resize my Image
widgets using nearest neighbour interpolation if the size of the widget is not the same as the asset size?
class PlayContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Color.fromARGB(255, 0, 110, 255),
child: SafeArea(
child: Image(
fit: BoxFit.contain,
image: AssetImage("assets/knight.png")
)
)
);
}
}
This resizes the image correctly, but it is blurry due to the bilinear interpolation used to resize it.
Based on the source seems to be rather hard coded?
解决方案
多亏了这个拉取请求,这现在可以在主分支中实现:
我添加了在图像上设置 filterQuality 的可能性。这是硬编码的。
先前硬编码的值被设置为默认参数。某些图像在没有滤镜质量(如像素艺术)的情况下缩放时看起来更好。这就是我添加参数的原因。
推荐阅读
- curl - 卷曲 | 上传多个 html 文件到 confluence
- json - 在 Scala 中使用递归字段解析基于模式的 JSON
- wordpress - Wordpress 中的 name 与 single_name 有什么区别?
- google-cloud-platform - 如何使用给定的服务帐户配置运行 gcloud 命令
- shell - 使用 Set -e ,如何使一个命令异常
- facebook - Facebook Instant Games API 方法 canSubscribeBotAsync() 在测试时总是返回 false
- assembly - 汇编语言混乱
- javascript - 防止动画期间的点击事件
- airflow - 气流 - 试图循环操作员。执行不是等待实际操作完成
- python - 如何在多索引数据框中折叠具有相同值的索引