How to read BMP images in Java

In this article, I will be writing about BMP images and how to read them in Java.

What is BMP?

A BMP, bitmBMP Imageap image file, is a file format which stores images. It supports 2d images in monochrome (one colour) and colour. The BMP file format supports 2 file extensions including .bmp and .dib (Device Independant Bitmap). It was primarily designed for Window platforms although it also works on other platforms.

BMP images are popular and can be read by JDeli, ImageIO and JAI.

How to read BMP images in Java?

Here are examples of how BMP images can be read in Java.

JDeli:

BmpDecoder decoder = new BmpDecoder();
BufferedImage image = decoder.read(rawImageBytes);

You can find the javadocs for JDeli here. If JDeli interests you, you can find more information here.

ImageIO:

File bmpFile = new File("bmpImage.bmp");
BufferedImage image = ImageIO.read(bmpFile);

You can find the javadocs for ImageIO here. You can find more information on ImageIO (included with the JDK) on their main page.

JAI:

 RenderedImage image = JAI.create("fileload", "test1.bmp");

You can find the javadocs for JAI here. More information on JAI can be found here.

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.

Related Posts:

The following two tabs change content below.
A Java developer at IDRSolutions with 4 years of experience in Java (self-taught). Now looking forward to speaking at Java One. A knowledge seeker who likes to try out and explore new things.
Zain

About Zain

A Java developer at IDRSolutions with 4 years of experience in Java (self-taught). Now looking forward to speaking at Java One. A knowledge seeker who likes to try out and explore new things.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>