HarmonyOS 鸿蒙Next base64字符串的图片如何使用Image加载出来?

发布于 1周前 作者 h691938207 来自 鸿蒙OS

HarmonyOS 鸿蒙Next base64字符串的图片如何使用Image加载出来?

后端返回了一个这样的字符串,我要是用Image,要如何加载出来?

iVBORw0KGgoAAAANSUhEUgAAADAAAACbCAYAAAAk2RiqAAARZElEQVR4Xu2Y6W8k13XF/XcGyIcARoB8CBD4WwQjQODAkS3JjgMrkSUYSizFcjTkcN+H5JAc7t1N9l5VvZAczgxnSA7X3reb33lVHEmUDAtBgkyAusDFe/XWc86971VX/+AHscUWW2yxxRZbbLHFFltsscUWW2yxxRZbbLHFFltsscUWW2yxxRZbbLHFFtvbZPYddn/MW2l3YJPlI0uWDvBDS5QPvkbjLSYicHvFI/zQ9koQ8KuWCg4s5YsIJaTeWhIClS4e2H7+wDIFSg8PDm3fP7R0cPSmLn/rSAhMBpWzPkBFwqtaGs9AIuNBwDui/ykEw3K/GJK4v87/mTkCZSl9aBlSJkO6ZFUWq5aDlJ7T9GdIoVz5qRvz1kRBIHKVEGTGr1i+VLZcUMLL1KvOcxXaqvTh2TJlhfboYN9f73vbGwn+BywHyIwABxWAA1gR8PUsMmorWQEvQi5Pe4ExBdr/O/YGfLr0DNVQrnxsGRTMVw6tgCpSsFCq4AdWZBNtJGAFKSkwfuhSVuPyqkfgNT9LW9apH5GhvViuWtEBL0MC9aN27XUXsazWde1R5Bif9QJXFu9wBSH5kEDlORs9IzePbf/gKaFlUCDQVfPuvFQyn0memyj1BF5gldshqVDlO6UFKvSQRNinZzdfXomIk0qObOQ5l1pEqqI9K+aztueVzCvy7IHBkwgVh8UROK4CunpiyUOIVMTw0HlBg1Dfk7JFj40IfVnKlc2n7pcDSOKeFquy2YFbuOhLtSgyFaWQQAqwz/yiBRXPgqpPlALz8CAqQ2fdqvbxqPtOOK9Ee8m3EvUS64iU5zMm8EMCvZ3f22Vmyg4OeemUn9s+Yc7pllCqoLIPwEBhrwCWDbSJJocLy8uAQBUUkVp+WRET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4vP6X3ZvEZq3EeQgIufVCIj/baBqAAerkCqJURp+414K5WH9r1Cv1rU2w8aReAv2Tsa8qL7Rk735iy11vT+LidPR62izXGI8jr1QeU446kSHfZuMnZqBOF5u6k+yxtJ8Jzp0tE6dkk4m0+bqy8Yj0Ob49odKtLpBBp5S2GP7e9R9b3F6JDvKVJ/OYnlwX4dHnUziHwenUMZQG0IiAiBJAVCEHiCsDqu1yHzMYsRERi2i42RQrCkJPfEsFactZuU6i2yx2enAtvEhHho6We1pcYHzLZ0Fv6BAV8Y4+vM7UX9fEzz+fkPJ+gC9al7BYhxdnoeW8IkBqoc748Yi+XRuzVypidkdOvnkjdaYBRJyqn+Pka41ZpXxN4QG5O2eXmND5jl0TgWgeMPL1NzXHI5qzOdXe7N2+1NNcebfWkHEBchXXam/tciXh9/5HV9hecNyBQT0MC16dmKwLf5EusQwT6PhFR6S2HBM4Wh+zF3Jd2ujRqr5YAD8hTwJ8D7oyovEbtcw7maw7v1aZUnnJpc7kz6/wCoBeJebvCb3RLcENc7UKGqF6j/s2u/pZRFFDfEZm3W4jUiEotBdkEpYilRSAkVttTueC+k9sFIuO+ziBARHqkj/s05bP0Gz+l/79ZhzS69zkTW2yxxRZbbLHFFltsscUWW2yxxRZbbLHFFltsscUWW2yxxRZbbLHFFltsscUWW2yxxRZbbLH9r9h/Acv0MBrpUH+uAAAAAElFTkSuQmCC

3 回复

没加前缀:data:image/png;base64,

Image('data:image/png;base64,iVBORw0KGgo...').width('200lpx') 

您好,可以使用三方库eftool中提供的ImageUtil.base64ToPixelMap方法将base64转换成pixelMap然后设置给Image

```

let dto =
await ImageUtil.base64ToPixelMap('iVBORw0KGgoAAAANSUhEUgAAADAAAACbCAYAAAAk2RiqAAARZElEQVR4Xu2Y6W8k13XF/XcGyIcARoB8CBD4WwQjQODAkS3JjgMrkSUYSizFcjTkcN+H5JAc7t1N9l5VvZAczgxnSA7X3reb33lVHEmUDAtBgkyAusDFe/XWc86971VX/+AHscUWW2yxxRZbbLH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W8IkBqoc748Yi+XRuzVypidkdOvnkjdaYBRJyqn+Pka41ZpXxN4QG5O2eXmND5jl0TgWgeMPL1NzXHI5qzOdXe7N2+1NNcebfWkHEBchXXam/tciXh9/5HV9hecNyBQT0MC16dmKwLf5EusQwT6PhFR6S2HBM4Wh+zF3Jd2ujRqr5YAD8hTwJ8D7oyovEbtcw7maw7v1aZUnnJpc7kz6/wCoBeJebvCb3RLcENc7UKGqF6j/s2u/pZRFFDfEZm3W4jUiEotBdkEpYilRSAkVttTueC+k9sFIuO+ziBARHqkj/s05bP0Gz+l/79ZhzS69zkTW2yxxRZbbLHFFltsscUWW2yxxRZbbLHFFltsscUWW2yxxRZbbLHFFltsscUWW2yxxRZbbLH9r9h/Acv0MBrpUH+uAAAAAElFTkSuQmCC')
this.img = dto.getDataRow();

```

cke_2404.jpeg

在HarmonyOS中,如果你想要使用Image组件加载一个基于Base64字符串的图片,你需要先将Base64字符串解码成字节数据(byte array),然后利用这些字节数据来创建一个Bitmap对象,最后将这个Bitmap对象设置给Image组件的source属性。

具体步骤如下:

  1. 解码Base64字符串:使用Java或Kotlin的Base64解码工具(如Base64.decode方法)将Base64字符串解码成字节数组。

  2. 创建Bitmap对象:使用BitmapFactory.decodeByteArray方法将字节数组解码成Bitmap对象。

  3. 设置给Image组件:将Bitmap对象封装成PixelMap(如果HarmonyOS API要求),或者直接使用Bitmap(如果Image组件支持),然后设置给Image组件的source属性。注意,HarmonyOS的Image组件可能直接支持Bitmap或需要特定的图片格式,具体请参考HarmonyOS的官方文档。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html 。注意,上述步骤基于一般Android或类似平台的经验,HarmonyOS的具体实现可能有所不同,请参考最新的HarmonyOS开发文档。

回到顶部