summaryrefslogtreecommitdiff
path: root/applications/jpip/util/opj_viewer/src/ImgdecClient.java
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2012-03-02 10:46:04 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2012-03-02 10:46:04 +0000
commitb158c25dc3c9262aa29fed2ca9e45b2cf0019be2 (patch)
tree47d7859bd6f4d251371248fb42b62655c0fc81b6 /applications/jpip/util/opj_viewer/src/ImgdecClient.java
parentbc8a3c5b6ff9be348337a7400e2937b8c349de04 (diff)
[trunk] Import rev 1103 into trunk.
Diffstat (limited to 'applications/jpip/util/opj_viewer/src/ImgdecClient.java')
-rw-r--r--applications/jpip/util/opj_viewer/src/ImgdecClient.java55
1 files changed, 49 insertions, 6 deletions
diff --git a/applications/jpip/util/opj_viewer/src/ImgdecClient.java b/applications/jpip/util/opj_viewer/src/ImgdecClient.java
index 35c97128..27750de7 100644
--- a/applications/jpip/util/opj_viewer/src/ImgdecClient.java
+++ b/applications/jpip/util/opj_viewer/src/ImgdecClient.java
@@ -49,7 +49,7 @@ public class ImgdecClient{
public static void send_JPIPstream( byte[] jpipstream)
{
try{
- Socket imgdecSocket = new Socket( "localhost", 5000);
+ Socket imgdecSocket = new Socket( "localhost", 50000);
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
@@ -74,7 +74,7 @@ public class ImgdecClient{
public static void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
{
try{
- Socket imgdecSocket = new Socket( "localhost", 5000);
+ Socket imgdecSocket = new Socket( "localhost", 50000);
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
int length = 0;
@@ -114,7 +114,7 @@ public class ImgdecClient{
PnmImage pnmstream = null;
try {
- Socket imgdecSocket = new Socket( "localhost", 5000);
+ Socket imgdecSocket = new Socket( "localhost", 50000);
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
byte []header = new byte[7];
@@ -171,7 +171,7 @@ public class ImgdecClient{
byte []xmldata = null;
try{
- Socket imgdecSocket = new Socket( "localhost", 5000);
+ Socket imgdecSocket = new Socket( "localhost", 50000);
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
byte []header = new byte[5];
@@ -222,7 +222,7 @@ public class ImgdecClient{
String id = null;
try{
- Socket imgdecSocket = new Socket( "localhost", 5000);
+ Socket imgdecSocket = new Socket( "localhost", 50000);
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
byte []header = new byte[4];
@@ -253,6 +253,49 @@ public class ImgdecClient{
return id;
}
+
+ public static java.awt.Dimension query_imagesize( String cid, String tid)
+ {
+ java.awt.Dimension dim = null;
+
+ try{
+ Socket imgdecSocket = new Socket( "localhost", 50000);
+ DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
+ DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
+ byte []header = new byte[3];
+
+ os.writeBytes( "SIZ request\n");
+ if( tid == null)
+ os.writeBytes( "0\n");
+ else
+ os.writeBytes( tid + "\n");
+ if( cid == null)
+ os.writeBytes( "0\n");
+ else
+ os.writeBytes( cid + "\n");
+
+ read_stream( is, header, 3);
+
+ if( header[0] == 83 && header[1] == 73 && header[2] == 90){
+
+ byte []data = new byte[ 3];
+ read_stream( is, data, 3);
+ int w = (data[0]&0xff)<<16 | (data[1]&0xff)<<8 | (data[2]&0xff);
+ read_stream( is, data, 3);
+ int h = (data[0]&0xff)<<16 | (data[1]&0xff)<<8 | (data[2]&0xff);
+ dim = new java.awt.Dimension( w, h);
+ }
+ else
+ System.err.println("Error in query_imagesize("+ cid + ", " + tid + "), wrong to start with " + header);
+ }
+ catch (UnknownHostException e) {
+ System.err.println("Trying to connect to unknown host: " + e);
+ } catch (IOException e) {
+ System.err.println("IOException: " + e);
+ }
+
+ return dim;
+ }
public static void read_stream( DataInputStream is, byte []stream, int length)
{
@@ -278,7 +321,7 @@ public class ImgdecClient{
public static void destroy_cid( String cid)
{
try{
- Socket imgdecSocket = new Socket( "localhost", 5000);
+ Socket imgdecSocket = new Socket( "localhost", 50000);
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());