Mercurial > hg > Members > nobuyasu > tightVNCClient
comparison src/myVncClient/VncCanvas.java @ 91:d89e03d99b7f
modify readJpegData()
author | e085711 |
---|---|
date | Thu, 22 Sep 2011 05:14:49 +0900 |
parents | 3ea33e683522 |
children | 71bfbb5241bf |
comparison
equal
deleted
inserted
replaced
90:7a1e934144e6 | 91:d89e03d99b7f |
---|---|
28 import java.io.*; | 28 import java.io.*; |
29 import java.lang.*; | 29 import java.lang.*; |
30 import java.util.zip.*; | 30 import java.util.zip.*; |
31 import java.net.*; | 31 import java.net.*; |
32 | 32 |
33 import javax.imageio.ImageIO; | |
34 | |
33 import test.TestComet; | 35 import test.TestComet; |
34 | 36 |
35 | 37 |
36 // | 38 // |
37 // VncCanvas is a subclass of Canvas which draws a VNC desktop on it. | 39 // VncCanvas is a subclass of Canvas which draws a VNC desktop on it. |
384 // main dispatch loop | 386 // main dispatch loop |
385 // | 387 // |
386 | 388 |
387 long count = 0; | 389 long count = 0; |
388 | 390 |
389 new Thread(){public void run() {TestComet.main(null);}}.start(); | 391 // new Thread(){public void run() {TestComet.main(null);}}.start(); |
390 | 392 |
391 | 393 |
392 while (true) { | 394 while (true) { |
393 // System.out.println("\ncount=" + count); | 395 // System.out.println("\ncount=" + count); |
394 count++; | 396 count++; |
407 // Read message type from the server. | 409 // Read message type from the server. |
408 int msgType = rfb.readServerMessageType(); | 410 int msgType = rfb.readServerMessageType(); |
409 | 411 |
410 // Process the message depending on its type. | 412 // Process the message depending on its type. |
411 switch (msgType) { | 413 switch (msgType) { |
414 case MyRfbProto.SpeedCheckMillis: | |
415 rfb.readSpeedCheck(); | |
416 break; | |
417 case MyRfbProto.WriteJpegData: | |
418 rfb.readWriteJpegData(); | |
419 | |
420 break; | |
412 case RfbProto.FramebufferUpdate: | 421 case RfbProto.FramebufferUpdate: |
413 | 422 |
414 if (statNumUpdates == viewer.debugStatsExcludeUpdates | 423 if (statNumUpdates == viewer.debugStatsExcludeUpdates |
415 && !statsRestarted) { | 424 && !statsRestarted) { |
416 resetStats(); | 425 resetStats(); |
1935 BufferedImage bimg = rfb.createBimg(); | 1944 BufferedImage bimg = rfb.createBimg(); |
1936 memGraphics.setClip(0,0, rfb.framebufferWidth, rfb.framebufferHeight ); | 1945 memGraphics.setClip(0,0, rfb.framebufferWidth, rfb.framebufferHeight ); |
1937 memGraphics.drawImage( bimg, 0,0, null); | 1946 memGraphics.drawImage( bimg, 0,0, null); |
1938 | 1947 |
1939 } | 1948 } |
1949 | |
1940 | 1950 |
1941 BufferedImage createBufferedImage(Image img){ | 1951 BufferedImage createBufferedImage(Image img){ |
1942 BufferedImage bimg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB ); | 1952 BufferedImage bimg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB ); |
1943 | 1953 |
1944 Graphics g = bimg.getGraphics(); | 1954 Graphics g = bimg.getGraphics(); |
1945 g.drawImage(img, 0, 0, null); | 1955 g.drawImage(img, 0, 0, null); |
1946 g.dispose(); | 1956 g.dispose(); |
1947 return bimg; | 1957 return bimg; |
1948 } | 1958 } |
1949 | 1959 |
1960 void drawBufferedImage(byte[] b, String imageFormat) throws IOException{ | |
1961 BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(b)); | |
1962 // ImageIO.write(bimg, "jpeg", new File("sample.jpeg")); | |
1963 memGraphics.setClip(0,0, rfb.framebufferWidth, rfb.framebufferHeight ); | |
1964 memGraphics.drawImage( bimg, 0,0, null); | |
1965 scheduleRepaint(0, 0, rfb.framebufferWidth, rfb.framebufferHeight ); | |
1966 } | |
1950 | 1967 |
1951 | 1968 |
1952 } | 1969 } |