commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1441892 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: common/ common/itu_t4/ formats/gif/ formats/ico/ formats/jpeg/iptc/ formats/png/ formats/png/scanlinefilters/ formats/psd/ formats/psd/datareaders/ format...
Date Sun, 03 Feb 2013 11:22:08 GMT
Author: damjan
Date: Sun Feb  3 11:22:08 2013
New Revision: 1441892

URL: http://svn.apache.org/viewvc?rev=1441892&view=rev
Log:
Make Eclipse happier.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java Sun Feb  3 11:22:08 2013
@@ -155,9 +155,6 @@ public class BasicCParser {
                     }
                     out.write('\'');
                 } else if (c == '\r' || c == '\n') {
-                    byte[] bb = out.toByteArray();
-                    System.err.println(new String(bb));
-                    System.err.println();
                     throw new ImageReadException("Unterminated single quote in file");
                 } else {
                     if (hadBackSlash) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java Sun Feb  3 11:22:08 2013
@@ -146,25 +146,32 @@ public class T4AndT6Compression {
             final int width, final int height) throws ImageReadException {
         final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(
                 new ByteArrayInputStream(compressed));
-        final BitArrayOutputStream outputStream = new BitArrayOutputStream();
-        for (int y = 0; y < height; y++) {
-            int color = WHITE;
-            int rowLength;
-            for (rowLength = 0; rowLength < width;) {
-                final int runLength = readTotalRunLength(inputStream, color);
-                for (int i = 0; i < runLength; i++) {
-                    outputStream.writeBit(color);
+        BitArrayOutputStream outputStream = null;
+        try {
+            outputStream = new BitArrayOutputStream();
+            for (int y = 0; y < height; y++) {
+                int color = WHITE;
+                int rowLength;
+                for (rowLength = 0; rowLength < width;) {
+                    final int runLength = readTotalRunLength(inputStream, color);
+                    for (int i = 0; i < runLength; i++) {
+                        outputStream.writeBit(color);
+                    }
+                    color = 1 - color;
+                    rowLength += runLength;
+                }
+    
+                if (rowLength == width) {
+                    inputStream.flushCache();
+                    outputStream.flush();
+                } else if (rowLength > width) {
+                    throw new ImageReadException(
+                            "Unrecoverable row length error in image row " + y);
                 }
-                color = 1 - color;
-                rowLength += runLength;
             }
-
-            if (rowLength == width) {
-                inputStream.flushCache();
-                outputStream.flush();
-            } else if (rowLength > width) {
-                throw new ImageReadException(
-                        "Unrecoverable row length error in image row " + y);
+        } finally {
+            if (outputStream != null) {
+                outputStream.close();
             }
         }
         return outputStream.toByteArray();
@@ -213,34 +220,41 @@ public class T4AndT6Compression {
             final int height, final boolean hasFill) throws ImageReadException {
         final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(
                 new ByteArrayInputStream(compressed));
-        final BitArrayOutputStream outputStream = new BitArrayOutputStream();
-        for (int y = 0; y < height; y++) {
-            T4_T6_Tables.Entry entry;
-            int rowLength;
-            try {
-                entry = (T4_T6_Tables.Entry) controlCodes.decode(inputStream);
-                if (!isEOL(entry, hasFill)) {
-                    throw new ImageReadException("Expected EOL not found");
-                }
-                int color = WHITE;
-                for (rowLength = 0; rowLength < width;) {
-                    final int runLength = readTotalRunLength(inputStream, color);
-                    for (int i = 0; i < runLength; i++) {
-                        outputStream.writeBit(color);
+        BitArrayOutputStream outputStream = null;
+        try {
+            outputStream = new BitArrayOutputStream();
+            for (int y = 0; y < height; y++) {
+                T4_T6_Tables.Entry entry;
+                int rowLength;
+                try {
+                    entry = (T4_T6_Tables.Entry) controlCodes.decode(inputStream);
+                    if (!isEOL(entry, hasFill)) {
+                        throw new ImageReadException("Expected EOL not found");
                     }
-                    color = 1 - color;
-                    rowLength += runLength;
+                    int color = WHITE;
+                    for (rowLength = 0; rowLength < width;) {
+                        final int runLength = readTotalRunLength(inputStream, color);
+                        for (int i = 0; i < runLength; i++) {
+                            outputStream.writeBit(color);
+                        }
+                        color = 1 - color;
+                        rowLength += runLength;
+                    }
+                } catch (final HuffmanTreeException huffmanException) {
+                    throw new ImageReadException("Decompression error",
+                            huffmanException);
+                }
+    
+                if (rowLength == width) {
+                    outputStream.flush();
+                } else if (rowLength > width) {
+                    throw new ImageReadException(
+                            "Unrecoverable row length error in image row " + y);
                 }
-            } catch (final HuffmanTreeException huffmanException) {
-                throw new ImageReadException("Decompression error",
-                        huffmanException);
             }
-
-            if (rowLength == width) {
-                outputStream.flush();
-            } else if (rowLength > width) {
-                throw new ImageReadException(
-                        "Unrecoverable row length error in image row " + y);
+        } finally {
+            if (outputStream != null) {
+                outputStream.close();
             }
         }
         return outputStream.toByteArray();
@@ -487,86 +501,96 @@ public class T4AndT6Compression {
 
     public static byte[] compressT6(final byte[] uncompressed, final int width, final int height)
             throws ImageWriteException {
-        final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(
-                new ByteArrayInputStream(uncompressed));
-        final BitArrayOutputStream outputStream = new BitArrayOutputStream();
-        int[] referenceLine = new int[width];
-        int[] codingLine = new int[width];
-        for (int y = 0; y < height; y++) {
-            for (int i = 0; i < width; i++) {
-                try {
-                    codingLine[i] = inputStream.readBits(1);
-                } catch (final IOException ioException) {
-                    throw new ImageWriteException(
-                            "Error reading image to compress", ioException);
-                }
-            }
-            int codingA0Color = WHITE;
-            int referenceA0Color = WHITE;
-            int a1 = nextChangingElement(codingLine, codingA0Color, 0);
-            int b1 = nextChangingElement(referenceLine, referenceA0Color, 0);
-            int b2 = nextChangingElement(referenceLine, 1 - referenceA0Color,
-                    b1 + 1);
-            for (int a0 = 0; a0 < width;) {
-                if (b2 < a1) {
-                    T4_T6_Tables.P.writeBits(outputStream);
-                    a0 = b2;
-                } else {
-                    final int a1b1 = a1 - b1;
-                    if (-3 <= a1b1 && a1b1 <= 3) {
-                        T4_T6_Tables.Entry entry;
-                        if (a1b1 == -3) {
-                            entry = T4_T6_Tables.VL3;
-                        } else if (a1b1 == -2) {
-                            entry = T4_T6_Tables.VL2;
-                        } else if (a1b1 == -1) {
-                            entry = T4_T6_Tables.VL1;
-                        } else if (a1b1 == 0) {
-                            entry = T4_T6_Tables.V0;
-                        } else if (a1b1 == 1) {
-                            entry = T4_T6_Tables.VR1;
-                        } else if (a1b1 == 2) {
-                            entry = T4_T6_Tables.VR2;
+        BitInputStreamFlexible inputStream = null;
+        try {
+            inputStream = new BitInputStreamFlexible(
+                    new ByteArrayInputStream(uncompressed));
+            final BitArrayOutputStream outputStream = new BitArrayOutputStream();
+            int[] referenceLine = new int[width];
+            int[] codingLine = new int[width];
+            for (int y = 0; y < height; y++) {
+                for (int i = 0; i < width; i++) {
+                    try {
+                        codingLine[i] = inputStream.readBits(1);
+                    } catch (final IOException ioException) {
+                        throw new ImageWriteException(
+                                "Error reading image to compress", ioException);
+                    }
+                }
+                int codingA0Color = WHITE;
+                int referenceA0Color = WHITE;
+                int a1 = nextChangingElement(codingLine, codingA0Color, 0);
+                int b1 = nextChangingElement(referenceLine, referenceA0Color, 0);
+                int b2 = nextChangingElement(referenceLine, 1 - referenceA0Color,
+                        b1 + 1);
+                for (int a0 = 0; a0 < width;) {
+                    if (b2 < a1) {
+                        T4_T6_Tables.P.writeBits(outputStream);
+                        a0 = b2;
+                    } else {
+                        final int a1b1 = a1 - b1;
+                        if (-3 <= a1b1 && a1b1 <= 3) {
+                            T4_T6_Tables.Entry entry;
+                            if (a1b1 == -3) {
+                                entry = T4_T6_Tables.VL3;
+                            } else if (a1b1 == -2) {
+                                entry = T4_T6_Tables.VL2;
+                            } else if (a1b1 == -1) {
+                                entry = T4_T6_Tables.VL1;
+                            } else if (a1b1 == 0) {
+                                entry = T4_T6_Tables.V0;
+                            } else if (a1b1 == 1) {
+                                entry = T4_T6_Tables.VR1;
+                            } else if (a1b1 == 2) {
+                                entry = T4_T6_Tables.VR2;
+                            } else {
+                                entry = T4_T6_Tables.VR3;
+                            }
+                            entry.writeBits(outputStream);
+                            codingA0Color = 1 - codingA0Color;
+                            a0 = a1;
                         } else {
-                            entry = T4_T6_Tables.VR3;
+                            final int a2 = nextChangingElement(codingLine,
+                                    1 - codingA0Color, a1 + 1);
+                            final int a0a1 = a1 - a0;
+                            final int a1a2 = a2 - a1;
+                            T4_T6_Tables.H.writeBits(outputStream);
+                            writeRunLength(outputStream, a0a1, codingA0Color);
+                            writeRunLength(outputStream, a1a2, 1 - codingA0Color);
+                            a0 = a2;
                         }
-                        entry.writeBits(outputStream);
-                        codingA0Color = 1 - codingA0Color;
-                        a0 = a1;
+                    }
+                    referenceA0Color = changingElementAt(referenceLine, a0);
+                    a1 = nextChangingElement(codingLine, codingA0Color, a0 + 1);
+                    if (codingA0Color == referenceA0Color) {
+                        b1 = nextChangingElement(referenceLine, referenceA0Color,
+                                a0 + 1);
                     } else {
-                        final int a2 = nextChangingElement(codingLine,
-                                1 - codingA0Color, a1 + 1);
-                        final int a0a1 = a1 - a0;
-                        final int a1a2 = a2 - a1;
-                        T4_T6_Tables.H.writeBits(outputStream);
-                        writeRunLength(outputStream, a0a1, codingA0Color);
-                        writeRunLength(outputStream, a1a2, 1 - codingA0Color);
-                        a0 = a2;
+                        b1 = nextChangingElement(referenceLine, referenceA0Color,
+                                a0 + 1);
+                        b1 = nextChangingElement(referenceLine,
+                                1 - referenceA0Color, b1 + 1);
                     }
+                    b2 = nextChangingElement(referenceLine, 1 - codingA0Color,
+                            b1 + 1);
                 }
-                referenceA0Color = changingElementAt(referenceLine, a0);
-                a1 = nextChangingElement(codingLine, codingA0Color, a0 + 1);
-                if (codingA0Color == referenceA0Color) {
-                    b1 = nextChangingElement(referenceLine, referenceA0Color,
-                            a0 + 1);
-                } else {
-                    b1 = nextChangingElement(referenceLine, referenceA0Color,
-                            a0 + 1);
-                    b1 = nextChangingElement(referenceLine,
-                            1 - referenceA0Color, b1 + 1);
+                final int[] swap = referenceLine;
+                referenceLine = codingLine;
+                codingLine = swap;
+                inputStream.flushCache();
+            }
+            // EOFB
+            T4_T6_Tables.EOL.writeBits(outputStream);
+            T4_T6_Tables.EOL.writeBits(outputStream);
+            return outputStream.toByteArray();
+        } finally {
+            try {
+                if (inputStream != null) {
+                    inputStream.close();
                 }
-                b2 = nextChangingElement(referenceLine, 1 - codingA0Color,
-                        b1 + 1);
+            } catch (IOException ignore) {
             }
-            final int[] swap = referenceLine;
-            referenceLine = codingLine;
-            codingLine = swap;
-            inputStream.flushCache();
         }
-        // EOFB
-        T4_T6_Tables.EOL.writeBits(outputStream);
-        T4_T6_Tables.EOL.writeBits(outputStream);
-        return outputStream.toByteArray();
     }
 
     /**

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java Sun Feb  3 11:22:08 2013
@@ -973,7 +973,7 @@ public class GifImageParser extends Imag
         }
 
         { // get Image Data.
-            int image_data_total = 0;
+//            int image_data_total = 0;
 
             int LZWMinimumCodeSize = colorTableScaleLessOne + 1;
             // LZWMinimumCodeSize = Math.max(8, LZWMinimumCodeSize);
@@ -1017,7 +1017,7 @@ public class GifImageParser extends Imag
 
             final byte compressed[] = compressor.compress(imagedata);
             writeAsSubBlocks(bos, compressed);
-            image_data_total += compressed.length;
+//            image_data_total += compressed.length;
         }
 
         // palette2.dump();

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java Sun Feb  3 11:22:08 2013
@@ -436,32 +436,39 @@ public class IcoImageParser extends Imag
         final int bitmapSize = 14 + 56 + RestOfFile.length;
 
         final ByteArrayOutputStream baos = new ByteArrayOutputStream(bitmapSize);
-        final BinaryOutputStream bos = new BinaryOutputStream(baos,
-                ByteOrder.LITTLE_ENDIAN);
-
-        bos.write('B');
-        bos.write('M');
-        bos.write4Bytes(bitmapSize);
-        bos.write4Bytes(0);
-        bos.write4Bytes(bitmapPixelsOffset);
-
-        bos.write4Bytes(56);
-        bos.write4Bytes(Width);
-        bos.write4Bytes(Height / 2);
-        bos.write2Bytes(Planes);
-        bos.write2Bytes(BitCount);
-        bos.write4Bytes(Compression);
-        bos.write4Bytes(SizeImage);
-        bos.write4Bytes(XPelsPerMeter);
-        bos.write4Bytes(YPelsPerMeter);
-        bos.write4Bytes(ColorsUsed);
-        bos.write4Bytes(ColorsImportant);
-        bos.write4Bytes(RedMask);
-        bos.write4Bytes(GreenMask);
-        bos.write4Bytes(BlueMask);
-        bos.write4Bytes(AlphaMask);
-        bos.write(RestOfFile);
-        bos.flush();
+        BinaryOutputStream bos = null;
+        try {
+            bos = new BinaryOutputStream(baos,
+                    ByteOrder.LITTLE_ENDIAN);
+    
+            bos.write('B');
+            bos.write('M');
+            bos.write4Bytes(bitmapSize);
+            bos.write4Bytes(0);
+            bos.write4Bytes(bitmapPixelsOffset);
+    
+            bos.write4Bytes(56);
+            bos.write4Bytes(Width);
+            bos.write4Bytes(Height / 2);
+            bos.write2Bytes(Planes);
+            bos.write2Bytes(BitCount);
+            bos.write4Bytes(Compression);
+            bos.write4Bytes(SizeImage);
+            bos.write4Bytes(XPelsPerMeter);
+            bos.write4Bytes(YPelsPerMeter);
+            bos.write4Bytes(ColorsUsed);
+            bos.write4Bytes(ColorsImportant);
+            bos.write4Bytes(RedMask);
+            bos.write4Bytes(GreenMask);
+            bos.write4Bytes(BlueMask);
+            bos.write4Bytes(AlphaMask);
+            bos.write(RestOfFile);
+            bos.flush();
+        } finally {
+            if (bos != null) {
+                bos.close();
+            }
+        }
 
         final ByteArrayInputStream bmpInputStream = new ByteArrayInputStream(
                 baos.toByteArray());

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java Sun Feb  3 11:22:08 2013
@@ -414,54 +414,61 @@ public class IptcParser extends BinaryFi
             throws ImageWriteException, IOException {
         byte blockData[];
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        final BinaryOutputStream bos = new BinaryOutputStream(baos,
-                getByteOrder());
-
-        // first, right record version record
-        bos.write(IPTC_RECORD_TAG_MARKER);
-        bos.write(IPTC_APPLICATION_2_RECORD_NUMBER);
-        bos.write(IptcTypes.RECORD_VERSION.type); // record version record
-                                                  // type.
-        bos.write2Bytes(2); // record version record size
-        bos.write2Bytes(2); // record version value
-
-        // make a copy of the list.
-        elements = new ArrayList<IptcRecord>(elements);
-
-        // sort the list. Records must be in numerical order.
-        final Comparator<IptcRecord> comparator = new Comparator<IptcRecord>() {
-            public int compare(final IptcRecord e1, final IptcRecord e2) {
-                return e2.iptcType.getType() - e1.iptcType.getType();
-            }
-        };
-        Collections.sort(elements, comparator);
-        // TODO: make sure order right
-
-        // write the list.
-        for (int i = 0; i < elements.size(); i++) {
-            final IptcRecord element = elements.get(i);
-
-            if (element.iptcType == IptcTypes.RECORD_VERSION) {
-                continue; // ignore
-            }
-
+        BinaryOutputStream bos = null;
+        try {
+            bos = new BinaryOutputStream(baos,
+                    getByteOrder());
+    
+            // first, right record version record
             bos.write(IPTC_RECORD_TAG_MARKER);
             bos.write(IPTC_APPLICATION_2_RECORD_NUMBER);
-            if (element.iptcType.getType() < 0
-                    || element.iptcType.getType() > 0xff) {
-                throw new ImageWriteException("Invalid record type: "
-                        + element.iptcType.getType());
+            bos.write(IptcTypes.RECORD_VERSION.type); // record version record
+                                                      // type.
+            bos.write2Bytes(2); // record version record size
+            bos.write2Bytes(2); // record version value
+    
+            // make a copy of the list.
+            elements = new ArrayList<IptcRecord>(elements);
+    
+            // sort the list. Records must be in numerical order.
+            final Comparator<IptcRecord> comparator = new Comparator<IptcRecord>() {
+                public int compare(final IptcRecord e1, final IptcRecord e2) {
+                    return e2.iptcType.getType() - e1.iptcType.getType();
+                }
+            };
+            Collections.sort(elements, comparator);
+            // TODO: make sure order right
+    
+            // write the list.
+            for (int i = 0; i < elements.size(); i++) {
+                final IptcRecord element = elements.get(i);
+    
+                if (element.iptcType == IptcTypes.RECORD_VERSION) {
+                    continue; // ignore
+                }
+    
+                bos.write(IPTC_RECORD_TAG_MARKER);
+                bos.write(IPTC_APPLICATION_2_RECORD_NUMBER);
+                if (element.iptcType.getType() < 0
+                        || element.iptcType.getType() > 0xff) {
+                    throw new ImageWriteException("Invalid record type: "
+                            + element.iptcType.getType());
+                }
+                bos.write(element.iptcType.getType());
+    
+                final byte recordData[] = element.value.getBytes("ISO-8859-1");
+                if (!new String(recordData, "ISO-8859-1").equals(element.value)) {
+                    throw new ImageWriteException(
+                            "Invalid record value, not ISO-8859-1");
+                }
+    
+                bos.write2Bytes(recordData.length);
+                bos.write(recordData);
             }
-            bos.write(element.iptcType.getType());
-
-            final byte recordData[] = element.value.getBytes("ISO-8859-1");
-            if (!new String(recordData, "ISO-8859-1").equals(element.value)) {
-                throw new ImageWriteException(
-                        "Invalid record value, not ISO-8859-1");
+        } finally {
+            if (bos != null) {
+                bos.close();
             }
-
-            bos.write2Bytes(recordData.length);
-            bos.write(recordData);
         }
 
         blockData = baos.toByteArray();

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=1441892&r1=1441891&r2=1441892&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 Sun Feb  3 11:22:08 2013
@@ -56,8 +56,8 @@ public class ScanExpediterInterlaced ext
     private static final int Starting_Col[] = { 0, 4, 0, 2, 0, 1, 0 };
     private static final int Row_Increment[] = { 8, 8, 8, 4, 4, 2, 2 };
     private static final int Col_Increment[] = { 8, 8, 4, 4, 2, 2, 1 };
-    private static final int Block_Height[] = { 8, 8, 4, 4, 2, 2, 1 };
-    private static final int Block_Width[] = { 8, 4, 4, 2, 2, 1, 1 };
+//    private static final int Block_Height[] = { 8, 8, 4, 4, 2, 2, 1 };
+//    private static final int Block_Width[] = { 8, 4, 4, 2, 2, 1, 1 };
 
     @Override
     public void drive() throws ImageReadException, IOException {
@@ -68,7 +68,7 @@ public class ScanExpediterInterlaced ext
 
             int y = Starting_Row[pass - 1];
             // int y_stride = Row_Increment[pass - 1];
-            final 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;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java Sun Feb  3 11:22:08 2013
@@ -21,10 +21,8 @@ import java.io.IOException;
 import org.apache.commons.imaging.ImageReadException;
 
 public class ScanlineFilterUp extends ScanlineFilter {
-    private final int BytesPerPixel;
 
     public ScanlineFilterUp(final int BytesPerPixel) {
-        this.BytesPerPixel = BytesPerPixel;
     }
 
     @Override

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java Sun Feb  3 11:22:08 2013
@@ -206,7 +206,8 @@ public class PsdImageParser extends Imag
                     "Not a Valid PSD File");
             available -= nameLength;
             if (((nameLength + 1) % 2) != 0) {
-                final int NameDiscard = readByte("NameDiscard", is,
+                //final int NameDiscard = 
+                readByte("NameDiscard", is,
                         "Not a Valid PSD File");
                 available -= 1;
             }
@@ -222,7 +223,8 @@ public class PsdImageParser extends Imag
             available -= DataSize;
 
             if ((DataSize % 2) != 0) {
-                final int DataDiscard = readByte("DataDiscard", is,
+                //final int DataDiscard =
+                readByte("DataDiscard", is,
                         "Not a Valid PSD File");
                 available -= 1;
             }
@@ -585,18 +587,18 @@ public class PsdImageParser extends Imag
         return result;
     }
 
-    // TODO not used
-    private ImageResourceBlock findImageResourceBlock(
-            final List<ImageResourceBlock> blocks, final int ID) {
-        for (int i = 0; i < blocks.size(); i++) {
-            final ImageResourceBlock block = blocks.get(i);
-
-            if (block.id == ID) {
-                return block;
-            }
-        }
-        return null;
-    }
+//    // TODO not used
+//    private ImageResourceBlock findImageResourceBlock(
+//            final List<ImageResourceBlock> blocks, final int ID) {
+//        for (int i = 0; i < blocks.size(); i++) {
+//            final ImageResourceBlock block = blocks.get(i);
+//
+//            if (block.id == ID) {
+//                return block;
+//            }
+//        }
+//        return null;
+//    }
 
     @Override
     public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource)
@@ -803,18 +805,18 @@ public class PsdImageParser extends Imag
         }
 
         final List<ImageResourceBlock> xmpBlocks = new ArrayList<ImageResourceBlock>();
-        if (false) {
-            // TODO: for PSD 7 and later, verify "XMP" name.
-            for (int i = 0; i < blocks.size(); i++) {
-                final ImageResourceBlock block = blocks.get(i);
-                if (!block.getName().equals(BLOCK_NAME_XMP)) {
-                    continue;
-                }
-                xmpBlocks.add(block);
-            }
-        } else {
+//        if (false) {
+//            // TODO: for PSD 7 and later, verify "XMP" name.
+//            for (int i = 0; i < blocks.size(); i++) {
+//                final ImageResourceBlock block = blocks.get(i);
+//                if (!block.getName().equals(BLOCK_NAME_XMP)) {
+//                    continue;
+//                }
+//                xmpBlocks.add(block);
+//            }
+//        } else {
             xmpBlocks.addAll(blocks);
-        }
+//        }
 
         if (xmpBlocks.size() < 1) {
             return null;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java Sun Feb  3 11:22:08 2013
@@ -73,16 +73,16 @@ public class CompressedDataReader extend
                 final InputStream bais = new ByteArrayInputStream(unpacked);
                 final MyBitInputStream mbis = new MyBitInputStream(bais,
                         ByteOrder.MOTOROLA);
-                final BitsToByteInputStream bbis = new BitsToByteInputStream(mbis, 8); // we
-                                                                                 // want
-                                                                                 // all
-                                                                                 // samples
-                                                                                 // to
-                                                                                 // be
-                                                                                 // bytes
-                final int scanline[] = bbis.readBitsArray(depth, width);
-                data[channel][y] = scanline;
-
+                BitsToByteInputStream bbis = null;
+                try {
+                    bbis = new BitsToByteInputStream(mbis, 8); // we want all samples to be bytes
+                    final int scanline[] = bbis.readBitsArray(depth, width);
+                    data[channel][y] = scanline;
+                } finally {
+                    if (bbis != null) {
+                        bbis.close();
+                    }
+                }
             }
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java Sun Feb  3 11:22:08 2013
@@ -48,20 +48,26 @@ public class UncompressedDataReader exte
         final int depth = header.Depth;
         final MyBitInputStream mbis = new MyBitInputStream(is, ByteOrder.MOTOROLA);
         // we want all samples to be bytes
-        final BitsToByteInputStream bbis = new BitsToByteInputStream(mbis, 8);
+        BitsToByteInputStream bbis = null;
+        try {
+            bbis = new BitsToByteInputStream(mbis, 8);
 
-        final int data[][][] = new int[channel_count][height][width];
-        for (int channel = 0; channel < channel_count; channel++) {
-            for (int y = 0; y < height; y++) {
-                for (int x = 0; x < width; x++) {
-                    final int b = bbis.readBits(depth);
-
-                    data[channel][y][x] = (byte) b;
+            final int data[][][] = new int[channel_count][height][width];
+            for (int channel = 0; channel < channel_count; channel++) {
+                for (int y = 0; y < height; y++) {
+                    for (int x = 0; x < width; x++) {
+                        final int b = bbis.readBits(depth);
+    
+                        data[channel][y][x] = (byte) b;
+                    }
                 }
             }
+    
+            dataParser.parseData(data, bi, imageContents);
+        } finally {
+            if (bbis != null) {
+                bbis.close();
+            }
         }
-
-        dataParser.parseData(data, bi, imageContents);
-
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java Sun Feb  3 11:22:08 2013
@@ -31,8 +31,6 @@ import java.util.Map;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
-import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
-import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
@@ -504,19 +502,6 @@ public class TiffField implements TiffCo
         pw.flush();
     }
 
-    // private void errorDump()
-    // {
-    // Debug.debug("tagInfo", tagInfo);
-    // Debug.debug("fieldType", fieldType);
-    // Debug.debug("tag", tag);
-    // Debug.debug("type", type);
-    // Debug.debug("length", length);
-    // Debug.debug("valueOffset", valueOffset);
-    // Debug.debug("valueOffsetBytes", valueOffsetBytes);
-    // Debug.debug("oversizeValue", oversizeValue);
-    // Debug.debug("byteOrder", byteOrder);
-    // }
-
     public String getDescriptionWithoutValue() {
         return tag + " (0x" + Integer.toHexString(tag) + ": " + tagInfo.name
                 + "): ";
@@ -578,58 +563,14 @@ public class TiffField implements TiffCo
                 map.put(tag.tag, tagList);
             }
             tagList.add(tag);
-
-            // if (map.get(key) == null)
-            // map.put(key, tag);
-            // else if (!ignoreDuplicates)
-            // {
-            // System.out.println("Duplicate tag in " + name + ": " + tag.tag
-            // + " (0x" + Integer.toHexString(tag.tag) + ")");
-            // System.out.println("\t" + "New name: " + tag.name);
-            // System.out.println("\t" + "Old name: "
-            // + ((TagInfo) map.get(key)).name);
-            // }
         }
 
         return map;
     }
 
-    private static final Map<Object, List<TagInfo>> GPS_TAG_MAP = makeTagMap(
-            GpsTagConstants.ALL_GPS_TAGS, false, "GPS");
-    private static final Map<Object, List<TagInfo>> TIFF_TAG_MAP = makeTagMap(
-            TiffTagConstants.ALL_TIFF_TAGS, false, "TIFF");
-    private static final Map<Object, List<TagInfo>> EXIF_TAG_MAP = makeTagMap(
-            ExifTagConstants.ALL_EXIF_TAGS, true, "EXIF");
     private static final Map<Object, List<TagInfo>> ALL_TAG_MAP = makeTagMap(
             ALL_TAGS, true, "All");
 
-    // static
-    // {
-    // Map map = new HashMap();
-    //
-    // for (int i = 0; i < ALL_TAGS.length; i++)
-    // {
-    // TagInfo2 tag = ALL_TAGS[i];
-    // Object o = map.get("" + tag.tag);
-    // if (o == null)
-    // map.put("" + tag.tag, tag);
-    // else
-    // {
-    // System.out.println("Duplicate tag: " + tag.tag);
-    // System.out.println("\t" + "New name: " + tag.name);
-    // System.out.println("\t" + "Old name: " + ((TagInfo2) o).name);
-    // }
-    // }
-    //
-    // }
-
-    // public static final TagInfo2 ALL_TAGS[] = TagConstantsUtils
-    // .mergeTagLists(new TagInfo2[][]{
-    // ALL_EXIF_TAGS, ALL_TIFF_TAGS, ALL_GPS_TAGS,
-    // });
-    //
-    //
-
     public int[] getIntArrayValue() throws ImageReadException {
         final Object o = getValue();
         // if (o == null)

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java Sun Feb  3 11:22:08 2013
@@ -22,7 +22,6 @@ import org.apache.commons.imaging.ImageR
 import org.apache.commons.imaging.common.ImageBuilder;
 
 public class PhotometricInterpreterPalette extends PhotometricInterpreter {
-    private final int[] fColorMap;
 
     /**
      * The color map of integer ARGB values tied to the pixel index of the
@@ -35,8 +34,6 @@ public class PhotometricInterpreterPalet
             final int[] fColorMap) {
         super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height);
 
-        this.fColorMap = fColorMap;
-
         final int fBitsPerPixel = bitsPerSample[0];
         final int colormap_scale = (1 << fBitsPerPixel);
         indexColorMap = new int[colormap_scale];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java Sun Feb  3 11:22:08 2013
@@ -28,7 +28,6 @@ import java.util.Map;
 import org.apache.commons.imaging.FormatCompliance;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
-import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.BinaryOutputStream;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
@@ -41,7 +40,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.formats.tiff.TiffImageData;
 import org.apache.commons.imaging.formats.tiff.TiffReader;
-import org.apache.commons.imaging.util.Debug;
 
 public class TiffImageWriterLossless extends TiffImageWriterBase {
     private final byte exifBytes[];
@@ -55,39 +53,6 @@ public class TiffImageWriterLossless ext
         this.exifBytes = exifBytes;
     }
 
-    private void dumpElements(final ByteSource byteSource, final List<TiffElement> elements)
-            throws IOException {
-        int last = TIFF_HEADER_SIZE;
-        for (int i = 0; i < elements.size(); i++) {
-            final TiffElement element = elements.get(i);
-            if (element.offset > last) {
-                final int SLICE_SIZE = 32;
-                final int gepLength = element.offset - last;
-                Debug.debug("gap of " + gepLength + " bytes.");
-                final byte bytes[] = byteSource.getBlock(last, gepLength);
-                if (bytes.length > 2 * SLICE_SIZE) {
-                    Debug.debug("\t" + "head",
-                            BinaryFunctions.head(bytes, SLICE_SIZE));
-                    Debug.debug("\t" + "tail",
-                            BinaryFunctions.tail(bytes, SLICE_SIZE));
-                } else {
-                    Debug.debug("\t" + "bytes", bytes);
-                }
-            }
-
-            Debug.debug("element[" + i + "]:" + element.getElementDescription()
-                    + " (" + element.offset + " + " + element.length + " = "
-                    + (element.offset + element.length) + ")");
-            if (element instanceof TiffDirectory) {
-                final TiffDirectory dir = (TiffDirectory) element;
-                Debug.debug("\t" + "next Directory Offset: "
-                        + dir.nextDirectoryOffset);
-            }
-            last = element.offset + element.length;
-        }
-        Debug.debug();
-    }
-    
     private List<TiffElement> analyzeOldTiff(Map<Integer,TiffOutputField> frozenFields) throws ImageWriteException,
             IOException {
         try {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java Sun Feb  3 11:22:08 2013
@@ -29,19 +29,26 @@ public enum IccTagDataTypes implements I
         public void dump(final String prefix, final byte bytes[])
                 throws ImageReadException, IOException
         {
-            final BinaryInputStream bis = new BinaryInputStream(
-                    new ByteArrayInputStream(bytes),
-                    ByteOrder.NETWORK);
-            bis.read4Bytes("type_signature", "ICC: corrupt tag data");
-
-            //            bis.setDebug(true);
-            bis.read4Bytes("ignore", "ICC: corrupt tag data");
-            final int string_length = bis.read4Bytes("string_length",
-                    "ICC: corrupt tag data");
-
-            //            bis.readByteArray("ignore", bytes.length -12, "none");
-            final String s = new String(bytes, 12, string_length - 1, "US-ASCII");
-            System.out.println(prefix + "s: '" + s + "'");
+            BinaryInputStream bis = null;
+            try {
+                bis = new BinaryInputStream(
+                        new ByteArrayInputStream(bytes),
+                        ByteOrder.NETWORK);
+                bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+    
+                //            bis.setDebug(true);
+                bis.read4Bytes("ignore", "ICC: corrupt tag data");
+                final int string_length = bis.read4Bytes("string_length",
+                        "ICC: corrupt tag data");
+    
+                //            bis.readByteArray("ignore", bytes.length -12, "none");
+                final String s = new String(bytes, 12, string_length - 1, "US-ASCII");
+                System.out.println(prefix + "s: '" + s + "'");
+            } finally {
+                if (bis != null) {
+                    bis.close();
+                }
+            }
         }
 
     },
@@ -51,10 +58,17 @@ public enum IccTagDataTypes implements I
         public void dump(final String prefix, final byte bytes[])
                 throws ImageReadException, IOException
         {
-            final BinaryInputStream bis = new BinaryInputStream(
-                    new ByteArrayInputStream(bytes),
-                    ByteOrder.NETWORK);
-            bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+            BinaryInputStream bis = null;
+            try {
+                bis = new BinaryInputStream(
+                        new ByteArrayInputStream(bytes),
+                        ByteOrder.NETWORK);
+                bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+            } finally {
+                if (bis != null) {
+                    bis.close();
+                }
+            }
         }
 
     },
@@ -64,10 +78,17 @@ public enum IccTagDataTypes implements I
         public void dump(final String prefix, final byte bytes[])
                 throws ImageReadException, IOException
         {
-            final BinaryInputStream bis = new BinaryInputStream(
-                    new ByteArrayInputStream(bytes),
-                    ByteOrder.NETWORK);
-            bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+            BinaryInputStream bis = null;
+            try {
+                bis = new BinaryInputStream(
+                        new ByteArrayInputStream(bytes),
+                        ByteOrder.NETWORK);
+                bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+            } finally {
+                if (bis != null) {
+                    bis.close();
+                }
+            }
         }
 
     },
@@ -77,23 +98,30 @@ public enum IccTagDataTypes implements I
         public void dump(final String prefix, final byte bytes[])
                 throws ImageReadException, IOException
         {
-            final BinaryInputStream bis = new BinaryInputStream(
-                    new ByteArrayInputStream(bytes),
-                    ByteOrder.NETWORK);
-            bis.read4Bytes("type_signature", "ICC: corrupt tag data");
-            bis.read4Bytes("ignore", "ICC: corrupt tag data");
-            final int thesignature = bis.read4Bytes("thesignature ",
-                    "ICC: corrupt tag data");
-            System.out.println(prefix
-                    + "thesignature: "
-                    + Integer.toHexString(thesignature)
-                    + " ("
-                    + new String(new byte[]{
-                            (byte) (0xff & (thesignature >> 24)),
-                            (byte) (0xff & (thesignature >> 16)),
-                            (byte) (0xff & (thesignature >> 8)),
-                            (byte) (0xff & (thesignature >> 0)), }, "US-ASCII")
-                    + ")");
+            BinaryInputStream bis = null;
+            try {
+                bis = new BinaryInputStream(
+                        new ByteArrayInputStream(bytes),
+                        ByteOrder.NETWORK);
+                bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+                bis.read4Bytes("ignore", "ICC: corrupt tag data");
+                final int thesignature = bis.read4Bytes("thesignature ",
+                        "ICC: corrupt tag data");
+                System.out.println(prefix
+                        + "thesignature: "
+                        + Integer.toHexString(thesignature)
+                        + " ("
+                        + new String(new byte[]{
+                                (byte) (0xff & (thesignature >> 24)),
+                                (byte) (0xff & (thesignature >> 16)),
+                                (byte) (0xff & (thesignature >> 8)),
+                                (byte) (0xff & (thesignature >> 0)), }, "US-ASCII")
+                        + ")");
+            } finally {
+                if (bis != null) {
+                    bis.close();
+                }
+            }
         }
 
     },
@@ -103,13 +131,20 @@ public enum IccTagDataTypes implements I
         public void dump(final String prefix, final byte bytes[])
                 throws ImageReadException, IOException
         {
-            final BinaryInputStream bis = new BinaryInputStream(
-                    new ByteArrayInputStream(bytes),
-                    ByteOrder.NETWORK);
-            bis.read4Bytes("type_signature", "ICC: corrupt tag data");
-            bis.read4Bytes("ignore", "ICC: corrupt tag data");
-            final String s = new String(bytes, 8, bytes.length - 8, "US-ASCII");
-            System.out.println(prefix + "s: '" + s + "'");
+            BinaryInputStream bis = null;
+            try {
+                bis = new BinaryInputStream(
+                        new ByteArrayInputStream(bytes),
+                        ByteOrder.NETWORK);
+                bis.read4Bytes("type_signature", "ICC: corrupt tag data");
+                bis.read4Bytes("ignore", "ICC: corrupt tag data");
+                final String s = new String(bytes, 8, bytes.length - 8, "US-ASCII");
+                System.out.println(prefix + "s: '" + s + "'");
+            } finally {
+                if (bis != null) {
+                    bis.close();
+                }
+            }
         }
 
     };

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java Sun Feb  3 11:22:08 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.imaging.palette;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -134,7 +135,9 @@ public class MedianCutMostPopulatedBoxes
         return true;
     }
     
-    private static class ColorComparer implements Comparator<ColorCount> {
+    private static class ColorComparer implements Comparator<ColorCount>, Serializable {
+        private static final long serialVersionUID = 1L;
+        
         private final ColorComponent colorComponent;
         
         public ColorComparer(final ColorComponent colorComponent) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java?rev=1441892&r1=1441891&r2=1441892&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java Sun Feb  3 11:22:08 2013
@@ -279,15 +279,7 @@ public class PaletteFactory {
             final int desired_count, final int table[], final int precision) {
         final List<ColorSpaceSubset> ignore = new ArrayList<ColorSpaceSubset>();
 
-        int count = 0;
         while (true) {
-            count++;
-
-            if (debug) {
-                System.out.println("cycle(" + count + "): " + v.size()
-                        + " done");
-            }
-
             int max_area = -1;
             ColorSpaceSubset max_subset = null;
 



Mime
View raw message