从字符串位图 [英] Bitmap from String

查看:115
本文介绍了从字符串位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法或我如何采取一个字符串,并从它创建使用Java进行开发的一个位图的Andr​​oid?

Is there a way or How do I take a String and create a bitmap from it using Java for development for Android?

我看了一下Java API的位图和无法找到任何东西。

I had a look at the java api for bitmaps and couldnt find anything

推荐答案

您可以使用位图工厂去codebytearray方法,像

You can use the decodebytearray method of bitmap factory like

byte[] imageAsBytes = Base64.decode(myImageData.getBytes());
Bitmap bp = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length);

在哪里myImageData是一个base64字符串。

Where myImageData is a base64 string.

如果您有一个数组只是传递到去codeByteArray方法。

If you have an array just pass that to the decodeByteArray method.

这篇关于从字符串位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆