Get Pixels from Image using Java

We will see how we can read an image using Java. We know there are several kinds of image formats such as JPEG, GIF, PNG, BMP, TIFF etc. Java has built-in Image I/O API in javax.imageio package and it can be used to load external image formats into its BufferedImage formats. By default, Image I/O supports image formats such as JPEG, PNG, GIF, BMP, WBMP. It can also be extensible to support additional image formats for TIFF and JPEG 2000.

Image I/O recognizes the contents of the file as a JPEG format image, and decodes it into a BufferedImage which can be directly used by Java 2D.

Image can be load or read using following code snippets, where imagePath is the full path with image name from where the image can be read.

 

You can save the below image for reading.
get pixels from image

Now I will put whole source code for reading pixels from an image file using Java. You can customize as per your requirements.

 

Download below sample pixels from the above attached image file.

imagetopixels

That’s all. Thank you for reading this article.

Soumitra

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.