So far I have the following code that reads a 30×40 pixel .bmp file:
public void setUp() throws IOException
{
BufferedImage image =
ImageIO.read(getClass().getResource("circle1.bmp"));
greenInputData = new byte[30][40];
for (int x = 0; x < greenInputData.length; x++)
{
for (int y = 0; y < greenInputData[x].length; y++)
{
int color = image.getRGB(x, y);
greenInputData[x][y] = (byte)(color >> 8);
}
}
System.out.println(greenInputData);
}
The console gives me the following right now when I call System.out.println(greenInputData):
[[B@1c8a1c9d
[[B@1cb4ee66
[[B@262580b3
[[B@450a3962
[[B@5d7138f4
[[B@44443799
[[B@5220c1b
[[B@52c4d93
[[B@3eaa2c1c
[[B@2b3fc0bb
[[B@4b8b7245
[[B@2623592
[[B@e689490
[[B@3849ca75
[[B@ebe5687
[[B@671ef55c
[[B@68c6fc84
[[B@53dc5341
But I want to be able to see an array printout of the image I am reading. For example, if I reading a bitmap of a circle, I want to be able to System.out.println() out a 30×40 bitmap array like the following:
<---------30---------------->
000000000000000000000000000000 ^
000000111110000000000000000000 |
000001111111100000000000000000 |
000011111111110000000000000000 |
000011111111110000000000000000 40
000001111111100000000000000000 |
000000011110000000000000000000 |
000000000000000000000000000000 |
000000000000000000000000000000 |
.
.
.
Hint :
You are forming
greenInputDatarightProblem is with the way you are displaying it.
hint: it is a 2d array