- merge r1808 from denis's branch
- name project in .project to deskshare-applet git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@1814 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
parent
cb7f5895ec
commit
aaca826e2a
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>deskShareClient</name>
|
||||
<name>deskshare-applet</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
@ -1,7 +1,9 @@
|
||||
package screenshot;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -21,7 +23,8 @@ public class Capture {
|
||||
private Toolkit toolkit;
|
||||
private Rectangle screenBounds;
|
||||
|
||||
private int width, height, x,y;
|
||||
private int width, height, x,y, videoWidth, videoHeight;
|
||||
private boolean needScale = true;
|
||||
|
||||
/**
|
||||
* The default constructor. Performs initialisation work
|
||||
@ -36,10 +39,12 @@ public class Capture {
|
||||
}
|
||||
this.toolkit = Toolkit.getDefaultToolkit();
|
||||
this.screenBounds = new Rectangle(x, y, this.width, this.height);
|
||||
this.needScale = areDimensionsScaled(this.width, this.height);
|
||||
}
|
||||
|
||||
public BufferedImage takeSingleSnapshot(){
|
||||
return robot.createScreenCapture(this.screenBounds);
|
||||
if (needScale) return getScaledImage(robot.createScreenCapture(this.screenBounds));
|
||||
else return robot.createScreenCapture(this.screenBounds);
|
||||
}
|
||||
|
||||
public int getScreenshotWidth(){
|
||||
@ -147,4 +152,48 @@ public class Capture {
|
||||
else return 10;
|
||||
}
|
||||
|
||||
private boolean areDimensionsScaled(int width, int height){
|
||||
int bigger = Math.max(width, height);
|
||||
if (bigger < 800){
|
||||
videoWidth = width;
|
||||
videoHeight = height;
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
if (width >= height){
|
||||
videoWidth = 800;
|
||||
videoHeight = Math.round(height/(width/800));
|
||||
} else if (height > width){
|
||||
videoHeight = 800;
|
||||
videoWidth = Math.round(width/(height/800));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage getScaledImage(BufferedImage image){
|
||||
BufferedImage scaledImage = new BufferedImage(
|
||||
videoWidth, videoHeight, BufferedImage.TYPE_3BYTE_BGR);
|
||||
|
||||
// Paint scaled version of image to new image
|
||||
Graphics2D graphics2D = scaledImage.createGraphics();
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
graphics2D.drawImage(image, 0, 0, videoWidth, videoHeight, null);
|
||||
|
||||
// clean up
|
||||
|
||||
graphics2D.dispose();
|
||||
|
||||
return scaledImage;
|
||||
}
|
||||
|
||||
public int getVideoWidth(){
|
||||
return videoWidth;
|
||||
}
|
||||
|
||||
public int getVideoHeight(){
|
||||
return videoHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ public class CaptureThread implements Runnable {
|
||||
socket = new Socket(IP, PORT);
|
||||
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
|
||||
out.println(roomNumber);
|
||||
out.println(Integer.toString(capture.getWidth())
|
||||
+ "x" + Integer.toString(capture.getHeight())
|
||||
out.println(Integer.toString(capture.getVideoWidth())
|
||||
+ "x" + Integer.toString(capture.getVideoHeight())
|
||||
+ "x" + Integer.toString(capture.getProperFrameRate()));
|
||||
outStream = new DataOutputStream(socket.getOutputStream());
|
||||
} catch(Exception e){
|
||||
@ -52,6 +52,7 @@ public class CaptureThread implements Runnable {
|
||||
outStream.writeLong(imageData.length);
|
||||
outStream.write(imageData);
|
||||
System.out.println("Sent: "+ imageData.length);
|
||||
outStream.flush();
|
||||
} catch(Exception e){
|
||||
e.printStackTrace(System.out);
|
||||
System.exit(0);
|
||||
|
@ -34,6 +34,8 @@ public class RunnerApplet extends JApplet {
|
||||
|
||||
/**
|
||||
* This method is called when the user closes the browser window containing the applet
|
||||
* It is very important that the connection to the server is closed at this point. That way the server knows to
|
||||
* close the stream.
|
||||
*/
|
||||
public void destroy(){
|
||||
capThread.closeConnection();
|
||||
|
Loading…
Reference in New Issue
Block a user