/[classpath]/classpath/javax/imageio/ImageIO.java
ViewVC logotype

Diff of /classpath/javax/imageio/ImageIO.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by fitzsim, Sun Oct 2 05:29:55 2005 UTC revision 1.9 by mark, Sun Oct 2 11:27:53 2005 UTC
# Line 52  import java.util.Collections; Line 52  import java.util.Collections;
52  import java.util.Iterator;  import java.util.Iterator;
53    
54  import javax.imageio.spi.IIORegistry;  import javax.imageio.spi.IIORegistry;
55    import javax.imageio.spi.ImageInputStreamSpi;
56    import javax.imageio.spi.ImageOutputStreamSpi;
57  import javax.imageio.spi.ImageReaderSpi;  import javax.imageio.spi.ImageReaderSpi;
58    import javax.imageio.spi.ImageTranscoderSpi;
59  import javax.imageio.spi.ImageWriterSpi;  import javax.imageio.spi.ImageWriterSpi;
60  import javax.imageio.spi.ServiceRegistry;  import javax.imageio.spi.ServiceRegistry;
61  import javax.imageio.stream.ImageInputStream;  import javax.imageio.stream.ImageInputStream;
# Line 138  public final class ImageIO Line 141  public final class ImageIO
141          {          {
142            ImageReaderSpi spi = (ImageReaderSpi) provider;            ImageReaderSpi spi = (ImageReaderSpi) provider;
143    
144            if (spi.canDecodeInput(object))            try
145              return true;              {
146                  if (spi.canDecodeInput(object))
147                    return true;
148                }
149              catch (IOException ioe)
150                {
151                  // Apparently it couldn't...
152                }
153          }          }
154    
155        return false;        return false;
# Line 257  public final class ImageIO Line 267  public final class ImageIO
267      private ImageReader reader;      private ImageReader reader;
268      private ImageWriter writer;      private ImageWriter writer;
269    
270      public WriterObjectFilter(ImageReader reader,      public TranscoderFilter(ImageReader reader,
271                                ImageWriter writer)                              ImageWriter writer)
272      {      {
273        this.reader = reader;        this.reader = reader;
274        this.writer = writer;        this.writer = writer;
# Line 447  public final class ImageIO Line 457  public final class ImageIO
457    {    {
458      if (fileSuffix == null)      if (fileSuffix == null)
459        throw new IllegalArgumentException("formatName may not be null");        throw new IllegalArgumentException("formatName may not be null");
460          
461        // XXX We use ReaderObjectFiler, should there be a ReaderSuffixFilter?
462      return getReadersByFilter(ImageReaderSpi.class,      return getReadersByFilter(ImageReaderSpi.class,
463                                new ReaderSuffixFilter(fileSuffix),                                new ReaderObjectFilter(fileSuffix),
464                                fileSuffix);                                fileSuffix);
465    }    }
466    
# Line 959  public final class ImageIO Line 970  public final class ImageIO
970        {        {
971          ImageInputStreamSpi spi = (ImageInputStreamSpi) spis.next();          ImageInputStreamSpi spi = (ImageInputStreamSpi) spis.next();
972    
973          if (input instanceof spi.getInputClass())          if (spi.getInputClass().isAssignableFrom(input.getClass()))
974            {            {
975              foundSpi = spi;              foundSpi = spi;
976              break;              break;
977            }            }
978        }        }
979    
980      if (foundSpi == false)      if (foundSpi == null)
981        return null;        return null;
982      else      else
983        return foundSpi.createInputStreamInstance (input,        return foundSpi.createInputStreamInstance (input,
# Line 1007  public final class ImageIO Line 1018  public final class ImageIO
1018        {        {
1019          ImageOutputStreamSpi spi = (ImageOutputStreamSpi) spis.next();          ImageOutputStreamSpi spi = (ImageOutputStreamSpi) spis.next();
1020    
1021          if (input instanceof spi.getOutputClass())          if (spi.getOutputClass().isAssignableFrom(output.getClass()))
1022            {            {
1023              foundSpi = spi;              foundSpi = spi;
1024              break;              break;
1025            }            }
1026        }        }
1027    
1028      if (foundSpi == false)      if (foundSpi == null)
1029        return null;        return null;
1030      else      else
1031        return foundSpi.createOutputStreamInstance (input,        return foundSpi.createOutputStreamInstance (output,
1032                                                    getUseCache(),                                                    getUseCache(),
1033                                                    getCacheDirectory());                                                    getCacheDirectory());
1034    }    }
# Line 1043  public final class ImageIO Line 1054  public final class ImageIO
1054    
1055      String[] readerSpiNames = spi.getImageReaderSpiNames();      String[] readerSpiNames = spi.getImageReaderSpiNames();
1056    
1057      return readerSpiNames == null ? null : readerSpiNames[0];      // XXX - Check this - How to map String to actual class instance?
1058        return null;
1059        // return readerSpiNames == null ? null : readerSpiNames[0];
1060    }    }
1061    
1062    /**    /**
# Line 1060  public final class ImageIO Line 1073  public final class ImageIO
1073        throw new IllegalArgumentException ("null argument");        throw new IllegalArgumentException ("null argument");
1074    
1075      return getRegistry().getServiceProviders (ImageReaderSpi.class,      return getRegistry().getServiceProviders (ImageReaderSpi.class,
1076                                                new ReaderObjectFilter(object),                                                new ReaderObjectFilter(input),
1077                                                true);                                                true);
1078    }    }
1079    
# Line 1070  public final class ImageIO Line 1083  public final class ImageIO
1083     * given format.     * given format.
1084     *     *
1085     * @param type the output image's colour and sample models     * @param type the output image's colour and sample models
1086     * @param formatName the output image format     * @param format the output image format
1087     *     *
1088     * @return an iterator over a collection of image writers     * @return an iterator over a collection of image writers
1089     */     */
1090    public static Iterator getImageWriters (ImageTypeSpecifier type,    public static Iterator getImageWriters (ImageTypeSpecifier type,
1091                                            String formatName)                                            String format)
1092    {    {
1093      if (type == null || formatName == null)      if (type == null || format == null)
1094        throw new IllegalArgumentException ("null argument");        throw new IllegalArgumentException ("null argument");
1095    
1096      return getRegistry().getServiceProviders (ImageWriterSpi.class,      return getRegistry().getServiceProviders(ImageWriterSpi.class,
1097                                                new WriterObjectFilter(object),                                               new WriterObjectFilter(type,
1098                                                true);                                                                      format),
1099                                                 true);
1100    }    }
1101    
1102    /**    /**
# Line 1109  public final class ImageIO Line 1123  public final class ImageIO
1123    
1124      String[] writerSpiNames = spi.getImageWriterSpiNames();      String[] writerSpiNames = spi.getImageWriterSpiNames();
1125    
1126      return writerSpiNames == null ? null : writerSpiNames[0];      // XXX - Check this - How to map String to actual class instance?
1127        return null;
1128        // return writerSpiNames == null ? null : writerSpiNames[0];
1129    }    }
1130    
1131    /**    /**
# Line 1132  public final class ImageIO Line 1148  public final class ImageIO
1148        throw new IllegalArgumentException ("null argument");        throw new IllegalArgumentException ("null argument");
1149    
1150      return getRegistry().getServiceProviders (ImageTranscoderSpi.class,      return getRegistry().getServiceProviders (ImageTranscoderSpi.class,
1151                                                new ImageTranscoderSpi (reader,                                                new TranscoderFilter (reader,
1152                                                                        writer),                                                                      writer),
1153                                                true);                                                true);
1154    }    }
1155  }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26