-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapCreator.java
executable file
·60 lines (52 loc) · 1.58 KB
/
mapCreator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;
import java.awt.image.*;
import java.util.*;
import java.io.*;
public class mapCreator {
public static void main (String [] args) {
Scanner scn = new Scanner (System.in);
BufferedImage img = null;
String strImgFileName;
String strCSVFileName;
String strImage;
FileWriter fr = null;
PrintWriter pr = null;
System.out.println ("Image name: ");
strImgFileName = scn.nextLine();
try {
img = ImageIO.read(new File (strImgFileName));
}catch (IOException e) {
}
System.out.println ("File name: ");
strCSVFileName = scn.nextLine();
try {
fr = new FileWriter (strCSVFileName);
pr = new PrintWriter (fr);
}catch (IOException e) {
}
System.out.println ("imagefile: ");
strImage = scn.nextLine();
pr.println (img.getHeight() + "," + img.getWidth() + "," + strImage);
for (int Count = 0; Count < img.getHeight(); Count ++) {
String strRow = "";
for (int Count1 = 0; Count1 < img.getWidth(); Count1 ++) {
Color thisColor = new Color (img.getRGB(Count1, Count));
if (thisColor.getGreen() == 255) {
strRow += "t_0_2";
}else {
strRow += "f_" + thisColor.getRed()/50 + "_" + thisColor.getBlue()/50;
}
if (Count1 != img.getWidth() - 1) {
strRow += ",";
}
}
pr.println (strRow);
}
try{
pr.close();
fr.close();
}catch (IOException e) {}
}
}