3

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.

Community
  • 1
  • 1
Tom
  • 43,810
  • 29
  • 138
  • 169
  • 2
    [This](http://www.javaworld.com/javaworld/javatips/jw-javatip43.html) post might help. No promises, just a bit of googling! ^_^ – Stephen Aug 22 '10 at 00:09

3 Answers3

1

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
  • 994
  • 5
  • 8
1

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
  • 21,942
  • 7
  • 74
  • 67
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 (under Java 1.6)

bmp
jpg
wbmp
jpeg
png
gif
Press any key to continue . . .
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433