I'm new to image processing in java. Actually what I'm trying to do is to save all the pixel values of an image into an array rgbArray[], and the problem is that I'm getting the same values in all the indexes of an array i.e. all the indexes of the array have the same value. A part of code is given below:
int[] rgbArray=new int[w*h]; // Array to store the Pixel values
BufferedImage buffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
buffer.getRGB(0, 0, w, h, rgbArray, 0, w );
for(int i=0;i
{
System.out.println("rgbArray["+i+"] = "+ rgbArray[i]);
}
The output which i'm getting is -16777216 for all indexes in rgbArray. How is it possible to have the same value for each and every pixel of the image? And how do I get the correct pixel value??
解决方案