字符串为位图的Java / Android的 [英] String to Bitmap java/android

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

问题描述

我正在开发中,我转换为位图,以字符串一些purprose的应用程序。 我如何可以转换字符串成位图了吗?

解决方案
  

我转换成一个位图转换为字符串做一些工作,现在我想将其转换回......它看起来像android.graphics.Bitmap@43fd34c0

简单地说,你不能。

这串由默认 Object.toString()法生产。它没有连接code中的对象的信息内容,并没有什么标准的类库,这将打开它变成一个引用原始对象......假设它仍然存在。

您唯一的希望是,如果你创建一个地图<字符串,位图> 和映射填充;例如,

 地图<字符串,位图>图=新的HashMap<字符串,位图>();
...
map.put(someBitmap.toString(),someBitmap);
...
位图检索= map.get(someString);
 

I am developing an application in which I converted a bitmap to string for some purprose. How can I convert that String into a Bitmap again?

解决方案

I converted an Bitmap to String to do some work, now I want to convert it back... it looks like "android.graphics.Bitmap@43fd34c0"

Simply stated, you can't.

That string is produced by the default Object.toString() method. It does not encode the information content of the object, and there is nothing in the standard class libraries that will turn it back into a reference to the original object ... assuming that it still exists.

Your only hope is if you create a Map<String,Bitmap> and populate it with mappings; e.g.

Map<String, Bitmap> map = new HashMap<String, Bitmap>();
...
map.put(someBitmap.toString(), someBitmap);
...
Bitmap retrieved = map.get(someString);

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

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