commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1417043 [9/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/ m...
Date Tue, 04 Dec 2012 17:24:32 GMT
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java Tue Dec  4 17:23:16 2012
@@ -33,19 +33,19 @@ public class SosSegment extends Segment 
         public final int dcCodingTableSelector;
         public final int acCodingTableSelector;
 
-        public Component(int scanComponentSelector, int dcCodingTableSelector,
-                int acCodingTableSelector) {
+        public Component(final int scanComponentSelector, final int dcCodingTableSelector,
+                final int acCodingTableSelector) {
             this.scanComponentSelector = scanComponentSelector;
             this.dcCodingTableSelector = dcCodingTableSelector;
             this.acCodingTableSelector = acCodingTableSelector;
         }
     }
 
-    public SosSegment(int marker, byte[] segmentData) throws IOException {
+    public SosSegment(final int marker, final byte[] segmentData) throws IOException {
         this(marker, segmentData.length, new ByteArrayInputStream(segmentData));
     }
 
-    public SosSegment(int marker, int marker_length, InputStream is)
+    public SosSegment(final int marker, final int marker_length, final InputStream is)
             throws IOException {
         super(marker, marker_length);
 
@@ -62,18 +62,18 @@ public class SosSegment extends Segment 
 
         components = new Component[numberOfComponents];
         for (int i = 0; i < numberOfComponents; i++) {
-            int scan_component_selector = readByte("scan_component_selector",
+            final int scan_component_selector = readByte("scan_component_selector",
                     is, "Not a Valid JPEG File");
             // Debug.debug("scan_component_selector", scan_component_selector);
 
-            int ac_dc_entropy_coding_table_selector = readByte(
+            final int ac_dc_entropy_coding_table_selector = readByte(
                     "ac_dc_entrooy_coding_table_selector", is,
                     "Not a Valid JPEG File");
             // Debug.debug("ac_dc_entrooy_coding_table_selector",
             // ac_dc_entropy_coding_table_selector);
 
-            int dcCodingTableSelector = (ac_dc_entropy_coding_table_selector >> 4) & 0xf;
-            int acCodingTableSelector = ac_dc_entropy_coding_table_selector & 0xf;
+            final int dcCodingTableSelector = (ac_dc_entropy_coding_table_selector >> 4) & 0xf;
+            final int acCodingTableSelector = ac_dc_entropy_coding_table_selector & 0xf;
             components[i] = new Component(scan_component_selector,
                     dcCodingTableSelector, acCodingTableSelector);
         }
@@ -84,7 +84,7 @@ public class SosSegment extends Segment 
         endOfSpectralSelection = readByte("end_of_spectral_selection", is,
                 "Not a Valid JPEG File");
         // Debug.debug("end_of_spectral_selection", endOfSpectralSelection);
-        int successive_approximation_bit_position = readByte(
+        final int successive_approximation_bit_position = readByte(
                 "successive_approximation_bit_position", is,
                 "Not a Valid JPEG File");
         // Debug.debug("successive_approximation_bit_position",

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/UnknownSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/UnknownSegment.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/UnknownSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/UnknownSegment.java Tue Dec  4 17:23:16 2012
@@ -20,12 +20,12 @@ import java.io.IOException;
 import java.io.InputStream;
 
 public class UnknownSegment extends GenericSegment {
-    public UnknownSegment(int marker, int marker_length, InputStream is)
+    public UnknownSegment(final int marker, final int marker_length, final InputStream is)
             throws IOException {
         super(marker, marker_length, is);
     }
 
-    public UnknownSegment(int marker, byte bytes[]) {
+    public UnknownSegment(final int marker, final byte bytes[]) {
         super(marker, bytes);
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java Tue Dec  4 17:23:16 2012
@@ -92,7 +92,7 @@ public class JpegRewriter extends Binary
         }
 
         @Override
-        protected void write(OutputStream os) throws IOException {
+        protected void write(final OutputStream os) throws IOException {
             os.write(markerBytes);
             os.write(segmentLengthBytes);
             os.write(segmentData);
@@ -150,35 +150,35 @@ public class JpegRewriter extends Binary
         }
 
         @Override
-        protected void write(OutputStream os) throws IOException {
+        protected void write(final OutputStream os) throws IOException {
             os.write(markerBytes);
             os.write(imageData);
         }
     }
 
-    protected JFIFPieces analyzeJFIF(ByteSource byteSource)
+    protected JFIFPieces analyzeJFIF(final ByteSource byteSource)
             throws ImageReadException, IOException
     // , ImageWriteException
     {
         final List<JFIFPiece> pieces = new ArrayList<JFIFPiece>();
         final List<JFIFPiece> segmentPieces = new ArrayList<JFIFPiece>();
 
-        JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
+        final JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
             // return false to exit before reading image data.
             public boolean beginSOS() {
                 return true;
             }
 
-            public void visitSOS(int marker, byte markerBytes[],
-                    byte imageData[]) {
+            public void visitSOS(final int marker, final byte markerBytes[],
+                    final byte imageData[]) {
                 pieces.add(new JFIFPieceImageData(markerBytes, imageData));
             }
 
             // return false to exit traversal.
-            public boolean visitSegment(int marker, byte markerBytes[],
-                    int segmentLength, byte segmentLengthBytes[],
-                    byte segmentData[]) throws ImageReadException, IOException {
-                JFIFPiece piece = new JFIFPieceSegment(marker, markerBytes,
+            public boolean visitSegment(final int marker, final byte markerBytes[],
+                    final int segmentLength, final byte segmentLengthBytes[],
+                    final byte segmentData[]) throws ImageReadException, IOException {
+                final JFIFPiece piece = new JFIFPieceSegment(marker, markerBytes,
                         segmentLengthBytes, segmentData);
                 pieces.add(piece);
                 segmentPieces.add(piece);
@@ -197,52 +197,52 @@ public class JpegRewriter extends Binary
     }
 
     private static final SegmentFilter EXIF_SEGMENT_FILTER = new SegmentFilter() {
-        public boolean filter(JFIFPieceSegment segment) {
+        public boolean filter(final JFIFPieceSegment segment) {
             return segment.isExifSegment();
         }
     };
 
     private static final SegmentFilter XMP_SEGMENT_FILTER = new SegmentFilter() {
-        public boolean filter(JFIFPieceSegment segment) {
+        public boolean filter(final JFIFPieceSegment segment) {
             return segment.isXmpSegment();
         }
     };
 
     private static final SegmentFilter PHOTOSHOP_APP13_SEGMENT_FILTER = new SegmentFilter() {
-        public boolean filter(JFIFPieceSegment segment) {
+        public boolean filter(final JFIFPieceSegment segment) {
             return segment.isPhotoshopApp13Segment();
         }
     };
 
-    protected <T extends JFIFPiece> List<T> removeXmpSegments(List<T> segments) {
+    protected <T extends JFIFPiece> List<T> removeXmpSegments(final List<T> segments) {
         return filterSegments(segments, XMP_SEGMENT_FILTER);
     }
 
     protected <T extends JFIFPiece> List<T> removePhotoshopApp13Segments(
-            List<T> segments) {
+            final List<T> segments) {
         return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER);
     }
 
     protected <T extends JFIFPiece> List<T> findPhotoshopApp13Segments(
-            List<T> segments) {
+            final List<T> segments) {
         return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER, true);
     }
 
-    protected <T extends JFIFPiece> List<T> removeExifSegments(List<T> segments) {
+    protected <T extends JFIFPiece> List<T> removeExifSegments(final List<T> segments) {
         return filterSegments(segments, EXIF_SEGMENT_FILTER);
     }
 
-    protected <T extends JFIFPiece> List<T> filterSegments(List<T> segments,
-            SegmentFilter filter) {
+    protected <T extends JFIFPiece> List<T> filterSegments(final List<T> segments,
+            final SegmentFilter filter) {
         return filterSegments(segments, filter, false);
     }
 
-    protected <T extends JFIFPiece> List<T> filterSegments(List<T> segments,
-            SegmentFilter filter, boolean reverse) {
-        List<T> result = new ArrayList<T>();
+    protected <T extends JFIFPiece> List<T> filterSegments(final List<T> segments,
+            final SegmentFilter filter, final boolean reverse) {
+        final List<T> result = new ArrayList<T>();
 
         for (int i = 0; i < segments.size(); i++) {
-            T piece = segments.get(i);
+            final T piece = segments.get(i);
             if (piece instanceof JFIFPieceSegment) {
                 if (filter.filter((JFIFPieceSegment) piece) ^ !reverse) {
                     result.add(piece);
@@ -256,15 +256,15 @@ public class JpegRewriter extends Binary
     }
 
     protected <T extends JFIFPiece, U extends JFIFPiece> List<JFIFPiece> insertBeforeFirstAppSegments(
-            List<T> segments, List<U> newSegments) throws ImageWriteException {
+            final List<T> segments, final List<U> newSegments) throws ImageWriteException {
         int firstAppIndex = -1;
         for (int i = 0; i < segments.size(); i++) {
-            JFIFPiece piece = segments.get(i);
+            final JFIFPiece piece = segments.get(i);
             if (!(piece instanceof JFIFPieceSegment)) {
                 continue;
             }
 
-            JFIFPieceSegment segment = (JFIFPieceSegment) piece;
+            final JFIFPieceSegment segment = (JFIFPieceSegment) piece;
             if (segment.isAppSegment()) {
                 if (firstAppIndex == -1) {
                     firstAppIndex = i;
@@ -272,7 +272,7 @@ public class JpegRewriter extends Binary
             }
         }
 
-        List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
+        final List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
         if (firstAppIndex == -1) {
             throw new ImageWriteException("JPEG file has no APP segments.");
         }
@@ -281,21 +281,21 @@ public class JpegRewriter extends Binary
     }
 
     protected <T extends JFIFPiece, U extends JFIFPiece> List<JFIFPiece> insertAfterLastAppSegments(
-            List<T> segments, List<U> newSegments) throws ImageWriteException {
+            final List<T> segments, final List<U> newSegments) throws ImageWriteException {
         int lastAppIndex = -1;
         for (int i = 0; i < segments.size(); i++) {
-            JFIFPiece piece = segments.get(i);
+            final JFIFPiece piece = segments.get(i);
             if (!(piece instanceof JFIFPieceSegment)) {
                 continue;
             }
 
-            JFIFPieceSegment segment = (JFIFPieceSegment) piece;
+            final JFIFPieceSegment segment = (JFIFPieceSegment) piece;
             if (segment.isAppSegment()) {
                 lastAppIndex = i;
             }
         }
 
-        List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
+        final List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
         if (lastAppIndex == -1) {
             if (segments.size() < 1) {
                 throw new ImageWriteException("JPEG file has no APP segments.");
@@ -309,12 +309,12 @@ public class JpegRewriter extends Binary
     }
 
     protected void writeSegments(OutputStream os,
-            List<? extends JFIFPiece> segments) throws IOException {
+            final List<? extends JFIFPiece> segments) throws IOException {
         try {
             SOI.writeTo(os);
 
             for (int i = 0; i < segments.size(); i++) {
-                JFIFPiece piece = segments.get(i);
+                final JFIFPiece piece = segments.get(i);
                 piece.write(os);
             }
             os.close();
@@ -324,7 +324,7 @@ public class JpegRewriter extends Binary
                 if (os != null) {
                     os.close();
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 // swallow exception; already in the context of an exception.
             }
         }
@@ -351,7 +351,7 @@ public class JpegRewriter extends Binary
             ImageWriteException {
         private static final long serialVersionUID = -1062145751550646846L;
 
-        public JpegSegmentOverflowException(String s) {
+        public JpegSegmentOverflowException(final String s) {
             super(s);
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java Tue Dec  4 17:23:16 2012
@@ -30,23 +30,23 @@ public class JpegXmpParser extends Binar
         setByteOrder(ByteOrder.NETWORK);
     }
 
-    public boolean isXmpJpegSegment(byte segmentData[]) {
+    public boolean isXmpJpegSegment(final byte segmentData[]) {
         return BinaryFileParser.byteArrayHasPrefix(segmentData, XMP_IDENTIFIER);
     }
 
-    public String parseXmpJpegSegment(byte segmentData[])
+    public String parseXmpJpegSegment(final byte segmentData[])
             throws ImageReadException {
         if (!isXmpJpegSegment(segmentData)) {
             throw new ImageReadException("Invalid JPEG XMP Segment.");
         }
-        int index = XMP_IDENTIFIER.size();
+        final int index = XMP_IDENTIFIER.size();
 
         try {
             // segment data is UTF-8 encoded xml.
-            String xml = new String(segmentData, index, segmentData.length
+            final String xml = new String(segmentData, index, segmentData.length
                     - index, "utf-8");
             return xml;
-        } catch (UnsupportedEncodingException e) {
+        } catch (final UnsupportedEncodingException e) {
             throw new ImageReadException("Invalid JPEG XMP Segment.");
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java Tue Dec  4 17:23:16 2012
@@ -49,9 +49,9 @@ public class JpegXmpRewriter extends Jpe
      * @see java.io.File
      * @see java.io.OutputStream
      */
-    public void removeXmpXml(File src, OutputStream os)
+    public void removeXmpXml(final File src, final OutputStream os)
             throws ImageReadException, IOException {
-        ByteSource byteSource = new ByteSourceFile(src);
+        final ByteSource byteSource = new ByteSourceFile(src);
         removeXmpXml(byteSource, os);
     }
 
@@ -65,9 +65,9 @@ public class JpegXmpRewriter extends Jpe
      * @param os
      *            OutputStream to write the image to.
      */
-    public void removeXmpXml(byte src[], OutputStream os)
+    public void removeXmpXml(final byte src[], final OutputStream os)
             throws ImageReadException, IOException {
-        ByteSource byteSource = new ByteSourceArray(src);
+        final ByteSource byteSource = new ByteSourceArray(src);
         removeXmpXml(byteSource, os);
     }
 
@@ -81,9 +81,9 @@ public class JpegXmpRewriter extends Jpe
      * @param os
      *            OutputStream to write the image to.
      */
-    public void removeXmpXml(InputStream src, OutputStream os)
+    public void removeXmpXml(final InputStream src, final OutputStream os)
             throws ImageReadException, IOException {
-        ByteSource byteSource = new ByteSourceInputStream(src, null);
+        final ByteSource byteSource = new ByteSourceInputStream(src, null);
         removeXmpXml(byteSource, os);
     }
 
@@ -97,9 +97,9 @@ public class JpegXmpRewriter extends Jpe
      * @param os
      *            OutputStream to write the image to.
      */
-    public void removeXmpXml(ByteSource byteSource, OutputStream os)
+    public void removeXmpXml(final ByteSource byteSource, final OutputStream os)
             throws ImageReadException, IOException {
-        JFIFPieces jfifPieces = analyzeJFIF(byteSource);
+        final JFIFPieces jfifPieces = analyzeJFIF(byteSource);
         List<JFIFPiece> pieces = jfifPieces.pieces;
         pieces = removeXmpSegments(pieces);
         writeSegments(os, pieces);
@@ -116,9 +116,9 @@ public class JpegXmpRewriter extends Jpe
      * @param xmpXml
      *            String containing XMP XML.
      */
-    public void updateXmpXml(byte src[], OutputStream os, String xmpXml)
+    public void updateXmpXml(final byte src[], final OutputStream os, final String xmpXml)
             throws ImageReadException, IOException, ImageWriteException {
-        ByteSource byteSource = new ByteSourceArray(src);
+        final ByteSource byteSource = new ByteSourceArray(src);
         updateXmpXml(byteSource, os, xmpXml);
     }
 
@@ -133,9 +133,9 @@ public class JpegXmpRewriter extends Jpe
      * @param xmpXml
      *            String containing XMP XML.
      */
-    public void updateXmpXml(InputStream src, OutputStream os, String xmpXml)
+    public void updateXmpXml(final InputStream src, final OutputStream os, final String xmpXml)
             throws ImageReadException, IOException, ImageWriteException {
-        ByteSource byteSource = new ByteSourceInputStream(src, null);
+        final ByteSource byteSource = new ByteSourceInputStream(src, null);
         updateXmpXml(byteSource, os, xmpXml);
     }
 
@@ -150,9 +150,9 @@ public class JpegXmpRewriter extends Jpe
      * @param xmpXml
      *            String containing XMP XML.
      */
-    public void updateXmpXml(File src, OutputStream os, String xmpXml)
+    public void updateXmpXml(final File src, final OutputStream os, final String xmpXml)
             throws ImageReadException, IOException, ImageWriteException {
-        ByteSource byteSource = new ByteSourceFile(src);
+        final ByteSource byteSource = new ByteSourceFile(src);
         updateXmpXml(byteSource, os, xmpXml);
     }
 
@@ -167,19 +167,19 @@ public class JpegXmpRewriter extends Jpe
      * @param xmpXml
      *            String containing XMP XML.
      */
-    public void updateXmpXml(ByteSource byteSource, OutputStream os,
-            String xmpXml) throws ImageReadException, IOException,
+    public void updateXmpXml(final ByteSource byteSource, final OutputStream os,
+            final String xmpXml) throws ImageReadException, IOException,
             ImageWriteException {
-        JFIFPieces jfifPieces = analyzeJFIF(byteSource);
+        final JFIFPieces jfifPieces = analyzeJFIF(byteSource);
         List<JFIFPiece> pieces = jfifPieces.pieces;
         pieces = removeXmpSegments(pieces);
 
-        List<JFIFPieceSegment> newPieces = new ArrayList<JFIFPieceSegment>();
-        byte xmpXmlBytes[] = xmpXml.getBytes("utf-8");
+        final List<JFIFPieceSegment> newPieces = new ArrayList<JFIFPieceSegment>();
+        final byte xmpXmlBytes[] = xmpXml.getBytes("utf-8");
         int index = 0;
         while (index < xmpXmlBytes.length) {
-            int segmentSize = Math.min(xmpXmlBytes.length, MAX_SEGMENT_SIZE);
-            byte segmentData[] = writeXmpSegment(xmpXmlBytes, index,
+            final int segmentSize = Math.min(xmpXmlBytes.length, MAX_SEGMENT_SIZE);
+            final byte segmentData[] = writeXmpSegment(xmpXmlBytes, index,
                     segmentSize);
             newPieces.add(new JFIFPieceSegment(JPEG_APP1_Marker, segmentData));
             index += segmentSize;
@@ -190,9 +190,9 @@ public class JpegXmpRewriter extends Jpe
         writeSegments(os, pieces);
     }
 
-    private byte[] writeXmpSegment(byte xmpXmlData[], int start, int length)
+    private byte[] writeXmpSegment(final byte xmpXmlData[], final int start, final int length)
             throws IOException {
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        final ByteArrayOutputStream os = new ByteArrayOutputStream();
 
         XMP_IDENTIFIER.writeTo(os);
         os.write(xmpXmlData, start, length);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java Tue Dec  4 17:23:16 2012
@@ -88,21 +88,21 @@ public class PcxImageParser extends Imag
     }
 
     @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 {
         return null;
     }
 
     @Override
-    public ImageInfo getImageInfo(ByteSource byteSource, Map<String,Object> params)
+    public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        PcxHeader pcxHeader = readPcxHeader(byteSource);
-        Dimension size = getImageSize(byteSource, params);
+        final PcxHeader pcxHeader = readPcxHeader(byteSource);
+        final Dimension size = getImageSize(byteSource, params);
         return new ImageInfo(
                 "PCX",
                 pcxHeader.nPlanes * pcxHeader.bitsPerPixel,
@@ -126,14 +126,14 @@ public class PcxImageParser extends Imag
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource, Map<String,Object> params)
+    public Dimension getImageSize(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        PcxHeader pcxHeader = readPcxHeader(byteSource);
-        int xSize = pcxHeader.xMax - pcxHeader.xMin + 1;
+        final PcxHeader pcxHeader = readPcxHeader(byteSource);
+        final int xSize = pcxHeader.xMax - pcxHeader.xMin + 1;
         if (xSize < 0) {
             throw new ImageReadException("Image width is negative");
         }
-        int ySize = pcxHeader.yMax - pcxHeader.yMin + 1;
+        final int ySize = pcxHeader.yMax - pcxHeader.yMin + 1;
         if (ySize < 0) {
             throw new ImageReadException("Image height is negative");
         }
@@ -141,7 +141,7 @@ public class PcxImageParser extends Imag
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource, Map<String,Object> params)
+    public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
         return null;
     }
@@ -205,7 +205,7 @@ public class PcxImageParser extends Imag
             this.vScreenSize = vScreenSize;
         }
 
-        public void dump(PrintWriter pw) {
+        public void dump(final PrintWriter pw) {
             pw.println("PcxHeader");
             pw.println("Manufacturer: " + manufacturer);
             pw.println("Version: " + version);
@@ -237,7 +237,7 @@ public class PcxImageParser extends Imag
         }
     }
 
-    private PcxHeader readPcxHeader(ByteSource byteSource)
+    private PcxHeader readPcxHeader(final ByteSource byteSource)
             throws ImageReadException, IOException {
         InputStream is = null;
         try {
@@ -248,47 +248,47 @@ public class PcxImageParser extends Imag
                 if (is != null) {
                     is.close();
                 }
-            } catch (IOException ignored) {
+            } catch (final IOException ignored) {
             }
         }
     }
 
-    private PcxHeader readPcxHeader(InputStream is, boolean isStrict)
+    private PcxHeader readPcxHeader(final InputStream is, final boolean isStrict)
             throws ImageReadException, IOException {
-        byte[] pcxHeaderBytes = readByteArray("PcxHeader", 128, is,
+        final byte[] pcxHeaderBytes = readByteArray("PcxHeader", 128, is,
                 "Not a Valid PCX File");
-        int manufacturer = 0xff & pcxHeaderBytes[0];
-        int version = 0xff & pcxHeaderBytes[1];
-        int encoding = 0xff & pcxHeaderBytes[2];
-        int bitsPerPixel = 0xff & pcxHeaderBytes[3];
-        int xMin = convertByteArrayToShort("xMin", 4, pcxHeaderBytes,
+        final int manufacturer = 0xff & pcxHeaderBytes[0];
+        final int version = 0xff & pcxHeaderBytes[1];
+        final int encoding = 0xff & pcxHeaderBytes[2];
+        final int bitsPerPixel = 0xff & pcxHeaderBytes[3];
+        final int xMin = convertByteArrayToShort("xMin", 4, pcxHeaderBytes,
                 ByteOrder.LITTLE_ENDIAN);
-        int yMin = convertByteArrayToShort("yMin", 6, pcxHeaderBytes,
+        final int yMin = convertByteArrayToShort("yMin", 6, pcxHeaderBytes,
                 ByteOrder.LITTLE_ENDIAN);
-        int xMax = convertByteArrayToShort("xMax", 8, pcxHeaderBytes,
+        final int xMax = convertByteArrayToShort("xMax", 8, pcxHeaderBytes,
                 ByteOrder.LITTLE_ENDIAN);
-        int yMax = convertByteArrayToShort("yMax", 10, pcxHeaderBytes,
+        final int yMax = convertByteArrayToShort("yMax", 10, pcxHeaderBytes,
                 ByteOrder.LITTLE_ENDIAN);
-        int hDpi = convertByteArrayToShort("hDpi", 12, pcxHeaderBytes,
+        final int hDpi = convertByteArrayToShort("hDpi", 12, pcxHeaderBytes,
                 ByteOrder.LITTLE_ENDIAN);
-        int vDpi = convertByteArrayToShort("vDpi", 14, pcxHeaderBytes,
+        final int vDpi = convertByteArrayToShort("vDpi", 14, pcxHeaderBytes,
                 ByteOrder.LITTLE_ENDIAN);
-        int[] colormap = new int[16];
+        final int[] colormap = new int[16];
         for (int i = 0; i < 16; i++) {
             colormap[i] = 0xff000000
                     | ((0xff & pcxHeaderBytes[16 + 3 * i]) << 16)
                     | ((0xff & pcxHeaderBytes[16 + 3 * i + 1]) << 8)
                     | (0xff & pcxHeaderBytes[16 + 3 * i + 2]);
         }
-        int reserved = 0xff & pcxHeaderBytes[64];
-        int nPlanes = 0xff & pcxHeaderBytes[65];
-        int bytesPerLine = convertByteArrayToShort("BytesPerLine", 66,
+        final int reserved = 0xff & pcxHeaderBytes[64];
+        final int nPlanes = 0xff & pcxHeaderBytes[65];
+        final int bytesPerLine = convertByteArrayToShort("BytesPerLine", 66,
                 pcxHeaderBytes, ByteOrder.LITTLE_ENDIAN);
-        int paletteInfo = convertByteArrayToShort("PaletteInfo", 68,
+        final int paletteInfo = convertByteArrayToShort("PaletteInfo", 68,
                 pcxHeaderBytes, ByteOrder.LITTLE_ENDIAN);
-        int hScreenSize = convertByteArrayToShort("hScreenSize", 70,
+        final int hScreenSize = convertByteArrayToShort("hScreenSize", 70,
                 pcxHeaderBytes, ByteOrder.LITTLE_ENDIAN);
-        int vScreenSize = convertByteArrayToShort("vScreenSize", 72,
+        final int vScreenSize = convertByteArrayToShort("vScreenSize", 72,
                 pcxHeaderBytes, ByteOrder.LITTLE_ENDIAN);
 
         if (manufacturer != 10) {
@@ -310,14 +310,14 @@ public class PcxImageParser extends Imag
     }
 
     @Override
-    public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
+    public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource)
             throws ImageReadException, IOException {
         readPcxHeader(byteSource).dump(pw);
         return true;
     }
 
-    private void readScanLine(PcxHeader pcxHeader, InputStream is,
-            byte[] samples) throws IOException, ImageReadException {
+    private void readScanLine(final PcxHeader pcxHeader, final InputStream is,
+            final byte[] samples) throws IOException, ImageReadException {
         if (pcxHeader.encoding == PcxHeader.ENCODING_UNCOMPRESSED) {
             int r;
             for (int bytesRead = 0; bytesRead < samples.length; bytesRead += r) {
@@ -330,7 +330,7 @@ public class PcxImageParser extends Imag
         } else {
             if (pcxHeader.encoding == PcxHeader.ENCODING_RLE) {
                 for (int bytesRead = 0; bytesRead < samples.length;) {
-                    byte b = readByte("Pixel", is, "Error reading image data");
+                    final byte b = readByte("Pixel", is, "Error reading image data");
                     int count;
                     byte sample;
                     if ((b & 0xc0) == 0xc0) {
@@ -353,13 +353,13 @@ public class PcxImageParser extends Imag
         }
     }
 
-    private int[] read256ColorPalette(InputStream stream) throws IOException {
-        byte[] paletteBytes = readByteArray("Palette", 769, stream,
+    private int[] read256ColorPalette(final InputStream stream) throws IOException {
+        final byte[] paletteBytes = readByteArray("Palette", 769, stream,
                 "Error reading palette");
         if (paletteBytes[0] != 12) {
             return null;
         }
-        int[] palette = new int[256];
+        final int[] palette = new int[256];
         for (int i = 0; i < palette.length; i++) {
             palette[i] = ((0xff & paletteBytes[1 + 3 * i]) << 16)
                     | ((0xff & paletteBytes[1 + 3 * i + 1]) << 8)
@@ -368,12 +368,12 @@ public class PcxImageParser extends Imag
         return palette;
     }
 
-    private int[] read256ColorPaletteFromEndOfFile(ByteSource byteSource)
+    private int[] read256ColorPaletteFromEndOfFile(final ByteSource byteSource)
             throws IOException {
         InputStream stream = null;
         try {
             stream = byteSource.getInputStream();
-            long toSkip = byteSource.getLength() - 769;
+            final long toSkip = byteSource.getLength() - 769;
             skipBytes(stream, (int) toSkip);
             return read256ColorPalette(stream);
         } finally {
@@ -381,35 +381,35 @@ public class PcxImageParser extends Imag
                 if (stream != null) {
                     stream.close();
                 }
-            } catch (IOException closeException) {
+            } catch (final IOException closeException) {
             }
         }
     }
 
-    private BufferedImage readImage(PcxHeader pcxHeader, InputStream is,
-            ByteSource byteSource) throws ImageReadException, IOException {
-        int xSize = pcxHeader.xMax - pcxHeader.xMin + 1;
+    private BufferedImage readImage(final PcxHeader pcxHeader, final InputStream is,
+            final ByteSource byteSource) throws ImageReadException, IOException {
+        final int xSize = pcxHeader.xMax - pcxHeader.xMin + 1;
         if (xSize < 0) {
             throw new ImageReadException("Image width is negative");
         }
-        int ySize = pcxHeader.yMax - pcxHeader.yMin + 1;
+        final int ySize = pcxHeader.yMax - pcxHeader.yMin + 1;
         if (ySize < 0) {
             throw new ImageReadException("Image height is negative");
         }
 
-        int scanlineLength = pcxHeader.bytesPerLine * pcxHeader.nPlanes;
-        byte[] scanline = new byte[scanlineLength];
+        final int scanlineLength = pcxHeader.bytesPerLine * pcxHeader.nPlanes;
+        final byte[] scanline = new byte[scanlineLength];
         if ((pcxHeader.bitsPerPixel == 1 || pcxHeader.bitsPerPixel == 2
                 || pcxHeader.bitsPerPixel == 4 || pcxHeader.bitsPerPixel == 8)
                 && pcxHeader.nPlanes == 1) {
-            int bytesPerImageRow = (xSize * pcxHeader.bitsPerPixel + 7) / 8;
-            byte[] image = new byte[ySize * bytesPerImageRow];
+            final int bytesPerImageRow = (xSize * pcxHeader.bitsPerPixel + 7) / 8;
+            final byte[] image = new byte[ySize * bytesPerImageRow];
             for (int y = 0; y < ySize; y++) {
                 readScanLine(pcxHeader, is, scanline);
                 System.arraycopy(scanline, 0, image, y * bytesPerImageRow,
                         bytesPerImageRow);
             }
-            DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
+            final DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
             int[] palette;
             if (pcxHeader.bitsPerPixel == 1) {
                 palette = new int[] { 0x000000, 0xffffff };
@@ -440,26 +440,26 @@ public class PcxImageParser extends Imag
                 raster = WritableRaster.createPackedRaster(dataBuffer, xSize,
                         ySize, pcxHeader.bitsPerPixel, null);
             }
-            IndexColorModel colorModel = new IndexColorModel(
+            final IndexColorModel colorModel = new IndexColorModel(
                     pcxHeader.bitsPerPixel, 1 << pcxHeader.bitsPerPixel,
                     palette, 0, false, -1, DataBuffer.TYPE_BYTE);
             return new BufferedImage(colorModel, raster,
                     colorModel.isAlphaPremultiplied(), new Properties());
         } else if (pcxHeader.bitsPerPixel == 1 && 2 <= pcxHeader.nPlanes
                 && pcxHeader.nPlanes <= 4) {
-            IndexColorModel colorModel = new IndexColorModel(pcxHeader.nPlanes,
+            final IndexColorModel colorModel = new IndexColorModel(pcxHeader.nPlanes,
                     1 << pcxHeader.nPlanes, pcxHeader.colormap, 0, false, -1,
                     DataBuffer.TYPE_BYTE);
-            BufferedImage image = new BufferedImage(xSize, ySize,
+            final BufferedImage image = new BufferedImage(xSize, ySize,
                     BufferedImage.TYPE_BYTE_BINARY, colorModel);
-            byte[] unpacked = new byte[xSize];
+            final byte[] unpacked = new byte[xSize];
             for (int y = 0; y < ySize; y++) {
                 readScanLine(pcxHeader, is, scanline);
                 int nextByte = 0;
                 Arrays.fill(unpacked, (byte) 0);
                 for (int plane = 0; plane < pcxHeader.nPlanes; plane++) {
                     for (int i = 0; i < pcxHeader.bytesPerLine; i++) {
-                        int b = 0xff & scanline[nextByte++];
+                        final int b = 0xff & scanline[nextByte++];
                         for (int j = 0; j < 8 && 8 * i + j < unpacked.length; j++) {
                             unpacked[8 * i + j] |= (byte) (((b >> (7 - j)) & 0x1) << plane);
                         }
@@ -469,7 +469,7 @@ public class PcxImageParser extends Imag
             }
             return image;
         } else if (pcxHeader.bitsPerPixel == 8 && pcxHeader.nPlanes == 3) {
-            byte[][] image = new byte[3][];
+            final byte[][] image = new byte[3][];
             image[0] = new byte[xSize * ySize];
             image[1] = new byte[xSize * ySize];
             image[2] = new byte[xSize * ySize];
@@ -481,20 +481,20 @@ public class PcxImageParser extends Imag
                 System.arraycopy(scanline, 2 * pcxHeader.bytesPerLine,
                         image[2], y * xSize, xSize);
             }
-            DataBufferByte dataBuffer = new DataBufferByte(image,
+            final DataBufferByte dataBuffer = new DataBufferByte(image,
                     image[0].length);
-            WritableRaster raster = WritableRaster.createBandedRaster(
+            final WritableRaster raster = WritableRaster.createBandedRaster(
                     dataBuffer, xSize, ySize, xSize, new int[] { 0, 1, 2 },
                     new int[] { 0, 0, 0 }, null);
-            ColorModel colorModel = new ComponentColorModel(
+            final ColorModel colorModel = new ComponentColorModel(
                     ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                     Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
             return new BufferedImage(colorModel, raster,
                     colorModel.isAlphaPremultiplied(), new Properties());
         } else if ((pcxHeader.bitsPerPixel == 24 && pcxHeader.nPlanes == 1)
                 || (pcxHeader.bitsPerPixel == 32 && pcxHeader.nPlanes == 1)) {
-            int rowLength = 3 * xSize;
-            byte[] image = new byte[rowLength * ySize];
+            final int rowLength = 3 * xSize;
+            final byte[] image = new byte[rowLength * ySize];
             for (int y = 0; y < ySize; y++) {
                 readScanLine(pcxHeader, is, scanline);
                 if (pcxHeader.bitsPerPixel == 24) {
@@ -508,11 +508,11 @@ public class PcxImageParser extends Imag
                     }
                 }
             }
-            DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
-            WritableRaster raster = WritableRaster.createInterleavedRaster(
+            final DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
+            final WritableRaster raster = WritableRaster.createInterleavedRaster(
                     dataBuffer, xSize, ySize, rowLength, 3,
                     new int[] { 2, 1, 0 }, null);
-            ColorModel colorModel = new ComponentColorModel(
+            final ColorModel colorModel = new ComponentColorModel(
                     ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                     Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
             return new BufferedImage(colorModel, raster,
@@ -526,11 +526,11 @@ public class PcxImageParser extends Imag
     }
 
     @Override
-    public final BufferedImage getBufferedImage(ByteSource byteSource,
+    public final BufferedImage getBufferedImage(final ByteSource byteSource,
             Map<String,Object> params) throws ImageReadException, IOException {
         params = (params == null) ? new HashMap<String,Object>() : new HashMap<String,Object>(params);
         boolean isStrict = false;
-        Object strictness = params.get(PARAM_KEY_STRICT);
+        final Object strictness = params.get(PARAM_KEY_STRICT);
         if (strictness != null) {
             isStrict = ((Boolean) strictness).booleanValue();
         }
@@ -538,20 +538,20 @@ public class PcxImageParser extends Imag
         InputStream is = null;
         try {
             is = byteSource.getInputStream();
-            PcxHeader pcxHeader = readPcxHeader(is, isStrict);
+            final PcxHeader pcxHeader = readPcxHeader(is, isStrict);
             return readImage(pcxHeader, is, byteSource);
         } finally {
             try {
                 if (is != null) {
                     is.close();
                 }
-            } catch (IOException ignored) {
+            } catch (final IOException ignored) {
             }
         }
     }
 
     @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 PcxWriter(params).writeImage(src, os);
     }
@@ -567,7 +567,7 @@ public class PcxImageParser 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 {
         return null;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java Tue Dec  4 17:23:16 2012
@@ -47,13 +47,13 @@ public class PcxWriter implements PcxCon
         // let alone supported by most image viewers
         encoding = PcxImageParser.PcxHeader.ENCODING_RLE;
         if (params.containsKey(PARAM_KEY_PCX_COMPRESSION)) {
-            Object value = params.remove(PARAM_KEY_PCX_COMPRESSION);
+            final Object value = params.remove(PARAM_KEY_PCX_COMPRESSION);
             if (value != null) {
                 if (!(value instanceof Number)) {
                     throw new ImageWriteException(
                             "Invalid compression parameter: " + value);
                 }
-                int compression = ((Number) value).intValue();
+                final int compression = ((Number) value).intValue();
                 if (compression == PCX_COMPRESSION_UNCOMPRESSED) {
                     encoding = PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED;
                 }
@@ -61,7 +61,7 @@ public class PcxWriter implements PcxCon
         }
 
         if (params.containsKey(PARAM_KEY_PCX_BIT_DEPTH)) {
-            Object value = params.remove(PARAM_KEY_PCX_BIT_DEPTH);
+            final Object value = params.remove(PARAM_KEY_PCX_BIT_DEPTH);
             if (value != null) {
                 if (!(value instanceof Number)) {
                     throw new ImageWriteException(
@@ -72,7 +72,7 @@ public class PcxWriter implements PcxCon
         }
 
         if (params.containsKey(PARAM_KEY_PIXEL_DENSITY)) {
-            Object value = params.remove(PARAM_KEY_PIXEL_DENSITY);
+            final Object value = params.remove(PARAM_KEY_PIXEL_DENSITY);
             if (value != null) {
                 if (!(value instanceof PixelDensity)) {
                     throw new ImageWriteException(
@@ -87,12 +87,12 @@ public class PcxWriter implements PcxCon
         }
 
         if (params.size() > 0) {
-            Object firstKey = params.keySet().iterator().next();
+            final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
     }
 
-    private void writeScanLine(BinaryOutputStream bos, byte[] scanline)
+    private void writeScanLine(final BinaryOutputStream bos, final byte[] scanline)
             throws IOException, ImageWriteException {
         if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED) {
             bos.writeByteArray(scanline);
@@ -100,7 +100,7 @@ public class PcxWriter implements PcxCon
             if (encoding == PcxImageParser.PcxHeader.ENCODING_RLE) {
                 int previousByte = -1;
                 int repeatCount = 0;
-                for (byte element : scanline) {
+                for (final byte element : scanline) {
                     if ((element & 0xff) == previousByte
                             && repeatCount < 63) {
                         ++repeatCount;
@@ -133,12 +133,12 @@ public class PcxWriter implements PcxCon
         }
     }
 
-    public void writeImage(BufferedImage src, OutputStream os)
+    public void writeImage(final BufferedImage src, final OutputStream os)
             throws ImageWriteException, IOException {
         final PaletteFactory paletteFactory = new PaletteFactory();
         final SimplePalette palette = paletteFactory
                 .makeExactRgbPaletteSimple(src, 256);
-        BinaryOutputStream bos = new BinaryOutputStream(os,
+        final BinaryOutputStream bos = new BinaryOutputStream(os,
                 ByteOrder.INTEL);
         if (palette == null || bitDepth == 24 || bitDepth == 32) {
             if (bitDepth == 32) {
@@ -153,13 +153,13 @@ public class PcxWriter implements PcxCon
         } else {
             boolean onlyBlackAndWhite = true;
             if (palette.length() >= 1) {
-                int rgb = palette.getEntry(0);
+                final int rgb = palette.getEntry(0);
                 if (rgb != 0 && rgb != 0xffffff) {
                     onlyBlackAndWhite = false;
                 }
             }
             if (palette.length() == 2) {
-                int rgb = palette.getEntry(1);
+                final int rgb = palette.getEntry(1);
                 if (rgb != 0 && rgb != 0xffffff) {
                     onlyBlackAndWhite = false;
                 }
@@ -172,7 +172,7 @@ public class PcxWriter implements PcxCon
         }
     }
 
-    private void write32BppPCX(BufferedImage src, BinaryOutputStream bos)
+    private void write32BppPCX(final BufferedImage src, final BinaryOutputStream bos)
             throws ImageWriteException, IOException {
         final int bytesPerLine = src.getWidth() % 2 == 0 ? src.getWidth() : src
                 .getWidth() + 1;
@@ -198,8 +198,8 @@ public class PcxWriter implements PcxCon
         bos.write2Bytes(0); // vScreenSize
         bos.writeByteArray(new byte[54]);
 
-        int rgbs[] = new int[src.getWidth()];
-        byte rgbBytes[] = new byte[4 * bytesPerLine];
+        final int rgbs[] = new int[src.getWidth()];
+        final byte rgbBytes[] = new byte[4 * bytesPerLine];
         for (int y = 0; y < src.getHeight(); y++) {
             src.getRGB(0, y, src.getWidth(), 1, rgbs, 0, src.getWidth());
             for (int x = 0; x < rgbs.length; x++) {
@@ -212,7 +212,7 @@ public class PcxWriter implements PcxCon
         }
     }
 
-    private void write24BppPCX(BufferedImage src, BinaryOutputStream bos)
+    private void write24BppPCX(final BufferedImage src, final BinaryOutputStream bos)
             throws ImageWriteException, IOException {
         final int bytesPerLine = src.getWidth() % 2 == 0 ? src.getWidth() : src
                 .getWidth() + 1;
@@ -238,8 +238,8 @@ public class PcxWriter implements PcxCon
         bos.write2Bytes(0); // vScreenSize
         bos.writeByteArray(new byte[54]);
 
-        int rgbs[] = new int[src.getWidth()];
-        byte rgbBytes[] = new byte[3 * bytesPerLine];
+        final int rgbs[] = new int[src.getWidth()];
+        final byte rgbBytes[] = new byte[3 * bytesPerLine];
         for (int y = 0; y < src.getHeight(); y++) {
             src.getRGB(0, y, src.getWidth(), 1, rgbs, 0, src.getWidth());
             for (int x = 0; x < rgbs.length; x++) {
@@ -251,8 +251,8 @@ public class PcxWriter implements PcxCon
         }
     }
 
-    private void writeBlackAndWhitePCX(BufferedImage src,
-            SimplePalette palette, BinaryOutputStream bos)
+    private void writeBlackAndWhitePCX(final BufferedImage src,
+            final SimplePalette palette, final BinaryOutputStream bos)
             throws ImageWriteException, IOException {
         int bytesPerLine = (src.getWidth() + 7) / 8;
         if (bytesPerLine % 2 != 0) {
@@ -281,11 +281,11 @@ public class PcxWriter implements PcxCon
         bos.write2Bytes(0); // vScreenSize
         bos.writeByteArray(new byte[54]);
 
-        byte[] row = new byte[bytesPerLine];
+        final byte[] row = new byte[bytesPerLine];
         for (int y = 0; y < src.getHeight(); y++) {
             Arrays.fill(row, (byte) 0);
             for (int x = 0; x < src.getWidth(); x++) {
-                int rgb = 0xffffff & src.getRGB(x, y);
+                final int rgb = 0xffffff & src.getRGB(x, y);
                 int bit;
                 if (rgb == 0x000000) {
                     bit = 0;
@@ -301,14 +301,14 @@ public class PcxWriter implements PcxCon
         }
     }
 
-    private void write16ColorPCX(BufferedImage src, SimplePalette palette,
-            BinaryOutputStream bos) throws ImageWriteException, IOException {
+    private void write16ColorPCX(final BufferedImage src, final SimplePalette palette,
+            final BinaryOutputStream bos) throws ImageWriteException, IOException {
         int bytesPerLine = (src.getWidth() + 1) / 2;
         if (bytesPerLine % 2 != 0) {
             ++bytesPerLine;
         }
 
-        byte[] palette16 = new byte[16 * 3];
+        final byte[] palette16 = new byte[16 * 3];
         for (int i = 0; i < 16; i++) {
             int rgb;
             if (i < palette.length()) {
@@ -342,20 +342,20 @@ public class PcxWriter implements PcxCon
         bos.write2Bytes(0); // vScreenSize
         bos.writeByteArray(new byte[54]);
 
-        byte[] indeces = new byte[bytesPerLine];
+        final byte[] indeces = new byte[bytesPerLine];
         for (int y = 0; y < src.getHeight(); y++) {
             Arrays.fill(indeces, (byte) 0);
             for (int x = 0; x < src.getWidth(); x++) {
-                int argb = src.getRGB(x, y);
-                int index = palette.getPaletteIndex(0xffffff & argb);
+                final int argb = src.getRGB(x, y);
+                final int index = palette.getPaletteIndex(0xffffff & argb);
                 indeces[x / 2] |= (index << 4 * (1 - (x % 2)));
             }
             writeScanLine(bos, indeces);
         }
     }
 
-    private void write256ColorPCX(BufferedImage src, SimplePalette palette,
-            BinaryOutputStream bos) throws ImageWriteException, IOException {
+    private void write256ColorPCX(final BufferedImage src, final SimplePalette palette,
+            final BinaryOutputStream bos) throws ImageWriteException, IOException {
         final int bytesPerLine = src.getWidth() % 2 == 0 ? src.getWidth() : src
                 .getWidth() + 1;
 
@@ -380,11 +380,11 @@ public class PcxWriter implements PcxCon
         bos.write2Bytes(0); // vScreenSize
         bos.writeByteArray(new byte[54]);
 
-        byte[] indeces = new byte[bytesPerLine];
+        final byte[] indeces = new byte[bytesPerLine];
         for (int y = 0; y < src.getHeight(); y++) {
             for (int x = 0; x < src.getWidth(); x++) {
-                int argb = src.getRGB(x, y);
-                int index = palette.getPaletteIndex(0xffffff & argb);
+                final int argb = src.getRGB(x, y);
+                final int index = palette.getPaletteIndex(0xffffff & argb);
                 indeces[x] = (byte) index;
             }
             writeScanLine(bos, indeces);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java Tue Dec  4 17:23:16 2012
@@ -23,26 +23,26 @@ public class BitParser {
     private final int bitsPerPixel;
     private final int bitDepth;
 
-    public BitParser(byte bytes[], int bitsPerPixel, int bitDepth) {
+    public BitParser(final byte bytes[], final int bitsPerPixel, final int bitDepth) {
         this.bytes = bytes;
         this.bitsPerPixel = bitsPerPixel;
         this.bitDepth = bitDepth;
     }
 
-    public int getSample(int pixelIndexInScanline, int sampleIndex)
+    public int getSample(final int pixelIndexInScanline, final int sampleIndex)
             throws ImageReadException {
-        int pixelIndexBits = bitsPerPixel * pixelIndexInScanline;
-        int sampleIndexBits = pixelIndexBits + (sampleIndex * bitDepth);
-        int sampleIndexBytes = sampleIndexBits >> 3;
+        final int pixelIndexBits = bitsPerPixel * pixelIndexInScanline;
+        final int sampleIndexBits = pixelIndexBits + (sampleIndex * bitDepth);
+        final int sampleIndexBytes = sampleIndexBits >> 3;
 
         if (bitDepth == 8) {
             return 0xff & bytes[sampleIndexBytes];
         } else if (bitDepth < 8) {
             int b = 0xff & bytes[sampleIndexBytes];
-            int bitsToShift = 8 - ((pixelIndexBits & 7) + bitDepth);
+            final int bitsToShift = 8 - ((pixelIndexBits & 7) + bitDepth);
             b >>= bitsToShift;
 
-            int bitmask = (1 << bitDepth) - 1;
+            final int bitmask = (1 << bitDepth) - 1;
             return b & bitmask;
         } else if (bitDepth == 16) {
             return (((0xff & bytes[sampleIndexBytes]) << 8) | (0xff & bytes[sampleIndexBytes + 1]));
@@ -51,11 +51,11 @@ public class BitParser {
         throw new ImageReadException("PNG: bad BitDepth: " + bitDepth);
     }
 
-    public int getSampleAsByte(int pixelIndexInScanline, int sampleIndex)
+    public int getSampleAsByte(final int pixelIndexInScanline, final int sampleIndex)
             throws ImageReadException {
         int sample = getSample(pixelIndexInScanline, sampleIndex);
 
-        int rot = 8 - bitDepth;
+        final int rot = 8 - bitDepth;
         if (rot > 0) {
             sample = sample * 255 / ((1 << bitDepth) - 1);
         } else if (rot < 0) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/GammaCorrection.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/GammaCorrection.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/GammaCorrection.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/GammaCorrection.java Tue Dec  4 17:23:16 2012
@@ -21,7 +21,7 @@ public class GammaCorrection {
 
     private final int lookupTable[];
 
-    public GammaCorrection(double src_gamma, double dst_gamma) {
+    public GammaCorrection(final double src_gamma, final double dst_gamma) {
 
         if (DEBUG) {
             System.out.println("src_gamma: " + src_gamma);
@@ -38,12 +38,12 @@ public class GammaCorrection {
         }
     }
 
-    public int correctSample(int sample) {
+    public int correctSample(final int sample) {
         return lookupTable[sample];
     }
 
-    public int correctARGB(int pixel) {
-        int alpha = (0xff000000) & pixel;
+    public int correctARGB(final int pixel) {
+        final int alpha = (0xff000000) & pixel;
         int red = (pixel >> 16) & 0xff;
         int green = (pixel >> 8) & 0xff;
         int blue = (pixel >> 0) & 0xff;
@@ -52,13 +52,13 @@ public class GammaCorrection {
         green = correctSample(green);
         blue = correctSample(blue);
 
-        int rgb = alpha | ((0xff & red) << 16) | ((0xff & green) << 8)
+        final int rgb = alpha | ((0xff & red) << 16) | ((0xff & green) << 8)
                 | ((0xff & blue) << 0);
 
         return rgb;
     }
 
-    private int correctSample(int sample, double src_gamma, double dst_gamma) {
+    private int correctSample(final int sample, final double src_gamma, final double dst_gamma) {
         // if (kUseAdobeGammaMethod && val <= 32)
         // {
         // double slope = Math.round(255.0d * Math.pow((32.0 / 255.0d),

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java Tue Dec  4 17:23:16 2012
@@ -49,7 +49,7 @@ public class PngCrc {
      * of the final running CRC (see the crc() routine below)).
      */
 
-    private final long update_crc(long crc, byte buf[]) {
+    private final long update_crc(final long crc, final byte buf[]) {
         long c = crc;
         int n;
 
@@ -66,19 +66,19 @@ public class PngCrc {
     }
 
     /* Return the CRC of the bytes buf[0..len-1]. */
-    public final int crc(byte buf[], int len) {
+    public final int crc(final byte buf[], final int len) {
         return (int) (update_crc(0xffffffffL, buf) ^ 0xffffffffL);
     }
 
-    public final long start_partial_crc(byte buf[], int len) {
+    public final long start_partial_crc(final byte buf[], final int len) {
         return update_crc(0xffffffffL, buf);
     }
 
-    public final long continue_partial_crc(long old_crc, byte buf[], int len) {
+    public final long continue_partial_crc(final long old_crc, final byte buf[], final int len) {
         return update_crc(old_crc, buf);
     }
 
-    public final long finish_partial_crc(long old_crc) {
+    public final long finish_partial_crc(final long old_crc) {
         return (old_crc ^ 0xffffffffL);
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageInfo.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageInfo.java Tue Dec  4 17:23:16 2012
@@ -25,13 +25,13 @@ import org.apache.commons.imaging.ImageI
 public class PngImageInfo extends ImageInfo {
     private final List<PngText> textChunks;
 
-    public PngImageInfo(String formatDetails, int bitsPerPixel,
-            List<String> comments, ImageFormat format, String formatName,
-            int height, String mimeType, int numberOfImages,
-            int physicalHeightDpi, float physicalHeightInch,
-            int physicalWidthDpi, float physicalWidthInch, int width,
-            boolean isProgressive, boolean isTransparent, boolean usesPalette,
-            int colorType, String compressionAlgorithm,
+    public PngImageInfo(final String formatDetails, final int bitsPerPixel,
+            final List<String> comments, final ImageFormat format, final String formatName,
+            final int height, final String mimeType, final int numberOfImages,
+            final int physicalHeightDpi, final float physicalHeightInch,
+            final int physicalWidthDpi, final float physicalWidthInch, final int width,
+            final boolean isProgressive, final boolean isTransparent, final boolean usesPalette,
+            final int colorType, final String compressionAlgorithm,
             final List<PngText> textChunks) {
         super(formatDetails, bitsPerPixel, comments, format, formatName,
                 height, mimeType, numberOfImages, physicalHeightDpi,



Mime
View raw message