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 ImageIcon(imageFile.getAbsolutePath());
ImageIcon support the typical png,gif,jpg
images.
In the project i am working, i can not open a bmp file and store the same file as a jpg, because i am not allow to store something at runtime. I could only generate the image in hold it in memory. But i dont know how to do this.
How can i show BMP
in Java
1.4
?
Thanks
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With