blob: 2c18a4643b540435329b1d07805e2dd9c62c9ada (
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
|
package imaging.framework;
import java.awt.*;
import java.io.*;
import JACE.OS.*;
import JACE.Connection.*;
public class GIFHandler extends BlobWriter
{
public GIFHandler (String filename, Image image, int length)
{
super (null, length, 0, filename);
this.image_ = image;
// this.initialize ();
}
private void initialize ()
{
System.out.println ("In initialize ()");
// Get the length -- number of bytes that will be sent
try
{
GIFOutputStream ostream = new GIFOutputStream ();
this.encoder_ = new GifEncoder (this.image_, ostream);
this.encoder_.encode ();
// this.encoder_.Write (ostream);
// this.encoder_ = new GIFEncoder (this.image_);
// this.encoder_.Write (ostream);
// StringBuffer buf = ostream.data ();
this.length_ = ostream.count ();
System.out.println ("initialize: " + this.length_);
}
catch (IOException e)
{
ACE.ERROR ("Error writing to server");
}
}
protected int sendRequest ()
{
if (this.sendHeader () == -1)
{
ACE.ERROR ("GIFHandler::sendHeader failed.");
return -1;
}
else
if (this.sendData () == -1)
{
ACE.ERROR ("GIFHandler::sendData failed.");
return -1;
}
return 0;
}
// Send the data
protected int sendData ()
{
try
{
if (this.length_ > 0)
{
OutputStream ostream = this.peer ().outputStream ();
this.encoder_ = new GifEncoder (this.image_, ostream);
this.encoder_.encode ();
// this.encoder_ = new GIFEncoder (this.image_);
// this.encoder_.Write (ostream);
}
this.bytesWritten_ = this.length_;
}
catch (IOException e)
{
ACE.ERROR ("Error writing to server");
}
return 0;
}
GifEncoder encoder_ = null;
// GIFEncoder encoder_ = null;
Image image_ = null;
}
|