blob: bdc4b5208fe83271091d4a29a6c35f4f2d106b44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
package imaging.framework;
import java.awt.*;
import java.net.*;
import java.io.*;
import JACE.OS.*;
import JACE.Connection.*;
public class ImageSender
{
public void open (Image image, String url)
{
this.image_ = image;
this.hostname_ = url;
if (this.hostname_.startsWith ("http://"))
this.hostname_ = this.hostname_.substring (7);
int index = -1;
if ((index = this.hostname_.indexOf (":")) != -1)
{
String temp = this.hostname_.substring (index + 1);
int i = -1;
if ((i = temp.indexOf ("/")) != -1)
{
this.port_ = (new Integer (temp.substring (0, i))).intValue ();
this.filename_ = temp.substring (i);
}
this.hostname_ = this.hostname_.substring (0, index);
}
else
{
int i = -1;
if ((i = this.hostname_.indexOf ("/")) != -1)
{
this.filename_ = hostname_.substring (i);
}
this.hostname_ = this.hostname_.substring (0, i);
this.port_ = 80;
}
}
public int send ()
{
int length = 0;
try
{
GIFOutputStream ostream = new GIFOutputStream ();
GifEncoder encoder = new GifEncoder (this.image_, ostream);
encoder.encode ();
// this.encoder_.Write (ostream);
// this.encoder_ = new GIFEncoder (this.image_);
// this.encoder_.Write (ostream);
// StringBuffer buf = ostream.data ();
length = ostream.count ();
System.out.println ("send: " + length);
}
catch (IOException e)
{
ACE.ERROR ("Exception generating gif");
}
GIFHandler gifHandler = new GIFHandler (this.filename_, this.image_, length);
try
{
// Connect to the server and send the image
this.connector_.open (this.hostname_, this.port_);
this.connector_.connect (gifHandler);
}
catch (UnknownHostException e)
{
ACE.ERROR (e);
}
catch (InstantiationException e)
{
ACE.ERROR (e);
}
catch (IllegalAccessException e)
{
ACE.ERROR (e);
}
catch (IOException e)
{
ACE.ERROR (e);
}
if (gifHandler.returnCode () != -1)
return gifHandler.bytesWritten ();
else
return -1;
}
private Image image_ = null;
String filename_;
String hostname_;
int port_;
Connector connector_ = new Connector ();
}
|