package readers; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; 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; public class ITGReader extends Reader{ final static int REGION_PADDING = 32; List extraRegions = new ArrayList<>(); static int lastJump=0; public ITGReader(){ readRegions.add(new Box(388,552,227,60)); //score[0] readRegions.add(new Box(797,438,164,58)); //fantastic+[1] readRegions.add(new Box(797,493,164,58)); //fantastic[2] readRegions.add(new Box(797,551,164,58)); //excellent[3] readRegions.add(new Box(797,618,164,58)); //great[4] readRegions.add(new Box(797,673,164,58)); //decent[5] readRegions.add(new Box(797,736,164,58)); //miss[6] readRegions.add(new Box(279,443,340,104)); //pct[7] readRegions.add(new Box(277,364,64,60)); //diffnumb[8] readRegions.add(new Box(344,393,266,36)); //playstyle[9] readRegions.add(new Box(277,174,324,171)); //grade[10] readRegions.add(new Box(632,106,656,43)); //songname[11] } 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, 130,255,130,255,130,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; 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