diff --git a/bin/SigShare.jar b/bin/SigShare.jar index 29dfa90..bf7bb76 100644 Binary files a/bin/SigShare.jar and b/bin/SigShare.jar differ diff --git a/bin/screenshot.jpg b/bin/screenshot.jpg index 01593a2..e68e49e 100644 Binary files a/bin/screenshot.jpg and b/bin/screenshot.jpg differ diff --git a/bin/screenshot_out.jpg b/bin/screenshot_out.jpg index eaaa798..e69de29 100644 Binary files a/bin/screenshot_out.jpg and b/bin/screenshot_out.jpg differ diff --git a/bin/screenshot_part.jpg b/bin/screenshot_part.jpg index 6f121e6..06d7794 100644 Binary files a/bin/screenshot_part.jpg and b/bin/screenshot_part.jpg differ diff --git a/src/sig/SigShare.java b/src/sig/SigShare.java index 2aae327..126ac92 100644 --- a/src/sig/SigShare.java +++ b/src/sig/SigShare.java @@ -45,7 +45,7 @@ public class SigShare { public static int REGION_WIDTH = SCREEN_WIDTH/REGION_X_COUNT; public static int REGION_HEIGHT = SCREEN_HEIGHT/REGION_Y_COUNT; public static long LAST_CLEANUP = System.currentTimeMillis(); - public static int CLEANUP_FREQUENCY = 2000; + public static int CLEANUP_FREQUENCY = 5000; public static HashMap REGION_CHECK = new HashMap<>(); public static void main(String[] args) throws AWTException { r = new Robot(); @@ -97,47 +97,63 @@ public class SigShare { in.readLine(); System.out.println("Begin diff analysis mode."); while (true) { - boolean fullCleanup=false; BufferedImage newCapture = CaptureScreen(SCREEN_WIDTH,SCREEN_HEIGHT); REGION_CHECK.clear(); - for (int y=0;y=5000) { - if (!REGION_CHECK.containsKey((char)(gridY*REGION_X_COUNT+gridX))) { - performSubimageUpdate(in, clientOutput, newCapture, gridX, gridY); - } - fullCleanup=true; - } else - if (currentPixel!=newPixel) { - img[y*newCapture.getWidth()+x]=newPixel; - //System.out.println("Changes ("+gridX+","+gridY+"): "+changes[gridY*REGION_X_COUNT+gridX]); - if (!REGION_CHECK.containsKey((char)(gridY*REGION_X_COUNT+gridX))) { - changes[gridY*REGION_X_COUNT+gridX]+=2; - if (gridY>0) { - changes[(gridY-1)*REGION_X_COUNT+gridX]+=1; - } - if (gridY0) { - changes[(gridY)*REGION_X_COUNT+(gridX-1)]+=1; - } - if (gridX=CHANGE_THRESHOLD) { - performSubimageUpdate(in, clientOutput, newCapture, gridX, gridY); + if (System.currentTimeMillis()-LAST_CLEANUP>=CLEANUP_FREQUENCY) { + System.out.println("New full refresh"); + CaptureScreen(SCREEN_WIDTH,SCREEN_HEIGHT); + clientOutput.write(255); + stream = new FileInputStream(new File("screenshot.jpg")); + while (stream.available()>0) { + clientOutput.writeByte(stream.read()); + } + stream.close(); + image = ImageIO.read(new File("screenshot.jpg")); + for (int y=0;y0) { + changes[(gridY-1)*REGION_X_COUNT+gridX]+=1; + } + if (gridY0) { + changes[(gridY)*REGION_X_COUNT+(gridX-1)]+=1; + } + if (gridX=CHANGE_THRESHOLD) { + performSubimageUpdate(in, clientOutput, newCapture, gridX, gridY); + } } } - } - } - } - if (fullCleanup) { - LAST_CLEANUP=System.currentTimeMillis(); + } + } } } } catch (IOException e) { @@ -223,6 +239,43 @@ public class SigShare { while (in.available()>0) { if (regionInfo==-1) { regionInfo=in.read(); + if (regionInfo==255) { + System.out.println("Full refresh received."); + while (true) { + while (in.available()>0) { + if (stream==null) { + //System.out.println("Stream opened."); + stream=new BufferedOutputStream(new FileOutputStream(new File("screenshot_out.jpg"),true)); + } + int val = in.read(); + stream.write(val); + //System.out.print((char)val); + if (val=='-') { + dashCount++; + } else + if (val!=0) { + dashCount=0; + } + } + if (dashCount>=10) { + stream.close(); + stream=null; + dashCount=0; + System.out.println("Frame "+frame+++" processed."); + BufferedImage i = ImageIO.read(new File("screenshot_out.jpg")); + if (i!=null) { + for (int y=0;y0) { if (stream==null) {