更新时间:2022-06-11 01:58:12
尝试 Image4J 。
这个快速的Scala REPL会话显示(可以粘贴为Java代码):
As this quick Scala REPL session shows (paste-able as Java code):
> net.sf.image4j.codec.ico.ICODecoder.read(new java.net.URL("http://www.google.com/favicon.ico").openStream())
res1: java.util.List[java.awt.image.BufferedImage] = [BufferedImage@65712a80: type = 2 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=ff000000 IntegerInterleavedRaster: width = 16 height = 16 #Bands = 4 xOff = 0 yOff = 0 dataOffset[0] 0]
更新
回答您的问题:Java是否支持ICO?看起来不像:
To answer your questions: Does Java support ICO? Doesn't seem like it:
> javax.imageio.ImageIO.read(new java.net.URL("http://www.google.com/favicon.ico"))
java.lang.IllegalArgumentException: Empty region!
为什么 ImageIO
无法从网址是什么?好吧,URL本身似乎对我有用,所以你可能有代理/防火墙问题,或者它可能是上面的问题。
Why does ImageIO
fail to read from the URL? Well, the URL itself seems to work for me, so you may have a proxy/firewall issue, or it could be the problem above.