changeset 93:71bfbb5241bf

modify CuiMyVncClient
author e085711
date Thu, 22 Sep 2011 05:43:48 +0900
parents 405ead268439
children 1783ca4e4877
files src/myVncClient/CuiMyVncClient.java src/myVncClient/CuiVncCanvas.java src/myVncClient/MyRfbProto.java src/myVncClient/MyVncClient.java src/myVncClient/VncCanvas.java
diffstat 5 files changed, 38 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncClient/CuiMyVncClient.java	Thu Sep 22 05:16:18 2011 +0900
+++ b/src/myVncClient/CuiMyVncClient.java	Thu Sep 22 05:43:48 2011 +0900
@@ -303,7 +303,7 @@
 		showConnectionStatus("Connecting to " + host + ", port " + port + "...");
 
 		// rfb = new RfbProto(host, port, this);
-		rfb = new MyRfbProto(pHost, port);
+		rfb = new MyRfbProto(pHost, port, this);
 
 		showConnectionStatus("Connected to server");
 
@@ -1056,13 +1056,11 @@
 	}
 
 	public void writeScreenData(byte[] b, String imageFormat) {
-/*
 		try{
-			vc.drawBufferedImage(b, imageFormat);
+			vc.drawBufferedImage(b);
 		}catch(IOException e){
 			e.printStackTrace();
 		}
-*/
 	}
 	
 }
--- a/src/myVncClient/CuiVncCanvas.java	Thu Sep 22 05:16:18 2011 +0900
+++ b/src/myVncClient/CuiVncCanvas.java	Thu Sep 22 05:43:48 2011 +0900
@@ -381,7 +381,11 @@
 			switch (msgType) {
 			case MyRfbProto.SpeedCheckMillis:
 				rfb.readSpeedCheck();
-				
+
+				break;
+			case MyRfbProto.WriteJpegData:
+				byte[] b = rfb.readJpegData();
+				drawBufferedImage(b);
 				break;
 			case RfbProto.FramebufferUpdate:
 
@@ -1939,5 +1943,13 @@
 		return bos.toByteArray();
 	}
 	
+	void drawBufferedImage(byte[] b) throws IOException{
+		BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(b));
+//		ImageIO.write(bimg, "jpeg", new File("sample.jpeg"));
+		memGraphics.setClip(0,0, rfb.framebufferWidth, rfb.framebufferHeight );
+		memGraphics.drawImage( bimg, 0,0, null);
+		scheduleRepaint(0, 0, rfb.framebufferWidth, rfb.framebufferHeight );
+	}
+	
 	
 }
--- a/src/myVncClient/MyRfbProto.java	Thu Sep 22 05:16:18 2011 +0900
+++ b/src/myVncClient/MyRfbProto.java	Thu Sep 22 05:43:48 2011 +0900
@@ -92,7 +92,7 @@
 	}
 
 	MyRfbProto(String h, int p, MyVncClient v) throws IOException {
-		super(h, p, v);
+		super(h, p);
 		this.viewer = v;
 		cliList = new LinkedList<Socket>();
 		cliListTmp = new LinkedList<Socket>();
@@ -102,6 +102,20 @@
 		// executor = Executors.newCachedThreadPool();
 		// executor = Executors.newSingleThreadExecutor();
 	}
+	
+	MyRfbProto(String h, int p, CuiMyVncClient v) throws IOException {
+		super(h, p);
+		this.viewer = v;
+		cliList = new LinkedList<Socket>();
+		cliListTmp = new LinkedList<Socket>();
+		createBimgFlag = false;
+		proxyFlag = false;
+		//		sendThreads = new LinkedList<Thread>();
+		// executor = Executors.newCachedThreadPool();
+		// executor = Executors.newSingleThreadExecutor();
+	}
+	
+	
 	MyRfbProto(String h, int p) throws IOException {
 		super(h, p);
 		cliList = new LinkedList<Socket>();
@@ -529,9 +543,7 @@
 			byte[] b = getImageBytes(bimg, imageFormat);
 //			int len = b.length;
 			byte[] length = castIntByte(b.length);
-			System.out.println("jpeg length = " + b.length);
-
-			byte c = 0x05;
+//			System.out.println("jpeg length = " + b.length);
 			os.write((byte)WriteJpegData);
 			os.write(length); // length of jpeg data
 			os.write(b); // jpeg data
@@ -540,7 +552,8 @@
 			e.printStackTrace();
 		}
 	}
-	
+
+	// unnecessary method 
 	void readWriteJpegData() throws IOException {
 		byte[] b = readJpegData();
 		viewer.writeScreenData(b, "jpeg");
--- a/src/myVncClient/MyVncClient.java	Thu Sep 22 05:16:18 2011 +0900
+++ b/src/myVncClient/MyVncClient.java	Thu Sep 22 05:43:48 2011 +0900
@@ -1206,7 +1206,7 @@
 	
 	public void writeScreenData(byte[] b, String imageFormat) {
 		try{
-			vc.drawBufferedImage(b, imageFormat);
+			vc.drawBufferedImage(b);
 		}catch(IOException e){
 			e.printStackTrace();
 		}
--- a/src/myVncClient/VncCanvas.java	Thu Sep 22 05:16:18 2011 +0900
+++ b/src/myVncClient/VncCanvas.java	Thu Sep 22 05:43:48 2011 +0900
@@ -415,8 +415,8 @@
 				rfb.readSpeedCheck();
 				break;
 			case MyRfbProto.WriteJpegData:
-				rfb.readWriteJpegData();
-				
+				byte[] buf = rfb.readJpegData();
+				drawBufferedImage(buf);
 				break;
 			case RfbProto.FramebufferUpdate:
 
@@ -1957,13 +1957,12 @@
 		return bimg;
 	}
 	
-	void drawBufferedImage(byte[] b, String imageFormat) throws IOException{
+	void drawBufferedImage(byte[] b) throws IOException{
 		BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(b));
 //		ImageIO.write(bimg, "jpeg", new File("sample.jpeg"));
 		memGraphics.setClip(0,0, rfb.framebufferWidth, rfb.framebufferHeight );
 		memGraphics.drawImage( bimg, 0,0, null);
 		scheduleRepaint(0, 0, rfb.framebufferWidth, rfb.framebufferHeight );
-	}
-	
+	}	
 	
 }