~ubuntu-branches/ubuntu/precise/classpath/precise

« back to all changes in this revision

Viewing changes to gnu/java/awt/image/ImageDecoder.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2006-05-27 16:11:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060527161115-h6e39eposdt5snb6
Tags: 2:0.91-3
* Install header files to /usr/include/classpath.
* debian/control: classpath: Conflict with jamvm < 1.4.3 and
  cacao < 0.96 (Closes: #368172).

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
import java.awt.image.ImageConsumer;
41
41
import java.awt.image.ImageProducer;
42
42
import java.io.ByteArrayInputStream;
 
43
import java.io.DataInput;
 
44
import java.io.EOFException;
43
45
import java.io.FileInputStream;
44
46
import java.io.IOException;
45
47
import java.io.InputStream;
55
57
  int offset;
56
58
  int length;
57
59
  InputStream input;
 
60
  DataInput datainput;
58
61
 
59
62
  static
60
63
  {
79
82
    this.input = is;
80
83
  }
81
84
 
 
85
  public ImageDecoder (DataInput datainput)
 
86
  {
 
87
    this.datainput = datainput;
 
88
  }
 
89
 
82
90
  public ImageDecoder (byte[] imagedata, int imageoffset, int imagelength)
83
91
  {
84
92
    data = imagedata;
119
127
              {
120
128
                if (url != null)
121
129
                  input = url.openStream();
 
130
                else if (datainput != null)
 
131
                  input = new DataInputStreamWrapper(datainput);
122
132
                else
123
133
                  {
124
134
                    if (filename != null)
153
163
  }
154
164
 
155
165
  public abstract void produce (Vector v, InputStream is) throws IOException;
 
166
 
 
167
  private static class DataInputStreamWrapper extends InputStream
 
168
  {
 
169
    private final DataInput datainput;
 
170
 
 
171
    DataInputStreamWrapper(DataInput datainput)
 
172
    {
 
173
      this.datainput = datainput;
 
174
    }
 
175
 
 
176
    public int read() throws IOException
 
177
    {
 
178
      try
 
179
        {
 
180
          return datainput.readByte() & 0xFF;
 
181
        }
 
182
      catch (EOFException eofe)
 
183
        {
 
184
          return -1;
 
185
        }
 
186
    }
 
187
  }
156
188
}