当前位置:网站首页>[chapter 71 of the flutter problem series] mutual conversion between uint8list and image in flutter
[chapter 71 of the flutter problem series] mutual conversion between uint8list and image in flutter
2022-06-28 22:59:00 【Allen Su】
This is a 【Flutter Question Series No 71 piece 】, If it works , Welcome to the column .
Flutter edition :2.5.0,Dart edition :2.14
Because I've been working on the camera recently 、 Crop pictures and OCR The function of picture recognition , So frequent and Image、Uint8List Dealing with .
This blog summarizes the methods of mutual transformation used in the work , It's convenient for you to check .
It needs to be introduced first
- import ‘dart:ui’ as ui;
- import ‘dart:typed_data’;
One :Uint8List turn Image
Uint8List turn Image It provides two ways , As shown in the following code
/// Uint8List turn Image Mode one
ui.Image _fun1(Uint8List list) {
late ui.Image image;
ui.decodeImageFromList(list, (ui.Image callBack) {
image = callBack;
});
return image;
}
/// Uint8List turn Image Mode two
Future<ui.Image> _fun2(Uint8List list) async {
ui.Codec codec = await ui.instantiateImageCodec(list);
ui.FrameInfo frame = await codec.getNextFrame();
return frame.image;
}
Two :Image turn Uint8List
As shown in the following code
Future<Uint8List?> _fun(ui.Image image) async {
ByteData? byteData = await image.toByteData();
if (byteData != null) {
Uint8List bytes = byteData.buffer.asUint8List();
return bytes;
}
return null;
}
Just take it and use it , There's nothing to say .
Has your problem been solved ? Feel free to leave a comment in the comments section .
A gift of rose , Fragrance in hand , If you think the article is good , I hope you can give me one button three times , thank .
Google Of Flutter More and more fire , end 2022 year 6 month 28 Japan GitHub Target star has reached 142K,Flutter Determination is a trend , So as a front-end Developer , There is no reason not to study as soon as possible .
Conclusion
No matter you are Flutter Novices are still getting started , You might as well pay attention to , In the future, I will Flutter Common components in ( Contains source code analysis 、 Usage and precautions of components ) As well as possible problems CSDN Blog , I hope I can learn at the same time , It can also help more people .
边栏推荐
- Redis+AOP+自定义注解实现限流
- 如何使用伦敦金画出支撑阻力线
- Tanghongbin, Yaya live CTO: to truly localize, the product should not have the attribute of "origin"
- Online linear programming: Dual convergence, new algorithms, and regret bounds
- Mono 的执行流程
- Heavyweight! CDA certification test preparation Q & A Online
- WMS仓库管理系统模块之波次拣货
- 一文读懂,WMS仓储管理系统与ERP有什么区别
- FANUC机器人_KAREL编程入门(2)_通用IO信号的使用方法
- 生产环境sonarqube安装
猜你喜欢

Zadig + sonarqube, ensuring the safety of the development process

稳!上千微服务如何快速接入 Zadig(Helm Chart 篇)

Interpretation of papers (DCN) towards k-means-friendly spaces: simultaneous deep learning and clustering

月薪6万,互联网“降本增效”后,这类人开始被疯抢

Production environment sonarqube installation

The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology

全面掌握const的用法《一》

Jointly explore digital technology and information security, and the fourth China Russia Digital Forum was successfully held

FANUC机器人_KAREL编程入门(2)_通用IO信号的使用方法

k线图基础知识图解——单根K线的含义
随机推荐
计数排序的简单理解
Basic knowledge diagram of K-line Diagram -- meaning of single K-line
torch. nn. Transformer import failed
带链接跳转的微信红包封面制作教程和使用指南
Understand shell script in one article
网上办理股票开户安全性高吗?
论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
生产环境sonarqube安装
在线SQL转HTMLTable工具
Qsrand, srand random number generating function in qt5.15 has been discarded
穿越过后,她说多元宇宙真的存在
云计算的迷路者
Panxiaoming, senior vice president of IC nansha|amd and President of Greater China: process, architecture and platform optimization break through the computing boundary
Multiomics single cell data integration and regulatory reasoning based on graph linked embedding
Interpretation of papers (DCN) towards k-means-friendly spaces: simultaneous deep learning and clustering
Differences among CPU, GPU, TPU and NPU
【HackTheBox】 meow
FANUC机器人_KAREL编程入门(2)_通用IO信号的使用方法
数学知识:求组合数 I—求组合数
邂逅阿维塔 11:强产品力下久违的新鲜感