Java Read BMP Files?

I am working on a map editor for a simple map builder.

My idea was to draw the walls on the map as black pixels, everything else (white) is the free space in the room.

Any .jar to read BMP files? To avoid the header, etc.?

Update

Im reading about Image4j

Thanks in adavance.

+3
source share
3 answers

If you want to use Image4j, this is a pretty simple way. This code will map BMP to JLabel.

    BufferedImage image = null;

    try
    {
        image = BMPDecoder.read(new File("C:\\test.bmp"));
    }
    catch(IOException ex)
    {
        Logger.getLogger(DesktopApplication1View.class.getName()).log(Level.SEVERE, null, ex);
    }

    jLabel1.setIcon(new ImageIcon(image));
+1
source

Java Advanced Imaging API Image I/O. Javadoc , BMP ( ).

+1
import javax.imageio.ImageIO;

class ListImageReaders {
    public static void main(String[] args) {
        String[] imageReaders = ImageIO.getReaderFileSuffixes();
        for (String imageReader : imageReaders) {
            System.out.println(imageReader);
        }
    }
}

Gives output (in Java 1.6)

bmp
jpg
wbmp
jpeg
png
gif
Press any key to continue . . .
+1
source

Source: https://habr.com/ru/post/1760932/


All Articles