【问题标题】:How to display an image from AttachedPicture | Flutter如何显示来自 AttachedPicture | 的图像扑
【发布时间】:2021-07-01 12:15:04
【问题描述】:

我正在尝试显示 MP3 文件中的封面图像。我正在从https://github.com/NiKoTron/dart-tags 获取 ID3 标签。

我的代码:

TagProcessor tp = TagProcessor();
tp.getTagsFromByteArray(bytes).then((l) async {

  AttachedPicture picture = l[1].tags['picture']['Cover (front)'];

  log(picture.toString()); // ->[log] {mime:image/png, description:, bitmap: iVBORw0KGgoAAAANSUhEUgAABLAAAASw...}
});

mime: image/png 只是一个字符串,所以我不知道如何获取图像。

【问题讨论】:

  • 您正在获取图像的位图。您是否尝试显示位图?我认为Image.memory 显示位图中的图像。

标签: flutter dart id3


【解决方案1】:

AttachedPicture 具有imageData 类型的属性List<int>

您可以使用Image.memory 来显示imageData,使用Uint8List.fromList

import 'dart:typed_data';

Image.memory(
  Uint8List.fromList(imageData),
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-10
    • 2013-06-12
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    相关资源
    最近更新 更多