blob: c907c9f1c92a3174c4c1ffaee0f724d34592ea59 (
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
|
package imaging.framework;
import java.io.*;
import java.awt.*;
import java.applet.*;
import java.net.*;
import JACE.OS.*;
public class ImageByteCounter
{
public ImageByteCounter (String title, Image image, Applet parent)
{
this.image_ = image;
this.parent_ = parent;
Image im = null;
try
{
im = this.parent_.getImage (new URL (this.parent_.getCodeBase () +
"../ImageProcessing/framework/" +
"10.gif"));
}
catch (MalformedURLException e)
{
ACE.ERROR (e);
}
indicator_ = new StatusIndicator ("", im);
}
public int count ()
{
int length = 0;
try
{
GIFOutputStream ostream = new GIFOutputStream (indicator_);
// GIFOutputStream ostream = new GIFOutputStream (null);
GifEncoder encoder = new GifEncoder (this.image_, ostream);
encoder.encode ();
length = ostream.count ();
System.out.println ("send: " + length);
}
catch (IOException e)
{
ACE.ERROR ("Exception generating gif");
}
indicator_.dispose ();
return length;
}
Image image_ = null;
StatusIndicator indicator_ = null;
boolean done_ = false;
Applet parent_;
}
class GIFOutputStream extends OutputStream
{
public GIFOutputStream (StatusIndicator indicator)
{
super ();
this.indicator_ = indicator;
}
public synchronized void write (int b) throws IOException
{
bytesWritten_++;
if (this.indicator_ != null)
this.indicator_.update (bytesWritten_);
}
public synchronized void write (byte buf[]) throws IOException
{
bytesWritten_ += buf.length;
if (this.indicator_ != null)
this.indicator_.update (bytesWritten_);
}
public synchronized void write (byte buf[], int offset, int length) throws IOException
{
bytesWritten_ += length;
if (this.indicator_ != null)
this.indicator_.update (bytesWritten_);
}
public int count ()
{
return this.bytesWritten_;
}
private int bytesWritten_ = 0;
private StatusIndicator indicator_ = null;
}
|