Amy Pearson Amy is the product lead for JDeli with expertise in image code, Java, web development, and cloud computing. She focuses on JDeli and has also contributed to JPedal, cloud services, and support. Outside work, she enjoys gaming, F1, and music.

How to write BMP images in Java (Tutorial)

3 min read

BMP icon

how to write BMP image (BMP icon)

TL;DR:

Java’s ImageIO can write BMP files but gives you almost no control over the output. For basic use that is fine. If you need control over bit depth, compression, or other encoder settings, you need an external library. JDeli is a pure Java option that works as a drop-in ImageIO plugin and provides a direct API with full encoder options.

Does Java support BMP natively?

Yes, but only at a basic level. ImageIO can write BMP files without any additional libraries:

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

The limitation is that ImageIO’s BMP writer exposes no encoder options. You cannot control bit depth, colour space, or compression. For many use cases this is acceptable, but if output quality or file size matter, an external library gives you the control ImageIO does not.

Which Java BMP library should you use?

ImageIO (native)Apache ImagingJDeli
Pure Java (no native binaries)
Works as ImageIO plugin
Direct API
Bit depth controlLimited
Encoder optionsLimited
Supports other formats (AVIF, HEIC, JPEG2000, PNG, TIFF, WebP…)
CostFreeFreeCommercial
SupportCommunityApache / communityIncluded

Native ImageIO is sufficient for straightforward BMP output where encoder control is not required. Apache Imaging is a reasonable free option if you need more control. JDeli is the better choice for production use or where you need consistent behaviour across multiple image formats.

Option 1: Write BMP with native ImageIO

If you just need to produce a BMP file with no particular constraints, native ImageIO is the simplest route:

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

Option 2: Add controlled BMP output to ImageIO (no code changes)

JDeli registers itself as an ImageIO plugin. Once it is on the classpath, your existing ImageIO.write() calls use JDeli automatically with no code changes required.

Maven

<dependency>
    <groupId>com.idrsolutions</groupId>
    <artifactId>jdeli</artifactId>
    <version>[JDELI_VERSION]</version>
</dependency>

Gradle

implementation 'com.idrsolutions:jdeli:[JDELI_VERSION]'

Alternatively, download the trial jar and add it to your classpath manually. See the ImageIO configuration guide for setup details.

// Your existing ImageIO code — no changes needed
File file = new File("/path/to/output.bmp");
ImageIO.write(bufferedImage, "BMP", file);

Option 3: Write BMP directly with the JDeli API

The JDeli API gives you explicit control over output and does not depend on ImageIO’s plugin registration order.

  1. Add JDeli to your class or module path. (download the trial jar)
  2. Create a File or OutputStream for the output.
  3. Call JDeli.write() with your image, format, and output target.
// String format
JDeli.write(bufferedImage, "BMP", new File("/path/to/output.bmp"));
// Type-safe enum (preferred)
JDeli.write(bufferedImage, OutputFormat.BMP, new File("/path/to/output.bmp"));

Controlling output with BmpEncoderOptions

For production use, pass a BmpEncoderOptions object to control bit depth and other output settings:

BmpEncoderOptions options = new BmpEncoderOptions();
JDeli.write(bufferedImage, options, new File("/path/to/output.bmp"));

See the JDeli BMP documentation for the full list of encoder options.

Frequently asked questions

Does Java support BMP natively?

Yes, but with limited control. ImageIO can write BMP files without any additional library, but exposes no encoder options. You cannot control bit depth, colour space, or compression without an external library such as JDeli.

What is the BMP format?

BMP (Bitmap Image File) is a raster image format developed by Microsoft. It stores pixel data with minimal compression and is widely supported across Windows applications. BMP files are typically larger than equivalent JPEG or PNG files but require no decoding overhead, making them useful in workflows where processing speed matters more than file size.

What is JDeli?

JDeli is a pure Java image library from IDR Solutions. It has no native binaries, works as both an ImageIO plugin and a standalone API, and supports BMP alongside AVIF, HEIC, JPEG2000, PNG, TIFF, and WebP.

Can I read BMP files in Java with JDeli?

Yes. See our companion article: how to read BMP files in Java.

Is JDeli pure Java?

Yes. JDeli has no native binaries and makes no calls to platform-specific libraries, making it straightforward to deploy on any Java-supported platform including containerised and server environments.

Other useful BMP resources

As experienced Java developers, we help you work with images in Java and bring over a decade of hands-on experience with many image file formats.



Are you a Java Developer working with Image files?

Amy Pearson Amy is the product lead for JDeli with expertise in image code, Java, web development, and cloud computing. She focuses on JDeli and has also contributed to JPedal, cloud services, and support. Outside work, she enjoys gaming, F1, and music.