views:

66

answers:

3

Hi,

I'm working on a map editor for a simple map builder.

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

Any .jar to read bmp files ? So as to avoid the header, etc?

update

Im reading about Image4j

Thanks in adavance.

+1  A: 

I'd recommend you also look at the Java Advanced Imaging API Image I/O sub-project. The project Javadoc indicates that there is support (mostly in raster mode) for BMP files.

mlschechter
+1  A: 

If you want to use Image4j, that's a pretty easy way to go. This code will display a bmp in a 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));
Arnold Spence
+1  A: 
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 (under Java 1.6)

bmp
jpg
wbmp
jpeg
png
gif
Press any key to continue . . .
Andrew Thompson