• Post Reply Bookmark Topic Watch Topic
  • New Topic

Load a bmp image

 
Silvio Fragata da Silva
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody
How do I do to load a bmp image into JLabel ??
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to use the Java Advanced Imaging (JAI) API or another third party loader to decode the BMP format data into a Java Image object.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's very simple using JAI too. You can create a PlanarImage and then convert that PlanarImage to a BufferedImage, from there you can use it like you normally would with AWT, either use drawImage or simply pass it to an ImageIcon and pass that to the JLabel.

In that example fileName would be a String with the URI for the image.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!