read image

read image

java code to read an image in the form of an array.

View Answers

May 9, 2011 at 4:22 PM

import java.io.*;
import javax.imageio.*;
import java.awt.image.*;
class ReadImageInArray 
{
    public static int[] getImagePixels(BufferedImage image)
{
    PixelGrabber grabber;
    int[] pixels = new int[image.getWidth() * image.getHeight()];
    try
    {
        grabber = new PixelGrabber(image, 0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
        grabber.grabPixels(0);

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return pixels;
}
    public static void main(String[] args) throws Exception
    {
        File input = new File("C:/rose.jpg");
        BufferedImage image = ImageIO.read(input);
      int array[]=getImagePixels(image);
      for(int i=0;i<array.length;i++){
          System.out.println(array[i]);
      }
    }
}









Related Tutorials/Questions & Answers:
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 an image in java
read an image in java  qns: how we can read an image tell me about its code
Advertisements
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]
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
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
image scrambling
image scrambling  Hi frinds : i want to read image and scrambling it then saved using java any help please
PHP Random image, PHP Randomizing image
PHP Random image PHP Random image Tutorial Ever wanted to know how to create... $imgpath = "path/to/image/dir"; $handle = opendir( "$imgpath"... comment the code. $handle = opendir( "path/to/image/dir"
read paragraph
read paragraph  how to read paragraph from one file to another file
Read bufferedreader
Read bufferedreader  Tell me the example of Read file using bufferedreader. Thanks   Read the tutorial Reading file using BufferedReader class. Thanks
xl read
xl read  hi, i have read excel sheet data using poi api and printed on console, now i have to store the same data which is printed on the console...: Insert excel file data into database Read Excel File
read a file
read a file  read a file byte by byte   import java.io.File; import java.io.FileInputStream; public class ReadFileByteArray {ADS_TO_REPLACE_1 public static void main(String[] args) { File file = new File("D
Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory
read xml
read xml   hi all, i want to ask about how to read an xml in java ME.. here is the xml file <data> <value> <struct> <member> <name> User_Name
image scrolling
image scrolling  A brief description of scrolling image
Image Steganography
Image Steganography  SOURCE CODE FOR IMAGE STEGANOGRAPHY
Use of Image I/O library
Use of Image I/O library       This section illustrates you how to use Image I/O library. The ImageIO class provides the method to read and write image. We are providing you
image format
image format  what are the different format available in image
image format
image format  what are the different format available in image
To scan a image encode that image in j2me
To scan a image encode that image in j2me  Hai team i am new man of j2me i have doubt to scan a image and encode the image in j2me... Please clarify that doubt... Thanks in Advance... Kumar
image in database
image in database  how to set image in database and retrieve it using servlet(java)in msaccess
Image_creation
Image_creation  how to create an image from a set of pixel values stored in array - in java
image Processing
image Processing   BCIF Image Compresssion Algorithm s alossless image Compression algorithm ,Pleas Help Me weather it can support only 24 bit bmp images
Image processing
Image processing  i want a browsing program in java in which we hv a small img and we hv to browse this img on a big image so that we can find the similar type of image in big img
scrolling image
scrolling image  How create a scrolling image in java
UIButton with image
UIButton with image  Hi, How to create UIButton with image? Thanks
PDF to Image
PDF to Image  Java code to convert PDF to Image
TextField on the Image
TextField on the Image  how we set label or textfield etc. on the Image
update image
update image  sir, I want to do update image into database
image retreival
image retreival  I ve stored the path of image and audio in mysql database. how to retrive it and display... Can u pls help me out
Icon image
Icon image  hiii how can we set image on the icon by which we can launch the application???   hello, when you will save a image named icon.png then it is automatically show this image on the icon ...ADS
image display
image display  Hai Friends..... Actually I uploaded filepath into database and image into a folder. Now i want to show that image as my profile photo. How it is?...Friends Can you help me? Thanks in advance to take time
image display
image display  Hai Friends..... Actually I uploaded filepath into database and image into a folder. Now i want to show that image as my profile photo. How it is?...Friends Can you help me? Thanks in advance to take time
image Processing
image Processing  Please give Me a JPEG or GIf "LOSS LESS" Image Compression and Decompression Source Code Please Help Me I don't want links Kindly help me Compression ratio not matter
image steganography
image steganography  Hello.could you please tell me how to start developing code for image steganography?could you provide some key points showimg its implementation
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
background image
background image  how to set background image in jsp using netbeans IDE 6.9
Image in Flex
Image in Flex  Hi..... Can you manipulate images using Flex programs? please give me the example....... Thanks
Image Album
Image Album  hi, i want to save image on server folder. and i want to save URL of this folder and name of image in database.on click of a link it retrieves the image data from server folder according to URL and File name stored
Image retrieve
Image retrieve  HI.. store image path/data Java Coding. ... It's supposed to take the image, store it in a directory as well as pass the image path to mysql database... Now I want to retrieve the data from directory using path
image selection
image selection  hi my issue is : I have select dropdown list when I selected image it displays some default color having image I change the color... it redirect to error image page. can you tell how to solve this problem and where
image scrolling
image scrolling  Hi My reqvirements are as below Input... image in a folder when i scroll mouse or press right arrow key then next image... should be diplayed on jframe Example : similar to image viewer
Image in mysql
Image in mysql  Hi. How to insert and retrieve images in mysql db using JSP or JAVA Servlet? Thanks in advance
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
image processing matching an 2 image
image processing matching an 2 image  source code for dense and sparse matching feature in lbp
image display
image display  sir the answer which you have sent to me is already I have I want to know that the syntax which you have writen for display... to display in image from databse plz help me i will wait for ur reply
Image in Flex
Image in Flex  Hi...... please give me the ans What type of images can be loaded in flex application? please give the name of images ........ Thanks

Ads