Georgia Ingham Georgia is a Java Developer. She has spoken at lots of conferences. Her hobbies include reading, completing puzzle books and cycling.

How to write BMP images in Java

50 sec read

BMP icon

In this article, I will show you how to write BMP images in Java. We also have a related article covering how to read BMP files in Java.

ImageIO can write out images as BMP files, but it offers very little control over the process or the output. So we added the ability to write out images as BMP files to JDeli. In this article, I show you how to use either JDeli or ImageIO and cover the benefits of JDeli.

How to write out an image as a BMP file in ImageIO

  1. Create a File (or OutputStream) object
    File file = new File("/path/to/outputFile.bmp"));
  2. Pass image, BMP type and File (or OutputStream) object into write method
    ImageIO.write(bufferedImage, "BMP", file);

Note you can easily switch to JDeli and replace ImageIO by just changing ImageIO.write to JDeli.write.

How to write out an image as a BMP file with JDeli

  1. Add JDeli to your class or module path. (download link to the trial jar).
  2. Create a File (or OutputStream) object
    File file = new File("/path/to/outputFile.bmp"));
  3. Pass image, BMP type and File (or OutputStream) object into write method
    JDeli.write(bufferedImage, "BMP", file);

In JDeli you can also use a typesafe version

JDeli.write(bufferedImage, OutputFormat.BMP, file);

or pass in a BmpEncoderOptions object for more control over BMP image output.

BmpEncoderOptions options = new BmpEncoderOptions();
JDeli.write(bufferedImage, options, file);


Why do developers choose JDeli over free alternatives?

  1. Works with newer image formats such as AVIF, HEIC, JPEG XL, WEBP (AVIF next release) that are not supported in Java.
  2. Better support than alternatives for JPEG, PNG, TIFF.
  3. Process images up to 3x faster than ImageIO and other Java image libraries.
  4. Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  5. Image security as JDeli processes images on your servers with no calls to any external system or third party library.

Are you a Java Developer working with Image files?

Georgia Ingham Georgia is a Java Developer. She has spoken at lots of conferences. Her hobbies include reading, completing puzzle books and cycling.