当前位置:网站首页>[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 .
边栏推荐
- Realization of 2D code generation in micro build low code
- How powerful is the Zadig build? Practice together
- Is the account opening of Guosheng securities really safe and reliable
- 在长投学堂开通证券账户是安全可靠的吗?
- Oracle删除归档日志及添加定时任务
- After crossing, she said that the multiverse really exists
- 带链接跳转的微信红包封面制作教程和使用指南
- Is it safe and reliable for changtou school to help open a securities account? How to drive
- 手机办理股票开户安全性高吗?
- Detailed explanation of Zadig's self-test and joint debugging sub environment for developers
猜你喜欢

Powerful open source API interface visual management platform Yapi

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

深入虚拟内存(Virtual Memory,VM)

How to use London gold to draw support resistance line

浅析搭建校园在线教学视频汇聚平台的必要性及解决方案
![LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)
LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路

Linq连表查询
利用Redis实现点赞功能的示例代码

How to analyze the trend chart of London gold market with the moving average

After crossing, she said that the multiverse really exists
随机推荐
Explanation: Luogu p1762 even number /6.21 internal examination T2
Ingénieur natif du nuage après 00: utiliser Zadig pour développer des sources ouvertes et des économies d'énergie pour la technologie innovante (bus de Guangzhou)
浅析搭建校园在线教学视频汇聚平台的必要性及解决方案
Qt5.15中qsrand,srand随机数生成函数已弃用问题
This simple little function saves 213 hours for our production research team in half a year
Web API learning notes 1
Detailed explanation of Zadig's self-test and joint debugging sub environment for developers
Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding
论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
Code example of hiredis
Multiomics single cell data integration and regulatory reasoning based on graph linked embedding
How to use London gold to draw support resistance line
微搭低代码中实现二维码生成
Mysql通过ibd文件恢复数据的详细步骤
Is the account opening of Guosheng securities really safe and reliable
torch. nn. Transformer import failed
【HackTheBox】dancing(SMB)
Online linear programming: Dual convergence, new algorithms, and regret bounds
邂逅阿维塔 11:强产品力下久违的新鲜感
Considerations on the construction of operation and maintenance system - stability