How to read an ico format picture in java?

我怕爱的太早我们不能终老 提交于 2019-11-28 08:08:05

问题


I have a lot of .ico formatted pictures, and I want to use them in my Java SE project, but it doesn't know the format. How can I work around this?


回答1:


Try out image4j - Image Library for Java

The image4j library allows you to read and write certain image formats in 100% pure Java.

Currently the following formats are supported:

  • BMP (Microsoft bitmap format - uncompressed; 1, 4, 8, 24 and 32 bit)
  • ICO (Microsoft icon format - 1, 4, 8, 24 and 32 bit [XP uncompressed, Vista compressed])

With the library you can easily decode your ico file

List<BufferedImage> image = ICODecoder.read(new File("input.ico"));



回答2:


Apache Commons Imaging allows to read and write ICO files:

    List<BufferedImage> images = Imaging.getAllBufferedImages(new File("input.ico"));

It supports several popular formats of metadata too (EXIF, IPTC and XMP).

TwelveMonkeys ImageIO allows to extend the ImageIO API to support ICO and numerous other image file formats.



来源:https://stackoverflow.com/questions/11400707/how-to-read-an-ico-format-picture-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!