This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: java.awt.image.ColorConvertOp


The attached patch (committed) adds a number of tests for the
ColorConvertOp class.  Many currently fail on Classpath, I'll be fixing
those soon.

Cheers,
Francis

2006-08-15  Francis Kung  <fkung@redhat.com>

	* gnu/testlet/java/awt/image/ColorConvertOp/constructors.java,
	*
gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java,
	*
gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestRaster.java,
	* gnu/testlet/java/awt/image/ColorConvertOp/filterImage.java,
	* gnu/testlet/java/awt/image/ColorConvertOp/filterRaster.java,
	* gnu/testlet/java/awt/image/ColorConvertOp/getBounds2D.java,
	* gnu/testlet/java/awt/image/ColorConvertOp/getPoint2D.java:
	New tests.


Index: gnu/testlet/java/awt/image/ColorConvertOp/getPoint2D.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/getPoint2D.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/getPoint2D.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/getPoint2D.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,59 @@
+/* getPoint2D.java -- some checks for the getPoint2D) method of the
+              ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.color.ColorSpace;
+import java.awt.geom.Point2D;
+import java.awt.image.ColorConvertOp;
+
+/**
+ * Checks the getPoint2D method in the
+ * {@link ColorConvertOp} class.
+ */
+public class getPoint2D implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    harness.checkPoint("getPoint2D");
+    
+    //  This is a simple test; the Op should not change the
+    // geometry of the raster
+    
+    ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+                                           null);
+    Point2D dest = null;
+    dest = op.getPoint2D(new Point2D.Double(3, 3), dest);
+    harness.check(dest, new Point2D.Double(3, 3));
+  }
+}
+
Index: gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,352 @@
+/* createCompatibleDestImage.java -- some checks for the
+       createCompatibleDestImage() method of the ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.ColorModel;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DirectColorModel;
+import java.awt.image.PixelInterleavedSampleModel;
+
+/**
+ * Checks for the createCompatibleDestImage method in the
+ * {@link ColorConvertOp} class.
+ */
+public class createCompatibleDestImage implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    simpleTest(harness);
+
+    // Try with all possible colorspaces
+    colorModelTest(harness, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_CIEXYZ);
+    colorModelTest(harness, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_LINEAR_RGB);
+    colorModelTest(harness, ColorSpace.CS_PYCC);
+    
+    // Specify both source and dest colourspaces
+    colorModelTest(harness, ColorSpace.CS_sRGB, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_CIEXYZ, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_GRAY, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_LINEAR_RGB, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_PYCC, ColorSpace.CS_sRGB);
+    
+    colorModelTest(harness, ColorSpace.CS_sRGB, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_CIEXYZ, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_GRAY, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_LINEAR_RGB, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_PYCC, ColorSpace.CS_GRAY);
+    
+    // Specify profile list
+    profileTest(harness, new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB),
+                                            ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ),
+                                            ICC_Profile.getInstance(ColorSpace.CS_sRGB),
+                                            ICC_Profile.getInstance(ColorSpace.CS_GRAY)});
+                             
+    profileTest(harness, new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_GRAY),
+                                            ICC_Profile.getInstance(ColorSpace.CS_sRGB)});
+                             
+    profileTest(harness, new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_GRAY),
+                                            ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ)});
+  }
+  
+  private void simpleTest(TestHarness harness)
+  {
+    harness.checkPoint("createCompatibleDestImage");
+
+    // Simple test
+    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    ColorConvertOp op = new ColorConvertOp(cs, null);
+    
+    BufferedImage img = new BufferedImage(25, 40, BufferedImage.TYPE_INT_RGB);
+    BufferedImage dest = op.createCompatibleDestImage(img, img.getColorModel());
+    
+    harness.check(dest.getHeight(), 40);
+    harness.check(dest.getWidth(), 25);
+    harness.check(dest.getColorModel(), img.getColorModel());
+    
+    // Try a different colour model
+    img = new BufferedImage(25, 40, BufferedImage.TYPE_BYTE_GRAY);
+    DirectColorModel cm = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff);
+    dest = op.createCompatibleDestImage(img, cm);
+    
+    harness.check(dest.getHeight(), 40);
+    harness.check(dest.getWidth(), 25);
+    harness.check(dest.getColorModel(), cm);
+
+    op = new ColorConvertOp(null);
+    dest = op.createCompatibleDestImage(img, img.getColorModel());
+    harness.check(dest.getHeight(), 40);
+    harness.check(dest.getWidth(), 25);
+    harness.check(dest.getColorModel(), img.getColorModel());
+
+    // ColorConvertOp's ColorModel can be null, or createCompatibleDestImage's
+    // ColorModel can be null, but not both
+    try
+    {
+      dest = op.createCompatibleDestImage(img, null);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+  }
+  
+  // This should probably go in the BufferedImage constructor 
+  // Test all the default color models
+  private void colorModelTest(TestHarness harness, int cspace)
+  {
+    colorModelTest(harness, -1, cspace);
+  }
+  
+  private void colorModelTest(TestHarness harness, int cspace, int cspace2)
+  {
+    ColorSpace cs;
+    ColorSpace cs2;
+    ColorConvertOp op;
+    
+    if (cspace == -1)
+      {
+        cs2 = ColorSpace.getInstance(cspace2);
+        op = new ColorConvertOp(cs2, null);
+      }
+    else
+      {
+        cs = ColorSpace.getInstance(cspace);
+        cs2 = ColorSpace.getInstance(cspace2);
+        op = new ColorConvertOp(cs, cs2, null);
+      }
+
+    int[] types = {BufferedImage.TYPE_INT_RGB,
+                   BufferedImage.TYPE_INT_ARGB,
+                   BufferedImage.TYPE_INT_ARGB_PRE,
+                   BufferedImage.TYPE_3BYTE_BGR,
+                   BufferedImage.TYPE_4BYTE_ABGR,
+                   BufferedImage.TYPE_4BYTE_ABGR_PRE,
+                   BufferedImage.TYPE_USHORT_565_RGB,
+                   BufferedImage.TYPE_USHORT_555_RGB,
+                   BufferedImage.TYPE_BYTE_GRAY,
+                   BufferedImage.TYPE_USHORT_GRAY};
+    // Skipped types that are not implemented yet:
+    // TYPE_CUSTOM, TYPE_INT_BGR, TYPE_BYTE_BINARY, TYPE_BYTE_INDEXED
+
+    for (int i = 0; i < types.length; i++)
+      {
+        int type = types[i];
+        if (cspace == -1)
+          harness.checkPoint("colorspace " + cspace2  + ", type: " + type);
+        else
+          harness.checkPoint("src colorspace " + cspace + ", dest colorspace " + cspace2 + ", type: " + type);
+        
+        BufferedImage img = new BufferedImage(25, 40, type);
+        BufferedImage dest = op.createCompatibleDestImage(img, null);
+        dest = op.createCompatibleDestImage(img, null);
+        
+        harness.check(dest.getColorModel() instanceof ComponentColorModel);
+        harness.check(dest.getSampleModel() instanceof PixelInterleavedSampleModel);
+        harness.check(dest.getColorModel().isCompatibleSampleModel(dest.getSampleModel()));
+        harness.check(dest.getColorModel().getTransferType(), DataBuffer.TYPE_BYTE);
+        harness.check(dest.getColorModel().getColorSpace().getType(), cs2.getType());
+
+        harness.check(dest.getColorModel().getPixelSize(),
+                      8 * dest.getRaster().getNumDataElements());
+
+        // This ensures that we have the same defaults as the reference implementation
+        switch (type)
+        {
+          case BufferedImage.TYPE_INT_ARGB:
+          case BufferedImage.TYPE_INT_ARGB_PRE:
+          case BufferedImage.TYPE_4BYTE_ABGR:
+          case BufferedImage.TYPE_4BYTE_ABGR_PRE:
+            if (cspace2 == ColorSpace.CS_GRAY)
+              {
+                harness.check(dest.getColorModel().getNumComponents(), 2);
+              }
+            else
+              {
+                harness.check(dest.getColorModel().getNumComponents(), 4);
+              }
+            
+            harness.check(dest.getColorModel().getNumColorComponents(),
+                          dest.getColorModel().getNumComponents() - 1);
+            harness.check(dest.getRaster().getNumDataElements(),
+                          dest.getColorModel().getNumColorComponents() + 1);
+            harness.check(dest.getColorModel().getTransparency(), ColorModel.TRANSLUCENT);
+            harness.check(dest.getColorModel().hasAlpha(), true);
+            harness.check(dest.getColorModel().isAlphaPremultiplied(),
+                          (type == BufferedImage.TYPE_INT_ARGB_PRE
+                              || type == BufferedImage.TYPE_4BYTE_ABGR_PRE));
+            harness.check(dest.getRaster().getNumBands(), dest.getRaster().getNumDataElements());
+            
+            harness.check(dest.getType(), BufferedImage.TYPE_CUSTOM);
+            break;
+            
+          case BufferedImage.TYPE_INT_RGB:
+          case BufferedImage.TYPE_3BYTE_BGR:
+          case BufferedImage.TYPE_USHORT_565_RGB:
+          case BufferedImage.TYPE_USHORT_555_RGB:
+          case BufferedImage.TYPE_BYTE_GRAY:
+          case BufferedImage.TYPE_USHORT_GRAY:
+            if (cspace2 == ColorSpace.CS_GRAY)
+              {
+                harness.check(dest.getType(), BufferedImage.TYPE_BYTE_GRAY);
+                harness.check(dest.getColorModel().getNumComponents(), 1);
+              }
+            else
+              {
+                harness.check(dest.getType(), BufferedImage.TYPE_CUSTOM);
+                harness.check(dest.getColorModel().getNumComponents(), 3);
+              }
+            
+            harness.check(dest.getColorModel().getNumColorComponents(),
+                          dest.getColorModel().getNumComponents());
+            harness.check(dest.getRaster().getNumDataElements(), dest.getColorModel().getNumColorComponents());
+            harness.check(dest.getColorModel().getTransparency(), ColorModel.OPAQUE);
+            harness.check(dest.getColorModel().hasAlpha(), false);
+            harness.check(dest.getColorModel().isAlphaPremultiplied(), false);
+            harness.check(dest.getRaster().getNumBands(), dest.getRaster().getNumDataElements());
+            
+            break;
+        }
+      }
+  }
+  
+  
+  private void profileTest(TestHarness harness, ICC_Profile[] profile)
+  {
+    ColorConvertOp op = new ColorConvertOp(profile, null);
+
+    int[] types = {BufferedImage.TYPE_INT_RGB,
+                   BufferedImage.TYPE_INT_ARGB,
+                   BufferedImage.TYPE_INT_ARGB_PRE,
+                   BufferedImage.TYPE_3BYTE_BGR,
+                   BufferedImage.TYPE_4BYTE_ABGR,
+                   BufferedImage.TYPE_4BYTE_ABGR_PRE,
+                   BufferedImage.TYPE_USHORT_565_RGB,
+                   BufferedImage.TYPE_USHORT_555_RGB,
+                   BufferedImage.TYPE_BYTE_GRAY,
+                   BufferedImage.TYPE_USHORT_GRAY};
+    // Skipped types that are not implemented yet:
+    // TYPE_CUSTOM, TYPE_INT_BGR, TYPE_BYTE_BINARY, TYPE_BYTE_INDEXED
+
+    for (int i = 0; i < types.length; i++)
+      {
+        int type = types[i];
+        harness.checkPoint("profile " + profile[profile.length-1].getClass() + ", type: " + type);
+        
+        BufferedImage img = new BufferedImage(25, 40, type);
+        BufferedImage dest = op.createCompatibleDestImage(img, null);
+        dest = op.createCompatibleDestImage(img, null);
+        
+        harness.check(dest.getColorModel() instanceof ComponentColorModel);
+        harness.check(dest.getSampleModel() instanceof PixelInterleavedSampleModel);
+        harness.check(dest.getColorModel().isCompatibleSampleModel(dest.getSampleModel()));
+        harness.check(dest.getColorModel().getTransferType(), DataBuffer.TYPE_BYTE);
+        harness.check(dest.getColorModel().getColorSpace().getType(),
+                      profile[profile.length-1].getColorSpaceType());
+
+        harness.check(dest.getColorModel().getPixelSize(),
+                      8 * dest.getRaster().getNumDataElements());
+
+        // This ensures that we have the same defaults as the reference implementation
+        switch (type)
+        {
+          case BufferedImage.TYPE_INT_ARGB:
+          case BufferedImage.TYPE_INT_ARGB_PRE:
+          case BufferedImage.TYPE_4BYTE_ABGR:
+          case BufferedImage.TYPE_4BYTE_ABGR_PRE:
+            if (profile[profile.length-1].getColorSpaceType() == ColorSpace.TYPE_GRAY)
+              {
+                harness.check(dest.getColorModel().getNumComponents(), 2);
+              }
+            else
+              {
+                harness.check(dest.getColorModel().getNumComponents(), 4);
+              }
+            //System.out.println("dest cmpt " + dest.getColorModel().getNumComponents());
+            
+            harness.check(dest.getColorModel().getNumColorComponents(),
+                          dest.getColorModel().getNumComponents() - 1);
+            harness.check(dest.getRaster().getNumDataElements(),
+                          dest.getColorModel().getNumColorComponents() + 1);
+            harness.check(dest.getColorModel().getTransparency(), ColorModel.TRANSLUCENT);
+            harness.check(dest.getColorModel().hasAlpha(), true);
+            harness.check(dest.getColorModel().isAlphaPremultiplied(),
+                          (type == BufferedImage.TYPE_INT_ARGB_PRE
+                              || type == BufferedImage.TYPE_4BYTE_ABGR_PRE));
+            harness.check(dest.getRaster().getNumBands(), dest.getRaster().getNumDataElements());
+            
+            harness.check(dest.getType(), BufferedImage.TYPE_CUSTOM);
+            break;
+            
+          case BufferedImage.TYPE_INT_RGB:
+          case BufferedImage.TYPE_3BYTE_BGR:
+          case BufferedImage.TYPE_USHORT_565_RGB:
+          case BufferedImage.TYPE_USHORT_555_RGB:
+          case BufferedImage.TYPE_BYTE_GRAY:
+          case BufferedImage.TYPE_USHORT_GRAY:
+            if (profile[profile.length-1].getColorSpaceType() == ColorSpace.TYPE_GRAY)
+              {
+                harness.check(dest.getType(), BufferedImage.TYPE_BYTE_GRAY);
+                harness.check(dest.getColorModel().getNumComponents(), 1);
+              }
+            else
+              {
+                harness.check(dest.getType(), BufferedImage.TYPE_CUSTOM);
+                harness.check(dest.getColorModel().getNumComponents(), 3);
+              }
+            //System.out.println("dest type " + dest.getType());
+            //System.out.println("dest cmpt " + dest.getColorModel().getNumComponents());
+            
+            harness.check(dest.getColorModel().getNumColorComponents(),
+                          dest.getColorModel().getNumComponents());
+            harness.check(dest.getRaster().getNumDataElements(), dest.getColorModel().getNumColorComponents());
+            harness.check(dest.getColorModel().getTransparency(), ColorModel.OPAQUE);
+            harness.check(dest.getColorModel().hasAlpha(), false);
+            harness.check(dest.getColorModel().isAlphaPremultiplied(), false);
+            harness.check(dest.getRaster().getNumBands(), dest.getRaster().getNumDataElements());
+            
+            break;
+        }
+      }
+  }
+}
+
+
+ 
Index: gnu/testlet/java/awt/image/ColorConvertOp/constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/constructors.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/constructors.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,225 @@
+/* constructors.java -- some checks for the constructors in the 
+       ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.RenderingHints;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.image.ColorConvertOp;
+import java.util.Arrays;
+
+/**
+ * Some checks for the constructors in the {@link ColorConvertOp} class.
+ */
+public class constructors implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    testConstructor1(harness);
+    testConstructor2(harness);
+    testConstructor3(harness);
+    testConstructor4(harness);
+  }
+  
+  public void testConstructor1(TestHarness harness)
+  {
+    harness.checkPoint("(ColorSpace, ColorSpace, RenderingHints)");
+
+    // Simple test
+    ColorSpace srcCs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    ColorSpace dstCs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+    RenderingHints hints = new RenderingHints(RenderingHints.KEY_DITHERING,
+                                              RenderingHints.VALUE_DITHER_ENABLE);
+    hints.put(RenderingHints.KEY_COLOR_RENDERING,
+              RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+    ColorConvertOp op = new ColorConvertOp(srcCs, dstCs, hints);
+    
+    harness.check(op.getICC_Profiles(), null);
+    harness.check(op.getRenderingHints(), hints);
+
+    
+    // Null arguments
+    op = new ColorConvertOp(srcCs, dstCs, null);
+    
+    harness.check(op.getICC_Profiles(), null);
+    harness.check(op.getRenderingHints(), null);
+
+    try
+    {
+      op = new ColorConvertOp(null, dstCs, null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+    
+    try
+    {
+      op = new ColorConvertOp(srcCs, null, null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+    
+    try
+    {
+      op = new ColorConvertOp(null, null, null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+    
+  }
+
+  public void testConstructor2(TestHarness harness)
+  {
+    harness.checkPoint("(ColorSpace, RenderingHints)");
+
+    // Simple test
+    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    RenderingHints hints = new RenderingHints(RenderingHints.KEY_DITHERING,
+                                              RenderingHints.VALUE_DITHER_ENABLE);
+    hints.put(RenderingHints.KEY_COLOR_RENDERING,
+              RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+    ColorConvertOp op = new ColorConvertOp(cs, hints);
+    
+    harness.check(op.getICC_Profiles(), null);
+    harness.check(op.getRenderingHints(), hints);
+    
+    // Null arguments
+    op = new ColorConvertOp(cs, null);
+    
+    harness.check(op.getICC_Profiles(), null);
+    harness.check(op.getRenderingHints(), null);
+
+    try
+    {
+      op = new ColorConvertOp((ColorSpace)null, (RenderingHints)null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+    
+  }
+
+  public void testConstructor3(TestHarness harness)
+  {
+    harness.checkPoint("(ICC_Profile[], RenderingHints)");
+
+    // Simple test
+    ICC_Profile[] profile = new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB),
+                                               ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ),
+                                               ICC_Profile.getInstance(ColorSpace.CS_sRGB),
+                                               ICC_Profile.getInstance(ColorSpace.CS_PYCC)};
+    
+    RenderingHints hints = new RenderingHints(RenderingHints.KEY_DITHERING,
+                                              RenderingHints.VALUE_DITHER_ENABLE);
+    hints.put(RenderingHints.KEY_COLOR_RENDERING,
+              RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+    ColorConvertOp op = new ColorConvertOp(profile, hints);
+    
+    // Work around lack of ICC_Profile.equals()
+    harness.check(Arrays.equals(op.getICC_Profiles(), profile));
+    harness.check(op.getRenderingHints(), hints);
+
+    // Empty or too few profiles are not caught until filter(), so they are
+    // allowed here
+    try
+    {
+      op = new ColorConvertOp(new ICC_Profile[0], null);
+      harness.check(Arrays.equals(op.getICC_Profiles(), new ICC_Profile[0]));
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    try
+    {
+      profile = new ICC_Profile[]{ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB)};
+      op = new ColorConvertOp(profile, null);
+      harness.check(Arrays.equals(op.getICC_Profiles(), profile));
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Null arguments
+    op = new ColorConvertOp(profile, null);
+    
+    // Work around lack of ICC_Profile.equals()
+    harness.check(Arrays.equals(op.getICC_Profiles(), profile));
+    harness.check(op.getRenderingHints(), null);
+
+    try
+    {
+      op = new ColorConvertOp((ICC_Profile[])null, null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+    
+  }
+  
+  public void testConstructor4(TestHarness harness)
+  {
+    harness.checkPoint("(RenderingHints)");
+
+    // Simple test
+    RenderingHints hints = new RenderingHints(RenderingHints.KEY_DITHERING,
+                                              RenderingHints.VALUE_DITHER_ENABLE);
+    hints.put(RenderingHints.KEY_COLOR_RENDERING,
+              RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+    ColorConvertOp op = new ColorConvertOp(hints);
+    
+    harness.check(op.getICC_Profiles(), null);
+    harness.check(op.getRenderingHints(), hints);
+    
+    // Null arguments
+    op = new ColorConvertOp(null);
+    
+    harness.check(op.getICC_Profiles(), null);
+    harness.check(op.getRenderingHints(), null);
+  }
+}
+
Index: gnu/testlet/java/awt/image/ColorConvertOp/filterImage.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/filterImage.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/filterImage.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/filterImage.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,242 @@
+/* filterImage.java -- some checks for the filter(Image) method of the
+              ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Graphics2D;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.geom.Line2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorConvertOp;
+
+/**
+ * Checks the filter(BufferedImage) method in the {@link ColorConvertOp} class.
+ */
+public class filterImage implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    test1(harness);
+    test2(harness);
+    test3(harness);
+    test4(harness);
+  }
+  
+  private void test1(TestHarness harness)
+  {
+    harness.checkPoint("filter(BufferedImage) from ColorConvertOp(RenderingHints)");
+    // Create an image to work on
+    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+    Graphics2D g = (Graphics2D)img.getGraphics();
+    g.draw(new Line2D.Double(0, 0, 20, 20));
+    
+    ColorConvertOp op = new ColorConvertOp(null);
+    
+    // Src and dst images can be the same (unlike some other Ops)
+    try
+    {
+      op.filter(img, img);
+      harness.check(true);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Src and dst are different sizes (not allowed, unlike some other Ops)
+    BufferedImage dst = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
+    try
+    {
+      op.filter(img, dst);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Dst cannot be null for this ColorConvertOp
+    try
+    {
+      op.filter(img, null);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Can I check that the actual filter operation happened properly?
+  }
+  
+  private void test2(TestHarness harness)
+  {
+    harness.checkPoint("filter(BufferedImage) from ColorConvertOp(ColorSpace, RenderingHints)");
+    // Create an image to work on
+    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+    Graphics2D g = (Graphics2D)img.getGraphics();
+    g.draw(new Line2D.Double(0, 0, 20, 20));
+    
+    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    ColorConvertOp op = new ColorConvertOp(cs, null);
+    
+    // Check null destination
+    try
+    {
+      BufferedImage dst = op.filter(img, null);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
+      // Any other checks to run?  Show the data was filtered properly?
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Check non-null destination
+    try
+    {
+      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB);
+      dst = op.filter(img, dst);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
+      // Any other checks to run?
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Can we introduce an alpha?
+    try
+    {
+      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
+      dst = op.filter(img, dst);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
+      // Any other checks to run?
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Incompatible destination type: this should end up as GRAY, via RGB
+    // (but how can I test the intermediate step?)
+    try
+    {
+      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY);
+      dst = op.filter(img, dst);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_GRAY);
+      // Any other checks to run?
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+  }
+  
+  private void test3(TestHarness harness)
+  {
+    harness.checkPoint("filter(BufferedImage) from ColorConvertOp(ColorSpace, ColorSpace, RenderingHints)");
+    // Create an image to work on
+    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+    Graphics2D g = (Graphics2D)img.getGraphics();
+    g.draw(new Line2D.Double(0, 0, 20, 20));
+    
+    ColorSpace cs1 = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
+    ColorSpace cs2 = ColorSpace.getInstance(ColorSpace.CS_PYCC);
+    ColorConvertOp op = new ColorConvertOp(cs1, cs2, null);
+
+    // Simpler tests (ie, src != dest) are skipped, assume they work here if
+    // they worked earlier
+    
+    try
+    {
+      BufferedImage dst = op.filter(img, null);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_3CLR);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+   
+    try
+    {
+      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB_PRE);
+      op.filter(img, dst);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Can I check that the actual filter operation happened properly?
+  }
+  
+  private void test4(TestHarness harness)
+  {
+    harness.checkPoint("filter(BufferedImage) from ColorConvertOp(ICC_Profile[], RenderingHints)");
+    // Create an image to work on
+    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+    Graphics2D g = (Graphics2D)img.getGraphics();
+    g.draw(new Line2D.Double(0, 0, 20, 20));
+    
+    ICC_Profile[] profile = new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB),
+                                               ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ),
+                                               ICC_Profile.getInstance(ColorSpace.CS_sRGB)};
+    ColorConvertOp op = new ColorConvertOp(profile, null);
+    
+    try
+    {
+      BufferedImage dst = op.filter(img, null);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    try
+    {
+      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY);
+      dst = op.filter(img, dst);
+      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_GRAY);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Can I check that the actual filter operation happened properly?
+  }
+}
+
Index: gnu/testlet/java/awt/image/ColorConvertOp/getBounds2D.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/getBounds2D.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/getBounds2D.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/getBounds2D.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,61 @@
+/* getBounds2D.java -- some checks for the getBounds2D() method of the
+              ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Point;
+import java.awt.color.ColorSpace;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+/**
+ * Checks the getBounds2D method in the
+ * {@link ColorConvertOp} class.
+ */
+public class getBounds2D implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    harness.checkPoint("getBounds2D");
+    
+    //  This is a simple test; the Op should not change the
+    // dimensions of the raster
+    
+    WritableRaster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 5, 5, 1, new Point(0,0));
+    ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+                                           null);
+    harness.check(op.getBounds2D(src), src.getBounds());
+  }
+}
+
Index: gnu/testlet/java/awt/image/ColorConvertOp/filterRaster.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/filterRaster.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/filterRaster.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/filterRaster.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,144 @@
+/* filterRaster.java -- some checks for the filter(Raster) method of the
+              ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Graphics2D;
+import java.awt.color.ColorSpace;
+import java.awt.geom.Line2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.WritableRaster;
+
+/**
+ * Checks the filter(Raster) method in the {@link ColorConvertOp} class.
+ */
+public class filterRaster implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    harness.checkPoint("filter(Raster)");
+    
+    // Create a raster to work on
+    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB);
+    Graphics2D g = (Graphics2D)img.getGraphics();
+    g.draw(new Line2D.Double(0, 0, 20, 20));
+    
+    ColorSpace cs1 = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    ColorSpace cs2 = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+    ColorConvertOp op = new ColorConvertOp(cs1, cs2, null);
+    WritableRaster raster = img.getRaster();
+    
+    // Src and dst rasters cannot be the same (different from 
+    // filter(BufferedImage, BufferedImage) )
+    try
+    {
+      op.filter(raster, raster);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Src and dst are different sizes (not allowed, unlike some other Ops)
+    BufferedImage dst = new BufferedImage(30, 40, BufferedImage.TYPE_BYTE_GRAY);
+    WritableRaster raster2 = dst.getRaster();
+    try
+    {
+      op.filter(raster, raster2);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Null destination
+    WritableRaster dstRaster = op.filter(raster, null);
+    harness.check(dstRaster.getTransferType(), op.createCompatibleDestRaster(raster).getTransferType());
+    harness.check(dstRaster.getNumBands(), op.createCompatibleDestRaster(raster).getNumBands());
+    harness.check(dstRaster.getNumDataElements(), op.createCompatibleDestRaster(raster).getNumDataElements());
+
+    // Incompatible constructor (ie, not enough information)
+    op = new ColorConvertOp(null);
+    try
+    {
+      op.filter(raster, null);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    op = new ColorConvertOp(cs1, null);
+    try
+    {
+      op.filter(raster, null);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Destination raster incompatible with defined conversion;
+    // ie, with this conversion, cs2 is TYPE_GRAY thus a dest raster of
+    // TYPE_RGB will have the wrong number of data elements
+    op = new ColorConvertOp(cs1, cs2, null);
+    dstRaster = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB).getRaster();
+    
+    try
+    {
+      op.filter(raster, dstRaster);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Also true if source raster is incompatible
+    raster = new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY).getRaster();
+    try
+    {
+      op.filter(raster, raster2);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+  }
+}
Index: gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestRaster.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestRaster.java
diff -N gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestRaster.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestRaster.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,238 @@
+/* createCompatibleDestRaster.java -- some checks for the
+              createCompatibleDestRaster() method of the ColorConvertOp class.
+   Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.java.awt.image.ColorConvertOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Point;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+
+/**
+ * Checks for the createCompatibleDestRaster method in the
+ * {@link ColorConvertOp} class.
+ */
+public class createCompatibleDestRaster implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted). 
+   */
+  public void test(TestHarness harness)      
+  {
+    harness.checkPoint("createCompatibleDestRaster");
+
+    simpleTest(harness);
+
+    // Try with all possible colorspaces
+    colorModelTest(harness, ColorSpace.CS_sRGB, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_CIEXYZ, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_GRAY, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_LINEAR_RGB, ColorSpace.CS_sRGB);
+    colorModelTest(harness, ColorSpace.CS_PYCC, ColorSpace.CS_sRGB);
+    
+    colorModelTest(harness, ColorSpace.CS_sRGB, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_CIEXYZ, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_GRAY, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_LINEAR_RGB, ColorSpace.CS_GRAY);
+    colorModelTest(harness, ColorSpace.CS_PYCC, ColorSpace.CS_GRAY);
+    
+    // Specify profile list
+    profileTest(harness, new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB),
+                                            ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ),
+                                            ICC_Profile.getInstance(ColorSpace.CS_sRGB),
+                                            ICC_Profile.getInstance(ColorSpace.CS_GRAY)});
+                             
+    profileTest(harness, new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_GRAY),
+                                            ICC_Profile.getInstance(ColorSpace.CS_sRGB)});
+                             
+    profileTest(harness, new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_GRAY),
+                                            ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ)});
+  }
+  
+  private void simpleTest(TestHarness harness)
+  {
+    // This method can never be used with these constructors
+    ColorConvertOp op = new ColorConvertOp(null);
+    Raster src = Raster.createBandedRaster(DataBuffer.TYPE_BYTE, 10, 10,
+                                           3, new Point(5, 5));
+    try
+    {
+      op.createCompatibleDestRaster(src);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    op = new ColorConvertOp(cs, null);
+    try
+    {
+      op.createCompatibleDestRaster(src);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+  }
+  
+  private void colorModelTest(TestHarness harness, int cspace1, int cspace2)
+  {
+    harness.checkPoint("two colorspaces defined, " + cspace1     + ", " + cspace2);
+
+    ColorSpace cs = ColorSpace.getInstance(cspace1);
+    ColorSpace cs2 = ColorSpace.getInstance(cspace2);
+    ColorConvertOp op = new ColorConvertOp(cs, cs2, null);
+    int bands = cs2.getNumComponents();
+
+    Raster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, bands, new Point(5, 5));
+
+    try
+    {
+      Raster dst = op.createCompatibleDestRaster(src);
+      harness.check(dst.getHeight(), src.getHeight());
+      harness.check(dst.getWidth(), src.getWidth());
+      harness.check(dst.getNumBands(), bands);
+      harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
+      harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
+      harness.check(dst.getNumDataElements(), cs2.getNumComponents());
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Try a different type
+    src = Raster.createBandedRaster(DataBuffer.TYPE_USHORT, 25, 40, bands, new Point(5, 5));
+    try
+    {
+      Raster dst = op.createCompatibleDestRaster(src);
+      harness.check(dst.getNumBands(), bands);
+      harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
+      harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
+      harness.check(dst.getNumDataElements(), cs2.getNumComponents());
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Try different number of bands in the source; the destination will
+    // ignore this and always have ColorSpace.getNumComponents() bands
+    for (int i = 1; i < bands + 5; i++)
+      {
+        src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, i, new Point(5, 5));
+        try
+        {
+          Raster dst = op.createCompatibleDestRaster(src);
+          harness.check(dst.getNumBands(), cs2.getNumComponents());
+          harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
+          harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
+          harness.check(dst.getNumDataElements(), cs2.getNumComponents());
+        }
+        catch (IllegalArgumentException e)
+        {
+          harness.check(false);
+        }
+      }
+  }
+  
+  private void profileTest(TestHarness harness, ICC_Profile[] profiles)
+  {
+    harness.checkPoint("profile test, " + profiles[profiles.length-1].getClass().getName());
+
+    ColorConvertOp op = new ColorConvertOp(profiles, null);
+    
+    Raster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 5, new Point(5, 5));
+
+    try
+    {
+      Raster dst = op.createCompatibleDestRaster(src);
+      harness.check(dst.getHeight(), src.getHeight());
+      harness.check(dst.getWidth(), src.getWidth());
+      
+      // It appears we always use TYPE_BYTE regardless of the source raster
+      harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
+      harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
+      
+      // GRAY is the exception with 1 band; all others have 3
+      if (profiles[profiles.length-1].getColorSpaceType() == ColorSpace.TYPE_GRAY)
+        {
+          harness.check(dst.getNumBands(), 1);
+          harness.check(dst.getNumDataElements(), 1);
+        }
+      else
+        {
+          harness.check(dst.getNumBands(), 3);
+          harness.check(dst.getNumDataElements(), 3);
+        }
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Try different number of bands in the source; the destination will
+    // ignore this and always have ColorSpace.getNumComponents() bands
+    
+    // Essentially the dest raster will be identical to the case above, 
+    // regardless of number of source bands (this makes sense)
+    for (int i = 1; i < 5; i++)
+      {
+        src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, i, new Point(5, 5));
+        try
+        {
+          Raster dst = op.createCompatibleDestRaster(src);
+          harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
+          harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
+          
+          if (profiles[profiles.length-1].getColorSpaceType() == ColorSpace.TYPE_GRAY)
+            {
+              harness.check(dst.getNumBands(), 1);
+              harness.check(dst.getNumDataElements(), 1);
+            }
+          else
+            {
+              harness.check(dst.getNumBands(), 3);
+              harness.check(dst.getNumDataElements(), 3);
+            }
+        }
+        catch (IllegalArgumentException e)
+        {
+          harness.check(false);
+        }
+      }
+  }
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]