[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: imageio improvements

Kaffe CVS cvs-commits at kaffe.org
Tue Oct 5 15:15:37 PDT 2004


PatchSet 5252 
Date: 2004/10/05 22:11:16
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: imageio improvements

2004-10-05  Dalibor Topic  <robilad at kaffe.org>

        * libraries/javalib/javax/imageio/spi/ImageReaderSpi.java,
        libraries/javalib/javax/imageio/spi/ImageWriterSpi.java:
        New files taken from GNU Classpath.

        * libraries/javalib/Makefile.am,
        libraries/javalib/Makefile.in,
        libraries/javalib/all.files:
        Regenerated.

        * libraries/javalib/javax/imageio/IIOParam.java,
        libraries/javalib/javax/imageio/ImageIO.java,
        libraries/javalib/javax/imageio/ImageReadParam.java,
        libraries/javalib/javax/imageio/ImageReader.java,
        libraries/javalib/javax/imageio/ImageWriter.java:
        Resynced with GNU Classpath.

        2004-10-05  Michael Koch  <konqueror at gmx.de>

        * javax/imageio/ImageIO.java:
        Added much new methods.

        2004-10-05  Michael Koch  <konqueror at gmx.de>

        * javax/imageio/ImageReader.java,
        javax/imageio/ImageWriter.java,
        javax/imageio/spi/ImageWriterSpi.java:
        Add SOME new methods.

        2004-10-05  Michael Koch  <konqueror at gmx.de>

        * javax/imageio/IIOParam.java,
        javax/imageio/ImageReadParam.java,
        javax/imageio/ImageReader.java,
        javax/imageio/ImageWriter.java:
        Mostly implemented.
        * javax/imageio/spi/ImageReaderSpi.java,
        javax/imageio/spi/ImageWriterSpi.java:
        New files.

Members: 
	ChangeLog:1.2806->1.2807 
	libraries/javalib/Makefile.am:1.244->1.245 
	libraries/javalib/Makefile.in:1.324->1.325 
	libraries/javalib/all.files:1.32->1.33 
	libraries/javalib/javax/imageio/IIOParam.java:1.1->1.2 
	libraries/javalib/javax/imageio/ImageIO.java:1.1->1.2 
	libraries/javalib/javax/imageio/ImageReadParam.java:1.1->1.2 
	libraries/javalib/javax/imageio/ImageReader.java:1.1->1.2 
	libraries/javalib/javax/imageio/ImageWriter.java:1.1->1.2 
	libraries/javalib/javax/imageio/spi/ImageReaderSpi.java:INITIAL->1.1 
	libraries/javalib/javax/imageio/spi/ImageWriterSpi.java:INITIAL->1.1 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2806 kaffe/ChangeLog:1.2807
--- kaffe/ChangeLog:1.2806	Tue Oct  5 01:25:53 2004
+++ kaffe/ChangeLog	Tue Oct  5 22:11:16 2004
@@ -1,3 +1,44 @@
+2004-10-05  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/javalib/javax/imageio/spi/ImageReaderSpi.java,
+	libraries/javalib/javax/imageio/spi/ImageWriterSpi.java:
+	New files taken from GNU Classpath.
+
+	* libraries/javalib/Makefile.am,
+	libraries/javalib/Makefile.in,
+	libraries/javalib/all.files:
+	Regenerated.
+
+	* libraries/javalib/javax/imageio/IIOParam.java,
+	libraries/javalib/javax/imageio/ImageIO.java,
+	libraries/javalib/javax/imageio/ImageReadParam.java,
+	libraries/javalib/javax/imageio/ImageReader.java,
+	libraries/javalib/javax/imageio/ImageWriter.java:
+	Resynced with GNU Classpath.
+
+	2004-10-05  Michael Koch  <konqueror at gmx.de>
+
+        * javax/imageio/ImageIO.java:
+        Added much new methods.
+
+	2004-10-05  Michael Koch  <konqueror at gmx.de>
+
+        * javax/imageio/ImageReader.java,
+        javax/imageio/ImageWriter.java,
+        javax/imageio/spi/ImageWriterSpi.java:
+        Add SOME new methods.
+
+	2004-10-05  Michael Koch  <konqueror at gmx.de>
+
+        * javax/imageio/IIOParam.java,
+        javax/imageio/ImageReadParam.java,
+        javax/imageio/ImageReader.java,
+        javax/imageio/ImageWriter.java:
+        Mostly implemented.
+        * javax/imageio/spi/ImageReaderSpi.java,
+        javax/imageio/spi/ImageWriterSpi.java:
+        New files.
+
 2004-10-05  Djordje Nikolic  <dmn at ict-tower.com>
 
 	* kaffe/kaffeh/mem.c
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.244 kaffe/libraries/javalib/Makefile.am:1.245
--- kaffe/libraries/javalib/Makefile.am:1.244	Mon Oct  4 19:33:52 2004
+++ kaffe/libraries/javalib/Makefile.am	Tue Oct  5 22:11:18 2004
@@ -2636,8 +2636,10 @@
 	javax/imageio/spi/IIOServiceProvider.java \
 	javax/imageio/spi/ImageInputStreamSpi.java \
 	javax/imageio/spi/ImageOutputStreamSpi.java \
+	javax/imageio/spi/ImageReaderSpi.java \
 	javax/imageio/spi/ImageReaderWriterSpi.java \
 	javax/imageio/spi/ImageTranscoderSpi.java \
+	javax/imageio/spi/ImageWriterSpi.java \
 	javax/imageio/spi/RegisterableService.java \
 	javax/imageio/spi/ServiceRegistry.java
 javax_imageio_stream_SRCS = \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.324 kaffe/libraries/javalib/Makefile.in:1.325
--- kaffe/libraries/javalib/Makefile.in:1.324	Mon Oct  4 19:33:53 2004
+++ kaffe/libraries/javalib/Makefile.in	Tue Oct  5 22:11:19 2004
@@ -3137,8 +3137,10 @@
 	javax/imageio/spi/IIOServiceProvider.java \
 	javax/imageio/spi/ImageInputStreamSpi.java \
 	javax/imageio/spi/ImageOutputStreamSpi.java \
+	javax/imageio/spi/ImageReaderSpi.java \
 	javax/imageio/spi/ImageReaderWriterSpi.java \
 	javax/imageio/spi/ImageTranscoderSpi.java \
+	javax/imageio/spi/ImageWriterSpi.java \
 	javax/imageio/spi/RegisterableService.java \
 	javax/imageio/spi/ServiceRegistry.java
 
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.32 kaffe/libraries/javalib/all.files:1.33
--- kaffe/libraries/javalib/all.files:1.32	Mon Oct  4 19:33:55 2004
+++ kaffe/libraries/javalib/all.files	Tue Oct  5 22:11:20 2004
@@ -2158,8 +2158,10 @@
 javax/imageio/spi/IIOServiceProvider.java
 javax/imageio/spi/ImageInputStreamSpi.java
 javax/imageio/spi/ImageOutputStreamSpi.java
+javax/imageio/spi/ImageReaderSpi.java
 javax/imageio/spi/ImageReaderWriterSpi.java
 javax/imageio/spi/ImageTranscoderSpi.java
+javax/imageio/spi/ImageWriterSpi.java
 javax/imageio/spi/RegisterableService.java
 javax/imageio/spi/ServiceRegistry.java
 javax/imageio/stream/IIOByteBuffer.java
Index: kaffe/libraries/javalib/javax/imageio/IIOParam.java
diff -u kaffe/libraries/javalib/javax/imageio/IIOParam.java:1.1 kaffe/libraries/javalib/javax/imageio/IIOParam.java:1.2
--- kaffe/libraries/javalib/javax/imageio/IIOParam.java:1.1	Mon Oct  4 15:36:10 2004
+++ kaffe/libraries/javalib/javax/imageio/IIOParam.java	Tue Oct  5 22:11:20 2004
@@ -38,15 +38,120 @@
 
 package javax.imageio;
 
+import java.awt.Point;
+import java.awt.Rectangle;
+
 /**
  * @author Michael Koch (konqueror at gmx.de)
  */
 public abstract class IIOParam
 {
+  protected IIOParamController controller;
+  protected IIOParamController defaultController;
+  protected Point destinationOffset = new Point(0, 0);
+  protected ImageTypeSpecifier destinationType;
+  protected int[] sourceBands;
+  protected Rectangle sourceRegion;
+  protected int sourceXSubsampling;
+  protected int sourceYSubsampling;
+  protected int subsamplingXOffset;
+  protected int subsamplingYOffset;
+
   /**
    * Initializes an <code>IIOParam</code> object.
    */
   protected IIOParam()
   {
+    // Do nothing here.
+  }
+
+  public boolean activateController()
+  {
+    if (controller == null)
+      return false;
+    
+    return controller.activate(this);
+  }
+  
+  public IIOParamController getController()
+  {
+    return controller;
+  }
+
+  public IIOParamController getDefaultController()
+  {
+    return defaultController;
+  }
+
+  public Point getDestinationOffset()
+  {
+    return destinationOffset;
+  }
+
+  public ImageTypeSpecifier getDestinationType()
+  {
+    return destinationType;
+  }
+
+  public int[] getSourceBands()
+  {
+    return sourceBands;
+  }
+
+  public Rectangle getSourceRegion()
+  {
+    return sourceRegion;
+  }
+
+  public int getSourceXSubsampling()
+  {
+    return sourceXSubsampling;
+  }
+  
+  public int getSourceYSubsampling()
+  {
+    return sourceYSubsampling;
+  }
+
+  public int getSubsamplingXOffset()
+  {
+    return subsamplingXOffset;
+  }
+  
+  public int getSubsamplingYOffset()
+  {
+    return subsamplingYOffset;
+  }
+
+  public boolean hasController()
+  {
+    return getController() != null;
+  }
+
+  public void setController(IIOParamController controller)
+  {
+    this.controller = controller;
+  }
+
+  public void setDestinationOffset(Point destinationOffset)
+  {
+    if (destinationOffset == null)
+      throw new IllegalArgumentException("destinationOffset is null");
+
+    this.destinationOffset = destinationOffset;
+  }
+
+  public void setSourceRegion(Rectangle sourceRegion)
+  {
+    if (sourceRegion != null
+	&& (sourceRegion.x < 0
+	    || sourceRegion.y < 0
+	    || sourceRegion.width <= 0
+	    || sourceRegion.height <= 0))
+      throw new IllegalArgumentException("illegal source region");
+    
+    // FIXME: Throw IllegalStateException.
+
+    this.sourceRegion = sourceRegion;
   }
 }
Index: kaffe/libraries/javalib/javax/imageio/ImageIO.java
diff -u kaffe/libraries/javalib/javax/imageio/ImageIO.java:1.1 kaffe/libraries/javalib/javax/imageio/ImageIO.java:1.2
--- kaffe/libraries/javalib/javax/imageio/ImageIO.java:1.1	Mon Oct  4 15:36:10 2004
+++ kaffe/libraries/javalib/javax/imageio/ImageIO.java	Tue Oct  5 22:11:20 2004
@@ -38,10 +38,433 @@
 
 package javax.imageio;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
 import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.spi.ServiceRegistry;
 
 public final class ImageIO
 {
+  private static final class ReaderFormatFilter implements ServiceRegistry.Filter
+  {
+    private String formatName;
+
+    public ReaderFormatFilter(String formatName)
+    {
+      this.formatName = formatName;
+    }
+
+    public boolean filter (Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageWriterSpi spi = (ImageWriterSpi) provider;
+          String[] formatNames = spi.getFormatNames();
+
+          for (int i = formatNames.length - 1; i >= 0; --i)
+            if (formatName.equals(formatNames[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+
+  private static final class ReaderMIMETypeFilter implements ServiceRegistry.Filter
+  {
+    private String MIMEType;
+
+    public ReaderMIMETypeFilter(String MIMEType)
+    {
+      this.MIMEType = MIMEType;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageReaderSpi spi = (ImageReaderSpi) provider;
+          String[] mimetypes = spi.getMIMETypes();
+
+          for (int i = mimetypes.length - 1; i >= 0; --i)
+            if (MIMEType.equals(mimetypes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+  
+  private static final class ReaderSuffixFilter implements ServiceRegistry.Filter
+  {
+    private String fileSuffix;
+
+    public ReaderSuffixFilter(String fileSuffix)
+    {
+      this.fileSuffix = fileSuffix;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageReaderSpi spi = (ImageReaderSpi) provider;
+          String[] suffixes = spi.getFileSuffixes();
+
+          for (int i = suffixes.length - 1; i >= 0; --i)
+            if (fileSuffix.equals(suffixes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+  
+  private static final class WriterFormatFilter implements ServiceRegistry.Filter
+  {
+    private String formatName;
+
+    public WriterFormatFilter(String formatName)
+    {
+      this.formatName = formatName;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+	{
+	  ImageReaderSpi spi = (ImageReaderSpi) provider;
+	  String[] formatNames = spi.getFormatNames();
+	  
+	  for (int i = formatNames.length - 1; i >= 0; --i)
+	    if (formatName.equals(formatNames[i]))
+	      return true;
+	}
+
+      return false;
+    }
+  }
+
+  private static final class WriterMIMETypeFilter implements ServiceRegistry.Filter
+  {
+    private String MIMEType;
+
+    public WriterMIMETypeFilter(String MIMEType)
+    {
+      this.MIMEType = MIMEType;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageWriterSpi spi = (ImageWriterSpi) provider;
+          String[] mimetypes = spi.getMIMETypes();
+
+          for (int i = mimetypes.length - 1; i >= 0; --i)
+            if (MIMEType.equals(mimetypes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+  
+  private static final class WriterSuffixFilter implements ServiceRegistry.Filter
+  {
+    private String fileSuffix;
+
+    public WriterSuffixFilter(String fileSuffix)
+    {
+      this.fileSuffix = fileSuffix;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageWriterSpi spi = (ImageWriterSpi) provider;
+          String[] suffixes = spi.getFileSuffixes();
+
+          for (int i = suffixes.length - 1; i >= 0; --i)
+            if (fileSuffix.equals(suffixes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+
+  private static final class ImageReaderIterator implements Iterator
+  {
+    Iterator it;
+    
+    public ImageReaderIterator(Iterator it)
+    {
+      this.it = it;
+    }
+
+    public boolean hasNext()
+    {
+      return it.hasNext();
+    }
+
+    public Object next()
+    {
+      try
+        {
+          return ((ImageReaderSpi) it.next()).createReaderInstance();
+        }
+      catch (IOException e)
+        {
+          return null;
+        }
+    }
+
+    public void remove()
+    {
+      throw new UnsupportedOperationException();
+    }
+  }
+
+  private static final class ImageWriterIterator implements Iterator
+  {
+    Iterator it;
+    
+    public ImageWriterIterator(Iterator it)
+    {
+      this.it = it;
+    }
+
+    public boolean hasNext()
+    {
+      return it.hasNext();
+    }
+
+    public Object next()
+    {
+      try
+        {
+          return ((ImageWriterSpi) it.next()).createWriterInstance();
+        }
+      catch (IOException e)
+        {
+          return null;
+        }
+    }
+
+    public void remove()
+    {
+      throw new UnsupportedOperationException();
+    }
+  }
+  
+  private static File cacheDirectory;
+  private static boolean useCache = true;
+
+  private static Iterator getReadersByFilter(Class type,
+                                             ServiceRegistry.Filter filter)
+  {
+    try
+      {
+        Iterator it = getRegistry().getServiceProviders(type, filter, true);
+        return new ImageReaderIterator(it);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return Collections.EMPTY_SET.iterator();
+      }
+  }
+  
+  private static Iterator getWritersByFilter(Class type,
+					     ServiceRegistry.Filter filter)
+  {
+    try
+      {
+        Iterator it = getRegistry().getServiceProviders(type, filter, true);
+        return new ImageWriterIterator(it);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return Collections.EMPTY_SET.iterator();
+      }
+  }
+
+  public static File getCacheDirectory()
+  {
+    return cacheDirectory;
+  }
+
+  public static Iterator getImageReadersByFormatName(String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException("formatName may not be null");
+
+    return getReadersByFilter(ImageReaderSpi.class,
+                              new ReaderFormatFilter(formatName));
+  }
+
+  public static Iterator getImageReadersByMIMEType(String MIMEType)
+  {
+    if (MIMEType == null)
+      throw new IllegalArgumentException("MIMEType may not be null");
+
+    return getReadersByFilter(ImageReaderSpi.class,
+                              new ReaderMIMETypeFilter(MIMEType));
+  }
+
+  public static Iterator getImageReadersBySuffix(String fileSuffix)
+  {
+    if (fileSuffix == null)
+      throw new IllegalArgumentException("formatName may not be null");
+    
+    return getReadersByFilter(ImageReaderSpi.class,
+                              new ReaderSuffixFilter(fileSuffix));
+  }
+
+  public static Iterator getImageWritersByFormatName(String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException("formatName may not be null");
+    
+    return getWritersByFilter(ImageWriterSpi.class,
+                              new WriterFormatFilter(formatName));
+  }
+
+  public static Iterator getImageWritersByMIMEType(String MIMEType)
+  {
+    if (MIMEType == null)
+      throw new IllegalArgumentException("MIMEType may not be null");
+    
+    return getWritersByFilter(ImageWriterSpi.class,
+                              new WriterMIMETypeFilter(MIMEType));
+  }
+
+  public static Iterator getImageWritersBySuffix(String fileSuffix)
+  {
+    if (fileSuffix == null)
+      throw new IllegalArgumentException("fileSuffix may not be null");
+    
+    return getWritersByFilter(ImageWriterSpi.class,
+                              new WriterSuffixFilter(fileSuffix));
+  }
+
+  public static String[] getReaderFormatNames()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageReaderSpi spi = (ImageReaderSpi) it.next();
+	    String[] names = spi.getFormatNames();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+
+  public static String[] getReaderMIMETypes()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageReaderSpi spi = (ImageReaderSpi) it.next();
+	    String[] names = spi.getMIMETypes();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+
+  private static IIORegistry getRegistry()
+  {
+    return IIORegistry.getDefaultInstance();
+  }
+
+  public static boolean getUseCache()
+  {
+    return useCache;
+  }
+
+  public static String[] getWriterFormatNames()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageWriterSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageWriterSpi spi = (ImageWriterSpi) it.next();
+	    String[] names = spi.getFormatNames();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+
+  public static String[] getWriterMIMETypes()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageWriterSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageWriterSpi spi = (ImageWriterSpi) it.next();
+	    String[] names = spi.getMIMETypes();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+  
   /**
    * Rescans the application classpath for ImageIO service providers
    * and registers them.
@@ -49,5 +472,23 @@
   public static void scanForPlugins()
   {
     IIORegistry.getDefaultInstance().registerApplicationClasspathSpis();
+  }
+
+  public static void setCacheDirectory(File cacheDirectory)
+  {
+    if (cacheDirectory != null)
+      {
+        if (!cacheDirectory.isDirectory())
+          throw new IllegalArgumentException("cacheDirectory must be a directory");
+
+        cacheDirectory.canWrite();
+      }
+    
+    ImageIO.cacheDirectory = cacheDirectory;
+  }
+
+  public static void setUseCache(boolean useCache)
+  {
+    ImageIO.useCache = useCache;
   }
 }
Index: kaffe/libraries/javalib/javax/imageio/ImageReadParam.java
diff -u kaffe/libraries/javalib/javax/imageio/ImageReadParam.java:1.1 kaffe/libraries/javalib/javax/imageio/ImageReadParam.java:1.2
--- kaffe/libraries/javalib/javax/imageio/ImageReadParam.java:1.1	Mon Oct  4 15:36:10 2004
+++ kaffe/libraries/javalib/javax/imageio/ImageReadParam.java	Tue Oct  5 22:11:20 2004
@@ -38,9 +38,73 @@
 
 package javax.imageio;
 
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+
 /**
  * @author Michel Koch (konqueror at gmx.de)
  */
 public class ImageReadParam extends IIOParam
 {
+  protected boolean canSetSourceRenderSize;
+  protected BufferedImage destination;
+  protected int[] destinationBands;
+  protected int minProgressivePass;
+  protected int numProgressivePasses = Integer.MAX_VALUE;
+  protected Dimension sourceRenderSize;
+
+  public ImageReadParam()
+  {
+  }
+
+  public boolean canSetSourceRenderSize()
+  {
+    return canSetSourceRenderSize;
+  }
+
+  public BufferedImage getDestination()
+  {
+    return destination;
+  }
+
+  public int[] getDestinationBands()
+  {
+    return destinationBands;
+  }
+
+  public int getSourceMaxProgressivePass()
+  {
+    if (getSourceNumProgressivePasses() == Integer.MAX_VALUE)
+      return Integer.MAX_VALUE;
+
+    return getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1;
+  }
+
+  public int getSourceMinProgressivePass()
+  {
+    return minProgressivePass;
+  }
+
+  public int getSourceNumProgressivePasses()
+  {
+    return numProgressivePasses;
+  }
+
+  public Dimension getSourceRenderSize()
+  {
+    return sourceRenderSize;
+  }
+  
+  public void setSourceRenderSize(Dimension size)
+    throws UnsupportedOperationException
+  {
+    if (! canSetSourceRenderSize())
+      throw new UnsupportedOperationException
+	("setting source render size not supported");
+    
+    if (size.width <= 0 || size.height <= 0)
+      throw new IllegalArgumentException("negative dimension not allowed");
+    
+    sourceRenderSize = size;
+  }
 }
Index: kaffe/libraries/javalib/javax/imageio/ImageReader.java
diff -u kaffe/libraries/javalib/javax/imageio/ImageReader.java:1.1 kaffe/libraries/javalib/javax/imageio/ImageReader.java:1.2
--- kaffe/libraries/javalib/javax/imageio/ImageReader.java:1.1	Tue May 18 20:23:04 2004
+++ kaffe/libraries/javalib/javax/imageio/ImageReader.java	Tue Oct  5 22:11:20 2004
@@ -1,5 +1,5 @@
 /* ImageReader.java -- Decodes raster images.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,9 +38,482 @@
 
 package javax.imageio;
 
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import javax.imageio.event.IIOReadProgressListener;
+import javax.imageio.event.IIOReadUpdateListener;
+import javax.imageio.event.IIOReadWarningListener;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.spi.ImageReaderSpi;
+
 public abstract class ImageReader
 {
-  // FIXME: Incomplete. This class is merely present in order to allow
-  // compilation of the javax.imageio.spi package, for which GNU
-  // Classpath does provide an implementation.
+  private boolean aborted;
+  
+  protected Locale[] availableLocales;
+  protected boolean ignoreMetadata;
+  protected Object input;
+  protected Locale locale;
+  protected int minIndex;
+  protected ImageReaderSpi originatingProvider;
+  protected List progressListeners;
+  protected boolean seekForwardOnly;
+  protected List updateListeners = new ArrayList();
+  protected List warningListeners = new ArrayList();
+  protected List warningLocales = new ArrayList();
+
+  protected ImageReader(ImageReaderSpi originatingProvider)
+  {
+    this.originatingProvider = originatingProvider;
+  }
+
+  public void abort()
+  {
+    aborted = true;
+  }
+
+  protected boolean abortRequested()
+  {
+    return aborted;
+  }
+
+  public void addIIOReadProgressListener(IIOReadProgressListener listener)
+  {
+    if (listener == null)
+      return;
+    
+    progressListeners.add(listener);    
+  }
+
+  public void addIIOReadUpdateListener(IIOReadUpdateListener listener)
+  {
+    if (listener == null)
+      return;
+    
+    updateListeners.add(listener);    
+  }
+  
+  public void addIIOReadWarningListener(IIOReadWarningListener listener)
+  {
+    if (listener == null)
+      return;
+    
+    warningListeners.add(listener);    
+  }
+
+  public boolean canReadRaster()
+  {
+    return false;
+  }
+
+  protected void clearAbortRequest()
+  {
+    aborted = false;
+  }
+  
+  public void dispose()
+  {
+    // The default implementation does nothing.
+  }
+  
+  public float getAspectRatio(int imageIndex)
+    throws IOException
+  {
+    return (float) (getWidth(imageIndex) / getHeight(imageIndex));
+  }
+
+  public Locale[] getAvailableLocales()
+  {
+    if (availableLocales == null)
+      return null;
+    
+    return (Locale[]) availableLocales.clone();
+  }
+
+  public ImageReadParam getDefaultReadParam()
+  {
+    return new ImageReadParam();
+  }
+
+  public String getFormatName()
+    throws IOException
+  {
+    return originatingProvider.getFormatNames()[0];
+  }
+
+  public abstract int getHeight(int imageIndex)
+    throws IOException;
+
+  public abstract IIOMetadata getImageMetadata(int imageIndex)
+    throws IOException;
+
+  public abstract Iterator getImageTypes(int imageIndex)
+    throws IOException;
+
+  public Object getInput()
+  {
+    return input;
+  }
+
+  public Locale getLocale()
+  {
+    return locale;
+  }
+
+  public abstract int getNumImages(boolean allowSearch)
+    throws IOException;
+
+  public int getNumThumbnails(int imageIndex)
+    throws IOException
+  {
+    return 0;
+  }
+
+  public ImageReaderSpi getOriginatingProvider()
+  {
+    return originatingProvider;
+  }
+
+  public abstract IIOMetadata getStreamMetadata()
+    throws IOException;
+
+  public int getThumbnailHeight(int imageIndex, int thumbnailIndex)
+    throws IOException
+  {
+    return readThumbnail(imageIndex, thumbnailIndex).getHeight();
+  }
+
+  public int getThumbnailWidth(int imageIndex, int thumbnailIndex)
+    throws IOException
+  {
+    return readThumbnail(imageIndex, thumbnailIndex).getWidth();
+  }
+
+  public int getTileGridXOffset(int imageIndex)
+    throws IOException
+  {
+    return 0;

*** Patch too long, truncated ***




More information about the kaffe mailing list