Display BMP in JLabel

后端 未结 2 867
清歌不尽
清歌不尽 2020-12-18 05:40

Java can display png, jpg a some other picture formats, but i have to display a bmp file in a JLable by getting the file path.

ImageIcon imageIcon = new Imag         


        
相关标签:
2条回答
  • 2020-12-18 05:52

    javax.imageio.ImageIO supports the BMP format:

    Image image = ImageIO.read(imageFile);
    ImageIcon icon = new ImageIcon(image);
    
    JLabel label = new JLabel(icon);
    

    ImageIO can also be used to convert between different formats.

    0 讨论(0)
  • 2020-12-18 06:00

    I find some classes written in Java 1.5 but you can easily update 2 classes so that you can use the classes in 1.4.

    imag4j can convert bmp and ico files to BufferedImage objects you can display in java. You can import 17 classes and have to update maybe 10 lines because of java 1.5 statements.

    You get a bmp converter which is working very fine.

    0 讨论(0)
提交回复
热议问题