获取32PX的favicon.ico [英] Get 32px favicon.ico
问题描述
林试图让网站的32PX favicon.ico的,但它得到的响应是16px的图标,我猜是因为我正尝试由smarthphone获得它,但我试图改变的用户代理这里没有结果HTTP上访是我的code:
Im trying to get the 32px favicon.ico of the websites, but the response it obtain is the 16px favicon, I guess because I´m trying to obtain it by the smarthphone, but I try to change the user agent of the http petition with no result here is my code:
DefaultHttpClient client = new DefaultHttpClient();
String baseUrl = getBaseUrl(url);
HttpGet httpGet = new HttpGet(baseUrl + "/favicon.ico");
httpGet.setHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19");
HttpResponse httpResponse = null;
try {
httpResponse = client.execute(httpGet);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}catch (NullPointerException e) {
e.printStackTrace();
}
InputStream is = null;
try {
is = (java.io.InputStream) httpResponse.getEntity().getContent();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
Drawable favicon = Drawable.createFromStream(is, "src");
final BitmapDrawable bd = (BitmapDrawable) favicon;
不知道如何得到它?
谢谢
Any idea how to get it? Thanks
推荐答案
A .ICO
文件可以包含多张照片。因此,的favicon.ico
文件,你可能包含一个16×16的图片的和的一个32x32的图片。
A .ico
file can contain several pictures. Therefore, the favicon.ico
file you get may well contain a 16x16 picture and a 32x32 picture.
您可以使用 icotool
命令行工具来分析 .ICO
文件:
You can use the icotool
command line tool to analyze a .ico
file:
# On Ubuntu
sudo apt-get install icoutils
icotool -l favicon.ico
--icon --index=1 --width=16 --height=16 --bit-depth=32 --palette-size=0
--icon --index=2 --width=32 --height=32 --bit-depth=32 --palette-size=0
--icon --index=3 --width=48 --height=48 --bit-depth=32 --palette-size=0
# 3 pictures in this favicon.ico file
在Windows上,当你打开一个 .ICO
使用默认浏览器文件(只需双击该文件),观众让你通过包含在多个图片浏览文件。它不打印它们的分辨率,但至少你有一个关于正在发生的事情与你的奇怪的行为线索。
On Windows, when you open a .ico
file with the default viewer (just double-click the file), the viewer let you navigate through the multiple pictures contained in the file. It does not print their resolution, but at least you have a clue about what is going on with your strange behavior.
这篇关于获取32PX的favicon.ico的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!