classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Complete javax.imageio


From: Mark Wielaard
Subject: Re: [cp-patches] Complete javax.imageio
Date: Sun, 02 Oct 2005 13:25:23 +0200

Hi Tom,

On Sun, 2005-10-02 at 01:30 -0400, Thomas Fitzsimmons wrote:
> This patch brings the javax.imageio package up to 1.5-level API
> coverage.  I also completed the documentation for all but two classes,
> ImageReadParam and ImageWriteParam.

Woot! Code plus documentation.

One little nitpick. I cannot get it to compile with any known compiler.
So I created this patch to at least make CVS compile again. It does have
some nasties marked with XXX where I couldn't immediately figure out
what the right approach was. Could you check?

2005-10-02  Mark Wielaard  <address@hidden>

    Workarounds for bug #24166
    * javax/imageio/ImageIO.java (filter): Catch IOException in
    canDecodeInput().
    (TranscoderFilter.WriterObjectFilter): Renamed to TranscoderFilter.
    (getImageReadersBySuffix): Use ReaderObjectFilter, not the
    nonexisting ReaderSuffixFilter.
    (createImageInputStream): Test with Class.isAssignableFrom() and for
    foundSpi == null.
    (createImageOutputStream): Likewise and use output, not input.
    (getImageReader): Always return null for now.
    (getImageReaders): Use input, not object.
    (getImageWriters): Rename formatName to format and create a
    WriterObjectFilter with type and format not just object.
    (getImageWriter): Always return null for now.
    (getImageTranscoders): Create TranscoderFilter not
    ImageTranscoderSpi instance.

Thanks,

Mark
Index: javax/imageio/ImageIO.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageIO.java,v
retrieving revision 1.8
diff -u -r1.8 ImageIO.java
--- javax/imageio/ImageIO.java  2 Oct 2005 05:29:55 -0000       1.8
+++ javax/imageio/ImageIO.java  2 Oct 2005 11:24:17 -0000
@@ -52,7 +52,10 @@
 import java.util.Iterator;
 
 import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageInputStreamSpi;
+import javax.imageio.spi.ImageOutputStreamSpi;
 import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ImageTranscoderSpi;
 import javax.imageio.spi.ImageWriterSpi;
 import javax.imageio.spi.ServiceRegistry;
 import javax.imageio.stream.ImageInputStream;
@@ -138,8 +141,15 @@
         {
           ImageReaderSpi spi = (ImageReaderSpi) provider;
 
-         if (spi.canDecodeInput(object))
-           return true;
+         try
+           {
+             if (spi.canDecodeInput(object))
+               return true;
+           }
+         catch (IOException ioe)
+           {
+             // Apparently it couldn't...
+           }
         }
 
       return false;
@@ -257,8 +267,8 @@
     private ImageReader reader;
     private ImageWriter writer;
 
-    public WriterObjectFilter(ImageReader reader,
-                             ImageWriter writer)
+    public TranscoderFilter(ImageReader reader,
+                           ImageWriter writer)
     {
       this.reader = reader;
       this.writer = writer;
@@ -447,9 +457,10 @@
   {
     if (fileSuffix == null)
       throw new IllegalArgumentException("formatName may not be null");
-    
+   
+    // XXX We use ReaderObjectFiler, should there be a ReaderSuffixFilter?
     return getReadersByFilter(ImageReaderSpi.class,
-                              new ReaderSuffixFilter(fileSuffix),
+                              new ReaderObjectFilter(fileSuffix),
                               fileSuffix);
   }
 
@@ -959,14 +970,14 @@
       {
        ImageInputStreamSpi spi = (ImageInputStreamSpi) spis.next();
 
-       if (input instanceof spi.getInputClass())
+       if (spi.getInputClass().isAssignableFrom(input.getClass()))
          {
            foundSpi = spi;
            break;
          }
       }
 
-    if (foundSpi == false)
+    if (foundSpi == null)
       return null;
     else
       return foundSpi.createInputStreamInstance (input,
@@ -1007,17 +1018,17 @@
       {
        ImageOutputStreamSpi spi = (ImageOutputStreamSpi) spis.next();
 
-       if (input instanceof spi.getOutputClass())
+       if (spi.getOutputClass().isAssignableFrom(output.getClass()))
          {
            foundSpi = spi;
            break;
          }
       }
 
-    if (foundSpi == false)
+    if (foundSpi == null)
       return null;
     else
-      return foundSpi.createOutputStreamInstance (input,
+      return foundSpi.createOutputStreamInstance (output,
                                                  getUseCache(),
                                                  getCacheDirectory());
   }
@@ -1043,7 +1054,9 @@
 
     String[] readerSpiNames = spi.getImageReaderSpiNames();
 
-    return readerSpiNames == null ? null : readerSpiNames[0];
+    // XXX - Check this - How to map String to actual class instance?
+    return null;
+    // return readerSpiNames == null ? null : readerSpiNames[0];
   }
 
   /**
@@ -1060,7 +1073,7 @@
       throw new IllegalArgumentException ("null argument");
 
     return getRegistry().getServiceProviders (ImageReaderSpi.class,
-                                             new ReaderObjectFilter(object),
+                                             new ReaderObjectFilter(input),
                                              true);
   }
 
@@ -1070,19 +1083,20 @@
    * given format.
    *
    * @param type the output image's colour and sample models
-   * @param formatName the output image format
+   * @param format the output image format
    *
    * @return an iterator over a collection of image writers
    */
   public static Iterator getImageWriters (ImageTypeSpecifier type,
-                                         String formatName)
+                                         String format)
   {
-    if (type == null || formatName == null)
+    if (type == null || format == null)
       throw new IllegalArgumentException ("null argument");
 
-    return getRegistry().getServiceProviders (ImageWriterSpi.class,
-                                             new WriterObjectFilter(object),
-                                             true);
+    return getRegistry().getServiceProviders(ImageWriterSpi.class,
+                                            new WriterObjectFilter(type,
+                                                                   format),
+                                            true);
   }
 
   /**
@@ -1109,7 +1123,9 @@
 
     String[] writerSpiNames = spi.getImageWriterSpiNames();
 
-    return writerSpiNames == null ? null : writerSpiNames[0];
+    // XXX - Check this - How to map String to actual class instance?
+    return null;
+    // return writerSpiNames == null ? null : writerSpiNames[0];
   }
 
   /**
@@ -1132,8 +1148,8 @@
       throw new IllegalArgumentException ("null argument");
 
     return getRegistry().getServiceProviders (ImageTranscoderSpi.class,
-                                             new ImageTranscoderSpi (reader,
-                                                                     writer),
+                                             new TranscoderFilter (reader,
+                                                                   writer),
                                              true);
   }
 }

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]