dart - 如何将图像转换为 base64 和 base64 为图像?我这样做的方式行不通
问题描述
这是一个示例代码。
var image = await ImagePicker.pickImage(source: ImageSource.camera);
var stringBytes = base64.encode(image.readAsBytesSync());
var bytes = base64.decode(stringBytes);
var newImage = new File.fromRawPath(bytes);
I/flutter (14608): The following FileSystemException was thrown resolving an image codec:
I/flutter (14608): Cannot open file, path = '����*�Exif
I/flutter (14608):
I/flutter (14608):
I/flutter (14608): Business
I/flutter (14608): 11:42:34
I/flutter (14608): �
I/flutter (14608):
I/flutter (14608): ��
I/flutter (14608): ��
I/flutter (14608): %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������
I/flutter (14608): ��
I/flutter (14608): $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������
I/flutter (14608): ��ت���U-%�����^
I/flutter (14608): }�m���
I/flutter (14608): u���V�N6R���
I/flutter (14608): j_8}W,1�ڹ�?ܻw^��� ��6��ꗚm���E[ϓ�������>���X�W��y������=�[!��2!ډ�'8�Mk^ܾ��eS�
并且未知字符的列表还在继续。
我究竟做错了什么?
我想将它转换为 base64,因为我要将它添加到数据库中。
解决方案
推荐阅读
- javascript - Firestore - 多次创建实例是一个不错的选择吗?
- firebase - Firebase ml vision:平台异常没有捆绑模型
- c++ - 非成员运算符重载的 SFINAE
- kubernetes - Kubernetes 网络策略拒绝所有策略不阻止基本通信
- macros - 两个互相“完成”的宏
- python - 在 VSCode 中调试动态加载的模块
- html - 为什么我的实际输出和开发人员工具布局不同?
- python - Scrapy 图像返回无
- postgresql - 带有 LAG() 的 PostgreSQL 更新查询返回“错误:用作表达式的子查询返回多行”
- c++ - RPi 上 C++ 中面向对象编程的性能