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]

ConvolveOp tests


Hi,

This patch, already committed, adds a number of tests for
java.awt.image.ConvolveOp as well as touching up some ColorConvertOp
tests.

Cheers,
Francis


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

	*
gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java:
	(colorModelTest): Add tests for value of transferType.
	(simpleTest): Add tests for value of transferType.
	* gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestImage.java,
	*
gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestRaster.java,
	* gnu/testlet/java/awt/image/ConvolveOp/filterImage.java: New tests.
	* gnu/testlet/java/awt/image/ConvolveOp/filter.java: Renamed to
filterRaster.java.
	* gnu/testlet/java/awt/image/ConvolveOp/filterRaster.java: Renamed from
filter.java.


Index: gnu/testlet/java/awt/image/ConvolveOp/filter.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ConvolveOp/filter.java
diff -N gnu/testlet/java/awt/image/ConvolveOp/filter.java
--- gnu/testlet/java/awt/image/ConvolveOp/filter.java	19 Jul 2006 15:09:00 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,284 +0,0 @@
-/* filter.java -- some checks for the filter() methods in the ConvolveOp class.
-   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.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.4
-
-package gnu.testlet.java.awt.image.ConvolveOp;
-
-import gnu.testlet.TestHarness;
-import gnu.testlet.Testlet;
-
-import java.awt.image.ConvolveOp;
-import java.awt.image.DataBuffer;
-import java.awt.image.Kernel;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
-
-public class filter implements Testlet
-{
-  public void test(TestHarness harness)
-  {
-    testRaster1(harness);
-    testRaster2(harness);
-    testRaster3(harness);
-  }
-  
-  public void testRaster1(TestHarness harness)
-  {
-    harness.checkPoint("testRaster1()");
-    Raster src = createRasterA();
-    WritableRaster dest = src.createCompatibleWritableRaster();
-    Kernel k1 = new Kernel(1, 1, new float[] {1});
-    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
-    dest = op.filter(src, dest);
-    harness.check(dest.getSample(0, 0, 0), 1);
-    harness.check(dest.getSample(1, 0, 0), 2);
-    harness.check(dest.getSample(2, 0, 0), 3);
-    harness.check(dest.getSample(3, 0, 0), 4);
-    harness.check(dest.getSample(4, 0, 0), 5);
-    harness.check(dest.getSample(0, 1, 0), 6);
-    harness.check(dest.getSample(1, 1, 0), 7);
-    harness.check(dest.getSample(2, 1, 0), 8);
-    harness.check(dest.getSample(3, 1, 0), 9);
-    harness.check(dest.getSample(4, 1, 0), 10);
-    harness.check(dest.getSample(0, 2, 0), 11);
-    harness.check(dest.getSample(1, 2, 0), 12);
-    harness.check(dest.getSample(2, 2, 0), 13);
-    harness.check(dest.getSample(3, 2, 0), 14);
-    harness.check(dest.getSample(4, 2, 0), 15);
-    harness.check(dest.getSample(0, 3, 0), 16);
-    harness.check(dest.getSample(1, 3, 0), 17);
-    harness.check(dest.getSample(2, 3, 0), 18);
-    harness.check(dest.getSample(3, 3, 0), 19);
-    harness.check(dest.getSample(4, 3, 0), 20);
-
-    harness.check(dest.getSample(0, 0, 1), 11);
-    harness.check(dest.getSample(1, 0, 1), 12);
-    harness.check(dest.getSample(2, 0, 1), 13);
-    harness.check(dest.getSample(3, 0, 1), 14);
-    harness.check(dest.getSample(4, 0, 1), 15);
-    harness.check(dest.getSample(0, 1, 1), 16);
-    harness.check(dest.getSample(1, 1, 1), 17);
-    harness.check(dest.getSample(2, 1, 1), 18);
-    harness.check(dest.getSample(3, 1, 1), 19);
-    harness.check(dest.getSample(4, 1, 1), 20);
-    harness.check(dest.getSample(0, 2, 1), 21);
-    harness.check(dest.getSample(1, 2, 1), 22);
-    harness.check(dest.getSample(2, 2, 1), 23);
-    harness.check(dest.getSample(3, 2, 1), 24);
-    harness.check(dest.getSample(4, 2, 1), 25);
-    harness.check(dest.getSample(0, 3, 1), 26);
-    harness.check(dest.getSample(1, 3, 1), 27);
-    harness.check(dest.getSample(2, 3, 1), 28);
-    harness.check(dest.getSample(3, 3, 1), 29);
-    harness.check(dest.getSample(4, 3, 1), 30);
-
-    harness.check(dest.getSample(0, 0, 2), 21);
-    harness.check(dest.getSample(1, 0, 2), 22);
-    harness.check(dest.getSample(2, 0, 2), 23);
-    harness.check(dest.getSample(3, 0, 2), 24);
-    harness.check(dest.getSample(4, 0, 2), 25);
-    harness.check(dest.getSample(0, 1, 2), 26);
-    harness.check(dest.getSample(1, 1, 2), 27);
-    harness.check(dest.getSample(2, 1, 2), 28);
-    harness.check(dest.getSample(3, 1, 2), 29);
-    harness.check(dest.getSample(4, 1, 2), 30);
-    harness.check(dest.getSample(0, 2, 2), 31);
-    harness.check(dest.getSample(1, 2, 2), 32);
-    harness.check(dest.getSample(2, 2, 2), 33);
-    harness.check(dest.getSample(3, 2, 2), 34);
-    harness.check(dest.getSample(4, 2, 2), 35);
-    harness.check(dest.getSample(0, 3, 2), 36);
-    harness.check(dest.getSample(1, 3, 2), 37);
-    harness.check(dest.getSample(2, 3, 2), 38);
-    harness.check(dest.getSample(3, 3, 2), 39);
-    harness.check(dest.getSample(4, 3, 2), 40);
-  }
-    
-  public void testRaster2(TestHarness harness)
-  {
-    harness.checkPoint("testRaster2()");
-    Raster src = createRasterA();
-    WritableRaster dest = src.createCompatibleWritableRaster();
-    Kernel k1 = new Kernel(3, 3, new float[] {0,0,0,
-                                              0,1,0,
-                                              0,0,0});
-    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
-    dest = op.filter(src, dest);
-    harness.check(dest.getSample(0, 0, 0), 0);
-    harness.check(dest.getSample(1, 0, 0), 0);
-    harness.check(dest.getSample(2, 0, 0), 0);
-    harness.check(dest.getSample(3, 0, 0), 0);
-    harness.check(dest.getSample(4, 0, 0), 0);
-    harness.check(dest.getSample(0, 1, 0), 0);
-    harness.check(dest.getSample(1, 1, 0), 7);
-    harness.check(dest.getSample(2, 1, 0), 8);
-    harness.check(dest.getSample(3, 1, 0), 9);
-    harness.check(dest.getSample(4, 1, 0), 0);
-    harness.check(dest.getSample(0, 2, 0), 0);
-    harness.check(dest.getSample(1, 2, 0), 12);
-    harness.check(dest.getSample(2, 2, 0), 13);
-    harness.check(dest.getSample(3, 2, 0), 14);
-    harness.check(dest.getSample(4, 2, 0), 0);
-    harness.check(dest.getSample(0, 3, 0), 0);
-    harness.check(dest.getSample(1, 3, 0), 0);
-    harness.check(dest.getSample(2, 3, 0), 0);
-    harness.check(dest.getSample(3, 3, 0), 0);
-    harness.check(dest.getSample(4, 3, 0), 0);
-
-    harness.check(dest.getSample(0, 0, 1), 0);
-    harness.check(dest.getSample(1, 0, 1), 0);
-    harness.check(dest.getSample(2, 0, 1), 0);
-    harness.check(dest.getSample(3, 0, 1), 0);
-    harness.check(dest.getSample(4, 0, 1), 0);
-    harness.check(dest.getSample(0, 1, 1), 0);
-    harness.check(dest.getSample(1, 1, 1), 17);
-    harness.check(dest.getSample(2, 1, 1), 18);
-    harness.check(dest.getSample(3, 1, 1), 19);
-    harness.check(dest.getSample(4, 1, 1), 0);
-    harness.check(dest.getSample(0, 2, 1), 0);
-    harness.check(dest.getSample(1, 2, 1), 22);
-    harness.check(dest.getSample(2, 2, 1), 23);
-    harness.check(dest.getSample(3, 2, 1), 24);
-    harness.check(dest.getSample(4, 2, 1), 0);
-    harness.check(dest.getSample(0, 3, 1), 0);
-    harness.check(dest.getSample(1, 3, 1), 0);
-    harness.check(dest.getSample(2, 3, 1), 0);
-    harness.check(dest.getSample(3, 3, 1), 0);
-    harness.check(dest.getSample(4, 3, 1), 0);
-
-    harness.check(dest.getSample(0, 0, 2), 0);
-    harness.check(dest.getSample(1, 0, 2), 0);
-    harness.check(dest.getSample(2, 0, 2), 0);
-    harness.check(dest.getSample(3, 0, 2), 0);
-    harness.check(dest.getSample(4, 0, 2), 0);
-    harness.check(dest.getSample(0, 1, 2), 0);
-    harness.check(dest.getSample(1, 1, 2), 27);
-    harness.check(dest.getSample(2, 1, 2), 28);
-    harness.check(dest.getSample(3, 1, 2), 29);
-    harness.check(dest.getSample(4, 1, 2), 0);
-    harness.check(dest.getSample(0, 2, 2), 0);
-    harness.check(dest.getSample(1, 2, 2), 32);
-    harness.check(dest.getSample(2, 2, 2), 33);
-    harness.check(dest.getSample(3, 2, 2), 34);
-    harness.check(dest.getSample(4, 2, 2), 0);
-    harness.check(dest.getSample(0, 3, 2), 0);
-    harness.check(dest.getSample(1, 3, 2), 0);
-    harness.check(dest.getSample(2, 3, 2), 0);
-    harness.check(dest.getSample(3, 3, 2), 0);
-    harness.check(dest.getSample(4, 3, 2), 0);
-  }
-  
-  public void testRaster3(TestHarness harness)
-  {
-    harness.checkPoint("testRaster3()");
-    Raster src = createRasterA();
-    WritableRaster dest = src.createCompatibleWritableRaster();
-    Kernel k1 = new Kernel(3, 3, new float[] {0.1f,0.2f,0.3f,
-                                              0.4f,0.5f,0.6f,
-                                              0.7f,0.8f,0.9f});
-    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_NO_OP, null);
-    dest = op.filter(src, dest);
-    harness.check(dest.getSample(0, 0, 0), 1);
-    harness.check(dest.getSample(1, 0, 0), 2);
-    harness.check(dest.getSample(2, 0, 0), 3);
-    harness.check(dest.getSample(3, 0, 0), 4);
-    harness.check(dest.getSample(4, 0, 0), 5);
-    harness.check(dest.getSample(0, 1, 0), 6);
-    harness.check(dest.getSample(1, 1, 0), 21);
-    harness.check(dest.getSample(2, 1, 0), 26);
-    harness.check(dest.getSample(3, 1, 0), 30);
-    harness.check(dest.getSample(4, 1, 0), 10);
-    harness.check(dest.getSample(0, 2, 0), 11);
-    harness.check(dest.getSample(1, 2, 0), 44);
-    harness.check(dest.getSample(2, 2, 0), 48);
-    harness.check(dest.getSample(3, 2, 0), 53);
-    harness.check(dest.getSample(4, 2, 0), 15);
-    harness.check(dest.getSample(0, 3, 0), 16);
-    harness.check(dest.getSample(1, 3, 0), 17);
-    harness.check(dest.getSample(2, 3, 0), 18);
-    harness.check(dest.getSample(3, 3, 0), 19);
-    harness.check(dest.getSample(4, 3, 0), 20);
-
-    harness.check(dest.getSample(0, 0, 1), 11);
-    harness.check(dest.getSample(1, 0, 1), 12);
-    harness.check(dest.getSample(2, 0, 1), 13);
-    harness.check(dest.getSample(3, 0, 1), 14);
-    harness.check(dest.getSample(4, 0, 1), 15);
-    harness.check(dest.getSample(0, 1, 1), 16);
-    harness.check(dest.getSample(1, 1, 1), 66);
-    harness.check(dest.getSample(2, 1, 1), 71);
-    harness.check(dest.getSample(3, 1, 1), 75);
-    harness.check(dest.getSample(4, 1, 1), 20);
-    harness.check(dest.getSample(0, 2, 1), 21);
-    harness.check(dest.getSample(1, 2, 1), 89);
-    harness.check(dest.getSample(2, 2, 1), 93);
-    harness.check(dest.getSample(3, 2, 1), 98);
-    harness.check(dest.getSample(4, 2, 1), 25);
-    harness.check(dest.getSample(0, 3, 1), 26);
-    harness.check(dest.getSample(1, 3, 1), 27);
-    harness.check(dest.getSample(2, 3, 1), 28);
-    harness.check(dest.getSample(3, 3, 1), 29);
-    harness.check(dest.getSample(4, 3, 1), 30);
-
-    harness.check(dest.getSample(0, 0, 2), 21);
-    harness.check(dest.getSample(1, 0, 2), 22);
-    harness.check(dest.getSample(2, 0, 2), 23);
-    harness.check(dest.getSample(3, 0, 2), 24);
-    harness.check(dest.getSample(4, 0, 2), 25);
-    harness.check(dest.getSample(0, 1, 2), 26);
-    harness.check(dest.getSample(1, 1, 2), 111);
-    harness.check(dest.getSample(2, 1, 2), 116);
-    harness.check(dest.getSample(3, 1, 2), 120);
-    harness.check(dest.getSample(4, 1, 2), 30);
-    harness.check(dest.getSample(0, 2, 2), 31);
-    harness.check(dest.getSample(1, 2, 2), 134);
-    harness.check(dest.getSample(2, 2, 2), 138);
-    harness.check(dest.getSample(3, 2, 2), 143);
-    harness.check(dest.getSample(4, 2, 2), 35);
-    harness.check(dest.getSample(0, 3, 2), 36);
-    harness.check(dest.getSample(1, 3, 2), 37);
-    harness.check(dest.getSample(2, 3, 2), 38);
-    harness.check(dest.getSample(3, 3, 2), 39);
-    harness.check(dest.getSample(4, 3, 2), 40);
-  }
-
-  /**
-   * Creates a sample raster for testing.
-   * 
-   * @return A raster.
-   */
-  private Raster createRasterA()
-  {
-    WritableRaster r = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 5, 
-            4, 3, null);
-    for (int i = 0; i < 5; i++)
-      {
-        for (int j = 0; j < 4; j++)
-          {
-            r.setSample(i, j, 0, j * 5 + i + 1);
-            r.setSample(i, j, 1, j * 5 + i + 11);
-            r.setSample(i, j, 2, j * 5 + i + 21);
-          }
-      }
-    return r;
-  }
-}
Index: gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java,v
retrieving revision 1.2
diff -u -r1.2 createCompatibleDestImage.java
--- gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java	18 Aug 2006 19:46:56 -0000	1.2
+++ gnu/testlet/java/awt/image/ColorConvertOp/createCompatibleDestImage.java	24 Aug 2006 18:51:13 -0000
@@ -94,6 +94,8 @@
     harness.check(dest.getHeight(), 40);
     harness.check(dest.getWidth(), 25);
     harness.check(dest.getColorModel(), img.getColorModel());
+    harness.check(dest.getSampleModel().getTransferType(),
+                  img.getColorModel().getTransferType());
     
     // Try a different colour model
     img = new BufferedImage(25, 40, BufferedImage.TYPE_BYTE_GRAY);
@@ -103,12 +105,15 @@
     harness.check(dest.getHeight(), 40);
     harness.check(dest.getWidth(), 25);
     harness.check(dest.getColorModel(), cm);
+    harness.check(dest.getSampleModel().getTransferType(), cm.getTransferType());
 
     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());
+    harness.check(dest.getSampleModel().getTransferType(),
+                  img.getColorModel().getTransferType());
 
     // ColorConvertOp's ColorModel can be null, or createCompatibleDestImage's
     // ColorModel can be null, but not both
@@ -194,6 +199,9 @@
         harness.check(dest.getRaster().getNumBands(),
                       dest.getRaster().getNumDataElements());
         
+        harness.check(dest.getSampleModel().getTransferType(),
+                      DataBuffer.TYPE_BYTE);
+        
         // This ensures that we have the same defaults as the reference implementation
         switch (type)
         {
Index: gnu/testlet/java/awt/image/ConvolveOp/filterImage.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ConvolveOp/filterImage.java
diff -N gnu/testlet/java/awt/image/ConvolveOp/filterImage.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ConvolveOp/filterImage.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,386 @@
+/* filterImage.java -- some checks for the filter(Image) method of the
+              ConvolveOp 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.ConvolveOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Line2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ConvolveOp;
+import java.awt.image.Kernel;
+import java.awt.image.WritableRaster;
+
+/**
+ * Checks the filter(BufferedImage) method in the {@link ConvolveOp} 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)      
+  {
+    testDefaults(harness);
+    testFilter(harness);
+    testPremultiplied(harness);
+  }
+  
+  private void testDefaults(TestHarness harness)
+  {
+    harness.checkPoint("testDefaults");
+    
+    // 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));
+    
+    Kernel k1 = new Kernel(3, 3, new float[] {0.1f,0.2f,0.3f,
+                                              0.4f,0.5f,0.6f,
+                                              0.7f,0.8f,0.9f});
+    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
+    
+    // Src and dst images cannot be the same
+    try
+    {
+      op.filter(img, img);
+      harness.check(false);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(true);
+    }
+    
+    // Src and dst are different sizes (allowed)
+    BufferedImage dst = new BufferedImage(30, 40, BufferedImage.TYPE_USHORT_GRAY);
+    try
+    {
+      op.filter(img, dst);
+      harness.check(true);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Src and dst have different tpyes (allowed)
+    dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
+    try
+    {
+      //op.filter(img, dst);
+      harness.check(true);
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+  }
+  
+  private void testFilter(TestHarness harness)
+  {
+    harness.checkPoint("testFilter");
+    
+    // Create an image to work on
+    BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
+    WritableRaster r = img.getRaster();
+    for (int i = 0; i < r.getHeight(); i++)
+      for (int j = 0; j < r.getWidth(); j++)
+        {
+          r.setSample(j, i, 0, i * 5 + j * 8);
+          r.setSample(j, i, 1, (r.getHeight() - i) * 5 + (r.getWidth() - j) * 8);
+          r.setSample(j, i, 2, 150);
+          if (i > (r.getHeight() / 2) && j > (r.getWidth() / 2))
+            r.setSample(j, i, 3, 200);
+          else
+            r.setSample(j, i, 3, 0);
+        }
+    
+    Kernel k1 = new Kernel(3, 3, new float[] {0.2f,0.3f,0.5f,
+                                              0.4f,0.6f,0.7f,
+                                              0.6f,0.9f,0.8f});
+    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
+    
+    BufferedImage dst = op.filter(img, null);
+    WritableRaster dest = dst.getRaster();
+    
+    harness.check(img.isAlphaPremultiplied(), false);
+    harness.check(dst.isAlphaPremultiplied(), false);
+    
+    harness.check(dest.getSample(0, 0, 0), 0);
+    harness.check(dest.getSample(1, 0, 0), 0);
+    harness.check(dest.getSample(2, 0, 0), 0);
+    harness.check(dest.getSample(3, 0, 0), 0);
+    harness.check(dest.getSample(4, 0, 0), 0);
+    harness.check(dest.getSample(0, 1, 0), 0);
+    harness.check(dest.getSample(1, 1, 0), 52);
+    harness.check(dest.getSample(2, 1, 0), 92);
+    harness.check(dest.getSample(3, 1, 0), 132);
+    harness.check(dest.getSample(4, 1, 0), 0);
+    harness.check(dest.getSample(0, 2, 0), 0);
+    harness.check(dest.getSample(1, 2, 0), 77);
+    harness.check(dest.getSample(2, 2, 0), 117);
+    harness.check(dest.getSample(3, 2, 0), 157);
+    harness.check(dest.getSample(4, 2, 0), 0);
+    harness.check(dest.getSample(0, 3, 0), 0);
+    harness.check(dest.getSample(1, 3, 0), 102);
+    harness.check(dest.getSample(2, 3, 0), 142);
+    harness.check(dest.getSample(3, 3, 0), 182);
+    harness.check(dest.getSample(4, 3, 0), 0);
+    harness.check(dest.getSample(0, 4, 0), 0);
+    harness.check(dest.getSample(1, 4, 0), 0);
+    harness.check(dest.getSample(2, 4, 0), 0);
+    harness.check(dest.getSample(3, 4, 0), 0);
+    harness.check(dest.getSample(4, 4, 0), 0);
+    
+    harness.check(dest.getSample(0, 0, 1), 0);
+    harness.check(dest.getSample(1, 0, 1), 0);
+    harness.check(dest.getSample(2, 0, 1), 0);
+    harness.check(dest.getSample(3, 0, 1), 0);
+    harness.check(dest.getSample(4, 0, 1), 0);
+    harness.check(dest.getSample(0, 1, 1), 0);
+    harness.check(dest.getSample(1, 1, 1), 255);
+    harness.check(dest.getSample(2, 1, 1), 232);
+    harness.check(dest.getSample(3, 1, 1), 192);
+    harness.check(dest.getSample(4, 1, 1), 0);
+    harness.check(dest.getSample(0, 2, 1), 0);
+    harness.check(dest.getSample(1, 2, 1), 247);
+    harness.check(dest.getSample(2, 2, 1), 207);
+    harness.check(dest.getSample(3, 2, 1), 167);
+    harness.check(dest.getSample(4, 2, 1), 0);
+    harness.check(dest.getSample(0, 3, 1), 0);
+    harness.check(dest.getSample(1, 3, 1), 222);
+    harness.check(dest.getSample(2, 3, 1), 182);
+    harness.check(dest.getSample(3, 3, 1), 142);
+    harness.check(dest.getSample(4, 3, 1), 0);
+    harness.check(dest.getSample(0, 4, 1), 0);
+    harness.check(dest.getSample(1, 4, 1), 0);
+    harness.check(dest.getSample(2, 4, 1), 0);
+    harness.check(dest.getSample(3, 4, 1), 0);
+    harness.check(dest.getSample(4, 4, 1), 0);
+    
+    harness.check(dest.getSample(0, 0, 2), 0);
+    harness.check(dest.getSample(1, 0, 2), 0);
+    harness.check(dest.getSample(2, 0, 2), 0);
+    harness.check(dest.getSample(3, 0, 2), 0);
+    harness.check(dest.getSample(4, 0, 2), 0);
+    harness.check(dest.getSample(0, 1, 2), 0);
+    harness.check(dest.getSample(1, 1, 2), 255);
+    harness.check(dest.getSample(2, 1, 2), 255);
+    harness.check(dest.getSample(3, 1, 2), 255);
+    harness.check(dest.getSample(4, 1, 2), 0);
+    harness.check(dest.getSample(0, 2, 2), 0);
+    harness.check(dest.getSample(1, 2, 2), 255);
+    harness.check(dest.getSample(2, 2, 2), 255);
+    harness.check(dest.getSample(3, 2, 2), 255);
+    harness.check(dest.getSample(4, 2, 2), 0);
+    harness.check(dest.getSample(0, 3, 2), 0);
+    harness.check(dest.getSample(1, 3, 2), 255);
+    harness.check(dest.getSample(2, 3, 2), 255);
+    harness.check(dest.getSample(3, 3, 2), 255);
+    harness.check(dest.getSample(4, 3, 2), 0);
+    harness.check(dest.getSample(0, 4, 2), 0);
+    harness.check(dest.getSample(1, 4, 2), 0);
+    harness.check(dest.getSample(2, 4, 2), 0);
+    harness.check(dest.getSample(3, 4, 2), 0);
+    harness.check(dest.getSample(4, 4, 2), 0);
+    
+    harness.check(dest.getSample(0, 0, 3), 0);
+    harness.check(dest.getSample(1, 0, 3), 0);
+    harness.check(dest.getSample(2, 0, 3), 0);
+    harness.check(dest.getSample(3, 0, 3), 0);
+    harness.check(dest.getSample(4, 0, 3), 0);
+    harness.check(dest.getSample(0, 1, 3), 0);
+    harness.check(dest.getSample(1, 1, 3), 0);
+    harness.check(dest.getSample(2, 1, 3), 0);
+    harness.check(dest.getSample(3, 1, 3), 0);
+    harness.check(dest.getSample(4, 1, 3), 0);
+    harness.check(dest.getSample(0, 2, 3), 0);
+    harness.check(dest.getSample(1, 2, 3), 0);
+    harness.check(dest.getSample(2, 2, 3) - 39 >= 0      // allow rounding error
+                  && dest.getSample(2, 2, 3) - 39 <= 1);
+    harness.check(dest.getSample(3, 2, 3), 100);
+    harness.check(dest.getSample(4, 2, 3), 0);
+    harness.check(dest.getSample(0, 3, 3), 0);
+    harness.check(dest.getSample(1, 3, 3), 0);
+    harness.check(dest.getSample(2, 3, 3) - 119 >= 0     // allow rounding error
+                  && dest.getSample(2, 3, 3) - 119 <= 1);
+    harness.check(dest.getSample(3, 3, 3), 255);
+    harness.check(dest.getSample(4, 3, 3), 0);
+    harness.check(dest.getSample(0, 4, 3), 0);
+    harness.check(dest.getSample(1, 4, 3), 0);
+    harness.check(dest.getSample(2, 4, 3), 0);
+    harness.check(dest.getSample(3, 4, 3), 0);
+    harness.check(dest.getSample(4, 4, 3), 0);
+  }
+  
+  // Test the pre-multiplied alpha stuff
+  private void testPremultiplied(TestHarness harness)
+  {
+    harness.checkPoint("testPremultiplied");
+    
+    // Create an image to work on
+    BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB_PRE);
+    WritableRaster r = img.getRaster();
+    for (int i = 0; i < r.getHeight(); i++)
+      for (int j = 0; j < r.getWidth(); j++)
+        {
+          r.setSample(j, i, 0, i * 5 + j * 8);
+          r.setSample(j, i, 1, (r.getHeight() - i) * 5 + (r.getWidth() - j) * 8);
+          r.setSample(j, i, 2, 150);
+          if (i > (r.getHeight() / 2) && j > (r.getWidth() / 2))
+            r.setSample(j, i, 3, 200);
+          else
+            r.setSample(j, i, 3, 0);
+        }
+
+    Kernel k1 = new Kernel(3, 3, new float[] {0.2f,0.3f,0.5f,
+                                              0.4f,0.6f,0.7f,
+                                              0.6f,0.9f,0.8f});
+    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
+    
+    BufferedImage dst = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
+    
+    dst = op.filter(img, dst);
+    WritableRaster dest = dst.getRaster();
+    
+    harness.check(img.isAlphaPremultiplied(), true);
+    harness.check(dst.isAlphaPremultiplied(), false);
+
+    // The following test values are COMPLETELY IDENTICAL to those in
+    // testFilter, even though this does a premultiplied conversion and
+    // testFilter does not.  It seems that the reference implementation
+    // IGNORES the pre-multiplied status of images, contrary to the spec.
+    
+    harness.check(dest.getSample(0, 0, 0), 0);
+    harness.check(dest.getSample(1, 0, 0), 0);
+    harness.check(dest.getSample(2, 0, 0), 0);
+    harness.check(dest.getSample(3, 0, 0), 0);
+    harness.check(dest.getSample(4, 0, 0), 0);
+    harness.check(dest.getSample(0, 1, 0), 0);
+    harness.check(dest.getSample(1, 1, 0), 52);
+    harness.check(dest.getSample(2, 1, 0), 92);
+    harness.check(dest.getSample(3, 1, 0), 132);
+    harness.check(dest.getSample(4, 1, 0), 0);
+    harness.check(dest.getSample(0, 2, 0), 0);
+    harness.check(dest.getSample(1, 2, 0), 77);
+    harness.check(dest.getSample(2, 2, 0), 117);
+    harness.check(dest.getSample(3, 2, 0), 157);
+    harness.check(dest.getSample(4, 2, 0), 0);
+    harness.check(dest.getSample(0, 3, 0), 0);
+    harness.check(dest.getSample(1, 3, 0), 102);
+    harness.check(dest.getSample(2, 3, 0), 142);
+    harness.check(dest.getSample(3, 3, 0), 182);
+    harness.check(dest.getSample(4, 3, 0), 0);
+    harness.check(dest.getSample(0, 4, 0), 0);
+    harness.check(dest.getSample(1, 4, 0), 0);
+    harness.check(dest.getSample(2, 4, 0), 0);
+    harness.check(dest.getSample(3, 4, 0), 0);
+    harness.check(dest.getSample(4, 4, 0), 0);
+    
+    harness.check(dest.getSample(0, 0, 1), 0);
+    harness.check(dest.getSample(1, 0, 1), 0);
+    harness.check(dest.getSample(2, 0, 1), 0);
+    harness.check(dest.getSample(3, 0, 1), 0);
+    harness.check(dest.getSample(4, 0, 1), 0);
+    harness.check(dest.getSample(0, 1, 1), 0);
+    harness.check(dest.getSample(1, 1, 1), 255);
+    harness.check(dest.getSample(2, 1, 1), 232);
+    harness.check(dest.getSample(3, 1, 1), 192);
+    harness.check(dest.getSample(4, 1, 1), 0);
+    harness.check(dest.getSample(0, 2, 1), 0);
+    harness.check(dest.getSample(1, 2, 1), 247);
+    harness.check(dest.getSample(2, 2, 1), 207);
+    harness.check(dest.getSample(3, 2, 1), 167);
+    harness.check(dest.getSample(4, 2, 1), 0);
+    harness.check(dest.getSample(0, 3, 1), 0);
+    harness.check(dest.getSample(1, 3, 1), 222);
+    harness.check(dest.getSample(2, 3, 1), 182);
+    harness.check(dest.getSample(3, 3, 1), 142);
+    harness.check(dest.getSample(4, 3, 1), 0);
+    harness.check(dest.getSample(0, 4, 1), 0);
+    harness.check(dest.getSample(1, 4, 1), 0);
+    harness.check(dest.getSample(2, 4, 1), 0);
+    harness.check(dest.getSample(3, 4, 1), 0);
+    harness.check(dest.getSample(4, 4, 1), 0);
+    
+    harness.check(dest.getSample(0, 0, 2), 0);
+    harness.check(dest.getSample(1, 0, 2), 0);
+    harness.check(dest.getSample(2, 0, 2), 0);
+    harness.check(dest.getSample(3, 0, 2), 0);
+    harness.check(dest.getSample(4, 0, 2), 0);
+    harness.check(dest.getSample(0, 1, 2), 0);
+    harness.check(dest.getSample(1, 1, 2), 255);
+    harness.check(dest.getSample(2, 1, 2), 255);
+    harness.check(dest.getSample(3, 1, 2), 255);
+    harness.check(dest.getSample(4, 1, 2), 0);
+    harness.check(dest.getSample(0, 2, 2), 0);
+    harness.check(dest.getSample(1, 2, 2), 255);
+    harness.check(dest.getSample(2, 2, 2), 255);
+    harness.check(dest.getSample(3, 2, 2), 255);
+    harness.check(dest.getSample(4, 2, 2), 0);
+    harness.check(dest.getSample(0, 3, 2), 0);
+    harness.check(dest.getSample(1, 3, 2), 255);
+    harness.check(dest.getSample(2, 3, 2), 255);
+    harness.check(dest.getSample(3, 3, 2), 255);
+    harness.check(dest.getSample(4, 3, 2), 0);
+    harness.check(dest.getSample(0, 4, 2), 0);
+    harness.check(dest.getSample(1, 4, 2), 0);
+    harness.check(dest.getSample(2, 4, 2), 0);
+    harness.check(dest.getSample(3, 4, 2), 0);
+    harness.check(dest.getSample(4, 4, 2), 0);
+    
+    harness.check(dest.getSample(0, 0, 3), 0);
+    harness.check(dest.getSample(1, 0, 3), 0);
+    harness.check(dest.getSample(2, 0, 3), 0);
+    harness.check(dest.getSample(3, 0, 3), 0);
+    harness.check(dest.getSample(4, 0, 3), 0);
+    harness.check(dest.getSample(0, 1, 3), 0);
+    harness.check(dest.getSample(1, 1, 3), 0);
+    harness.check(dest.getSample(2, 1, 3), 0);
+    harness.check(dest.getSample(3, 1, 3), 0);
+    harness.check(dest.getSample(4, 1, 3), 0);
+    harness.check(dest.getSample(0, 2, 3), 0);
+    harness.check(dest.getSample(1, 2, 3), 0);
+    harness.check(dest.getSample(2, 2, 3) - 39 >= 0      // allow rounding error
+                  && dest.getSample(2, 2, 3) - 39 <= 1);
+    harness.check(dest.getSample(3, 2, 3), 100);
+    harness.check(dest.getSample(4, 2, 3), 0);
+    harness.check(dest.getSample(0, 3, 3), 0);
+    harness.check(dest.getSample(1, 3, 3), 0);
+    harness.check(dest.getSample(2, 3, 3) - 119 >= 0     // allow rounding error
+                  && dest.getSample(2, 3, 3) - 119 <= 1);
+    harness.check(dest.getSample(3, 3, 3), 255);
+    harness.check(dest.getSample(4, 3, 3), 0);
+    harness.check(dest.getSample(0, 4, 3), 0);
+    harness.check(dest.getSample(1, 4, 3), 0);
+    harness.check(dest.getSample(2, 4, 3), 0);
+    harness.check(dest.getSample(3, 4, 3), 0);
+    harness.check(dest.getSample(4, 4, 3), 0);
+  }
+}
+
Index: gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestImage.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestImage.java
diff -N gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestImage.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestImage.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,124 @@
+/* createCompatibleDestImage.java -- some checks for the
+       createCompatibleDestImage() method of the ConvolveOp 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.ConvolveOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.ConvolveOp;
+import java.awt.image.DirectColorModel;
+import java.awt.image.Kernel;
+
+/**
+ * Checks for the createCompatibleDestImage method in the
+ * {@link ConvolveOp} 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);
+    colorModelTest(harness);
+  }
+  
+  private void simpleTest(TestHarness harness)
+  {
+    harness.checkPoint("createCompatibleDestImage");
+
+    // Simple test
+    Kernel kern = new Kernel(3, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f});
+    ConvolveOp op = new ConvolveOp(kern, ConvolveOp.EDGE_NO_OP, 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_INT_RGB);
+    DirectColorModel cm = new DirectColorModel(16, 0x0f00, 0x00f0, 0x000f);
+    dest = op.createCompatibleDestImage(img, cm);
+    
+    harness.check(dest.getHeight(), 40);
+    harness.check(dest.getWidth(), 25);
+    harness.check(dest.getColorModel(), cm);
+  }
+  
+  // Test all the default color models
+  private void colorModelTest(TestHarness harness)
+  {
+    Kernel kern = new Kernel(3, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f});
+    ConvolveOp op = new ConvolveOp(kern, ConvolveOp.EDGE_NO_OP, 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("type: " + type);
+        
+        BufferedImage img = new BufferedImage(25, 40, type);
+        BufferedImage dest = op.createCompatibleDestImage(img, null);
+        
+        // Unlike most Ops, this one creates a clone of the original image
+        harness.check(dest.getColorModel().getPixelSize(),
+                      img.getColorModel().getPixelSize());
+
+        harness.check(dest.getColorModel().getClass() == img.getColorModel().getClass());
+        harness.check(dest.getSampleModel().getClass() == img.getSampleModel().getClass());
+        harness.check(dest.getColorModel().getNumComponents(), img.getColorModel().getNumComponents());
+        harness.check(dest.getColorModel().getTransparency(), img.getColorModel().getTransparency());
+        harness.check(dest.getColorModel().hasAlpha(), img.getColorModel().hasAlpha());
+        harness.check(dest.getColorModel().getTransferType(), img.getColorModel().getTransferType());
+        harness.check(dest.getColorModel().isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
+        harness.check(dest.getColorModel().getColorSpace().getType(), img.getColorModel().getColorSpace().getType());
+        harness.check(dest.getRaster().getNumBands(), img.getRaster().getNumBands());
+        harness.check(dest.getRaster().getNumDataElements(), img.getRaster().getNumDataElements());
+      }
+  }
+}
+
+
+ 
Index: gnu/testlet/java/awt/image/ConvolveOp/filterRaster.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ConvolveOp/filterRaster.java
diff -N gnu/testlet/java/awt/image/ConvolveOp/filterRaster.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ConvolveOp/filterRaster.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,285 @@
+/* filterRaster.java -- some checks for the filter() methods in the ConvolveOp class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.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.4
+
+package gnu.testlet.java.awt.image.ConvolveOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ConvolveOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Kernel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+public class filterRaster implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    testRaster1(harness);
+    testRaster2(harness);
+    testRaster3(harness);
+  }
+  
+  public void testRaster1(TestHarness harness)
+  {
+    harness.checkPoint("testRaster1()");
+    Raster src = createRasterA();
+    WritableRaster dest = src.createCompatibleWritableRaster();
+    Kernel k1 = new Kernel(1, 1, new float[] {1});
+    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
+    dest = op.filter(src, dest);
+    harness.check(dest.getSample(0, 0, 0), 1);
+    harness.check(dest.getSample(1, 0, 0), 2);
+    harness.check(dest.getSample(2, 0, 0), 3);
+    harness.check(dest.getSample(3, 0, 0), 4);
+    harness.check(dest.getSample(4, 0, 0), 5);
+    harness.check(dest.getSample(0, 1, 0), 6);
+    harness.check(dest.getSample(1, 1, 0), 7);
+    harness.check(dest.getSample(2, 1, 0), 8);
+    harness.check(dest.getSample(3, 1, 0), 9);
+    harness.check(dest.getSample(4, 1, 0), 10);
+    harness.check(dest.getSample(0, 2, 0), 11);
+    harness.check(dest.getSample(1, 2, 0), 12);
+    harness.check(dest.getSample(2, 2, 0), 13);
+    harness.check(dest.getSample(3, 2, 0), 14);
+    harness.check(dest.getSample(4, 2, 0), 15);
+    harness.check(dest.getSample(0, 3, 0), 16);
+    harness.check(dest.getSample(1, 3, 0), 17);
+    harness.check(dest.getSample(2, 3, 0), 18);
+    harness.check(dest.getSample(3, 3, 0), 19);
+    harness.check(dest.getSample(4, 3, 0), 20);
+
+    harness.check(dest.getSample(0, 0, 1), 11);
+    harness.check(dest.getSample(1, 0, 1), 12);
+    harness.check(dest.getSample(2, 0, 1), 13);
+    harness.check(dest.getSample(3, 0, 1), 14);
+    harness.check(dest.getSample(4, 0, 1), 15);
+    harness.check(dest.getSample(0, 1, 1), 16);
+    harness.check(dest.getSample(1, 1, 1), 17);
+    harness.check(dest.getSample(2, 1, 1), 18);
+    harness.check(dest.getSample(3, 1, 1), 19);
+    harness.check(dest.getSample(4, 1, 1), 20);
+    harness.check(dest.getSample(0, 2, 1), 21);
+    harness.check(dest.getSample(1, 2, 1), 22);
+    harness.check(dest.getSample(2, 2, 1), 23);
+    harness.check(dest.getSample(3, 2, 1), 24);
+    harness.check(dest.getSample(4, 2, 1), 25);
+    harness.check(dest.getSample(0, 3, 1), 26);
+    harness.check(dest.getSample(1, 3, 1), 27);
+    harness.check(dest.getSample(2, 3, 1), 28);
+    harness.check(dest.getSample(3, 3, 1), 29);
+    harness.check(dest.getSample(4, 3, 1), 30);
+
+    harness.check(dest.getSample(0, 0, 2), 21);
+    harness.check(dest.getSample(1, 0, 2), 22);
+    harness.check(dest.getSample(2, 0, 2), 23);
+    harness.check(dest.getSample(3, 0, 2), 24);
+    harness.check(dest.getSample(4, 0, 2), 25);
+    harness.check(dest.getSample(0, 1, 2), 26);
+    harness.check(dest.getSample(1, 1, 2), 27);
+    harness.check(dest.getSample(2, 1, 2), 28);
+    harness.check(dest.getSample(3, 1, 2), 29);
+    harness.check(dest.getSample(4, 1, 2), 30);
+    harness.check(dest.getSample(0, 2, 2), 31);
+    harness.check(dest.getSample(1, 2, 2), 32);
+    harness.check(dest.getSample(2, 2, 2), 33);
+    harness.check(dest.getSample(3, 2, 2), 34);
+    harness.check(dest.getSample(4, 2, 2), 35);
+    harness.check(dest.getSample(0, 3, 2), 36);
+    harness.check(dest.getSample(1, 3, 2), 37);
+    harness.check(dest.getSample(2, 3, 2), 38);
+    harness.check(dest.getSample(3, 3, 2), 39);
+    harness.check(dest.getSample(4, 3, 2), 40);
+  }
+    
+  public void testRaster2(TestHarness harness)
+  {
+    harness.checkPoint("testRaster2()");
+    Raster src = createRasterA();
+    WritableRaster dest = src.createCompatibleWritableRaster();
+    Kernel k1 = new Kernel(3, 3, new float[] {0,0,0,
+                                              0,1,0,
+                                              0,0,0});
+    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
+    dest = op.filter(src, dest);
+    harness.check(dest.getSample(0, 0, 0), 0);
+    harness.check(dest.getSample(1, 0, 0), 0);
+    harness.check(dest.getSample(2, 0, 0), 0);
+    harness.check(dest.getSample(3, 0, 0), 0);
+    harness.check(dest.getSample(4, 0, 0), 0);
+    harness.check(dest.getSample(0, 1, 0), 0);
+    harness.check(dest.getSample(1, 1, 0), 7);
+    harness.check(dest.getSample(2, 1, 0), 8);
+    harness.check(dest.getSample(3, 1, 0), 9);
+    harness.check(dest.getSample(4, 1, 0), 0);
+    harness.check(dest.getSample(0, 2, 0), 0);
+    harness.check(dest.getSample(1, 2, 0), 12);
+    harness.check(dest.getSample(2, 2, 0), 13);
+    harness.check(dest.getSample(3, 2, 0), 14);
+    harness.check(dest.getSample(4, 2, 0), 0);
+    harness.check(dest.getSample(0, 3, 0), 0);
+    harness.check(dest.getSample(1, 3, 0), 0);
+    harness.check(dest.getSample(2, 3, 0), 0);
+    harness.check(dest.getSample(3, 3, 0), 0);
+    harness.check(dest.getSample(4, 3, 0), 0);
+
+    harness.check(dest.getSample(0, 0, 1), 0);
+    harness.check(dest.getSample(1, 0, 1), 0);
+    harness.check(dest.getSample(2, 0, 1), 0);
+    harness.check(dest.getSample(3, 0, 1), 0);
+    harness.check(dest.getSample(4, 0, 1), 0);
+    harness.check(dest.getSample(0, 1, 1), 0);
+    harness.check(dest.getSample(1, 1, 1), 17);
+    harness.check(dest.getSample(2, 1, 1), 18);
+    harness.check(dest.getSample(3, 1, 1), 19);
+    harness.check(dest.getSample(4, 1, 1), 0);
+    harness.check(dest.getSample(0, 2, 1), 0);
+    harness.check(dest.getSample(1, 2, 1), 22);
+    harness.check(dest.getSample(2, 2, 1), 23);
+    harness.check(dest.getSample(3, 2, 1), 24);
+    harness.check(dest.getSample(4, 2, 1), 0);
+    harness.check(dest.getSample(0, 3, 1), 0);
+    harness.check(dest.getSample(1, 3, 1), 0);
+    harness.check(dest.getSample(2, 3, 1), 0);
+    harness.check(dest.getSample(3, 3, 1), 0);
+    harness.check(dest.getSample(4, 3, 1), 0);
+
+    harness.check(dest.getSample(0, 0, 2), 0);
+    harness.check(dest.getSample(1, 0, 2), 0);
+    harness.check(dest.getSample(2, 0, 2), 0);
+    harness.check(dest.getSample(3, 0, 2), 0);
+    harness.check(dest.getSample(4, 0, 2), 0);
+    harness.check(dest.getSample(0, 1, 2), 0);
+    harness.check(dest.getSample(1, 1, 2), 27);
+    harness.check(dest.getSample(2, 1, 2), 28);
+    harness.check(dest.getSample(3, 1, 2), 29);
+    harness.check(dest.getSample(4, 1, 2), 0);
+    harness.check(dest.getSample(0, 2, 2), 0);
+    harness.check(dest.getSample(1, 2, 2), 32);
+    harness.check(dest.getSample(2, 2, 2), 33);
+    harness.check(dest.getSample(3, 2, 2), 34);
+    harness.check(dest.getSample(4, 2, 2), 0);
+    harness.check(dest.getSample(0, 3, 2), 0);
+    harness.check(dest.getSample(1, 3, 2), 0);
+    harness.check(dest.getSample(2, 3, 2), 0);
+    harness.check(dest.getSample(3, 3, 2), 0);
+    harness.check(dest.getSample(4, 3, 2), 0);
+  }
+  
+  public void testRaster3(TestHarness harness)
+  {
+    harness.checkPoint("testRaster3()");
+    Raster src = createRasterA();
+    WritableRaster dest = src.createCompatibleWritableRaster();
+    Kernel k1 = new Kernel(3, 3, new float[] {0.1f,0.2f,0.3f,
+                                              0.4f,0.5f,0.6f,
+                                              0.7f,0.8f,0.9f});
+    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_NO_OP, null);
+    dest = op.filter(src, dest);
+    harness.check(dest.getSample(0, 0, 0), 1);
+    harness.check(dest.getSample(1, 0, 0), 2);
+    harness.check(dest.getSample(2, 0, 0), 3);
+    harness.check(dest.getSample(3, 0, 0), 4);
+    harness.check(dest.getSample(4, 0, 0), 5);
+    harness.check(dest.getSample(0, 1, 0), 6);
+    harness.check(dest.getSample(1, 1, 0), 21);
+    harness.check(dest.getSample(2, 1, 0), 26);
+    harness.check(dest.getSample(3, 1, 0), 30);
+    harness.check(dest.getSample(4, 1, 0), 10);
+    harness.check(dest.getSample(0, 2, 0), 11);
+    harness.check(dest.getSample(1, 2, 0), 44);
+    harness.check(dest.getSample(2, 2, 0), 48);
+    harness.check(dest.getSample(3, 2, 0), 53);
+    harness.check(dest.getSample(4, 2, 0), 15);
+    harness.check(dest.getSample(0, 3, 0), 16);
+    harness.check(dest.getSample(1, 3, 0), 17);
+    harness.check(dest.getSample(2, 3, 0), 18);
+    harness.check(dest.getSample(3, 3, 0), 19);
+    harness.check(dest.getSample(4, 3, 0), 20);
+
+    harness.check(dest.getSample(0, 0, 1), 11);
+    harness.check(dest.getSample(1, 0, 1), 12);
+    harness.check(dest.getSample(2, 0, 1), 13);
+    harness.check(dest.getSample(3, 0, 1), 14);
+    harness.check(dest.getSample(4, 0, 1), 15);
+    harness.check(dest.getSample(0, 1, 1), 16);
+    harness.check(dest.getSample(1, 1, 1), 66);
+    harness.check(dest.getSample(2, 1, 1), 71);
+    harness.check(dest.getSample(3, 1, 1), 75);
+    harness.check(dest.getSample(4, 1, 1), 20);
+    harness.check(dest.getSample(0, 2, 1), 21);
+    harness.check(dest.getSample(1, 2, 1), 89);
+    harness.check(dest.getSample(2, 2, 1), 93);
+    harness.check(dest.getSample(3, 2, 1), 98);
+    harness.check(dest.getSample(4, 2, 1), 25);
+    harness.check(dest.getSample(0, 3, 1), 26);
+    harness.check(dest.getSample(1, 3, 1), 27);
+    harness.check(dest.getSample(2, 3, 1), 28);
+    harness.check(dest.getSample(3, 3, 1), 29);
+    harness.check(dest.getSample(4, 3, 1), 30);
+
+    harness.check(dest.getSample(0, 0, 2), 21);
+    harness.check(dest.getSample(1, 0, 2), 22);
+    harness.check(dest.getSample(2, 0, 2), 23);
+    harness.check(dest.getSample(3, 0, 2), 24);
+    harness.check(dest.getSample(4, 0, 2), 25);
+    harness.check(dest.getSample(0, 1, 2), 26);
+    harness.check(dest.getSample(1, 1, 2), 111);
+    harness.check(dest.getSample(2, 1, 2), 116);
+    harness.check(dest.getSample(3, 1, 2), 120);
+    harness.check(dest.getSample(4, 1, 2), 30);
+    harness.check(dest.getSample(0, 2, 2), 31);
+    harness.check(dest.getSample(1, 2, 2), 134);
+    harness.check(dest.getSample(2, 2, 2), 138);
+    harness.check(dest.getSample(3, 2, 2), 143);
+    harness.check(dest.getSample(4, 2, 2), 35);
+    harness.check(dest.getSample(0, 3, 2), 36);
+    harness.check(dest.getSample(1, 3, 2), 37);
+    harness.check(dest.getSample(2, 3, 2), 38);
+    harness.check(dest.getSample(3, 3, 2), 39);
+
+    harness.check(dest.getSample(4, 3, 2), 40);
+  }
+
+  /**
+   * Creates a sample raster for testing.
+   * 
+   * @return A raster.
+   */
+  private Raster createRasterA()
+  {
+    WritableRaster r = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 5, 
+            4, 3, null);
+    for (int i = 0; i < 5; i++)
+      {
+        for (int j = 0; j < 4; j++)
+          {
+            r.setSample(i, j, 0, j * 5 + i + 1);
+            r.setSample(i, j, 1, j * 5 + i + 11);
+            r.setSample(i, j, 2, j * 5 + i + 21);
+          }
+      }
+    return r;
+  }
+}
Index: gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestRaster.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestRaster.java
diff -N gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestRaster.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ConvolveOp/createCompatibleDestRaster.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,102 @@
+/* createCompatibleDestRaster.java -- some checks for the
+              createCompatibleDestRaster() method of the ConvolveOp 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.ConvolveOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Point;
+import java.awt.image.ConvolveOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Kernel;
+import java.awt.image.Raster;
+
+/**
+ * Checks for the createCompatibleDestRaster method in the
+ * {@link ConvolveOp} 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");
+
+    // Simple test
+    Raster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 3, new Point(5, 5));
+    Kernel kern = new Kernel(3, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f});
+    ConvolveOp op = new ConvolveOp(kern, ConvolveOp.EDGE_NO_OP, null);
+    
+    try
+    {
+      Raster dst = op.createCompatibleDestRaster(src);
+      harness.check(dst.getHeight(), src.getHeight());
+      harness.check(dst.getWidth(), src.getWidth());
+      harness.check(dst.getNumBands(), src.getNumBands());
+      harness.check(dst.getTransferType(), src.getTransferType());
+      harness.check(dst.getDataBuffer().getDataType(), src.getDataBuffer().getDataType());
+      harness.check(dst.getNumDataElements(), src.getNumDataElements());
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Try a different type
+    src = Raster.createBandedRaster(DataBuffer.TYPE_BYTE, 25, 40, 3, new Point(5, 5));
+    try
+    {
+      Raster dst = op.createCompatibleDestRaster(src);
+      harness.check(dst.getNumBands(), src.getNumBands());
+      harness.check(dst.getTransferType(), src.getTransferType());
+      harness.check(dst.getDataBuffer().getDataType(), src.getDataBuffer().getDataType());
+      harness.check(dst.getNumDataElements(), src.getNumDataElements());
+    }
+    catch (IllegalArgumentException e)
+    {
+      harness.check(false);
+    }
+    
+    // Try a different number of bands
+    src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 5, new Point(5, 5));
+    try
+    {
+      Raster dst = op.createCompatibleDestRaster(src);
+      harness.check(dst.getNumBands(), src.getNumBands());
+      harness.check(dst.getTransferType(), src.getTransferType());
+      harness.check(dst.getDataBuffer().getDataType(), src.getDataBuffer().getDataType());
+      harness.check(dst.getNumDataElements(), src.getNumDataElements());
+    }
+    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]