HarmonyOS 鸿蒙Next base64 解码,以及解码后如何加载到 Image 中

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

HarmonyOS 鸿蒙Next base64 解码,以及解码后如何加载到 Image 中
项目中验证码登录流程中,有条件的会触发图形验证码,后端返回的图形验证码为 base64 编码过的 string 数据,在原 android 项目中,是通过 Base64.decode() 解码后加载到 ImageView 中,想咨询这种方式到 harmony Next 开发这边如何实现,在下面贴一个编码过的字符串:

iVBORw0KGgoAAAANSUhEUgAAAUAAAABQCAIAAADnUzvSAAAEiElEQVR42u2dS1LoMAwEuf+lzeJtKIoHcazPjNyzpIBY8q89UZKPhRCy1QdCyFisYQixAyOEEEIIhEYIhEYIIYQQCI0QAqERQt37/OzY7+xi5ggIjRAInbZMyP43tdgdt6PzNrMJX7elXxX7bT0+acBPmG83k/8NhxpOc0MQunLtVFunU9ujvCklLdBjzg4esZQtGF//SXtqwhdOO8J83pjd5OiPe4ldtHhDD3E7vvaxKcz87/fP57Zs4A9/U7Nzz2OXRujwXnw4gX3R8ce/rUyjcq4sogtsZFu871aIkHHf2MeBtPx8Wx5vUHtNYCGgy77Yj8P0/Fou+LSFxLvb9SSz9Ju1cZv929CM8xHsqHe3hVKvOMOgNhonNU3NvcrW2jBjDr9eF8MnsEuGd3PlcvQ99y8jE1IARRfeNw8EwidGgHW67MbJ4Vb5HKmyEPpCeNapZ3bZsq6C59hgged+bM6L3cKwvQ2e826GpyD0hfD8bmrV8Bvw3BjUvx82Fn6koNEY10rQnJyUt+X/WKhZpx9CkVGVr9lDJIaHDq8JoNuhsSNvEjwLTvt5x40BcdmM0kN49vKus5sxchOeV/A86tj4cD3YPdYLAme9vQQ8609g0UG71aAnCH0ejy8/bY3Jd8Jz0hJfEJdmh6aAREaptz48n9zYHHDDfHyw3n2asUIIMsm5n/F7543E6Rc9uAY9z9zcoallwCG2VjGfnHTn8xk+jKh3x8akGE8W66LMr+hXT2gySXYFwtQa8jX3RSJDDOrD9eBJCYsCSG9deh08GDyJokVKxBUm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XT2gySXYFwtQa8jX3RSJDDOrD9eBJCYsCSG9deh08GDyJokVKxBUmcM/ojfKff5+rUfMhm0ae88IJ7cRaA+L8XFMirhB7y/nIiS2zl/BV8u6LScXk9xTGe5+Psm/Q73objWGqIY/FkeqGOfxwDMdnI7CEI5st2xG64CpenDnYc3Y5HwnhQTuEgNBG5x3T5IgidNQElkXoqOwH7tLAs6knr4jQIdWtyggdWL7bbrZT8Nx1CtNF6DK27ELoygCVN66bazaGI3QZXja60PP


更多关于HarmonyOS 鸿蒙Next base64 解码,以及解码后如何加载到 Image 中的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

直接把编码过的字符串添加一个图片头就行,比如:

this.base64Str = "data:image/jpeg;base64," + "图片编码字符串"

然后在Image组件就可以,Image(this.base64Str)

更多关于HarmonyOS 鸿蒙Next base64 解码,以及解码后如何加载到 Image 中的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS(鸿蒙)系统中,进行base64解码并将解码后的数据加载到Image中的过程,通常涉及以下几个步骤:

  1. Base64解码: HarmonyOS提供了丰富的API供开发者使用。对于base64解码,你可以使用ohos.utils.base64.Base64类。具体调用方式为:

    String encodedStr = "your_base64_encoded_string";
    byte[] decodedBytes = Base64.decode(encodedStr, Base64.DEFAULT);
    
  2. 加载到Image中: 解码后的字节数组decodedBytes可以直接用于创建ohos.media.image.PixelMap对象(或其他适合图像显示的类,取决于你的具体需求)。例如:

    PixelMapFactory.create(decodedBytes, width, height, PixelMap.PixelFormat.ARGB_8888, (pixelMap) -> {
        // pixelMap即为加载后的图像,可用于显示
    });
    

    注意:你需要知道解码后图像的宽度width和高度height,这些信息通常在编码前已知或在编码信息中附带。

如果上述方法在你的具体实现中遇到问题,可能是由于图像格式不兼容、解码错误或其他特定于应用的错误。请检查你的base64字符串是否完整且正确,以及确保图像尺寸和格式与你的应用需求相匹配。

如果问题依旧没法解决请联系官网客服,官网地址是 https://www.itying.com/category-93-b0.html

回到顶部