public static void main(String[] args) {
String s = "D";
if (s != null) {
BufferedImage bi = new BufferedImage(80,20,BufferedImage.TYPE_INT_BGR);
Graphics2D g2 = (Graphics2D)bi.getGraphics();
g2.setFont(new Font("Serif", Font.BOLD, 12));
g2.drawString(s, 0, 16);
Raster ras = bi.getData();
for (int row = 0; row < 20; row++) {
String line = "";
for (int col = 0; col < 80; col++) {
if (ras.getSample(col,row,1) > 128) {
line += "*";
} else {
line += " ";
}
}
System.out.println(line);
}
}
}
I know it prints out the character in ascii, what I want to know (being a noob) is how do I tell what each field does and how does the program function in general? I have a general gist but I'm not quite there.
Say the 80 and the 20? Where do I look, what do I do to see that? What happens if I change it etc. I can see that it is width, height, type etc, but I dont know how much of an affect changing them has, and what values I should set. Is it measured in pixels? i can see it is coupled with the loop further down. I assume 12 is the size of the serif font? Then how does the 12 relate to the 80 and 20?
Similarly for g2.drawString(s, 0, 16);
Clearly s is d. What is 0 and what is 16? Just the location that I want to draw s? I just have trouble finding/understanding this information from documentation.