diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2005-11-27 21:00:34 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2005-11-27 21:00:34 +0000 |
commit | 15ee25b923180850794e71cc44c9859e65eea8a2 (patch) | |
tree | 5115c5c9f0dacfbeb537decc2bcb25ef362e039f /gnu/java/awt/image | |
parent | 6f383d9c78e81a535c35c5e69df90cd5a4d1dbfa (diff) | |
download | classpath-15ee25b923180850794e71cc44c9859e65eea8a2.tar.gz |
2005-11-27 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics from the release of Classpath 0.19
to 2005/11/27.
Diffstat (limited to 'gnu/java/awt/image')
-rw-r--r-- | gnu/java/awt/image/ImageDecoder.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gnu/java/awt/image/ImageDecoder.java b/gnu/java/awt/image/ImageDecoder.java index 141c85417..8e8eecb25 100644 --- a/gnu/java/awt/image/ImageDecoder.java +++ b/gnu/java/awt/image/ImageDecoder.java @@ -40,6 +40,8 @@ package gnu.java.awt.image; import java.awt.image.ImageConsumer; import java.awt.image.ImageProducer; import java.io.ByteArrayInputStream; +import java.io.DataInput; +import java.io.EOFException; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -55,6 +57,7 @@ public abstract class ImageDecoder implements ImageProducer int offset; int length; InputStream input; + DataInput datainput; static { @@ -79,6 +82,11 @@ public abstract class ImageDecoder implements ImageProducer this.input = is; } + public ImageDecoder (DataInput datainput) + { + this.datainput = datainput; + } + public ImageDecoder (byte[] imagedata, int imageoffset, int imagelength) { data = imagedata; @@ -119,6 +127,8 @@ public abstract class ImageDecoder implements ImageProducer { if (url != null) input = url.openStream(); + else if (datainput != null) + input = new DataInputStreamWrapper(datainput); else { if (filename != null) @@ -153,4 +163,26 @@ public abstract class ImageDecoder implements ImageProducer } public abstract void produce (Vector v, InputStream is) throws IOException; + + private static class DataInputStreamWrapper extends InputStream + { + private final DataInput datainput; + + DataInputStreamWrapper(DataInput datainput) + { + this.datainput = datainput; + } + + public int read() throws IOException + { + try + { + return datainput.readByte() & 0xFF; + } + catch (EOFException eofe) + { + return -1; + } + } + } } |