Fix sub region parsing issues (#1)

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago
parent 0f3c03be58
commit ca117c8fab
  1. 17
      readers/DDRReader.java
  2. 2
      readers/fonts/Font.java
  3. BIN
      sub.png

@ -2,6 +2,7 @@ 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;
@ -132,13 +133,19 @@ public class DDRReader extends Reader{
Graphics2D g = cutImg.createGraphics();
int currentHeight=0;
for (int i=0;i<readRegions.size();i++) {
int[] arr = originalImg.getRGB(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h, null, 0, readRegions.get(i).w);
BufferedImage subRegion = new BufferedImage(readRegions.get(i).w, readRegions.get(i).h,BufferedImage.TYPE_INT_ARGB);
subRegion.setRGB(0,0,readRegions.get(i).w,readRegions.get(i).h,originalImg.getRGB(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h, null, 0, readRegions.get(i).w),0,readRegions.get(i).w);
int[] arr = subRegion.getRGB(0, 0, readRegions.get(i).w, readRegions.get(i).h, null, 0, readRegions.get(i).w);
//System.out.println(Arrays.toString(arr));
//System.out.println(i);
//ImageIO.write(originalImg.getSubimage(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h),"png",new File("cut.png"));
ColorFilter(arr,i,readRegions.get(i).w);
subRegion.setRGB(0,0,readRegions.get(i).w,readRegions.get(i).h,arr,0,readRegions.get(i).w);
ImageIO.write(subRegion,"png",new File("sub.png"));
cutImg.setRGB(0,currentHeight,readRegions.get(i).w,readRegions.get(i).h,arr,0,readRegions.get(i).w);
System.out.println(interpretImage(cutImg,i));
System.out.println(interpretImage(subRegion,i));
currentHeight+=readRegions.get(i).h+REGION_PADDING;
}
Path output = Paths.get("result.png");
@ -176,6 +183,12 @@ public class DDRReader extends Reader{
}
return f.convertGlyphs(glyphs);
}
case 1:
case 8:{
Font f = Font.FONT_DDR_EXCOMBO;
List<Glyph> glyphs = Glyph.split(cutImg);
return f.convertGlyphs(glyphs);
}
}
return "";
}

@ -184,7 +184,7 @@ public class Font {
if (score>bestScore) {
bestScore=score;
bestGlyph=j;
System.out.println("Glyph "+j+" has a score of "+bestScore+".");
//System.out.println("Glyph "+j+" has a score of "+bestScore+".");
}
}
sb.append(bestGlyph);

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Loading…
Cancel
Save