[gui] Fix loop bounds in image Ops

Jerry Quinn jlquinn@optonline.net
Tue Nov 2 02:39:00 GMT 2004


2004-11-01  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/image/RescaleOp.java (BandCombineOp, ColorConvertOp,
	LookupOp, RescaleOp): Fix loop bounds.

Index: BandCombineOp.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/Attic/BandCombineOp.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- BandCombineOp.java	1 Nov 2004 04:27:15 -0000	1.1.2.1
+++ BandCombineOp.java	2 Nov 2004 02:36:56 -0000	1.1.2.2
@@ -97,8 +97,8 @@
      // Filter the pixels
      float[] spix = new float[matrix[0].length];
      float[] dpix = new float[matrix.length];
-    for (int y = src.getMinY(); y < src.getHeight() - src.getMinY(); y++)
-      for (int x = src.getMinX(); x < src.getWidth() - src.getMinX(); x++)
+    for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+      for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
        {
          // In case matrix rows have implicit translation
          spix[spix.length - 1] = 1.0f;
Index: ColorConvertOp.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/Attic/ColorConvertOp.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ColorConvertOp.java	28 Oct 2004 06:08:08 -0000	1.1.2.1
+++ ColorConvertOp.java	2 Nov 2004 02:36:56 -0000	1.1.2.2
@@ -300,16 +300,16 @@
          RenderingHints.VALUE_COLOR_RENDER_QUALITY)
      {
        // use cie for accuracy
-      for (int y = src.getMinY(); y < src.getHeight() - src.getMinY(); y++)
-        for (int x = src.getMinX(); x < src.getWidth() - src.getMinX(); x++)
+      for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+        for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
            dst.setPixel(x, y,
  		       dcs.fromCIEXYZ(scs.toCIEXYZ(src.getPixel(x, y, sbuf))));
      }
      else
      {
        // use rgb - it's probably faster
-      for (int y = src.getMinY(); y < src.getHeight() - src.getMinY(); y++)
-        for (int x = src.getMinX(); x < src.getWidth() - src.getMinX(); x++)
+      for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+        for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
            dst.setPixel(x, y,
  		       dcs.fromRGB(scs.toRGB(src.getPixel(x, y, sbuf))));
      }
Index: LookupOp.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/Attic/LookupOp.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- LookupOp.java	1 Nov 2004 00:11:49 -0000	1.1.2.1
+++ LookupOp.java	2 Nov 2004 02:36:56 -0000	1.1.2.2
@@ -113,8 +113,8 @@
        int[] tmp = new int[tmpBands];

        // Filter the pixels
-      for (int y = src.getMinY(); y < src.getHeight() - src.getMinY(); y++)
-        for (int x = src.getMinX(); x < src.getWidth() - src.getMinX(); x++)
+      for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+        for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
          {	
            // Filter only color components, but also copy alpha
            sr.getPixel(x, y, dbuf);
@@ -131,8 +131,8 @@
      int[] dbuf = new int[src.getColorModel().getNumComponents()];

      // Filter the pixels
-    for (int y = src.getMinY(); y < src.getHeight() - src.getMinY(); y++)
-      for (int x = src.getMinX(); x < src.getWidth() - src.getMinX(); x++)
+    for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+      for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
          dr.setPixel(x, y, lut.lookupPixel(sr.getPixel(x, y, dbuf), dbuf));

      if (tgt != dst)
@@ -226,8 +226,8 @@
      int[] tmp = new int[src.getNumBands()];

      // Filter the pixels
-    for (int y = src.getMinY(); y < src.getHeight() - src.getMinY(); y++)
-      for (int x = src.getMinX(); x < src.getWidth() - src.getMinX(); x++)
+    for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+      for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
          dest.setPixel(x, y, lut.lookupPixel(src.getPixel(x, y, tmp), tmp));
      return dest;
    }
Index: RescaleOp.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/Attic/RescaleOp.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- RescaleOp.java	29 Sep 2004 02:08:47 -0000	1.1.2.2
+++ RescaleOp.java	2 Nov 2004 02:36:56 -0000	1.1.2.3
@@ -158,8 +158,8 @@
      // TODO The efficiency here can be improved for various data storage
      // patterns, aka SampleModels.
      float[] pixel = new float[src.numBands];
-    for (int y = src.minY; y < src.height- src.minY; y++)
-      for (int x = src.minX; x < src.width - src.minX; x++)
+    for (int y = src.minY; y < src.height + src.minY; y++)
+      for (int x = src.minX; x < src.width + src.minX; x++)
  	{
  	  src.getPixel(x, y, pixel);
  	  for (int b = 0; b < src.numBands; b++)



More information about the Java-patches mailing list