commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1417043 [10/21] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/color/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ ...
Date Tue, 04 Dec 2012 17:24:32 GMT
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Tue Dec  4 17:23:16 2012
@@ -95,8 +95,8 @@ public class PngImageParser extends Imag
 
     // private final static int tRNS = CharsToQuad('t', 'R', 'N', 's');
 
-    public static final String getChunkTypeName(int chunkType) {
-        StringBuilder result = new StringBuilder();
+    public static final String getChunkTypeName(final int chunkType) {
+        final StringBuilder result = new StringBuilder();
         result.append((char) (0xff & (chunkType >> 24)));
         result.append((char) (0xff & (chunkType >> 16)));
         result.append((char) (0xff & (chunkType >> 8)));
@@ -107,18 +107,18 @@ public class PngImageParser extends Imag
     /**
      * @return List of String-formatted chunk types, ie. "tRNs".
      */
-    public List<String> getChuckTypes(InputStream is)
+    public List<String> getChuckTypes(final InputStream is)
             throws ImageReadException, IOException {
-        List<PngChunk> chunks = readChunks(is, null, false);
-        List<String> chunkTypes = new ArrayList<String>();
+        final List<PngChunk> chunks = readChunks(is, null, false);
+        final List<String> chunkTypes = new ArrayList<String>();
         for (int i = 0; i < chunks.size(); i++) {
-            PngChunk chunk = chunks.get(i);
+            final PngChunk chunk = chunks.get(i);
             chunkTypes.add(getChunkTypeName(chunk.chunkType));
         }
         return chunkTypes;
     }
 
-    public boolean hasChuckType(ByteSource byteSource, int chunkType)
+    public boolean hasChuckType(final ByteSource byteSource, final int chunkType)
             throws ImageReadException, IOException {
         InputStream is = null;
 
@@ -135,19 +135,19 @@ public class PngImageParser extends Imag
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 Debug.debug(e);
             }
         }
     }
 
-    private boolean keepChunk(int ChunkType, int chunkTypes[]) {
+    private boolean keepChunk(final int ChunkType, final int chunkTypes[]) {
         // System.out.println("keepChunk: ");
         if (chunkTypes == null) {
             return true;
         }
 
-        for (int chunkType2 : chunkTypes) {
+        for (final int chunkType2 : chunkTypes) {
             if (chunkType2 == ChunkType) {
                 return true;
             }
@@ -155,23 +155,23 @@ public class PngImageParser extends Imag
         return false;
     }
 
-    private List<PngChunk> readChunks(InputStream is, int chunkTypes[],
-            boolean returnAfterFirst) throws ImageReadException, IOException {
-        List<PngChunk> result = new ArrayList<PngChunk>();
+    private List<PngChunk> readChunks(final InputStream is, final int chunkTypes[],
+            final boolean returnAfterFirst) throws ImageReadException, IOException {
+        final List<PngChunk> result = new ArrayList<PngChunk>();
 
         while (true) {
             if (debug) {
                 System.out.println("");
             }
 
-            int length = read4Bytes("Length", is, "Not a Valid PNG File");
-            int chunkType = read4Bytes("ChunkType", is, "Not a Valid PNG File");
+            final int length = read4Bytes("Length", is, "Not a Valid PNG File");
+            final int chunkType = read4Bytes("ChunkType", is, "Not a Valid PNG File");
 
             if (debug) {
                 printCharQuad("ChunkType", chunkType);
                 debugNumber("Length", length, 4);
             }
-            boolean keep = keepChunk(chunkType, chunkTypes);
+            final boolean keep = keepChunk(chunkType, chunkTypes);
 
             byte bytes[] = null;
             if (keep) {
@@ -187,7 +187,7 @@ public class PngImageParser extends Imag
                 }
             }
 
-            int CRC = read4Bytes("CRC", is, "Not a Valid PNG File");
+            final int CRC = read4Bytes("CRC", is, "Not a Valid PNG File");
 
             if (keep) {
                 if (chunkType == iCCP) {
@@ -227,15 +227,15 @@ public class PngImageParser extends Imag
 
     }
 
-    public void readSignature(InputStream is) throws ImageReadException,
+    public void readSignature(final InputStream is) throws ImageReadException,
             IOException {
         readAndVerifyBytes(is, PNG_Signature,
                 "Not a Valid PNG Segment: Incorrect Signature");
 
     }
 
-    private List<PngChunk> readChunks(ByteSource byteSource, int chunkTypes[],
-            boolean returnAfterFirst) throws ImageReadException, IOException {
+    private List<PngChunk> readChunks(final ByteSource byteSource, final int chunkTypes[],
+            final boolean returnAfterFirst) throws ImageReadException, IOException {
         InputStream is = null;
 
         try {
@@ -249,16 +249,16 @@ public class PngImageParser extends Imag
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 Debug.debug(e);
             }
         }
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource, Map<String,Object> params)
+    public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        List<PngChunk> chunks = readChunks(byteSource, new int[] { iCCP, },
+        final List<PngChunk> chunks = readChunks(byteSource, new int[] { iCCP, },
                 true);
 
         if ((chunks == null) || (chunks.size() < 1)) {
@@ -271,16 +271,16 @@ public class PngImageParser extends Imag
                     "PNG contains more than one ICC Profile ");
         }
 
-        PngChunkIccp pngChunkiCCP = (PngChunkIccp) chunks.get(0);
-        byte bytes[] = pngChunkiCCP.UncompressedProfile;
+        final PngChunkIccp pngChunkiCCP = (PngChunkIccp) chunks.get(0);
+        final byte bytes[] = pngChunkiCCP.UncompressedProfile;
 
         return (bytes);
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource, Map<String,Object> params)
+    public Dimension getImageSize(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, },
+        final List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, },
                 true);
 
         if ((chunks == null) || (chunks.size() < 1)) {
@@ -291,34 +291,34 @@ public class PngImageParser extends Imag
             throw new ImageReadException("PNG contains more than one Header");
         }
 
-        PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) chunks.get(0);
+        final PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) chunks.get(0);
 
         return new Dimension(pngChunkIHDR.width, pngChunkIHDR.height);
     }
 
-    public byte[] embedICCProfile(byte image[], byte profile[]) {
+    public byte[] embedICCProfile(final byte image[], final byte profile[]) {
         return null;
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[]) {
+    public boolean embedICCProfile(final File src, final File dst, final byte profile[]) {
         return false;
     }
 
     @Override
-    public IImageMetadata getMetadata(ByteSource byteSource, Map<String,Object> params)
+    public IImageMetadata getMetadata(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        List<PngChunk> chunks = readChunks(byteSource,
+        final List<PngChunk> chunks = readChunks(byteSource,
                 new int[] { tEXt, zTXt, }, true);
 
         if ((chunks == null) || (chunks.size() < 1)) {
             return null;
         }
 
-        ImageMetadata result = new ImageMetadata();
+        final ImageMetadata result = new ImageMetadata();
 
         for (int i = 0; i < chunks.size(); i++) {
-            PngTextChunk chunk = (PngTextChunk) chunks.get(i);
+            final PngTextChunk chunk = (PngTextChunk) chunks.get(i);
 
             result.add(chunk.getKeyword(), chunk.getText());
         }
@@ -326,7 +326,7 @@ public class PngImageParser extends Imag
         return result;
     }
 
-    private boolean isGrayscale(int colorType) throws ImageReadException {
+    private boolean isGrayscale(final int colorType) throws ImageReadException {
         // Color type is a single-byte integer that describes the interpretation
         // of the
         // image data. Color type codes represent sums of the following values:
@@ -372,7 +372,7 @@ public class PngImageParser extends Imag
         throw new ImageReadException("PNG: unknown color type: " + colorType);
     }
 
-    private int samplesPerPixel(int colorType) throws ImageReadException {
+    private int samplesPerPixel(final int colorType) throws ImageReadException {
         // Color type is a single-byte integer that describes the interpretation
         // of the
         // image data. Color type codes represent sums of the following values:
@@ -418,11 +418,11 @@ public class PngImageParser extends Imag
         throw new ImageReadException("PNG: unknown color type: " + colorType);
     }
 
-    private List<PngChunk> filterChunks(List<PngChunk> v, int type) {
-        List<PngChunk> result = new ArrayList<PngChunk>();
+    private List<PngChunk> filterChunks(final List<PngChunk> v, final int type) {
+        final List<PngChunk> result = new ArrayList<PngChunk>();
 
         for (int i = 0; i < v.size(); i++) {
-            PngChunk chunk = v.get(i);
+            final PngChunk chunk = v.get(i);
             if (chunk.chunkType == type) {
                 result.add(chunk);
             }
@@ -431,7 +431,7 @@ public class PngImageParser extends Imag
         return result;
     }
 
-    private boolean hasAlphaChannel(int ColorType) throws ImageReadException {
+    private boolean hasAlphaChannel(final int ColorType) throws ImageReadException {
         switch (ColorType) {
         case COLOR_TYPE_GREYSCALE: // 1,2,4,8,16 Each pixel is a grayscale
             // sample.
@@ -451,7 +451,7 @@ public class PngImageParser extends Imag
         }
     }
 
-    private String getColorTypeDescription(int ColorType) {
+    private String getColorTypeDescription(final int ColorType) {
         switch (ColorType) {
         case COLOR_TYPE_GREYSCALE: // 1,2,4,8,16 Each pixel is a grayscale
             // sample.
@@ -477,8 +477,8 @@ public class PngImageParser extends Imag
     // BinaryFileParser
     // I may not have always preserved byte order correctly.
 
-    private TransparencyFilter getTransparencyFilter(int ColorType,
-            PngChunk pngChunktRNS) throws ImageReadException, IOException {
+    private TransparencyFilter getTransparencyFilter(final int ColorType,
+            final PngChunk pngChunktRNS) throws ImageReadException, IOException {
         // this.printCharQuad("pngChunktRNS.ChunkType", pngChunktRNS.ChunkType);
         // this.debugNumber("pngChunktRNS.Length", pngChunktRNS.Length);
 
@@ -502,9 +502,9 @@ public class PngImageParser extends Imag
     }
 
     @Override
-    public ImageInfo getImageInfo(ByteSource byteSource, Map<String,Object> params)
+    public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, pHYs,
+        final List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, pHYs,
                 tEXt, zTXt, tRNS, PLTE, iTXt, }, false);
 
         // if(chunks!=null)
@@ -514,16 +514,16 @@ public class PngImageParser extends Imag
             throw new ImageReadException("PNG: no chunks");
         }
 
-        List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
+        final List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
         if (IHDRs.size() != 1) {
             throw new ImageReadException("PNG contains more than one Header");
         }
 
-        PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
+        final PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
 
         boolean isTransparent = false;
 
-        List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
+        final List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
         if (tRNSs.size() > 0) {
             isTransparent = true;
         } else {
@@ -534,7 +534,7 @@ public class PngImageParser extends Imag
 
         PngChunkPhys pngChunkpHYs = null;
 
-        List<PngChunk> pHYss = filterChunks(chunks, pHYs);
+        final List<PngChunk> pHYss = filterChunks(chunks, pHYs);
         if (pHYss.size() > 1) {
             throw new ImageReadException("PNG contains more than one pHYs: "
                     + pHYss.size());
@@ -542,38 +542,38 @@ public class PngImageParser extends Imag
             pngChunkpHYs = (PngChunkPhys) pHYss.get(0);
         }
 
-        List<PngChunk> tEXts = filterChunks(chunks, tEXt);
-        List<PngChunk> zTXts = filterChunks(chunks, zTXt);
-        List<PngChunk> iTXts = filterChunks(chunks, iTXt);
+        final List<PngChunk> tEXts = filterChunks(chunks, tEXt);
+        final List<PngChunk> zTXts = filterChunks(chunks, zTXt);
+        final List<PngChunk> iTXts = filterChunks(chunks, iTXt);
 
-        List<String> comments = new ArrayList<String>();
-        List<PngText> textChunks = new ArrayList<PngText>();
+        final List<String> comments = new ArrayList<String>();
+        final List<PngText> textChunks = new ArrayList<PngText>();
 
         for (int i = 0; i < tEXts.size(); i++) {
-            PngChunkText pngChunktEXt = (PngChunkText) tEXts.get(i);
+            final PngChunkText pngChunktEXt = (PngChunkText) tEXts.get(i);
             comments.add(pngChunktEXt.keyword + ": " + pngChunktEXt.text);
             textChunks.add(pngChunktEXt.getContents());
         }
         for (int i = 0; i < zTXts.size(); i++) {
-            PngChunkZtxt pngChunkzTXt = (PngChunkZtxt) zTXts.get(i);
+            final PngChunkZtxt pngChunkzTXt = (PngChunkZtxt) zTXts.get(i);
             comments.add(pngChunkzTXt.keyword + ": " + pngChunkzTXt.text);
             textChunks.add(pngChunkzTXt.getContents());
         }
         for (int i = 0; i < iTXts.size(); i++) {
-            PngChunkItxt pngChunkiTXt = (PngChunkItxt) iTXts.get(i);
+            final PngChunkItxt pngChunkiTXt = (PngChunkItxt) iTXts.get(i);
             comments.add(pngChunkiTXt.keyword + ": " + pngChunkiTXt.text);
             textChunks.add(pngChunkiTXt.getContents());
         }
 
-        int BitsPerPixel = pngChunkIHDR.bitDepth
+        final int BitsPerPixel = pngChunkIHDR.bitDepth
                 * samplesPerPixel(pngChunkIHDR.colorType);
-        ImageFormat Format = ImageFormat.IMAGE_FORMAT_PNG;
-        String FormatName = "PNG Portable Network Graphics";
-        int Height = pngChunkIHDR.height;
-        String MimeType = "image/png";
-        int NumberOfImages = 1;
-        int Width = pngChunkIHDR.width;
-        boolean isProgressive = (pngChunkIHDR.interlaceMethod != 0);
+        final ImageFormat Format = ImageFormat.IMAGE_FORMAT_PNG;
+        final String FormatName = "PNG Portable Network Graphics";
+        final int Height = pngChunkIHDR.height;
+        final String MimeType = "image/png";
+        final int NumberOfImages = 1;
+        final int Width = pngChunkIHDR.width;
+        final boolean isProgressive = (pngChunkIHDR.interlaceMethod != 0);
 
         int PhysicalHeightDpi = -1;
         float PhysicalHeightInch = -1;
@@ -590,7 +590,7 @@ public class PngImageParser extends Imag
         // pngChunkpHYs.PixelsPerUnitXAxis );
         // }
         if ((pngChunkpHYs != null) && (pngChunkpHYs.UnitSpecifier == 1)) { // meters
-            double meters_per_inch = 0.0254;
+            final double meters_per_inch = 0.0254;
 
             PhysicalWidthDpi = (int) Math
                     .round(pngChunkpHYs.PixelsPerUnitXAxis
@@ -602,11 +602,11 @@ public class PngImageParser extends Imag
             PhysicalHeightInch = (float) (Height / (pngChunkpHYs.PixelsPerUnitYAxis * meters_per_inch));
         }
 
-        String FormatDetails = "Png";
+        final String FormatDetails = "Png";
 
         boolean usesPalette = false;
 
-        List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
+        final List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
         if (PLTEs.size() > 1) {
             usesPalette = true;
         }
@@ -633,7 +633,7 @@ public class PngImageParser extends Imag
                     + pngChunkIHDR.colorType);
         }
 
-        String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_PNG_FILTER;
+        final String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_PNG_FILTER;
 
         return new PngImageInfo(FormatDetails, BitsPerPixel, comments,
                 Format, FormatName, Height, MimeType, NumberOfImages,
@@ -643,7 +643,7 @@ public class PngImageParser extends Imag
     }
 
     @Override
-    public BufferedImage getBufferedImage(ByteSource byteSource, Map<String,Object> params)
+    public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
         ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);
 
@@ -656,21 +656,21 @@ public class PngImageParser extends Imag
         // throw new ImageWriteException("Unknown parameter: " + firstKey);
         // }
 
-        List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, PLTE,
+        final List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, PLTE,
                 IDAT, tRNS, iCCP, gAMA, sRGB, }, false);
 
         if ((chunks == null) || (chunks.size() < 1)) {
             throw new ImageReadException("PNG: no chunks");
         }
 
-        List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
+        final List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
         if (IHDRs.size() != 1) {
             throw new ImageReadException("PNG contains more than one Header");
         }
 
-        PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
+        final PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
 
-        List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
+        final List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
         if (PLTEs.size() > 1) {
             throw new ImageReadException("PNG contains more than one Palette");
         }
@@ -682,28 +682,28 @@ public class PngImageParser extends Imag
 
         // -----
 
-        List<PngChunk> IDATs = filterChunks(chunks, IDAT);
+        final List<PngChunk> IDATs = filterChunks(chunks, IDAT);
         if (IDATs.size() < 1) {
             throw new ImageReadException("PNG missing image data");
         }
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         for (int i = 0; i < IDATs.size(); i++) {
-            PngChunkIdat pngChunkIDAT = (PngChunkIdat) IDATs.get(i);
-            byte bytes[] = pngChunkIDAT.bytes;
+            final PngChunkIdat pngChunkIDAT = (PngChunkIdat) IDATs.get(i);
+            final byte bytes[] = pngChunkIDAT.bytes;
             // System.out.println(i + ": bytes: " + bytes.length);
             baos.write(bytes);
         }
 
-        byte compressed[] = baos.toByteArray();
+        final byte compressed[] = baos.toByteArray();
 
         baos = null;
 
         TransparencyFilter transparencyFilter = null;
 
-        List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
+        final List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
         if (tRNSs.size() > 0) {
-            PngChunk pngChunktRNS = tRNSs.get(0);
+            final PngChunk pngChunktRNS = tRNSs.get(0);
             transparencyFilter = getTransparencyFilter(pngChunkIHDR.colorType,
                     pngChunktRNS);
         }
@@ -711,9 +711,9 @@ public class PngImageParser extends Imag
         ICC_Profile icc_profile = null;
         GammaCorrection gammaCorrection = null;
         {
-            List<PngChunk> sRGBs = filterChunks(chunks, sRGB);
-            List<PngChunk> gAMAs = filterChunks(chunks, gAMA);
-            List<PngChunk> iCCPs = filterChunks(chunks, iCCP);
+            final List<PngChunk> sRGBs = filterChunks(chunks, sRGB);
+            final List<PngChunk> gAMAs = filterChunks(chunks, gAMA);
+            final List<PngChunk> iCCPs = filterChunks(chunks, iCCP);
             if (sRGBs.size() > 1) {
                 throw new ImageReadException("PNG: unexpected sRGB chunk");
             }
@@ -734,18 +734,18 @@ public class PngImageParser extends Imag
                     System.out.println("iCCP.");
                 }
 
-                PngChunkIccp pngChunkiCCP = (PngChunkIccp) iCCPs.get(0);
-                byte bytes[] = pngChunkiCCP.UncompressedProfile;
+                final PngChunkIccp pngChunkiCCP = (PngChunkIccp) iCCPs.get(0);
+                final byte bytes[] = pngChunkiCCP.UncompressedProfile;
 
                 icc_profile = ICC_Profile.getInstance(bytes);
             } else if (gAMAs.size() == 1) {
-                PngChunkGama pngChunkgAMA = (PngChunkGama) gAMAs.get(0);
-                double gamma = pngChunkgAMA.getGamma();
+                final PngChunkGama pngChunkgAMA = (PngChunkGama) gAMAs.get(0);
+                final double gamma = pngChunkgAMA.getGamma();
 
                 // charles: what is the correct target value here?
                 // double targetGamma = 2.2;
-                double targetGamma = 1.0;
-                double diff = Math.abs(targetGamma - gamma);
+                final double targetGamma = 1.0;
+                final double diff = Math.abs(targetGamma - gamma);
                 if (diff >= 0.5) {
                     gammaCorrection = new GammaCorrection(gamma, targetGamma);
                 }
@@ -760,24 +760,24 @@ public class PngImageParser extends Imag
         }
 
         {
-            int width = pngChunkIHDR.width;
-            int height = pngChunkIHDR.height;
-            int colorType = pngChunkIHDR.colorType;
-            int bitDepth = pngChunkIHDR.bitDepth;
+            final int width = pngChunkIHDR.width;
+            final int height = pngChunkIHDR.height;
+            final int colorType = pngChunkIHDR.colorType;
+            final int bitDepth = pngChunkIHDR.bitDepth;
 
-            int bitsPerSample = bitDepth;
+            final int bitsPerSample = bitDepth;
 
             if (pngChunkIHDR.filterMethod != 0) {
                 throw new ImageReadException("PNG: unknown FilterMethod: "
                         + pngChunkIHDR.filterMethod);
             }
 
-            int samplesPerPixel = samplesPerPixel(pngChunkIHDR.colorType);
-            boolean isGrayscale = isGrayscale(pngChunkIHDR.colorType);
+            final int samplesPerPixel = samplesPerPixel(pngChunkIHDR.colorType);
+            final boolean isGrayscale = isGrayscale(pngChunkIHDR.colorType);
 
-            int bitsPerPixel = bitsPerSample * samplesPerPixel;
+            final int bitsPerPixel = bitsPerSample * samplesPerPixel;
 
-            boolean hasAlpha = colorType == COLOR_TYPE_GREYSCALE_WITH_ALPHA
+            final boolean hasAlpha = colorType == COLOR_TYPE_GREYSCALE_WITH_ALPHA
                     || colorType == COLOR_TYPE_TRUE_COLOR_WITH_ALPHA;
 
             BufferedImage result;
@@ -789,8 +789,8 @@ public class PngImageParser extends Imag
                         width, height, hasAlpha);
             }
 
-            ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
-            InflaterInputStream iis = new InflaterInputStream(bais);
+            final ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
+            final InflaterInputStream iis = new InflaterInputStream(bais);
 
             ScanExpediter scanExpediter;
 
@@ -810,12 +810,12 @@ public class PngImageParser extends Imag
             scanExpediter.drive();
 
             if (icc_profile != null) {
-                Boolean is_srgb = new IccProfileParser().issRGB(icc_profile);
+                final Boolean is_srgb = new IccProfileParser().issRGB(icc_profile);
                 if (is_srgb == null || !is_srgb.booleanValue()) {
-                    ICC_ColorSpace cs = new ICC_ColorSpace(icc_profile);
+                    final ICC_ColorSpace cs = new ICC_ColorSpace(icc_profile);
 
-                    ColorModel srgbCM = ColorModel.getRGBdefault();
-                    ColorSpace cs_sRGB = srgbCM.getColorSpace();
+                    final ColorModel srgbCM = ColorModel.getRGBdefault();
+                    final ColorSpace cs_sRGB = srgbCM.getColorSpace();
 
                     result = new ColorTools().convertBetweenColorSpaces(result,
                             cs, cs_sRGB);
@@ -829,24 +829,24 @@ public class PngImageParser extends Imag
     }
 
     @Override
-    public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
+    public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource)
             throws ImageReadException, IOException {
-        ImageInfo imageInfo = getImageInfo(byteSource);
+        final ImageInfo imageInfo = getImageInfo(byteSource);
         if (imageInfo == null) {
             return false;
         }
 
         imageInfo.toString(pw, "");
 
-        List<PngChunk> chunks = readChunks(byteSource, null, false);
-        List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
+        final List<PngChunk> chunks = readChunks(byteSource, null, false);
+        final List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
         if (IHDRs.size() != 1) {
             if (debug) {
                 System.out.println("PNG contains more than one Header");
             }
             return false;
         }
-        PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
+        final PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
         pw.println("Color: "
                 + getColorTypeDescription(pngChunkIHDR.colorType));
 
@@ -857,7 +857,7 @@ public class PngImageParser extends Imag
         }
 
         for (int i = 0; i < chunks.size(); i++) {
-            PngChunk chunk = chunks.get(i);
+            final PngChunk chunk = chunks.get(i);
             printCharQuad(pw, "\t" + i + ": ", chunk.chunkType);
         }
 
@@ -869,7 +869,7 @@ public class PngImageParser extends Imag
     }
 
     @Override
-    public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+    public void writeImage(final BufferedImage src, final OutputStream os, final Map<String,Object> params)
             throws ImageWriteException, IOException {
         new PngWriter(params).writeImage(src, os, params);
     }
@@ -885,19 +885,19 @@ public class PngImageParser extends Imag
      * @return Xmp Xml as String, if present. Otherwise, returns null.
      */
     @Override
-    public String getXmpXml(ByteSource byteSource, Map<String,Object> params)
+    public String getXmpXml(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
 
-        List<PngChunk> chunks = readChunks(byteSource, new int[] { iTXt, },
+        final List<PngChunk> chunks = readChunks(byteSource, new int[] { iTXt, },
                 false);
 
         if ((chunks == null) || (chunks.size() < 1)) {
             return null;
         }
 
-        List<PngChunkItxt> xmpChunks = new ArrayList<PngChunkItxt>();
+        final List<PngChunkItxt> xmpChunks = new ArrayList<PngChunkItxt>();
         for (int i = 0; i < chunks.size(); i++) {
-            PngChunkItxt chunk = (PngChunkItxt) chunks.get(i);
+            final PngChunkItxt chunk = (PngChunkItxt) chunks.get(i);
             if (!chunk.getKeyword().equals(XMP_KEYWORD)) {
                 continue;
             }
@@ -912,7 +912,7 @@ public class PngImageParser extends Imag
                     "PNG contains more than one XMP chunk.");
         }
 
-        PngChunkItxt chunk = xmpChunks.get(0);
+        final PngChunkItxt chunk = xmpChunks.get(0);
         return chunk.getText();
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java Tue Dec  4 17:23:16 2012
@@ -17,7 +17,7 @@
 package org.apache.commons.imaging.formats.png;
 
 public abstract class PngText {
-    public PngText(String keyword, String text) {
+    public PngText(final String keyword, final String text) {
         this.keyword = keyword;
         this.text = text;
     }
@@ -25,13 +25,13 @@ public abstract class PngText {
     public final String keyword, text;
 
     public static class Text extends PngText {
-        public Text(String keyword, String text) {
+        public Text(final String keyword, final String text) {
             super(keyword, text);
         }
     }
 
     public static class Ztxt extends PngText {
-        public Ztxt(String keyword, String text) {
+        public Ztxt(final String keyword, final String text) {
             super(keyword, text);
         }
     }
@@ -52,8 +52,8 @@ public abstract class PngText {
 
         public final String translatedKeyword;
 
-        public Itxt(String keyword, String text, String languageTag,
-                String translatedKeyword) {
+        public Itxt(final String keyword, final String text, final String languageTag,
+                final String translatedKeyword) {
             super(keyword, text);
             this.languageTag = languageTag;
             this.translatedKeyword = translatedKeyword;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java Tue Dec  4 17:23:16 2012
@@ -38,11 +38,11 @@ import org.apache.commons.imaging.util.U
 public class PngWriter implements PngConstants {
     private final boolean verbose;
 
-    public PngWriter(boolean verbose) {
+    public PngWriter(final boolean verbose) {
         this.verbose = verbose;
     }
 
-    public PngWriter(Map<String,Object> params) {
+    public PngWriter(final Map<String,Object> params) {
         this.verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
                 false);
     }
@@ -62,28 +62,28 @@ public class PngWriter implements PngCon
      5. Time information: tIME (see 11.3.6: Time stamp information).
     */
     
-    private final void writeInt(OutputStream os, int value) throws IOException {
+    private final void writeInt(final OutputStream os, final int value) throws IOException {
         os.write(0xff & (value >> 24));
         os.write(0xff & (value >> 16));
         os.write(0xff & (value >> 8));
         os.write(0xff & (value >> 0));
     }
 
-    private final void writeChunk(OutputStream os, byte chunkType[],
-            byte data[]) throws IOException {
-        int dataLength = data == null ? 0 : data.length;
+    private final void writeChunk(final OutputStream os, final byte chunkType[],
+            final byte data[]) throws IOException {
+        final int dataLength = data == null ? 0 : data.length;
         writeInt(os, dataLength);
         os.write(chunkType);
         if (data != null) {
             os.write(data);
         }
 
-        PngCrc png_crc = new PngCrc();
+        final PngCrc png_crc = new PngCrc();
 
-        long crc1 = png_crc.start_partial_crc(chunkType, chunkType.length);
-        long crc2 = data == null ? crc1 : png_crc.continue_partial_crc(
+        final long crc1 = png_crc.start_partial_crc(chunkType, chunkType.length);
+        final long crc2 = data == null ? crc1 : png_crc.continue_partial_crc(
                 crc1, data, data.length);
-        int crc = (int) png_crc.finish_partial_crc(crc2);
+        final int crc = (int) png_crc.finish_partial_crc(crc2);
 
         writeInt(os, crc);
     }
@@ -97,9 +97,9 @@ public class PngWriter implements PngCon
         public final byte filterMethod;
         public final byte interlaceMethod;
 
-        public ImageHeader(int width, int height, byte bit_depth,
-                byte colorType, byte compressionMethod, byte filterMethod,
-                byte interlaceMethod) {
+        public ImageHeader(final int width, final int height, final byte bit_depth,
+                final byte colorType, final byte compressionMethod, final byte filterMethod,
+                final byte interlaceMethod) {
             this.width = width;
             this.height = height;
             this.bit_depth = bit_depth;
@@ -111,9 +111,9 @@ public class PngWriter implements PngCon
 
     }
 
-    private void writeChunkIHDR(OutputStream os, ImageHeader value)
+    private void writeChunkIHDR(final OutputStream os, final ImageHeader value)
             throws IOException {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         writeInt(baos, value.width);
         writeInt(baos, value.height);
         baos.write(0xff & value.bit_depth);
@@ -127,7 +127,7 @@ public class PngWriter implements PngCon
         writeChunk(os, IHDR_CHUNK_TYPE.toByteArray(), baos.toByteArray());
     }
 
-    private void writeChunkiTXt(OutputStream os, PngText.Itxt text)
+    private void writeChunkiTXt(final OutputStream os, final PngText.Itxt text)
             throws IOException, ImageWriteException {
         if (!UnicodeUtils.isValidISO_8859_1(text.keyword)) {
             throw new ImageWriteException(
@@ -139,7 +139,7 @@ public class PngWriter implements PngCon
                             + text.languageTag);
         }
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
         // keyword
         baos.write(text.keyword.getBytes("ISO-8859-1"));
@@ -161,7 +161,7 @@ public class PngWriter implements PngCon
         writeChunk(os, iTXt_CHUNK_TYPE.toByteArray(), baos.toByteArray());
     }
 
-    private void writeChunkzTXt(OutputStream os, PngText.Ztxt text)
+    private void writeChunkzTXt(final OutputStream os, final PngText.Ztxt text)
             throws IOException, ImageWriteException {
         if (!UnicodeUtils.isValidISO_8859_1(text.keyword)) {
             throw new ImageWriteException(
@@ -172,7 +172,7 @@ public class PngWriter implements PngCon
                     "Png zTXt chunk text is not ISO-8859-1: " + text.text);
         }
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
         // keyword
         baos.write(text.keyword.getBytes("ISO-8859-1"));
@@ -187,7 +187,7 @@ public class PngWriter implements PngCon
         writeChunk(os, zTXt_CHUNK_TYPE.toByteArray(), baos.toByteArray());
     }
 
-    private void writeChunktEXt(OutputStream os, PngText.Text text)
+    private void writeChunktEXt(final OutputStream os, final PngText.Text text)
             throws IOException, ImageWriteException {
         if (!UnicodeUtils.isValidISO_8859_1(text.keyword)) {
             throw new ImageWriteException(
@@ -198,7 +198,7 @@ public class PngWriter implements PngCon
                     "Png tEXt chunk text is not ISO-8859-1: " + text.text);
         }
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
         // keyword
         baos.write(text.keyword.getBytes("ISO-8859-1"));
@@ -210,10 +210,10 @@ public class PngWriter implements PngCon
         writeChunk(os, tEXt_CHUNK_TYPE.toByteArray(), baos.toByteArray());
     }
 
-    private void writeChunkXmpiTXt(OutputStream os, String xmpXml)
+    private void writeChunkXmpiTXt(final OutputStream os, final String xmpXml)
             throws IOException {
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
         // keyword
         baos.write(XMP_KEYWORD.getBytes("ISO-8859-1"));
@@ -233,15 +233,15 @@ public class PngWriter implements PngCon
         writeChunk(os, iTXt_CHUNK_TYPE.toByteArray(), baos.toByteArray());
     }
 
-    private void writeChunkPLTE(OutputStream os, Palette palette)
+    private void writeChunkPLTE(final OutputStream os, final Palette palette)
             throws IOException {
-        int length = palette.length();
-        byte bytes[] = new byte[length * 3];
+        final int length = palette.length();
+        final byte bytes[] = new byte[length * 3];
 
         // Debug.debug("length", length);
         for (int i = 0; i < length; i++) {
-            int rgb = palette.getEntry(i);
-            int index = i * 3;
+            final int rgb = palette.getEntry(i);
+            final int index = i * 3;
             // Debug.debug("index", index);
             bytes[index + 0] = (byte) (0xff & (rgb >> 16));
             bytes[index + 1] = (byte) (0xff & (rgb >> 8));
@@ -251,8 +251,8 @@ public class PngWriter implements PngCon
         writeChunk(os, PLTE_CHUNK_TYPE.toByteArray(), bytes);
     }
 
-    private void writeChunkTRNS(OutputStream os, Palette palette) throws IOException {
-        byte[] bytes = new byte[palette.length()];
+    private void writeChunkTRNS(final OutputStream os, final Palette palette) throws IOException {
+        final byte[] bytes = new byte[palette.length()];
         
         for (int i = 0; i < bytes.length; i++) {
             bytes[i] = (byte) (0xff & (palette.getEntry(i) >> 24));
@@ -261,18 +261,18 @@ public class PngWriter implements PngCon
         writeChunk(os, TRNS_CHUNK_TYPE.toByteArray(), bytes);
     }
 
-    private void writeChunkIEND(OutputStream os) throws IOException {
+    private void writeChunkIEND(final OutputStream os) throws IOException {
         writeChunk(os, IEND_CHUNK_TYPE.toByteArray(), null);
     }
 
-    private void writeChunkIDAT(OutputStream os, byte bytes[])
+    private void writeChunkIDAT(final OutputStream os, final byte bytes[])
             throws IOException {
         writeChunk(os, IDAT_CHUNK_TYPE.toByteArray(), bytes);
     }
 
-    private void writeChunkPHYS(OutputStream os, int xPPU, int yPPU, byte units)
+    private void writeChunkPHYS(final OutputStream os, final int xPPU, final int yPPU, final byte units)
             throws IOException {
-        byte[] bytes = new byte[9];
+        final byte[] bytes = new byte[9];
         bytes[0] = (byte) (0xff & (xPPU >> 24));
         bytes[1] = (byte) (0xff & (xPPU >> 16));
         bytes[2] = (byte) (0xff & (xPPU >> 8));
@@ -285,10 +285,10 @@ public class PngWriter implements PngCon
         writeChunk(os, IPHYS_CHUNK_TYPE.toByteArray(), bytes);
     }
 
-    private byte getColourType(boolean hasAlpha, boolean isGrayscale) {
+    private byte getColourType(final boolean hasAlpha, final boolean isGrayscale) {
         byte result;
 
-        boolean index = false; // charles
+        final boolean index = false; // charles
 
         if (index) {
             result = COLOR_TYPE_INDEXED_COLOR;
@@ -307,12 +307,12 @@ public class PngWriter implements PngCon
         return result;
     }
 
-    private byte getBitDepth(final byte colorType, Map<String,Object> params) {
+    private byte getBitDepth(final byte colorType, final Map<String,Object> params) {
         byte result = 8;
 
-        Object o = params.get(PARAM_KEY_PNG_BIT_DEPTH);
+        final Object o = params.get(PARAM_KEY_PNG_BIT_DEPTH);
         if (o != null && o instanceof Number) {
-            int value = ((Number) o).intValue();
+            final int value = ((Number) o).intValue();
             switch (value) {
             case 1:
             case 2:
@@ -371,7 +371,7 @@ public class PngWriter implements PngCon
      tEXt   Yes None
      zTXt   Yes None
      */
-    public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+    public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
             throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = new HashMap<String,Object>(params);
@@ -385,7 +385,7 @@ public class PngWriter implements PngCon
             params.remove(PARAM_KEY_VERBOSE);
         }
 
-        Map<String,Object> rawParams = new HashMap<String,Object>(params);
+        final Map<String,Object> rawParams = new HashMap<String,Object>(params);
         if (params.containsKey(PARAM_KEY_PNG_FORCE_TRUE_COLOR)) {
             params.remove(PARAM_KEY_PNG_FORCE_TRUE_COLOR);
         }
@@ -403,15 +403,15 @@ public class PngWriter implements PngCon
         }
         params.remove(PARAM_KEY_PIXEL_DENSITY);
         if (params.size() > 0) {
-            Object firstKey = params.keySet().iterator().next();
+            final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
         params = rawParams;
 
-        int width = src.getWidth();
-        int height = src.getHeight();
+        final int width = src.getWidth();
+        final int height = src.getHeight();
 
-        boolean hasAlpha = new PaletteFactory().hasTransparency(src);
+        final boolean hasAlpha = new PaletteFactory().hasTransparency(src);
         if (verbose) {
             Debug.debug("hasAlpha", hasAlpha);
         }
@@ -424,9 +424,9 @@ public class PngWriter implements PngCon
 
         byte colorType;
         {
-            boolean forceIndexedColor = ParamMap.getParamBoolean(params,
+            final boolean forceIndexedColor = ParamMap.getParamBoolean(params,
                     PARAM_KEY_PNG_FORCE_INDEXED_COLOR, false);
-            boolean forceTrueColor = ParamMap.getParamBoolean(params,
+            final boolean forceTrueColor = ParamMap.getParamBoolean(params,
                     PARAM_KEY_PNG_FORCE_TRUE_COLOR, false);
 
             if (forceIndexedColor && forceTrueColor) {
@@ -446,7 +446,7 @@ public class PngWriter implements PngCon
             }
         }
 
-        byte bitDepth = getBitDepth(colorType, params);
+        final byte bitDepth = getBitDepth(colorType, params);
         if (verbose) {
             Debug.debug("bit_depth", bitDepth);
         }
@@ -467,11 +467,11 @@ public class PngWriter implements PngCon
         {
             // IHDR must be first
 
-            byte compressionMethod = COMPRESSION_TYPE_INFLATE_DEFLATE;
-            byte filterMethod = FILTER_METHOD_ADAPTIVE;
-            byte interlaceMethod = INTERLACE_METHOD_NONE;
+            final byte compressionMethod = COMPRESSION_TYPE_INFLATE_DEFLATE;
+            final byte filterMethod = FILTER_METHOD_ADAPTIVE;
+            final byte interlaceMethod = INTERLACE_METHOD_NONE;
 
-            ImageHeader imageHeader = new ImageHeader(width, height, bitDepth,
+            final ImageHeader imageHeader = new ImageHeader(width, height, bitDepth,
                     colorType, compressionMethod, filterMethod, interlaceMethod);
 
             writeChunkIHDR(os, imageHeader);
@@ -488,7 +488,7 @@ public class PngWriter implements PngCon
         if (colorType == COLOR_TYPE_INDEXED_COLOR) {
             // PLTE No Before first IDAT
 
-            int max_colors = hasAlpha ? 255 : 256;
+            final int max_colors = hasAlpha ? 255 : 256;
 
             palette = new MedianCutQuantizer(true).process(src, max_colors,
                     verbose);
@@ -500,9 +500,9 @@ public class PngWriter implements PngCon
             writeChunkPLTE(os, palette);
         }
 
-        Object pixelDensityObj = params.get(PARAM_KEY_PIXEL_DENSITY);
+        final Object pixelDensityObj = params.get(PARAM_KEY_PIXEL_DENSITY);
         if (pixelDensityObj instanceof PixelDensity) {
-            PixelDensity pixelDensity = (PixelDensity) pixelDensityObj;
+            final PixelDensity pixelDensity = (PixelDensity) pixelDensityObj;
             if (pixelDensity.isUnitless()) {
                 writeChunkPHYS(os, (int) Math.round(pixelDensity
                         .getRawHorizontalDensity()),
@@ -517,14 +517,14 @@ public class PngWriter implements PngCon
         }
 
         if (params.containsKey(PARAM_KEY_XMP_XML)) {
-            String xmpXml = (String) params.get(PARAM_KEY_XMP_XML);
+            final String xmpXml = (String) params.get(PARAM_KEY_XMP_XML);
             writeChunkXmpiTXt(os, xmpXml);
         }
 
         if (params.containsKey(PARAM_KEY_PNG_TEXT_CHUNKS)) {
-            List<?> outputTexts = (List<?>) params.get(PARAM_KEY_PNG_TEXT_CHUNKS);
+            final List<?> outputTexts = (List<?>) params.get(PARAM_KEY_PNG_TEXT_CHUNKS);
             for (int i = 0; i < outputTexts.size(); i++) {
-                PngText text = (PngText) outputTexts.get(i);
+                final PngText text = (PngText) outputTexts.get(i);
                 if (text instanceof PngText.Text) {
                     writeChunktEXt(os, (PngText.Text) text);
                 } else if (text instanceof PngText.Ztxt) {
@@ -545,32 +545,32 @@ public class PngWriter implements PngCon
 
             byte uncompressed[];
             {
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-                boolean useAlpha = colorType == COLOR_TYPE_GREYSCALE_WITH_ALPHA
+                final boolean useAlpha = colorType == COLOR_TYPE_GREYSCALE_WITH_ALPHA
                         || colorType == COLOR_TYPE_TRUE_COLOR_WITH_ALPHA;
 
-                int row[] = new int[width];
+                final int row[] = new int[width];
                 for (int y = 0; y < height; y++) {
                     // Debug.debug("y", y + "/" + height);
                     src.getRGB(0, y, width, 1, row, 0, width);
 
-                    byte filter_type = FILTER_TYPE_NONE;
+                    final byte filter_type = FILTER_TYPE_NONE;
                     baos.write(filter_type);
                     for (int x = 0; x < width; x++) {
-                        int argb = row[x];
+                        final int argb = row[x];
 
                         if (palette != null) {
-                            int index = palette.getPaletteIndex(argb);
+                            final int index = palette.getPaletteIndex(argb);
                             baos.write(0xff & index);
                         } else {
-                            int alpha = 0xff & (argb >> 24);
-                            int red = 0xff & (argb >> 16);
-                            int green = 0xff & (argb >> 8);
-                            int blue = 0xff & (argb >> 0);
+                            final int alpha = 0xff & (argb >> 24);
+                            final int red = 0xff & (argb >> 16);
+                            final int green = 0xff & (argb >> 8);
+                            final int blue = 0xff & (argb >> 0);
 
                             if (isGrayscale) {
-                                int gray = (red + green + blue) / 3;
+                                final int gray = (red + green + blue) / 3;
                                 // if(y==0)
                                 // {
                                 // Debug.debug("gray: " + x + ", " + y +
@@ -600,18 +600,18 @@ public class PngWriter implements PngCon
 
             // Debug.debug("uncompressed", uncompressed.length);
 
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            DeflaterOutputStream dos = new DeflaterOutputStream(baos);
-            int chunk_size = 256 * 1024;
+            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            final DeflaterOutputStream dos = new DeflaterOutputStream(baos);
+            final int chunk_size = 256 * 1024;
             for (int index = 0; index < uncompressed.length; index += chunk_size) {
-                int end = Math.min(uncompressed.length, index + chunk_size);
-                int length = end - index;
+                final int end = Math.min(uncompressed.length, index + chunk_size);
+                final int length = end - index;
 
                 dos.write(uncompressed, index, length);
                 dos.flush();
                 baos.flush();
 
-                byte compressed[] = baos.toByteArray();
+                final byte compressed[] = baos.toByteArray();
                 baos.reset();
                 if (compressed.length > 0) {
                     // Debug.debug("compressed", compressed.length);
@@ -621,7 +621,7 @@ public class PngWriter implements PngCon
             }
             {
                 dos.finish();
-                byte compressed[] = baos.toByteArray();
+                final byte compressed[] = baos.toByteArray();
                 if (compressed.length > 0) {
                     // Debug.debug("compressed final", compressed.length);
                     writeChunkIDAT(os, compressed);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java Tue Dec  4 17:23:16 2012
@@ -44,10 +44,10 @@ public abstract class ScanExpediter exte
     protected final GammaCorrection gammaCorrection;
     protected final TransparencyFilter transparencyFilter;
 
-    public ScanExpediter(int width, int height, InputStream is,
-            BufferedImage bi, int color_type, int bitDepth, int bitsPerPixel,
-            PngChunkPlte pngChunkPLTE, GammaCorrection gammaCorrection,
-            TransparencyFilter transparencyFilter)
+    public ScanExpediter(final int width, final int height, final InputStream is,
+            final BufferedImage bi, final int color_type, final int bitDepth, final int bitsPerPixel,
+            final PngChunkPlte pngChunkPLTE, final GammaCorrection gammaCorrection,
+            final TransparencyFilter transparencyFilter)
 
     {
         this.width = width;
@@ -63,7 +63,7 @@ public abstract class ScanExpediter exte
         this.transparencyFilter = transparencyFilter;
     }
 
-    protected int getBitsToBytesRoundingUp(int bits) {
+    protected int getBitsToBytesRoundingUp(final int bits) {
         int bytes = bits / 8;
         if ((bits % 8 > 0)) {
             bytes++;
@@ -71,20 +71,20 @@ public abstract class ScanExpediter exte
         return bytes;
     }
 
-    protected final int getPixelARGB(int alpha, int red, int green, int blue) {
-        int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+    protected final int getPixelARGB(final int alpha, final int red, final int green, final int blue) {
+        final int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
                 | ((0xff & green) << 8) | ((0xff & blue) << 0);
 
         return rgb;
     }
 
-    protected final int getPixelRGB(int red, int green, int blue) {
+    protected final int getPixelRGB(final int red, final int green, final int blue) {
         return getPixelARGB(0xff, red, green, blue);
     }
 
     public abstract void drive() throws ImageReadException, IOException;
 
-    protected int getRGB(BitParser bitParser, int pixelIndexInScanline)
+    protected int getRGB(final BitParser bitParser, final int pixelIndexInScanline)
             throws ImageReadException, IOException {
 
         switch (colorType) {
@@ -118,7 +118,7 @@ public abstract class ScanExpediter exte
             }
 
             if (gammaCorrection != null) {
-                int alpha = (0xff000000 & rgb) >> 24; // make sure to preserve
+                final int alpha = (0xff000000 & rgb) >> 24; // make sure to preserve
                 // transparency
                 red = gammaCorrection.correctSample(red);
                 green = gammaCorrection.correctSample(green);
@@ -132,7 +132,7 @@ public abstract class ScanExpediter exte
         case 3: {
             // 1,2,4,8 Each pixel is a palette index;
             // a PLTE chunk must appear.
-            int index = bitParser.getSample(pixelIndexInScanline, 0);
+            final int index = bitParser.getSample(pixelIndexInScanline, 0);
 
             int rgb = pngChunkPLTE.getRGB(index);
 
@@ -146,13 +146,13 @@ public abstract class ScanExpediter exte
             // 8,16 Each pixel is a grayscale sample,
             // followed by an alpha sample.
             int sample = bitParser.getSampleAsByte(pixelIndexInScanline, 0);
-            int alpha = bitParser.getSampleAsByte(pixelIndexInScanline, 1);
+            final int alpha = bitParser.getSampleAsByte(pixelIndexInScanline, 1);
 
             if (gammaCorrection != null) {
                 sample = gammaCorrection.correctSample(sample);
             }
 
-            int rgb = getPixelARGB(alpha, sample, sample, sample);
+            final int rgb = getPixelARGB(alpha, sample, sample, sample);
             return rgb;
 
         }
@@ -161,7 +161,7 @@ public abstract class ScanExpediter exte
             int red = bitParser.getSampleAsByte(pixelIndexInScanline, 0);
             int green = bitParser.getSampleAsByte(pixelIndexInScanline, 1);
             int blue = bitParser.getSampleAsByte(pixelIndexInScanline, 2);
-            int alpha = bitParser.getSampleAsByte(pixelIndexInScanline, 3);
+            final int alpha = bitParser.getSampleAsByte(pixelIndexInScanline, 3);
 
             if (gammaCorrection != null) {
                 red = gammaCorrection.correctSample(red);
@@ -169,7 +169,7 @@ public abstract class ScanExpediter exte
                 blue = gammaCorrection.correctSample(blue);
             }
 
-            int rgb = getPixelARGB(alpha, red, green, blue);
+            final int rgb = getPixelARGB(alpha, red, green, blue);
             return rgb;
         }
         default:
@@ -178,8 +178,8 @@ public abstract class ScanExpediter exte
         }
     }
 
-    protected ScanlineFilter getScanlineFilter(int filter_type,
-            int BytesPerPixel) throws ImageReadException {
+    protected ScanlineFilter getScanlineFilter(final int filter_type,
+            final int BytesPerPixel) throws ImageReadException {
         ScanlineFilter filter;
 
         switch (filter_type) {
@@ -212,26 +212,26 @@ public abstract class ScanExpediter exte
         return filter;
     }
 
-    protected byte[] unfilterScanline(int filter_type, byte src[], byte prev[],
-            int BytesPerPixel) throws ImageReadException, IOException {
-        ScanlineFilter filter = getScanlineFilter(filter_type, BytesPerPixel);
+    protected byte[] unfilterScanline(final int filter_type, final byte src[], final byte prev[],
+            final int BytesPerPixel) throws ImageReadException, IOException {
+        final ScanlineFilter filter = getScanlineFilter(filter_type, BytesPerPixel);
 
-        byte dst[] = new byte[src.length];
+        final byte dst[] = new byte[src.length];
         filter.unfilter(src, dst, prev);
         return dst;
     }
 
-    protected byte[] getNextScanline(InputStream is, int length, byte prev[],
-            int BytesPerPixel) throws ImageReadException, IOException {
-        int filterType = is.read();
+    protected byte[] getNextScanline(final InputStream is, final int length, final byte prev[],
+            final int BytesPerPixel) throws ImageReadException, IOException {
+        final int filterType = is.read();
         if (filterType < 0) {
             throw new ImageReadException("PNG: missing filter type");
         }
 
-        byte scanline[] = this.readByteArray("scanline", length, is,
+        final byte scanline[] = this.readByteArray("scanline", length, is,
                 "PNG: missing image data");
 
-        byte unfiltered[] = unfilterScanline(filterType, scanline, prev,
+        final byte unfiltered[] = unfilterScanline(filterType, scanline, prev,
                 BytesPerPixel);
 
         return unfiltered;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java Tue Dec  4 17:23:16 2012
@@ -25,21 +25,21 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilter;
 
 public class ScanExpediterInterlaced extends ScanExpediter {
-    public ScanExpediterInterlaced(int width, int height, InputStream is,
-            BufferedImage bi, int color_type, int BitDepth, int bits_per_pixel,
-            PngChunkPlte fPNGChunkPLTE, GammaCorrection fGammaCorrection,
-            TransparencyFilter fTransparencyFilter)
+    public ScanExpediterInterlaced(final int width, final int height, final InputStream is,
+            final BufferedImage bi, final int color_type, final int BitDepth, final int bits_per_pixel,
+            final PngChunkPlte fPNGChunkPLTE, final GammaCorrection fGammaCorrection,
+            final TransparencyFilter fTransparencyFilter)
 
     {
         super(width, height, is, bi, color_type, BitDepth, bits_per_pixel,
                 fPNGChunkPLTE, fGammaCorrection, fTransparencyFilter);
     }
 
-    private void visit(int x, int y, BufferedImage bi, BitParser fBitParser,
-            int color_type, int pixel_index_in_scanline,
-            PngChunkPlte fPNGChunkPLTE, GammaCorrection fGammaCorrection)
+    private void visit(final int x, final int y, final BufferedImage bi, final BitParser fBitParser,
+            final int color_type, final int pixel_index_in_scanline,
+            final PngChunkPlte fPNGChunkPLTE, final GammaCorrection fGammaCorrection)
             throws ImageReadException, IOException {
-        int rgb = getRGB(fBitParser,
+        final int rgb = getRGB(fBitParser,
         // color_type,
                 pixel_index_in_scanline
         // ,
@@ -68,23 +68,23 @@ public class ScanExpediterInterlaced ext
 
             int y = Starting_Row[pass - 1];
             // int y_stride = Row_Increment[pass - 1];
-            boolean rows_in_pass = (y < height);
+            final boolean rows_in_pass = (y < height);
             while (y < height) {
                 int x = Starting_Col[pass - 1];
                 int pixel_index_in_scanline = 0;
 
                 if (x < width) {
                     // only get data if there are pixels in this scanline/pass
-                    int ColumnsInRow = 1 + ((width - Starting_Col[pass - 1] - 1) / Col_Increment[pass - 1]);
-                    int bitsPerScanLine = bitsPerPixel * ColumnsInRow;
-                    int pixel_bytes_per_scan_line = getBitsToBytesRoundingUp(bitsPerScanLine);
+                    final int ColumnsInRow = 1 + ((width - Starting_Col[pass - 1] - 1) / Col_Increment[pass - 1]);
+                    final int bitsPerScanLine = bitsPerPixel * ColumnsInRow;
+                    final int pixel_bytes_per_scan_line = getBitsToBytesRoundingUp(bitsPerScanLine);
 
-                    byte unfiltered[] = getNextScanline(is,
+                    final byte unfiltered[] = getNextScanline(is,
                             pixel_bytes_per_scan_line, prev, bytesPerPixel);
 
                     prev = unfiltered;
 
-                    BitParser fBitParser = new BitParser(unfiltered,
+                    final BitParser fBitParser = new BitParser(unfiltered,
                             bitsPerPixel, bitDepth);
 
                     while (x < width) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterSimple.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterSimple.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterSimple.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterSimple.java Tue Dec  4 17:23:16 2012
@@ -25,10 +25,10 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilter;
 
 public class ScanExpediterSimple extends ScanExpediter {
-    public ScanExpediterSimple(int width, int height, InputStream is,
-            BufferedImage bi, int color_type, int BitDepth, int bitsPerPixel,
-            PngChunkPlte pngChunkPLTE, GammaCorrection gammaCorrection,
-            TransparencyFilter transparencyFilter)
+    public ScanExpediterSimple(final int width, final int height, final InputStream is,
+            final BufferedImage bi, final int color_type, final int BitDepth, final int bitsPerPixel,
+            final PngChunkPlte pngChunkPLTE, final GammaCorrection gammaCorrection,
+            final TransparencyFilter transparencyFilter)
 
     {
         super(width, height, is, bi, color_type, BitDepth, bitsPerPixel,
@@ -37,21 +37,21 @@ public class ScanExpediterSimple extends
 
     @Override
     public void drive() throws ImageReadException, IOException {
-        int bitsPerScanLine = bitsPerPixel * width;
-        int pixelBytesPerScanLine = getBitsToBytesRoundingUp(bitsPerScanLine);
+        final int bitsPerScanLine = bitsPerPixel * width;
+        final int pixelBytesPerScanLine = getBitsToBytesRoundingUp(bitsPerScanLine);
         byte prev[] = null;
 
         for (int y = 0; y < height; y++) {
-            byte unfiltered[] = getNextScanline(is, pixelBytesPerScanLine,
+            final byte unfiltered[] = getNextScanline(is, pixelBytesPerScanLine,
                     prev, bytesPerPixel);
 
             prev = unfiltered;
 
-            BitParser bitParser = new BitParser(unfiltered, bitsPerPixel,
+            final BitParser bitParser = new BitParser(unfiltered, bitsPerPixel,
                     bitDepth);
 
             for (int x = 0; x < width; x++) {
-                int rgb = getRGB(bitParser, x);
+                final int rgb = getRGB(bitParser, x);
 
                 bi.setRGB(x, y, rgb);
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java Tue Dec  4 17:23:16 2012
@@ -29,7 +29,7 @@ public class PngChunk extends BinaryFile
     public final boolean propertyBits[];
     public final boolean ancillary, isPrivate, reserved, safeToCopy;
 
-    public PngChunk(int Length, int ChunkType, int CRC, byte bytes[]) {
+    public PngChunk(final int Length, final int ChunkType, final int CRC, final byte bytes[]) {
         this.length = Length;
         this.chunkType = ChunkType;
         this.crc = CRC;
@@ -38,9 +38,9 @@ public class PngChunk extends BinaryFile
         propertyBits = new boolean[4];
         int shift = 24;
         for (int i = 0; i < 4; i++) {
-            int theByte = 0xff & (ChunkType >> shift);
+            final int theByte = 0xff & (ChunkType >> shift);
             shift -= 8;
-            int theMask = 1 << 5;
+            final int theMask = 1 << 5;
             propertyBits[i] = ((theByte & theMask) > 0);
         }
 
@@ -51,7 +51,7 @@ public class PngChunk extends BinaryFile
     }
 
     protected ByteArrayInputStream getDataStream() {
-        ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+        final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
         return is;
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java Tue Dec  4 17:23:16 2012
@@ -22,11 +22,11 @@ import java.io.IOException;
 public class PngChunkGama extends PngChunk {
     public final int Gamma;
 
-    public PngChunkGama(int Length, int ChunkType, int CRC, byte bytes[])
+    public PngChunkGama(final int Length, final int ChunkType, final int CRC, final byte bytes[])
             throws IOException {
         super(Length, ChunkType, CRC, bytes);
 
-        ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+        final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
         Gamma = read4Bytes("Gamma", is, "Not a Valid Png File: gAMA Corrupt");
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java Tue Dec  4 17:23:16 2012
@@ -30,22 +30,22 @@ public class PngChunkIccp extends PngChu
 
     public PngChunkIccp(
     // PngImageParser parser,
-            int Length, int ChunkType, int CRC, byte bytes[])
+            final int Length, final int ChunkType, final int CRC, final byte bytes[])
             throws ImageReadException, IOException {
         super(Length, ChunkType, CRC, bytes);
         // this.parser = parser;
 
-        int index = findNull(bytes);
+        final int index = findNull(bytes);
         if (index < 0) {
             throw new ImageReadException("PngChunkIccp: No Profile Name");
         }
-        byte name_bytes[] = new byte[index];
+        final byte name_bytes[] = new byte[index];
         System.arraycopy(bytes, 0, name_bytes, 0, index);
         ProfileName = new String(name_bytes, "ISO-8859-1");
 
         CompressionMethod = bytes[index + 1];
 
-        int CompressedProfileLength = bytes.length - (index + 1 + 1);
+        final int CompressedProfileLength = bytes.length - (index + 1 + 1);
         CompressedProfile = new byte[CompressedProfileLength];
         System.arraycopy(bytes, index + 1 + 1, CompressedProfile, 0,
                 CompressedProfileLength);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIdat.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIdat.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIdat.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIdat.java Tue Dec  4 17:23:16 2012
@@ -17,7 +17,7 @@
 package org.apache.commons.imaging.formats.png.chunks;
 
 public class PngChunkIdat extends PngChunk {
-    public PngChunkIdat(int Length, int ChunkType, int CRC, byte bytes[]) {
+    public PngChunkIdat(final int Length, final int ChunkType, final int CRC, final byte bytes[]) {
         super(Length, ChunkType, CRC, bytes);
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java Tue Dec  4 17:23:16 2012
@@ -28,11 +28,11 @@ public class PngChunkIhdr extends PngChu
     public final int filterMethod;
     public final int interlaceMethod;
 
-    public PngChunkIhdr(int Length, int ChunkType, int CRC, byte bytes[])
+    public PngChunkIhdr(final int Length, final int ChunkType, final int CRC, final byte bytes[])
             throws IOException {
         super(Length, ChunkType, CRC, bytes);
 
-        ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+        final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
         width = read4Bytes("Width", is, "Not a Valid Png File: IHDR Corrupt");
         height = read4Bytes("Height", is, "Not a Valid Png File: IHDR Corrupt");
         bitDepth = readByte("BitDepth", is,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java Tue Dec  4 17:23:16 2012
@@ -39,7 +39,7 @@ public class PngChunkItxt extends PngTex
 
     public final String translatedKeyword;
 
-    public PngChunkItxt(int length, int chunkType, int crc, byte bytes[])
+    public PngChunkItxt(final int length, final int chunkType, final int crc, final byte bytes[])
             throws ImageReadException, IOException {
         super(length, chunkType, crc, bytes);
         int terminator = findNull(bytes);
@@ -51,16 +51,16 @@ public class PngChunkItxt extends PngTex
         keyword = new String(bytes, 0, terminator, "ISO-8859-1");
         int index = terminator + 1;
 
-        int compressionFlag = bytes[index++];
+        final int compressionFlag = bytes[index++];
         if (compressionFlag != 0 && compressionFlag != 1) {
             throw new ImageReadException(
                     "PNG iTXt chunk has invalid compression flag: "
                             + compressionFlag);
         }
 
-        boolean compressed = compressionFlag == 1;
+        final boolean compressed = compressionFlag == 1;
 
-        int compressionMethod = bytes[index++];
+        final int compressionMethod = bytes[index++];
         if (compressed) {
             if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE) {
                 throw new ImageReadException(
@@ -94,9 +94,9 @@ public class PngChunkItxt extends PngTex
         index = terminator + 1;
 
         if (compressed) {
-            int compressedTextLength = bytes.length - index;
+            final int compressedTextLength = bytes.length - index;
 
-            byte compressedText[] = new byte[compressedTextLength];
+            final byte compressedText[] = new byte[compressedTextLength];
             System.arraycopy(bytes, index, compressedText, 0,
                     compressedTextLength);
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java Tue Dec  4 17:23:16 2012
@@ -24,11 +24,11 @@ public class PngChunkPhys extends PngChu
     public final int PixelsPerUnitYAxis;
     public final int UnitSpecifier;
 
-    public PngChunkPhys(int Length, int ChunkType, int CRC, byte bytes[])
+    public PngChunkPhys(final int Length, final int ChunkType, final int CRC, final byte bytes[])
             throws IOException {
         super(Length, ChunkType, CRC, bytes);
 
-        ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+        final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
 
         PixelsPerUnitXAxis = read4Bytes("PixelsPerUnitXAxis", is,
                 "Not a Valid Png File: pHYs Corrupt");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java Tue Dec  4 17:23:16 2012
@@ -25,33 +25,33 @@ import org.apache.commons.imaging.format
 public class PngChunkPlte extends PngChunk {
     public final int rgb[];
 
-    public PngChunkPlte(int length, int ChunkType, int CRC, byte bytes[])
+    public PngChunkPlte(final int length, final int ChunkType, final int CRC, final byte bytes[])
             throws ImageReadException, IOException {
         super(length, ChunkType, CRC, bytes);
 
-        ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+        final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
 
         if ((length % 3) != 0) {
             throw new ImageReadException("PLTE: wrong length: " + length);
         }
 
-        int count = length / 3;
+        final int count = length / 3;
 
         rgb = new int[count];
 
         for (int i = 0; i < count; i++) {
-            int red = readByte("red[" + i + "]", is,
+            final int red = readByte("red[" + i + "]", is,
                     "Not a Valid Png File: PLTE Corrupt");
-            int green = readByte("green[" + i + "]", is,
+            final int green = readByte("green[" + i + "]", is,
                     "Not a Valid Png File: PLTE Corrupt");
-            int blue = readByte("blue[" + i + "]", is,
+            final int blue = readByte("blue[" + i + "]", is,
                     "Not a Valid Png File: PLTE Corrupt");
             rgb[i] = 0xff000000 | ((0xff & red) << 16) | ((0xff & green) << 8)
                     | ((0xff & blue) << 0);
         }
     }
 
-    public int getRGB(int index) throws ImageReadException {
+    public int getRGB(final int index) throws ImageReadException {
         if ((index < 0) || (index >= rgb.length)) {
             throw new ImageReadException("PNG: unknown Palette reference: "
                     + index);
@@ -70,7 +70,7 @@ public class PngChunkPlte extends PngChu
     // Debug.debug();
     // }
 
-    public void correct(GammaCorrection gammaCorrection) {
+    public void correct(final GammaCorrection gammaCorrection) {
         for (int i = 0; i < rgb.length; i++) {
             rgb[i] = gammaCorrection.correctARGB(rgb[i]);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java Tue Dec  4 17:23:16 2012
@@ -24,10 +24,10 @@ import org.apache.commons.imaging.format
 public class PngChunkText extends PngTextChunk {
     public final String keyword, text;
 
-    public PngChunkText(int length, int chunkType, int crc, byte bytes[])
+    public PngChunkText(final int length, final int chunkType, final int crc, final byte bytes[])
             throws ImageReadException, IOException {
         super(length, chunkType, crc, bytes);
-        int index = findNull(bytes);
+        final int index = findNull(bytes);
         if (index < 0) {
             throw new ImageReadException(
                     "PNG tEXt chunk keyword is not terminated.");
@@ -35,7 +35,7 @@ public class PngChunkText extends PngTex
 
         keyword = new String(bytes, 0, index, "ISO-8859-1");
 
-        int textLength = bytes.length - (index + 1);
+        final int textLength = bytes.length - (index + 1);
         text = new String(bytes, index + 1, textLength, "ISO-8859-1");
 
         if (getDebug()) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java Tue Dec  4 17:23:16 2012
@@ -27,7 +27,7 @@ public class PngChunkZtxt extends PngTex
 
     public final String keyword, text;
 
-    public PngChunkZtxt(int length, int chunkType, int crc, byte bytes[])
+    public PngChunkZtxt(final int length, final int chunkType, final int crc, final byte bytes[])
             throws ImageReadException, IOException {
         super(length, chunkType, crc, bytes);
 
@@ -40,15 +40,15 @@ public class PngChunkZtxt extends PngTex
         keyword = new String(bytes, 0, index, "ISO-8859-1");
         index++;
 
-        int compressionMethod = bytes[index++];
+        final int compressionMethod = bytes[index++];
         if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE) {
             throw new ImageReadException(
                     "PNG zTXt chunk has unexpected compression method: "
                             + compressionMethod);
         }
 
-        int compressedTextLength = bytes.length - index;
-        byte compressedText[] = new byte[compressedTextLength];
+        final int compressedTextLength = bytes.length - index;
+        final byte compressedText[] = new byte[compressedTextLength];
         System.arraycopy(bytes, index, compressedText, 0,
                 compressedTextLength);
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngTextChunk.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngTextChunk.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngTextChunk.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngTextChunk.java Tue Dec  4 17:23:16 2012
@@ -20,7 +20,7 @@ import org.apache.commons.imaging.format
 
 public abstract class PngTextChunk extends PngChunk {
 
-    public PngTextChunk(int Length, int ChunkType, int CRC, byte bytes[]) {
+    public PngTextChunk(final int Length, final int ChunkType, final int CRC, final byte bytes[]) {
         super(Length, ChunkType, CRC, bytes);
 
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java Tue Dec  4 17:23:16 2012
@@ -23,16 +23,16 @@ import org.apache.commons.imaging.ImageR
 public class ScanlineFilterAverage extends ScanlineFilter {
     private final int BytesPerPixel;
 
-    public ScanlineFilterAverage(int BytesPerPixel) {
+    public ScanlineFilterAverage(final int BytesPerPixel) {
         this.BytesPerPixel = BytesPerPixel;
     }
 
     @Override
-    public void unfilter(byte src[], byte dst[], byte up[])
+    public void unfilter(final byte src[], final byte dst[], final byte up[])
             throws ImageReadException, IOException {
         for (int i = 0; i < src.length; i++) {
             int Raw = 0;
-            int prev_index = i - BytesPerPixel;
+            final int prev_index = i - BytesPerPixel;
             if (prev_index >= 0) {
                 Raw = dst[prev_index];
             }
@@ -42,7 +42,7 @@ public class ScanlineFilterAverage exten
                 Prior = up[i];
             }
 
-            int Average = ((0xff & Raw) + (0xff & Prior)) / 2;
+            final int Average = ((0xff & Raw) + (0xff & Prior)) / 2;
 
             dst[i] = (byte) ((src[i] + Average) % 256);
             // dst[i] = src[i];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java Tue Dec  4 17:23:16 2012
@@ -22,7 +22,7 @@ import org.apache.commons.imaging.ImageR
 
 public class ScanlineFilterNone extends ScanlineFilter {
     @Override
-    public void unfilter(byte src[], byte dst[], byte up[])
+    public void unfilter(final byte src[], final byte dst[], final byte up[])
             throws ImageReadException, IOException {
         for (int i = 0; i < src.length; i++) {
             dst[i] = src[i];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java Tue Dec  4 17:23:16 2012
@@ -23,16 +23,16 @@ import org.apache.commons.imaging.ImageR
 public class ScanlineFilterPaeth extends ScanlineFilter {
     private final int BytesPerPixel;
 
-    public ScanlineFilterPaeth(int BytesPerPixel) {
+    public ScanlineFilterPaeth(final int BytesPerPixel) {
         this.BytesPerPixel = BytesPerPixel;
     }
 
-    private int PaethPredictor(int a, int b, int c) {
+    private int PaethPredictor(final int a, final int b, final int c) {
         // ; a = left, b = above, c = upper left
-        int p = a + b - c; // ; initial estimate
-        int pa = Math.abs(p - a); // ; distances to a, b, c
-        int pb = Math.abs(p - b);
-        int pc = Math.abs(p - c);
+        final int p = a + b - c; // ; initial estimate
+        final int pa = Math.abs(p - a); // ; distances to a, b, c
+        final int pb = Math.abs(p - b);
+        final int pc = Math.abs(p - c);
         // ; return nearest of a,b,c,
         // ; breaking ties in order a,b,c.
         if ((pa <= pb) && (pa <= pc)) {
@@ -45,11 +45,11 @@ public class ScanlineFilterPaeth extends
     }
 
     @Override
-    public void unfilter(byte src[], byte dst[], byte up[])
+    public void unfilter(final byte src[], final byte dst[], final byte up[])
             throws ImageReadException, IOException {
         for (int i = 0; i < src.length; i++) {
             int left = 0;
-            int prev_index = i - BytesPerPixel;
+            final int prev_index = i - BytesPerPixel;
             if (prev_index >= 0) {
                 left = dst[prev_index];
             }
@@ -66,7 +66,7 @@ public class ScanlineFilterPaeth extends
             }
             // upperleft = 255;
 
-            int PaethPredictor = PaethPredictor(0xff & left, 0xff & above,
+            final int PaethPredictor = PaethPredictor(0xff & left, 0xff & above,
                     0xff & upperleft);
 
             dst[i] = (byte) ((src[i] + PaethPredictor) % 256);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java Tue Dec  4 17:23:16 2012
@@ -23,15 +23,15 @@ import org.apache.commons.imaging.ImageR
 public class ScanlineFilterSub extends ScanlineFilter {
     private final int BytesPerPixel;
 
-    public ScanlineFilterSub(int BytesPerPixel) {
+    public ScanlineFilterSub(final int BytesPerPixel) {
         this.BytesPerPixel = BytesPerPixel;
     }
 
     @Override
-    public void unfilter(byte src[], byte dst[], byte up[])
+    public void unfilter(final byte src[], final byte dst[], final byte up[])
             throws ImageReadException, IOException {
         for (int i = 0; i < src.length; i++) {
-            int prev_index = i - BytesPerPixel;
+            final int prev_index = i - BytesPerPixel;
             if (prev_index >= 0) {
                 dst[i] = (byte) ((src[i] + dst[prev_index]) % 256);
             // dst[i] = 0xff & (src[i] + src[prev_index]);



Mime
View raw message