Toolkit.getDefaultToolkit().createImage() vs ImageIO.read()

前端 未结 2 2063
栀梦
栀梦 2021-01-02 13:22

I\'m creating a UI using Swing and I want to display an image in a JLabel. The code I use is the following:

 JLabel label = new JLabel(new Image         


        
2条回答
  •  自闭症患者
    2021-01-02 13:53

    As discussed here, your JPEG image may contain spurious transparency information. One simple expedient is to render the image in a buffer having a compatible color model, as shown here.

提交回复
热议问题