Georgia Ingham

Georgia is a Java Developer at IDRSolutions and mainly works on maintaining and improving the core product code. Her hobbies include reading, completing puzzle books and cycling.

How to write out BMP images in Java

52 sec read

Previously, we have written about how to read BMP files as images in Java. This time around we wanted to highlight how you can write out BMP images in Java.

What is a BMP file?

BMP ImageA BMP is an image file format, commonly known as a bitmap image, with the extension .bmp or .dib. It was originally created by Microsoft for computers running Windows, and it specifies the color of the pixels in a way that allows them to be displayed on any device.

There are two different ways you can write out BMP files in Java. One way is to use ImageIO, and an alternative is to use our JDeli image library.

ImageIO

ImageIO.write(bufferedImage, "BMP", new File("/path/to/outputFile.bmp"));

Javadoc  (included in JDK)

JDeli

BmpEncoder encoder = new BmpEncoder();
encoder.write(bufferedImage, outputStream);

Alternatively, JDeli also has a static write method. This makes it easy to swap out ImageIO for JDeli in your code:

JDeli.write(bufferedImage, JDeli.OutputFormat.BMP, new File("/path/to/outputFile.bmp"));

Javadoc and Download

The JDeli library supports Bilevel, Grayscale and RGB images.

 

If you found this guide useful, you can find more image tutorials in our how to series on how to read and write various Image formats.

 

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (TwitterFacebook and Google+) or the  Blog RSS.

Georgia Ingham

Georgia is a Java Developer at IDRSolutions and mainly works on maintaining and improving the core product code. Her hobbies include reading, completing puzzle books and cycling.

Leave a Reply

Your email address will not be published. Required fields are marked *