首页 > 其他 > 详细

如何在Flutter / Dart中读取(从磁盘)和调整图像大小

时间:2021-06-21 11:45:35      阅读:45      评论:0      收藏:0      [点我收藏+]
import ‘dart:io‘ as Io;
import ‘package:image/image.dart‘;
void main() {
  // Read a jpeg image from file.
  Image image = decodeImage(new Io.File(‘test.jpg‘).readAsBytesSync());
 
  // Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
  Image thumbnail = copyResize(image,120);
 
  // Save the thumbnail as a PNG.
  new Io.File(‘out/thumbnail-test.png‘)
        ..writeAsBytesSync(encodePng(thumbnail));
}

 

如何在Flutter / Dart中读取(从磁盘)和调整图像大小

原文:https://www.cnblogs.com/liuys635/p/14911101.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!