BitmapFactory.decodeFile 可以处理 .ICO(Windows 图标)文件吗? [英] Can BitmapFactory.decodeFile handle .ICO (Windows icons) files?
本文介绍了BitmapFactory.decodeFile 可以处理 .ICO(Windows 图标)文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发 Android.尝试显示收藏夹图标"(又名快捷方式图标")或网页.
I am working on Android. Trying to display the "favicon" (aka "shortcut icon") or web pages.
所以我已经有了从任何网站获取此图标 URL 的代码,并将其下载到我的 Android 上.
So I already have the code to get the URL of this icon from any website, and download it onto my Android.
现在我试图用它制作位图,但结果总是为空.
Now I am trying to make a Bitmap out of it, but always get null as a result.
代码:
String src = String.format("file:///data/data/com.intuitiveui.android/files/%s",prefName);
// prefName is "facebook.ico", and I do see tht file in my DDMS file browser. It's
// a valid icon file.
Bitmap res = BitmapFactory.decodeFile(src);
// This returns null
TIA
推荐答案
这里是 支持的 Android 媒体格式.ICO 不在其中.不过,您或许可以找到基于 Java 的 ICO 解码器.
Here is a list of the supported Android media formats. ICO is not among them. You might be able to find a Java-based ICO decoder, though.
这篇关于BitmapFactory.decodeFile 可以处理 .ICO(Windows 图标)文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文