Posts: 699 Location: Switzerland Liked others: 485 Was liked: 166
Rank: DDK
KGS: aco
IGS: oca
OGS: oca
Hello,
Just wanted to share with you a quick tool I did to convert an EidoGo board to a [go] "text" diagram
The tool is a java application that you start and that will do a copy of the screen and then processes the image to find the goban and render it as text.
Once that done, the "text" is placed into the clipboard ready to be paste where you want, and finally a dialog is shown to show what as been found.
here is a screenshoot.
To use it, you need java to be on your computer, and you need to download the program "DiagToTxt.jar" (jar stands for Java ARchive).
to execute the programme, you need to type the following command (or put it in a .bat file which must be in the smae folder as diagtotxt.jar)
Code:
start javaw -cp diagtotxt.jar oca.DiagToTxt
It's really important to start it that way so that no java console is displayed (if the console is displayed, it may comes in front of the Eidigo diagram and the console will be present in the image...)
public class DiagToTxt { public static void main(String[] args) throws Exception {
BufferedImage image;
Robot robot = new Robot(); image = robot.createScreenCapture(new Rectangle(Toolkit .getDefaultToolkit().getScreenSize())); // String format ="PNG" ; // ImageIO.write(image, format, new File("screenShot."+format)); // image = ImageIO.read(new File("screenShot."+format));
int startPosY = -1; int startPosX = -1; /* * Find starting point */ for (int y = 0; y < image.getHeight(); y++) { StringBuffer line = new StringBuffer(); for (int x = 0; x < image.getWidth(); x++) { int clr = image.getRGB(x, y); if (clr == -2245525) { // = background color "DDBC6B" line.append("_"); } else { line.append("X"); } } int tmp = line .toString() .indexOf( "___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________"); if (tmp > -1) { startPosY = y; startPosX = tmp; break; } } int margin = 14; int nbPixPerSquare = 19; int py = 0;
StringBuffer goban = new StringBuffer(); goban.append("[go]$$\n"); goban.append("$$ ----------------------------------------\n");
for (int y = startPosY + margin; y < (startPosY + margin + 18 * nbPixPerSquare + 1); y += nbPixPerSquare) { py++; goban.append("$$ | "); for (int x = startPosX + margin; x < (startPosX + margin + 18 * nbPixPerSquare + 1); x += nbPixPerSquare) { int clr = image.getRGB(x, y - 6); int red = (clr & 0x00ff0000) >> 16; int green = (clr & 0x0000ff00) >> 8; int blue = clr & 0x000000ff; String r = String.format("%02X%02X%02X", red, green, blue); int clrCenter = image.getRGB(x, y );
String car = "."; if (clrCenter==-9412810) { car = ","; } else if (r.equals("383838")) { car = "X"; } else if (r.equals("FEFEFE")) { car = "O"; } goban.append(car + " "); } goban.append("|\n"); } goban.append("$$ ----------------------------------------[/go]\n");
StringSelection selection = new StringSelection(goban.toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); javax.swing.UIManager.put("OptionPane.messageFont", new FontUIResource( new Font("Courier", Font.PLAIN, 12))); JOptionPane.showMessageDialog(null, "DiagToTxt 1.0 by oca\nClipboard content :\n" + goban.toString()); } }
_________________ Converting the book Shape UP! by Charles Matthews/Seong-June Kim to the gobook format. last updated april 2015 - Index of shapes, p.211 / 216
Posts: 2180 Location: ʍoquıɐɹ ǝɥʇ ɹǝʌo 'ǝɹǝɥʍǝɯos Liked others: 237 Was liked: 662
Rank: AGA 5d
GD Posts: 4312
Online playing schedule: Every tenth February 29th from 20:00-20:01 (if time permits)
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.
_________________ Still officially AGA 5d but I play so irregularly these days that I am probably only 3d or 4d over the board (but hopefully still 5d in terms of knowledge, theory and the ability to contribute).
Posts: 1585 Location: Barcelona, Spain (GMT+1) Liked others: 577 Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
DrStraw wrote:
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.
For pasting specific positions or areas here, in this same forum or in Sensei's library. For example.
_________________ Geek of all trades, master of none: the motto for my blog mostlymaths.net
Posts: 699 Location: Switzerland Liked others: 485 Was liked: 166
Rank: DDK
KGS: aco
IGS: oca
OGS: oca
DrStraw wrote:
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.
Yes, you right, there is not that much usage for it... so I don't excpect it to win the "2014 Most downloaded go program award" I still missed that kind of tool in a few occasions,for taking a "snapshoot" of the game to talk about a specific position. For that purpose, I prefer the [go] tag.
_________________ Converting the book Shape UP! by Charles Matthews/Seong-June Kim to the gobook format. last updated april 2015 - Index of shapes, p.211 / 216
Posts: 2180 Location: ʍoquıɐɹ ǝɥʇ ɹǝʌo 'ǝɹǝɥʍǝɯos Liked others: 237 Was liked: 662
Rank: AGA 5d
GD Posts: 4312
Online playing schedule: Every tenth February 29th from 20:00-20:01 (if time permits)
RBerenguel wrote:
DrStraw wrote:
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.
For pasting specific positions or areas here, in this same forum or in Sensei's library. For example.
oh, yeah. I tend to forget about SL.
_________________ Still officially AGA 5d but I play so irregularly these days that I am probably only 3d or 4d over the board (but hopefully still 5d in terms of knowledge, theory and the ability to contribute).
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum