package readers; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; import javax.imageio.ImageIO; import readers.fonts.Font; import readers.fonts.Glyph; public class ITGReader extends Reader{ final static int REGION_PADDING = 32; List extraRegions = new ArrayList<>(); static int lastJump=0; public ITGReader(){ addRegion(new Box(388,552,227,60),NUMBER); //score[0] addRegion(new Box(797,438,164,58),NUMBER); //fantastic+[1] addRegion(new Box(797,493,164,58),NUMBER); //fantastic[2] addRegion(new Box(797,551,164,58),NUMBER); //excellent[3] addRegion(new Box(797,618,164,58),NUMBER); //great[4] addRegion(new Box(797,673,164,58),NUMBER); //decent[5] addRegion(new Box(797,736,164,58),NUMBER); //miss[6] addRegion(new Box(279,443,340,104),NUMBER); //pct[7] addRegion(new Box(277,364,64,60),NUMBER); //diffnumb[8] addRegion(new Box(344,393,266,36)); //playstyle[9] addRegion(new Box(277,174,324,171)); //grade[10] addRegion(new Box(632,106,656,43)); //songname[11] init(); } void ColorFilter(int[] arr,int region,int width) { switch (region) { case 0: case 1:{ process(arr,width, 20,40,195,215,225,240, 20,40,195,215,225,240); }break; case 2: case 7: case 10:{ process(arr,width, 240,255,240,255,240,255, 240,255,240,255,240,255); }break; case 3:{ process(arr,width, 215,240,145,165,10,30, 215,240,145,165,10,30); }break; case 4:{ process(arr,width, 90,110,190,210,75,100, 90,110,190,210,75,100); }break; case 5:{ process(arr,width, 170,190,80,105,240,255, 170,190,80,105,240,255); }break; case 6:{ process(arr,width, 240,255,40,55,40,55, 240,255,40,55,40,55); }break; case 8:{ process(arr,width, 0,5,0,5,0,5, 0,5,0,5,0,5); }break; case 9:{ process(arr,width, 170,255,170,255,170,255, 170,255,100,255,120,255); }break; case 11:{ process(arr,width, 180,255,180,255,180,255, 150,255,150,255,150,255); }break; } } public void interpretBoxes(Path img){ /*String dataString = readAllBoxes(img); String[] data = dataString.split(Pattern.quote("\n")); String[] ja_data = data[0].split(Pattern.quote(")")); String[] en_data = data[2].split(Pattern.quote(")")); trimAllData(ja_data); trimAllData(en_data); System.out.println(Arrays.toString(ja_data)); System.out.println(Arrays.toString(en_data));*/ int regionHeights = 0; int maxWidth = 0; int counter = 0; for (int i=0;imaxWidth) { maxWidth=readRegions.get(i).w*2; } } try { BufferedImage originalImg = ImageIO.read(img.toFile()); BufferedImage cutImg = new BufferedImage(maxWidth,regionHeights,BufferedImage.TYPE_INT_ARGB); Graphics2D g = cutImg.createGraphics(); int currentHeight=0; for (int i=0;i glyphs = Glyph.split(cutImg); glyphs.remove(glyphs.size()-3); String res = f.convertGlyphs(glyphs); return res.substring(0,res.length()-2)+"."+res.substring(res.length()-2,res.length()); } case 7:{ Font f = Font.FONT_ITG_PCT; List glyphs = Glyph.split(cutImg); glyphs.remove(glyphs.size()-3); String res = f.convertGlyphs(glyphs); return res.substring(0,res.length()-2)+"."+res.substring(res.length()-2,res.length()); } case 1: case 2: case 3: case 4: case 5: case 6:{ Font f = Font.FONT_ITG_NOTECOUNT; List glyphs = Glyph.split(cutImg); return f.convertGlyphs(glyphs); } case 8:{ Font f = Font.FONT_ITG_DIFF; List glyphs = Glyph.split(cutImg); return f.convertGlyphs(glyphs); } } return ""; } @Override void interpretResults(String[] finalData) { // TODO Auto-generated method stub } }