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; import readers.fonts.Font; import readers.fonts.Glyph; public class DDRReader extends Reader{ final static int REGION_PADDING = 32; List extraRegions = new ArrayList<>(); static int lastJump=0; public DDRReader(){ readRegions.add(new Box(305,428,402,69)); //score[0] readRegions.add(new Box(603,565,133,37)); //max combo[1] readRegions.add(new Box(603,612,133,37)); //marvelous[2] readRegions.add(new Box(603,651,133,37)); //perfect[3] readRegions.add(new Box(603,698,133,37)); //great[4] readRegions.add(new Box(603,742,133,37)); //good[5] readRegions.add(new Box(603,787,133,37)); //OK[6] readRegions.add(new Box(603,830,133,37)); //miss[7] readRegions.add(new Box(603,876,133,37)); //ex score[8] readRegions.add(new Box(783,738,133,37)); //fast[9] readRegions.add(new Box(783,821,133,37)); //slow[10] readRegions.add(new Box(600,165,133,53)); //diffnumb[11] readRegions.add(new Box(577,91,174,36)); //playstyle[12] readRegions.add(new Box(253,207,357,183)); //grade[13] readRegions.add(new Box(756,432,411,38)); //songname[14] readRegions.add(new Box(576,126,185,40)); //difficulty text[15] } void ColorFilter(int[] arr,int region,int width) { switch (region) { case 0:{ process(arr,width, 247,255,247,255,247,255, 200,255,200,255,200,255); }break; case 1:{ process(arr,width, 180,255,180,255,180,255, 70,255,70,255,70,255); }break; case 2:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 3:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 4:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 5:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 6:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 7:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 8:{ process(arr,width, 190,255,190,255,190,255, 140,255,140,255,140,255); }break; case 9:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 10:{ process(arr,width, 0,50,0,50,0,50, 0,160,0,160,0,160); }break; case 11:{ process(arr,width, 190,255,190,255,190,255, 140,255,140,255,140,255); }break; case 12:{ process(arr,width, 190,255,190,255,190,255, 140,255,140,255,140,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 glyphs = Glyph.split(cutImg); if (glyphs.size()==9) { //This is a 1,000,000 score. glyphs.remove(5); glyphs.remove(1); } else if (glyphs.size()>4) { //This is a XXX,XXX score. glyphs.remove(3); } return f.convertGlyphs(glyphs); } } return ""; } @Override void interpretResults(String[] finalData) { // TODO Auto-generated method stub } }