read an image in java



Share on Google+Share on Google+

amit kumar gupta
read an image in java
1 Answer(s)      6 years and 11 months ago
Posted in : Java Beginners

qns: how we can read an image tell me about its code?

View Answers

February 7, 2013 at 12:26 PM

import java.awt.image.*;

import javax.imageio.ImageIO;


public class Converter


public static void main(String[] args) throws FileNotFoundException, IOException
    File output_file=new File("C:/pixels.txt");                   //Output Text file
    PrintStream out=new PrintStream(new FileOutputStream(output_file));
    BufferedImage image = readImage("C:/Untitled.jpg");               //Input Image file

public static void printAllARGBDetails(BufferedImage image)
    int width = image.getWidth();
    int height = image.getHeight();
    int pix_num=1;
    int total_pix=width*height;
    System.out.println("Image Scrambler");   
    System.out.println("Image Dimension: Height-" + height + ", Width-" + width);
    System.out.println("Total Pixels: " + (height * width));
    for (int i = 0; i < width; i++)
        for (int j = 0; j < height; j++)
            int pixel = image.getRGB(i, j);
            String idata=(getARGBPixelData(pixel));
            System.out.print("Pixel ("+i+","+j+"): ");

public static String getARGBPixelData(int pixel)
    String ARGBvalue="";
    int alpha = (pixel >> 24) & 0x000000FF;
    int red = (pixel >> 16) & 0x000000FF;
    int green = (pixel >>8 ) & 0x000000FF;
    int blue = (pixel) & 0x000000FF;
    ARGBvalue = alpha + " " + red + " " + green + " " + blue;
    return ARGBvalue;

public static BufferedImage readImage(String fileLocation) throws IOException
    BufferedImage img = null;
    img = File(fileLocation));
    return img;



Related Tutorials/Questions & Answers:
read an image in java
read an image in java  qns: how we can read an image tell me about its code
read image
read image  java code to read an image in the form of an array.  ... ReadImageInArray { public static int[] getImagePixels(BufferedImage image...() * image.getHeight()]; try { grabber = new PixelGrabber(image, 0, 0
Read content for JPEG image File in Java - Java Beginners
Read content for JPEG image File in Java  How to Read content for JPEG image File in Java? or Extract text from JPEG image File in Java
JME image read
JME image read  how to display more then one image in jme after reading from nokia 6303 phone. reply me at [email protected]
java read file
java read file  Hello i need some help... i want to read an MS Excel file in java so how to read that file
Read file in java
Read file in java  Hi, How to Read file in java? Thanks   Hi, Read complete tutorial with example at Read file in java. Thanks
How to read loops in Java
How to read loops in Java  Example that explains how to read loop in Java
Java read binary file
Java read binary file  I want Java read binary file example code that is easy to read and learn. Thanks   Hi, Please see the code at Reading binary file into byte array in Java. Thanks   Hi, There is many
image compression - Java Beginners
image compression  image compression in java coding
Read from file java
Read from file java  How to Read from file java? What is the best method for a text file having a size of 10GB. Since i have to process the file one line at a time so tell me the very best method. Thank you
java image compression - Java Beginners
java image compression  image compression in java
Read XML using Java
of all i need to read xml using java . i did good research in google and came to know...Read XML using Java  Hi All, Good Morning, I have been working as a Manual Test engineer for last 4 years. Now i started learning java
Read XML in java - XML
Read XML in java  Hi Deepak, I want to read a xml file which have only one element with multiple attributes with same tag name. here is my file... a java code is given below. import; import
image - Java Beginners
image  how to identify the watermarked image? or how to convert the watermarked image into original image? can you send that corresponding java code
java rotate image
java rotate image   How to rotate image to 90 and 180. can you please post an example to rotate image
Read from a window - Java Beginners
Read from a window  HI, I need to open a website and read the content from the site using Java script. Please suggest. Thanks
READ DATA - Java Beginners
READ DATA  i still don't understand, i have a data like this : d00002;Marketing;Finance; d00002;Marketing;Acct-Tax; d00002;Marketing;Acct-Tax... = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line
image retrieve - Java Beginners
Image Retrieve  How to retrieve the image from mysql field using java
Converting HTML to image - Java Beginners
Converting HTML to image   Is it possible to convert html to image with java code ?   Hi friend, Please give the problem in details for complete solution. For read more information : http
read xml using java
read xml using java  <p>to read multiple attributes and elements from xml in an order.... ex :component name="csl"\layerinterfacefile="poo.c...;   Please visit the following link: Read XML data
image insert - Java Beginners
image insert  i browsed the image by clicking d browse button.if i press submit button means d image automatically stored in db.then i have 2 retrieve d image separately...................... Untitled Document
image comparison - Java Beginners
image comparison  hi all, pls help me to compare 2 images(in pixel and pattern) using jsp...the image pixels are in a xml file...  Hi friend, Read for more information.
To read a excel with chart - Java Beginners
To read a excel with chart   Hi, I need to read the data in an excel which is in chart format using java. when I directly change the extention of excel file to CSV i am not getting the data in the chart.Please help me
Image using Java coding
Image using Java coding  Hai, Display image in pdf file using Java coding through Xsl file.. Please help me.. xsl file generate the pdf file
Java Image Browsing Applet
Java Image Browsing Applet  Hi. I want to create an applet which is embedded in html page which display image by browsing the files in the computers hard disk... Please help me out
image save to folder in java
image save to folder in java  Hi, I am working with java. In my application i want to give facility to user to add and change image. I use open dialog box to select image, it will work properly i.e on button click open dialog
image upload in java
image upload in java  Hi, I am working with java. In my application i want to give facility to user to add and change image. I use open dialog box to select image, it will work properly i.e on button click open dialog is open
Java read lines from file
Java read lines from file  Any code example related to Java read... of reading file line by line in Java. Can any one share me the code for reading java file line by line. My file is very big around 6.5GB so it's not possible
Display Image in Java
Display Image in Java       This example takes an image from the system and displays.... The image is read from the system by using file) method
image effects - Java Beginners
image effects  hey can u help me in loadin an image file... that will show you image crop effect: import java.sql.*; import java.awt.... java.awt.image.FilteredImageSource; public class Upload extends JPanel { BufferedImage image; Image img
read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : Thanks


Advertisement null