You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by dv...@apache.org on 2007/05/14 20:23:16 UTC

svn commit: r537934 - /xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java

Author: dvholten
Date: Mon May 14 11:23:15 2007
New Revision: 537934

URL: http://svn.apache.org/viewvc?view=rev&rev=537934
Log:
fix some strange indexes

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java?view=diff&rev=537934&r1=537933&r2=537934
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java Mon May 14 11:23:15 2007
@@ -39,13 +39,14 @@
  * new image.
  *
  * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id$ */
+ * @version $Id$
+ */
 public class Any2sRGBRed extends AbstractRed {
 
     boolean srcIsLsRGB = false;
 
     /**
-     * Construct a luminace image from src.
+     * Construct a luminance image from src.
      *
      * @param src The image to convert to a luminance image
      */
@@ -96,6 +97,7 @@
      * be on the sRGB scale to begin with.
      */
     private static final int[] linearToSRGBLut = new int[256];
+
     static {
         final double scale = 1.0/255;
         final double exp   = 1.0/GAMMA;
@@ -107,7 +109,7 @@
             else
                 value = 1.055 * Math.pow(value, exp) - 0.055;
 
-            linearToSRGBLut[i] = (int)Math.round(value*255.);
+            linearToSRGBLut[i] = (int)Math.round(value*255.0);
             // System.out.print(linearToSRGBLut[i] + ",");
         }
         // System.out.println("");
@@ -184,7 +186,7 @@
                 matrix = new float[4][2];
                 matrix[0][0] = 1; // Red
                 matrix[1][0] = 1; // Grn
-                matrix[3][0] = 1; // Blu
+                matrix[2][0] = 1; // Blu
                 matrix[3][1] = 1; // Alpha
                 break;
             case 3:
@@ -215,26 +217,26 @@
             // many things use this when the data _really_
             // has sRGB gamma applied.
             try {
-            float [][] matrix = null;
-            switch (srcSM.getNumBands()) {
-            case 1:
-                matrix = new float[3][1];
-                matrix[0][0] = 1; // Red
-                matrix[1][0] = 1; // Grn
-                matrix[2][0] = 1; // Blu
-                break;
-            case 2:
-            default:
-                matrix = new float[4][2];
-                matrix[0][0] = 1; // Red
-                matrix[1][0] = 1; // Grn
-                matrix[3][0] = 1; // Blu
-                matrix[4][1] = 1; // Alpha
-                break;
-            }
-            Raster srcRas = src.getData(wr.getBounds());
-            BandCombineOp op = new BandCombineOp(matrix, null);
-            op.filter(srcRas, wr);
+                float [][] matrix = null;
+                switch (srcSM.getNumBands()) {
+                case 1:
+                    matrix = new float[3][1];
+                    matrix[0][0] = 1; // Red
+                    matrix[1][0] = 1; // Grn
+                    matrix[2][0] = 1; // Blu
+                    break;
+                case 2:
+                default:
+                    matrix = new float[4][2];
+                    matrix[0][0] = 1; // Red
+                    matrix[1][0] = 1; // Grn
+                    matrix[2][0] = 1; // Blu
+                    matrix[3][1] = 1; // Alpha
+                    break;
+                }
+                Raster srcRas = src.getData(wr.getBounds());
+                BandCombineOp op = new BandCombineOp(matrix, null);
+                op.filter(srcRas, wr);
             } catch (Throwable t) {
                 t.printStackTrace();
             }
@@ -289,11 +291,11 @@
         return wr;
     }
 
-        /**
-         * This function 'fixes' the source's color model.  Right now
-         * it just selects if it should have one or two bands based on
-         * if the source had an alpha channel.
-         */
+    /**
+     * This function 'fixes' the source's color model.  Right now
+     * it just selects if it should have one or two bands based on
+     * if the source had an alpha channel.
+     */
     protected static ColorModel fixColorModel(CachableRed src) {
         ColorModel  cm = src.getColorModel();
         if (cm != null) {