diff options
| author | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-25 18:17:02 +0000 |
|---|---|---|
| committer | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-25 18:17:02 +0000 |
| commit | ecb69a6cb04bb925efe017529e52ce0064227f7a (patch) | |
| tree | a2a80f240b59b00a370536eb06d7a8d96394cea3 /java/ImageProcessing/framework/ImageByteCounter.java | |
| parent | 2e64cf5aa0c0686b211f6566d8e189b37a74eff9 (diff) | |
| download | ATCD-ecb69a6cb04bb925efe017529e52ce0064227f7a.tar.gz | |
New files used to show status of image being uploaded
Diffstat (limited to 'java/ImageProcessing/framework/ImageByteCounter.java')
| -rw-r--r-- | java/ImageProcessing/framework/ImageByteCounter.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/java/ImageProcessing/framework/ImageByteCounter.java b/java/ImageProcessing/framework/ImageByteCounter.java new file mode 100644 index 00000000000..9b238c02b22 --- /dev/null +++ b/java/ImageProcessing/framework/ImageByteCounter.java @@ -0,0 +1,76 @@ +package imaging.framework; + +import java.io.*; +import java.awt.*; +import JACE.OS.*; + +public class ImageByteCounter +{ + public ImageByteCounter (String title, Image image) + { + this.image_ = image; + } + + public int count () + { + indicator_ = new StatusIndicator (""); + int length = 0; + try + { + // GIFOutputStream ostream = new GIFOutputStream (statusIndicator_); + 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; +} + +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; +} |
