include client resizing
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
79ea82da4f
commit
1d37ec04a8
BIN
bin/SigShare.jar
BIN
bin/SigShare.jar
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 119 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 48 KiB |
@ -37,6 +37,9 @@ import java.awt.Graphics2D;
|
|||||||
public class SigShare {
|
public class SigShare {
|
||||||
static Robot r;
|
static Robot r;
|
||||||
public static final String PROGRAM_NAME="SigShare";
|
public static final String PROGRAM_NAME="SigShare";
|
||||||
|
public static double SCREEN_MULT=2;
|
||||||
|
public static int SCREEN_WIDTH=(int)(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth()/SCREEN_MULT);
|
||||||
|
public static int SCREEN_HEIGHT=(int)(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight()/SCREEN_MULT);
|
||||||
public static void main(String[] args) throws AWTException {
|
public static void main(String[] args) throws AWTException {
|
||||||
r = new Robot();
|
r = new Robot();
|
||||||
if (args.length==2&&args[1].equalsIgnoreCase("server")) {
|
if (args.length==2&&args[1].equalsIgnoreCase("server")) {
|
||||||
@ -50,9 +53,6 @@ public class SigShare {
|
|||||||
System.out.println("Sending initial data...");
|
System.out.println("Sending initial data...");
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),"ISO-8859-1"));
|
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),"ISO-8859-1"));
|
||||||
DataOutputStream clientOutput = new DataOutputStream(client.getOutputStream());
|
DataOutputStream clientOutput = new DataOutputStream(client.getOutputStream());
|
||||||
double SCREEN_MULT=2;
|
|
||||||
int SCREEN_WIDTH=(int)(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth()/SCREEN_MULT);
|
|
||||||
int SCREEN_HEIGHT=(int)(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight()/SCREEN_MULT);
|
|
||||||
clientOutput.write(("DESKTOP "+SCREEN_WIDTH+" "+SCREEN_HEIGHT+"\r\n").getBytes());
|
clientOutput.write(("DESKTOP "+SCREEN_WIDTH+" "+SCREEN_HEIGHT+"\r\n").getBytes());
|
||||||
System.out.println("Send initial screen");
|
System.out.println("Send initial screen");
|
||||||
//char[] screen = new char[SCREEN_WIDTH*SCREEN_HEIGHT];
|
//char[] screen = new char[SCREEN_WIDTH*SCREEN_HEIGHT];
|
||||||
@ -113,8 +113,8 @@ public class SigShare {
|
|||||||
if (line.contains("DESKTOP")) {
|
if (line.contains("DESKTOP")) {
|
||||||
String[] split = line.split(Pattern.quote(" "));
|
String[] split = line.split(Pattern.quote(" "));
|
||||||
|
|
||||||
int SCREEN_WIDTH=Integer.parseInt(split[1]);
|
SCREEN_WIDTH=Integer.parseInt(split[1]);
|
||||||
int SCREEN_HEIGHT=Integer.parseInt(split[2]);
|
SCREEN_HEIGHT=Integer.parseInt(split[2]);
|
||||||
p.init(SCREEN_WIDTH,SCREEN_HEIGHT);
|
p.init(SCREEN_WIDTH,SCREEN_HEIGHT);
|
||||||
|
|
||||||
f.add(p);
|
f.add(p);
|
||||||
@ -176,7 +176,7 @@ public class SigShare {
|
|||||||
ImageWriter writer = iter.next();
|
ImageWriter writer = iter.next();
|
||||||
ImageWriteParam iwp = writer.getDefaultWriteParam();
|
ImageWriteParam iwp = writer.getDefaultWriteParam();
|
||||||
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
||||||
iwp.setCompressionQuality(0.3f);
|
iwp.setCompressionQuality(0.8f);
|
||||||
writer.setOutput(ios);
|
writer.setOutput(ios);
|
||||||
writer.write(null, new IIOImage(resizeImage(r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()),w,h),null,null),iwp);
|
writer.write(null, new IIOImage(resizeImage(r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()),w,h),null,null),iwp);
|
||||||
writer.dispose();
|
writer.dispose();
|
||||||
|
@ -56,7 +56,7 @@ public class Panel extends JPanel implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
System.out.println("Resized");
|
System.out.println("Resized");
|
||||||
|
setSize(getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -107,7 +107,7 @@ public class Panel extends JPanel implements Runnable {
|
|||||||
// ask ImageProducer to update image
|
// ask ImageProducer to update image
|
||||||
mImageProducer.newPixels();
|
mImageProducer.newPixels();
|
||||||
// draw it on panel
|
// draw it on panel
|
||||||
g.drawImage(this.imageBuffer, 0, 0, this);
|
g.drawImage(this.imageBuffer.getScaledInstance(getWidth(), getHeight(), Image.SCALE_FAST), 0, 0, this);
|
||||||
|
|
||||||
|
|
||||||
if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) {
|
if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user