Alright well here is one way to do this:
-Find the length and width of the 1s and 0s block in the file.
-Create a multi-dimensional array of integers with that length and width
int[][] plane;
//inside of a method...
plane = new int[length][width]; //where length is the number of rows (left/right) and width is the number of columns (up/down)
-Instantiate an Image or BufferedImage using a GUI component or by whatever means you want.
(personally I would use BufferedImage and call createGraphics() to get a Graphics2D object to work with)
-Make a Scanner reading from your binary text file.
-Scan each line using the Scanner's next() method.
public void example() {
Scanner sc = new Scanner(file);
for(int[] row:plane) {
String s = sc.next();
char[] chars = s.toCharArray();
for(int i=0;i<s.length();i++) {
row[i] = Integer.parseInt(Character.toString(chars[i]));
}
}
}
You now have a set of 1s and 0s. You can iterate through that and draw squares onto an image with different colors depending on the number.
//g2 is a Graphics2D object of the image
int pixelWidth = 5; //Each of our picture "pixels" is 5 actual screen pixels in width and length.
int pixelHeight = 5;
int x,y = 0; //Location at which the "pixel" is being drawn.
for(int[] row:plane) {
for(int i:row) {
if(i==0)
g2.setColor(color);
else if(i==1)
g2.setColor(color2);
g2.fillRect(x,y,pixelWidth,pixelHeight);
x+=pixelWidth;
}
y+=pixelHeight;
}
You could easily incorporate those last two examples into one block of code. Just think about it. Instead of converting to integers, you could make your plane a multidimensional array of characters (chars), then test for the characters 1 and 0.
This should work. I kind of threw the code together on the spot (didn't compile it or anything) so if there are any syntax errors or simple logical errors, I apologize. Let me know and I will correct them.
See where you can get yourself and if you have more questions just ask.