commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1441728 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: common/ common/bytesource/ formats/bmp/ formats/jpeg/ formats/jpeg/exif/ formats/jpeg/iptc/ formats/jpeg/xmp/ formats/pcx/ formats/png/ formats/rgbe/ form...
Date Sat, 02 Feb 2013 10:41:40 GMT
Author: damjan
Date: Sat Feb  2 10:41:39 2013
New Revision: 1441728

URL: http://svn.apache.org/viewvc?rev=1441728&view=rev
Log:
Cleanups.


Added:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
      - copied, changed from r1441610, commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java
Removed:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java
Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSource.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.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/jpeg/xmp/JpegRewriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java Sat Feb  2 10:41:39 2013
@@ -320,13 +320,7 @@ public class BinaryConversions {
     }
 
     public static short toShort(final byte[] bytes, final int offset, final ByteOrder byteOrder) {
-        final int byte0 = 0xff & bytes[offset + 0];
-        final int byte1 = 0xff & bytes[offset + 1];
-        if (byteOrder == ByteOrder.MOTOROLA) {
-            return (short) ((byte0 << 8) | byte1);
-        } else {
-            return (short) ((byte1 << 8) | byte0);
-        }
+        return (short) toUInt16(bytes, offset, byteOrder);
     }
 
     public static short[] toShorts(final byte[] bytes, final ByteOrder byteOrder) {
@@ -347,10 +341,24 @@ public class BinaryConversions {
         return result;
     }
 
+    public static int toUInt16(final byte[] bytes, final ByteOrder byteOrder) {
+        return toUInt16(bytes, 0, byteOrder);
+    }
+    
+    public static int toUInt16(final byte[] bytes, final int offset, final ByteOrder byteOrder) {
+        final int byte0 = 0xff & bytes[offset + 0];
+        final int byte1 = 0xff & bytes[offset + 1];
+        if (byteOrder == ByteOrder.MOTOROLA) {
+            return ((byte0 << 8) | byte1);
+        } else {
+            return ((byte1 << 8) | byte0);
+        }
+    }
+    
     public static int toInt(final byte[] bytes, final ByteOrder byteOrder) {
         return toInt(bytes, 0, byteOrder);
     }
-
+    
     public static int toInt(final byte[] bytes, final int offset, final ByteOrder byteOrder) {
         final int byte0 = 0xff & bytes[offset + 0];
         final int byte1 = 0xff & bytes[offset + 1];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java Sat Feb  2 10:41:39 2013
@@ -18,23 +18,24 @@ package org.apache.commons.imaging.commo
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
 
 import org.apache.commons.imaging.ImageReadException;
 
-public class BinaryFileParser extends BinaryFileFunctions {
+public class BinaryFileParser {
+    // default byte order for Java, many file formats.
+    private ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+    protected boolean debug = false;
+
     public BinaryFileParser(final ByteOrder byteOrder) {
         this.byteOrder = byteOrder;
     }
 
     public BinaryFileParser() {
-
     }
 
-    // default byte order for Java, many file formats.
-    private ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
-
-    // protected boolean BYTE_ORDER_reversed = true;
-
     protected void setByteOrder(final ByteOrder byteOrder) {
         this.byteOrder = byteOrder;
     }
@@ -42,36 +43,176 @@ public class BinaryFileParser extends Bi
     public ByteOrder getByteOrder() {
         return byteOrder;
     }
+    
+    public boolean getDebug() {
+        return debug;
+    }
+    
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
 
-    protected final int convertByteArrayToInt(final String name, final byte bytes[]) {
-        return BinaryConversions.toInt(bytes, byteOrder);
+    protected final byte[] toBytes(short value) {
+        return BinaryConversions.toBytes(value, byteOrder);
     }
 
-    public final int convertByteArrayToShort(final String name, final byte[] bytes)
-            throws ImageReadException {
-        return convertByteArrayToShort(name, bytes, byteOrder);
+    protected final byte[] toBytes(short value, ByteOrder byteOrder) {
+        return BinaryConversions.toBytes(value, byteOrder);
+    }
+
+    protected final int toInt(final byte bytes[]) {
+        return BinaryConversions.toInt(bytes, byteOrder);
     }
     
-    public final int convertByteArrayToShort(final String name, final int start,
-            final byte bytes[]) throws ImageReadException {
-        return convertByteArrayToShort(name, start, bytes, byteOrder);
+    protected final int toUInt16(final byte[] bytes) {
+        return BinaryConversions.toUInt16(bytes, byteOrder);
+    }
+
+    public final int toUInt16(final byte bytes[], final int start) {
+        return BinaryConversions.toUInt16(bytes, start, byteOrder);
     }
 
+    public byte[] getStreamBytes(final InputStream is) throws IOException {
+        return BinaryFunctions.getStreamBytes(is);
+    }
+    
     public final int read4Bytes(final String name, final InputStream is, final String exception)
             throws IOException {
-        return read4Bytes(name, is, exception, byteOrder);
+        return BinaryFunctions.read4Bytes(name, is, exception, byteOrder);
     }
 
     public final int read3Bytes(final String name, final InputStream is, final String exception)
             throws IOException {
-        return read3Bytes(name, is, exception, byteOrder);
+        return BinaryFunctions.read3Bytes(name, is, exception, byteOrder);
     }
 
     public final int read2Bytes(final String name, final InputStream is, final String exception)
             throws ImageReadException, IOException {
-        return read2Bytes(name, is, exception, byteOrder);
+        return BinaryFunctions.read2Bytes(name, is, exception, byteOrder);
+    }
+    
+    public final byte readByte(final String name, final InputStream is, final String exception)
+            throws IOException {
+        return BinaryFunctions.readByte(name, is, exception);
+    }
+    
+    public final byte[] readByteArray(final String name, final int length, final InputStream is,
+            final String exception) throws IOException {
+        return BinaryFunctions.readByteArray(name, length, is, exception);
+    }
+    
+    public final byte[] readByteArray(final String name, final int length, final InputStream is)
+            throws IOException {
+        return BinaryFunctions.readByteArray(name, length, is);
+    }
+    
+    public byte[] readBytearray(final String name, final byte bytes[], final int start,
+            final int count) throws ImageReadException {
+        return BinaryFunctions.readBytearray(name, bytes, start, count);
+    }
+    
+    public final byte[] readBytes(final InputStream is, final int count) throws IOException {
+        return BinaryFunctions.readBytes(is, count);
+    }
+    
+    public final void readAndVerifyBytes(final InputStream is,
+            final BinaryConstant expected, final String exception)
+                    throws IOException, ImageReadException {
+        BinaryFunctions.readAndVerifyBytes(is, expected, exception);
+    }
+    
+    public final void readAndVerifyBytes(final InputStream is, final byte expected[],
+            final String exception) throws ImageReadException, IOException {
+        BinaryFunctions.readAndVerifyBytes(is, expected, exception);
+    }
+    
+    public final void skipBytes(final InputStream is, final int length)
+            throws IOException {
+        BinaryFunctions.skipBytes(is, length);
+    }
+    
+    public final void skipBytes(final InputStream is, final int length, final String exception)
+            throws IOException {
+        BinaryFunctions.skipBytes(is, length, exception);
+    }
+    
+    public final byte[] getByteArrayTail(final String name, final byte bytes[], final int count)
+            throws ImageReadException {
+        return BinaryFunctions.getByteArrayTail(name, bytes, count);
+    }
+    
+    public final int findNull(final byte src[]) {
+        return BinaryFunctions.findNull(src);
+    }
+    
+    public final int findNull(final byte src[], final int start) {
+        return BinaryFunctions.findNull(src, start);
+    }
+    
+    public void printByteBits(final String msg, final byte i) {
+        BinaryFunctions.printByteBits(msg, i);
+    }
+    
+    public void printCharQuad(final String msg, final int i) {
+        BinaryFunctions.printCharQuad(msg, i);
+    }
+
+    public final void printCharQuad(final PrintWriter pw, final String msg, final int i) {
+        BinaryFunctions.printCharQuad(pw, msg, i);
+    }
+    
+    public final void debugNumber(final String msg, final int data) {
+        debugNumber(msg, data, 1);
+    }
+
+    public final void debugNumber(final String msg, final int data, final int bytes) {
+        final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
+        debugNumber(pw, msg, data, bytes);
+        pw.flush();
+    }
+
+    public final void debugNumber(final PrintWriter pw, final String msg, final int data) {
+        debugNumber(pw, msg, data, 1);
     }
 
+    public final void debugNumber(final PrintWriter pw, final String msg, final int data,
+            final int bytes) {
+        pw.print(msg + ": " + data + " (");
+        int byteData = data;
+        for (int i = 0; i < bytes; i++) {
+            if (i > 0) {
+                pw.print(",");
+            }
+            final int singleByte = 0xff & byteData;
+            pw.print((char) singleByte + " [" + singleByte + "]");
+            byteData >>= 8;
+        }
+        pw.println(") [0x" + Integer.toHexString(data) + ", "
+                + Integer.toBinaryString(data) + "]");
+        pw.flush();
+    }
+
+    public final void debugByteArray(final String name, final byte bytes[]) {
+        System.out.println(name + ": " + bytes.length);
+
+        for (int i = 0; ((i < bytes.length) && (i < 50)); i++) {
+            debugNumber("\t" + " (" + i + ")", 0xff & bytes[i]);
+        }
+    }
+
+    public final void debugNumberArray(final String name, final int numbers[], final int length) {
+        System.out.println(name + ": " + numbers.length);
+
+        for (int i = 0; ((i < numbers.length) && (i < 50)); i++) {
+            debugNumber(name + " (" + i + ")", numbers[i], length);
+        }
+    }
+
+    public final boolean compareByteArrays(final byte a[], final int aStart, final byte b[],
+            final int bStart, final int length) {
+        return BinaryFunctions.compareByteArrays(a, aStart, b, bStart, length);
+    }
+    
     public static boolean byteArrayHasPrefix(final byte bytes[], final BinaryConstant prefix) {
         if ((bytes == null) || (bytes.length < prefix.size())) {
             return false;

Copied: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java (from r1441610, commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java)
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java?p2=commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java&p1=commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java&r1=1441610&r2=1441728&rev=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java Sat Feb  2 10:41:39 2013
@@ -20,64 +20,17 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.RandomAccessFile;
-import java.nio.charset.Charset;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
 
-public class BinaryFileFunctions {
-    protected boolean debug = false;
-
-    public final void setDebug(final boolean b) {
-        debug = b;
-    }
-
-    public final boolean getDebug() {
-        return debug;
-    }
-
-    protected final void readRandomBytes(final InputStream is) throws IOException {
-
-        for (int counter = 0; counter < 100; counter++) {
-            readByte("" + counter, is, "Random Data");
-        }
-    }
-
-    public final void debugNumber(final String msg, final int data) {
-        debugNumber(msg, data, 1);
-    }
-
-    public final void debugNumber(final String msg, final int data, final int bytes) {
-        final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
-        debugNumber(pw, msg, data, bytes);
-        pw.flush();
-    }
-
-    public final void debugNumber(final PrintWriter pw, final String msg, final int data) {
-        debugNumber(pw, msg, data, 1);
-    }
-
-    public final void debugNumber(final PrintWriter pw, final String msg, final int data,
-            final int bytes) {
-        pw.print(msg + ": " + data + " (");
-        int byteData = data;
-        for (int i = 0; i < bytes; i++) {
-            if (i > 0) {
-                pw.print(",");
-            }
-            final int singleByte = 0xff & byteData;
-            pw.print((char) singleByte + " [" + singleByte + "]");
-            byteData >>= 8;
-        }
-        pw.println(") [0x" + Integer.toHexString(data) + ", "
-                + Integer.toBinaryString(data) + "]");
-        pw.flush();
-    }
-
-    public final boolean startsWith(final byte haystack[], final byte needle[]) {
+/**
+ * Convenience methods for various binary and I/O operations.
+ */
+public class BinaryFunctions {
+    public static final boolean startsWith(final byte haystack[], final byte needle[]) {
         if (needle == null) {
             return false;
         }
@@ -97,16 +50,19 @@ public class BinaryFileFunctions {
         return true;
     }
 
-    public final byte[] readBytes(final InputStream is, final int count) throws IOException {
+    public static final byte[] readBytes(final InputStream is, final int count) throws IOException {
         final byte result[] = new byte[count];
         for (int i = 0; i < count; i++) {
             final int data = is.read();
+            if (data < 0) {
+                throw new IOException("Unexpected EOF");
+            }
             result[i] = (byte) data;
         }
         return result;
     }
 
-    public final void readAndVerifyBytes(final InputStream is, final byte expected[],
+    public static final void readAndVerifyBytes(final InputStream is, final byte expected[],
             final String exception) throws ImageReadException, IOException {
         for (final byte element : expected) {
             final int data = is.read();
@@ -117,18 +73,12 @@ public class BinaryFileFunctions {
             }
 
             if (b != element) {
-                // System.out.println("i" + ": " + i);
-
-                // this.debugByteArray("expected", expected);
-                // debugNumber("data[" + i + "]", b);
-                // debugNumber("expected[" + i + "]", expected[i]);
-
                 throw new ImageReadException(exception);
             }
         }
     }
 
-    public final void readAndVerifyBytes(final InputStream is,
+    public static final void readAndVerifyBytes(final InputStream is,
             final BinaryConstant expected, final String exception)
             throws ImageReadException, IOException {
         for (int i = 0; i < expected.size(); i++) {
@@ -145,23 +95,19 @@ public class BinaryFileFunctions {
         }
     }
 
-    protected final void readAndVerifyBytes(final String name, final InputStream is,
+    public static final void readAndVerifyBytes(final String name, final InputStream is,
             final byte expected[], final String exception) throws ImageReadException,
             IOException {
         final byte bytes[] = readByteArray(name, expected.length, is, exception);
 
         for (int i = 0; i < expected.length; i++) {
             if (bytes[i] != expected[i]) {
-                // System.out.println("i" + ": " + i);
-                // debugNumber("bytes[" + i + "]", bytes[i]);
-                // debugNumber("expected[" + i + "]", expected[i]);
-
                 throw new ImageReadException(exception);
             }
         }
     }
 
-    public final void skipBytes(final InputStream is, final int length, final String exception)
+    public static final void skipBytes(final InputStream is, final int length, final String exception)
             throws IOException {
         long total = 0;
         while (length != total) {
@@ -173,7 +119,7 @@ public class BinaryFileFunctions {
         }
     }
 
-    protected final void scanForByte(final InputStream is, final byte value)
+    public static final void scanForByte(final InputStream is, final byte value)
             throws IOException {
         int count = 0;
         for (int i = 0; count < 3; i++) {
@@ -188,23 +134,16 @@ public class BinaryFileFunctions {
         }
     }
 
-    public final byte readByte(final String name, final InputStream is, final String exception)
+    public static final byte readByte(final String name, final InputStream is, final String exception)
             throws IOException {
         final int result = is.read();
-
         if ((result < 0)) {
-            System.out.println(name + ": " + result);
             throw new IOException(exception);
         }
-
-        if (debug) {
-            debugNumber(name, result);
-        }
-
         return (byte) (0xff & result);
     }
 
-    protected final void writeIntInToByteArray(final int value, final byte bytes[],
+    public static final void writeIntInToByteArray(final int value, final byte bytes[],
             final int start, final ByteOrder byteOrder) {
         if (byteOrder == ByteOrder.MOTOROLA) {
             bytes[start + 0] = (byte) (value >> 24);
@@ -219,7 +158,7 @@ public class BinaryFileFunctions {
         }
     }
 
-    protected static final byte[] int2ToByteArray(final int value, final ByteOrder byteOrder) {
+    public static final byte[] int2ToByteArray(final int value, final ByteOrder byteOrder) {
         if (byteOrder == ByteOrder.MOTOROLA) {
             return new byte[] { (byte) (value >> 8), (byte) (value >> 0), };
         } else {
@@ -227,7 +166,7 @@ public class BinaryFileFunctions {
         }
     }
 
-    protected final byte[] convertShortToByteArray(final int value, final ByteOrder byteOrder) {
+    public static final byte[] convertShortToByteArray(final int value, final ByteOrder byteOrder) {
         final byte result[] = new byte[2];
 
         if (byteOrder == ByteOrder.MOTOROLA) {
@@ -241,7 +180,7 @@ public class BinaryFileFunctions {
         return result;
     }
 
-    protected final byte[] convertIntArrayToRationalArray(final int numerators[],
+    public static final byte[] convertIntArrayToRationalArray(final int numerators[],
             final int denominators[], final ByteOrder byteOrder) throws ImageWriteException {
         if (numerators.length != denominators.length) {
             throw new ImageWriteException("numerators.length ("
@@ -259,52 +198,19 @@ public class BinaryFileFunctions {
         return result;
     }
 
-    protected final int convertByteArrayToShort(final String name, final byte bytes[],
-            final ByteOrder byteOrder) throws ImageReadException {
-        return convertByteArrayToShort(name, 0, bytes, byteOrder);
-    }
-
-    protected final int convertByteArrayToShort(final String name, final int index,
-            final byte bytes[], final ByteOrder byteOrder) throws ImageReadException {
-        if (index + 1 >= bytes.length) {
-            throw new ImageReadException("Index out of bounds. Array size: "
-                    + bytes.length + ", index: " + index);
-        }
-
-        final int byte0 = 0xff & bytes[index + 0];
-        final int byte1 = 0xff & bytes[index + 1];
-
-        int result;
-
-        if (byteOrder == ByteOrder.MOTOROLA) {
-            result = (byte0 << 8) | byte1;
-        } else {
-            // intel, little endian
-            result = (byte1 << 8) | byte0;
-        }
-
-        if (debug) {
-            debugNumber(name, result, 2);
-        }
-
-        return result;
-    }
-
-    public final byte[] readByteArray(final String name, final int length, final InputStream is)
+    public static final byte[] readByteArray(final String name, final int length, final InputStream is)
             throws IOException {
         final String exception = name + " could not be read.";
         return readByteArray(name, length, is, exception);
     }
 
-    public final byte[] readByteArray(final String name, final int length, final InputStream is,
+    public static final byte[] readByteArray(final String name, final int length, final InputStream is,
             final String exception) throws IOException {
         final byte result[] = new byte[length];
-
         int read = 0;
         while (read < length) {
             final int count = is.read(result, read, length - read);
-            // Debug.debug("count", count);
-            if (count < 1) {
+            if (count < 0) {
                 throw new IOException(exception + " count: " + count
                         + " read: " + read + " length: " + length);
             }
@@ -312,54 +218,28 @@ public class BinaryFileFunctions {
             read += count;
         }
 
-        if (debug) {
-            for (int i = 0; ((i < length) && (i < 50)); i++) {
-                debugNumber(name + " (" + i + ")", 0xff & result[i]);
-            }
-        }
         return result;
     }
 
-    public final void debugByteArray(final String name, final byte bytes[]) {
-        System.out.println(name + ": " + bytes.length);
-
-        for (int i = 0; ((i < bytes.length) && (i < 50)); i++) {
-            debugNumber("\t" + " (" + i + ")", 0xff & bytes[i]);
-        }
-    }
-
-    protected final void debugNumberArray(final String name, final int numbers[], final int length) {
-        System.out.println(name + ": " + numbers.length);
-
-        for (int i = 0; ((i < numbers.length) && (i < 50)); i++) {
-            debugNumber(name + " (" + i + ")", numbers[i], length);
-        }
-    }
-
-    public final byte[] readBytearray(final String name, final byte bytes[], final int start,
+    public static final byte[] readBytearray(final String name, final byte bytes[], final int start,
             final int count) throws ImageReadException {
         if (bytes.length < (start + count)) {
             throw new ImageReadException("Invalid read. bytes.length: "
                     + bytes.length + ", start: " + start + ", count: " + count);
-            // return null;
         }
 
         final byte result[] = new byte[count];
         System.arraycopy(bytes, start, result, 0, count);
 
-        if (debug) {
-            debugByteArray(name, result);
-        }
-
         return result;
     }
 
-    protected final byte[] getByteArrayTail(final String name, final byte bytes[], final int count)
+    public static final byte[] getByteArrayTail(final String name, final byte bytes[], final int count)
             throws ImageReadException {
         return readBytearray(name, bytes, count, bytes.length - count);
     }
 
-    protected final byte[] getBytearrayHead(final String name, final byte bytes[], final int count)
+    public static final byte[] getBytearrayHead(final String name, final byte bytes[], final int count)
             throws ImageReadException {
         return readBytearray(name, bytes, 0, bytes.length - count);
     }
@@ -389,7 +269,7 @@ public class BinaryFileFunctions {
         return slice(bytes, 0, count);
     }
 
-    public final boolean compareByteArrays(final byte a[], final byte b[]) {
+    public static final boolean compareByteArrays(final byte a[], final byte b[]) {
         if (a.length != b.length) {
             return false;
         }
@@ -397,7 +277,7 @@ public class BinaryFileFunctions {
         return compareByteArrays(a, 0, b, 0, a.length);
     }
 
-    public final boolean compareByteArrays(final byte a[], final int aStart, final byte b[],
+    public static final boolean compareByteArrays(final byte a[], final int aStart, final byte b[],
             final int bStart, final int length) {
         if (a.length < (aStart + length)) {
             return false;
@@ -408,9 +288,6 @@ public class BinaryFileFunctions {
 
         for (int i = 0; i < length; i++) {
             if (a[aStart + i] != b[bStart + i]) {
-                // debugNumber("\t" + "a[" + (aStart + i) + "]", a[aStart + i]);
-                // debugNumber("\t" + "b[" + (bStart + i) + "]", b[bStart + i]);
-
                 return false;
             }
         }
@@ -444,7 +321,7 @@ public class BinaryFileFunctions {
         return true;
     }
 
-    protected final int read4Bytes(final String name, final InputStream is,
+    public static final int read4Bytes(final String name, final InputStream is,
             final String exception, final ByteOrder byteOrder) throws IOException {
         final int byte0 = is.read();
         final int byte1 = is.read();
@@ -463,14 +340,10 @@ public class BinaryFileFunctions {
                     | (byte1 << 8) | (byte0 << 0);
         }
 
-        if (debug) {
-            debugNumber(name, result, 4);
-        }
-
         return result;
     }
 
-    protected final int read3Bytes(final String name, final InputStream is,
+    public static final int read3Bytes(final String name, final InputStream is,
             final String exception, final ByteOrder byteOrder) throws IOException {
         final int byte0 = is.read();
         final int byte1 = is.read();
@@ -488,14 +361,10 @@ public class BinaryFileFunctions {
                     | (byte0 << 0);
         }
 
-        if (debug) {
-            debugNumber(name, result, 3);
-        }
-
         return result;
     }
 
-    protected final int read2Bytes(final String name, final InputStream is,
+    public static final int read2Bytes(final String name, final InputStream is,
             final String exception, final ByteOrder byteOrder) throws ImageReadException,
             IOException {
         final int byte0 = is.read();
@@ -511,40 +380,36 @@ public class BinaryFileFunctions {
             result = (byte1 << 8) | byte0;
         }
         
-        if (debug) {
-            debugNumber(name, result, 2);
-        }
-
         return result;
     }
 
-    protected final void printCharQuad(final String msg, final int i) {
+    public static final void printCharQuad(final String msg, final int i) {
         System.out.println(msg + ": '" + (char) (0xff & (i >> 24))
                 + (char) (0xff & (i >> 16)) + (char) (0xff & (i >> 8))
                 + (char) (0xff & (i >> 0)) + "'");
 
     }
 
-    protected final void printCharQuad(final PrintWriter pw, final String msg, final int i) {
+    public static final void printCharQuad(final PrintWriter pw, final String msg, final int i) {
         pw.println(msg + ": '" + (char) (0xff & (i >> 24))
                 + (char) (0xff & (i >> 16)) + (char) (0xff & (i >> 8))
                 + (char) (0xff & (i >> 0)) + "'");
 
     }
 
-    protected final void printByteBits(final String msg, final byte i) {
+    public static final void printByteBits(final String msg, final byte i) {
         System.out.println(msg + ": '" + Integer.toBinaryString(0xff & i));
     }
 
-    public final static int charsToQuad(final char c1, final char c2, final char c3, final char c4) {
+    public static final int charsToQuad(final char c1, final char c2, final char c3, final char c4) {
         return (((0xff & c1) << 24) | ((0xff & c2) << 16) | ((0xff & c3) << 8) | ((0xff & c4) << 0));
     }
 
-    public final int findNull(final byte src[]) {
+    public static final int findNull(final byte src[]) {
         return findNull(src, 0);
     }
 
-    public final int findNull(final byte src[], final int start) {
+    public static final int findNull(final byte src[], final int start) {
         for (int i = start; i < src.length; i++) {
             if (src[i] == 0) {
                 return i;
@@ -553,13 +418,8 @@ public class BinaryFileFunctions {
         return -1;
     }
 
-    protected final byte[] getRAFBytes(final RandomAccessFile raf, final long pos,
+    public static final byte[] getRAFBytes(final RandomAccessFile raf, final long pos,
             final int length, final String exception) throws IOException {
-        if (debug) {
-            System.out.println("getRAFBytes pos" + ": " + pos);
-            System.out.println("getRAFBytes length" + ": " + length);
-        }
-
         final byte result[] = new byte[length];
 
         raf.seek(pos);
@@ -567,7 +427,7 @@ public class BinaryFileFunctions {
         int read = 0;
         while (read < length) {
             final int count = raf.read(result, read, length - read);
-            if (count < 1) {
+            if (count < 0) {
                 throw new IOException(exception);
             }
 
@@ -578,11 +438,11 @@ public class BinaryFileFunctions {
 
     }
 
-    protected void skipBytes(final InputStream is, final int length) throws IOException {
-        this.skipBytes(is, length, "Couldn't skip bytes");
+    public static final void skipBytes(final InputStream is, final int length) throws IOException {
+        skipBytes(is, length, "Couldn't skip bytes");
     }
 
-    public final void copyStreamToStream(final InputStream is, final OutputStream os)
+    public static final void copyStreamToStream(final InputStream is, final OutputStream os)
             throws IOException {
         final byte buffer[] = new byte[1024];
         int read;
@@ -591,7 +451,7 @@ public class BinaryFileFunctions {
         }
     }
 
-    public final byte[] getStreamBytes(final InputStream is) throws IOException {
+    public static final byte[] getStreamBytes(final InputStream is) throws IOException {
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
         copyStreamToStream(is, os);
         return os.toByteArray();

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java Sat Feb  2 10:41:39 2013
@@ -22,7 +22,7 @@ import java.io.IOException;
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.InflaterInputStream;
 
-public class ZLibUtils extends BinaryFileFunctions {
+public class ZLibUtils extends BinaryFunctions {
     public final byte[] inflate(final byte bytes[]) throws IOException {
         final ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         final InflaterInputStream zIn = new InflaterInputStream(in);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSource.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSource.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSource.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSource.java Sat Feb  2 10:41:39 2013
@@ -19,9 +19,9 @@ package org.apache.commons.imaging.commo
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.commons.imaging.common.BinaryFileFunctions;
+import org.apache.commons.imaging.common.BinaryFunctions;
 
-public abstract class ByteSource extends BinaryFileFunctions {
+public abstract class ByteSource extends BinaryFunctions {
     protected final String filename;
 
     public ByteSource(final String filename) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java Sat Feb  2 10:41:39 2013
@@ -200,50 +200,50 @@ public class BmpImageParser extends Imag
         }
 
         if (verbose) {
-            this.debugNumber("identifier1", identifier1, 1);
-            this.debugNumber("identifier2", identifier2, 1);
-            this.debugNumber("fileSize", fileSize, 4);
-            this.debugNumber("reserved", reserved, 4);
-            this.debugNumber("bitmapDataOffset", bitmapDataOffset, 4);
-            this.debugNumber("bitmapHeaderSize", bitmapHeaderSize, 4);
-            this.debugNumber("width", width, 4);
-            this.debugNumber("height", height, 4);
-            this.debugNumber("planes", planes, 2);
-            this.debugNumber("bitsPerPixel", bitsPerPixel, 2);
-            this.debugNumber("compression", compression, 4);
-            this.debugNumber("bitmapDataSize", bitmapDataSize, 4);
-            this.debugNumber("hResolution", hResolution, 4);
-            this.debugNumber("vResolution", vResolution, 4);
-            this.debugNumber("colorsUsed", colorsUsed, 4);
-            this.debugNumber("colorsImportant", colorsImportant, 4);
+            debugNumber("identifier1", identifier1, 1);
+            debugNumber("identifier2", identifier2, 1);
+            debugNumber("fileSize", fileSize, 4);
+            debugNumber("reserved", reserved, 4);
+            debugNumber("bitmapDataOffset", bitmapDataOffset, 4);
+            debugNumber("bitmapHeaderSize", bitmapHeaderSize, 4);
+            debugNumber("width", width, 4);
+            debugNumber("height", height, 4);
+            debugNumber("planes", planes, 2);
+            debugNumber("bitsPerPixel", bitsPerPixel, 2);
+            debugNumber("compression", compression, 4);
+            debugNumber("bitmapDataSize", bitmapDataSize, 4);
+            debugNumber("hResolution", hResolution, 4);
+            debugNumber("vResolution", vResolution, 4);
+            debugNumber("colorsUsed", colorsUsed, 4);
+            debugNumber("colorsImportant", colorsImportant, 4);
             if (bitmapHeaderSize >= 52 || compression == BI_BITFIELDS) {
-                this.debugNumber("redMask", redMask, 4);
-                this.debugNumber("greenMask", greenMask, 4);
-                this.debugNumber("blueMask", blueMask, 4);
+                debugNumber("redMask", redMask, 4);
+                debugNumber("greenMask", greenMask, 4);
+                debugNumber("blueMask", blueMask, 4);
             }
             if (bitmapHeaderSize >= 56) {
-                this.debugNumber("alphaMask", alphaMask, 4);
+                debugNumber("alphaMask", alphaMask, 4);
             }
             if (bitmapHeaderSize >= 108) {
-                this.debugNumber("colorSpaceType", colorSpaceType, 4);
-                this.debugNumber("colorSpace.red.x", colorSpace.red.x);
-                this.debugNumber("colorSpace.red.y", colorSpace.red.y);
-                this.debugNumber("colorSpace.red.z", colorSpace.red.z);
-                this.debugNumber("colorSpace.green.x", colorSpace.green.x);
-                this.debugNumber("colorSpace.green.y", colorSpace.green.y);
-                this.debugNumber("colorSpace.green.z", colorSpace.green.z);
-                this.debugNumber("colorSpace.blue.x", colorSpace.blue.x);
-                this.debugNumber("colorSpace.blue.y", colorSpace.blue.y);
-                this.debugNumber("colorSpace.blue.z", colorSpace.blue.z);
-                this.debugNumber("gammaRed", gammaRed, 4);
-                this.debugNumber("gammaGreen", gammaGreen, 4);
-                this.debugNumber("gammaBlue", gammaBlue, 4);
+                debugNumber("colorSpaceType", colorSpaceType, 4);
+                debugNumber("colorSpace.red.x", colorSpace.red.x);
+                debugNumber("colorSpace.red.y", colorSpace.red.y);
+                debugNumber("colorSpace.red.z", colorSpace.red.z);
+                debugNumber("colorSpace.green.x", colorSpace.green.x);
+                debugNumber("colorSpace.green.y", colorSpace.green.y);
+                debugNumber("colorSpace.green.z", colorSpace.green.z);
+                debugNumber("colorSpace.blue.x", colorSpace.blue.x);
+                debugNumber("colorSpace.blue.y", colorSpace.blue.y);
+                debugNumber("colorSpace.blue.z", colorSpace.blue.z);
+                debugNumber("gammaRed", gammaRed, 4);
+                debugNumber("gammaGreen", gammaGreen, 4);
+                debugNumber("gammaBlue", gammaBlue, 4);
             }
             if (bitmapHeaderSize >= 124) {
-                this.debugNumber("intent", intent, 4);
-                this.debugNumber("profileData", profileData, 4);
-                this.debugNumber("profileSize", profileSize, 4);
-                this.debugNumber("reservedV5", reservedV5, 4);
+                debugNumber("intent", intent, 4);
+                debugNumber("profileData", profileData, 4);
+                debugNumber("profileSize", profileSize, 4);
+                debugNumber("reservedV5", reservedV5, 4);
             }
         }
 
@@ -332,11 +332,11 @@ public class BmpImageParser extends Imag
         }
 
         if (verbose) {
-            this.debugNumber("ColorsUsed", bhi.colorsUsed, 4);
-            this.debugNumber("BitsPerPixel", bhi.bitsPerPixel, 4);
-            this.debugNumber("ColorTableSize", colorTableSize, 4);
-            this.debugNumber("bhi.colorsUsed", bhi.colorsUsed, 4);
-            this.debugNumber("Compression", bhi.compression, 4);
+            debugNumber("ColorsUsed", bhi.colorsUsed, 4);
+            debugNumber("BitsPerPixel", bhi.bitsPerPixel, 4);
+            debugNumber("ColorTableSize", colorTableSize, 4);
+            debugNumber("bhi.colorsUsed", bhi.colorsUsed, 4);
+            debugNumber("Compression", bhi.compression, 4);
         }
 
         // A palette is always valid, even for images that don't need it
@@ -411,7 +411,7 @@ public class BmpImageParser extends Imag
         }
 
         if (verbose) {
-            this.debugNumber("paletteLength", paletteLength, 4);
+            debugNumber("paletteLength", paletteLength, 4);
             System.out.println("ColorTable: "
                     + ((colorTable == null) ? "null" : "" + colorTable.length));
         }
@@ -426,11 +426,11 @@ public class BmpImageParser extends Imag
             // this.debugNumber("Total Bit Per Line",
             // ((ExtraBitsPerPixel + bhi.BitsPerPixel) * bhi.Width), 4);
             // this.debugNumber("ExtraBitsPerPixel", ExtraBitsPerPixel, 4);
-            this.debugNumber("bhi.Width", bhi.width, 4);
-            this.debugNumber("bhi.Height", bhi.height, 4);
-            this.debugNumber("ImageLineLength", imageLineLength, 4);
+            debugNumber("bhi.Width", bhi.width, 4);
+            debugNumber("bhi.Height", bhi.height, 4);
+            debugNumber("ImageLineLength", imageLineLength, 4);
             // this.debugNumber("imageDataSize", imageDataSize, 4);
-            this.debugNumber("PixelCount", pixelCount, 4);
+            debugNumber("PixelCount", pixelCount, 4);
         }
         // int ImageLineLength = BytesPerPixel * bhi.Width;
         while ((imageLineLength % 4) != 0) {
@@ -444,8 +444,8 @@ public class BmpImageParser extends Imag
         final int expectedDataOffset = headerSize + paletteLength;
 
         if (verbose) {
-            this.debugNumber("bhi.BitmapDataOffset", bhi.bitmapDataOffset, 4);
-            this.debugNumber("expectedDataOffset", expectedDataOffset, 4);
+            debugNumber("bhi.BitmapDataOffset", bhi.bitmapDataOffset, 4);
+            debugNumber("expectedDataOffset", expectedDataOffset, 4);
         }
         final int extraBytes = bhi.bitmapDataOffset - expectedDataOffset;
         if (extraBytes < 0) {
@@ -461,7 +461,7 @@ public class BmpImageParser extends Imag
         final int imageDataSize = bhi.height * imageLineLength;
 
         if (verbose) {
-            this.debugNumber("imageDataSize", imageDataSize, 4);
+            debugNumber("imageDataSize", imageDataSize, 4);
         }
 
         byte imageData[];
@@ -473,7 +473,7 @@ public class BmpImageParser extends Imag
         }
 
         if (verbose) {
-            this.debugNumber("ImageData.length", imageData.length, 4);
+            debugNumber("ImageData.length", imageData.length, 4);
         }
 
         PixelParser pixelParser;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java Sat Feb  2 10:41:39 2013
@@ -78,8 +78,7 @@ public class JpegUtils extends BinaryFil
 
                 final byte segmentLengthBytes[] = readByteArray("segmentLengthBytes",
                         2, is, "segmentLengthBytes");
-                final int segmentLength = convertByteArrayToShort("segmentLength",
-                        segmentLengthBytes);
+                final int segmentLength = toUInt16(segmentLengthBytes);
 
                 final byte segmentData[] = readByteArray("Segment Data",
                         segmentLength - 2, is,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java Sat Feb  2 10:41:39 2013
@@ -496,7 +496,6 @@ public class ExifRewriter extends Binary
     private void writeSegmentsReplacingExif(final OutputStream os,
             final List<JFIFPiece> segments, final byte newBytes[])
             throws ImageWriteException, IOException {
-        final ByteOrder byteOrder = getByteOrder();
 
         try {
             SOI.writeTo(os);
@@ -511,15 +510,13 @@ public class ExifRewriter extends Binary
             }
 
             if (!hasExif && newBytes != null) {
-                final byte markerBytes[] = convertShortToByteArray(JPEG_APP1_Marker,
-                        byteOrder);
+                final byte markerBytes[] = toBytes((short)JPEG_APP1_Marker);
                 if (newBytes.length > 0xffff) {
                     throw new ExifOverflowException(
                             "APP1 Segment is too long: " + newBytes.length);
                 }
                 final int markerLength = newBytes.length + 2;
-                final byte markerLengthBytes[] = convertShortToByteArray(
-                        markerLength, byteOrder);
+                final byte markerLengthBytes[] = toBytes((short)markerLength);
 
                 int index = 0;
                 final JFIFPieceSegment firstSegment = (JFIFPieceSegment) segments
@@ -546,15 +543,13 @@ public class ExifRewriter extends Binary
                         continue;
                     }
 
-                    final byte markerBytes[] = convertShortToByteArray(
-                            JPEG_APP1_Marker, byteOrder);
+                    final byte markerBytes[] = toBytes((short)JPEG_APP1_Marker);
                     if (newBytes.length > 0xffff) {
                         throw new ExifOverflowException(
                                 "APP1 Segment is too long: " + newBytes.length);
                     }
                     final int markerLength = newBytes.length + 2;
-                    final byte markerLengthBytes[] = convertShortToByteArray(
-                            markerLength, byteOrder);
+                    final byte markerLengthBytes[] = toBytes((short)markerLength);
 
                     os.write(markerBytes);
                     os.write(markerLengthBytes);

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=1441728&r1=1441727&r2=1441728&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 Sat Feb  2 10:41:39 2013
@@ -183,7 +183,7 @@ public class IptcParser extends BinaryFi
             }
             index++;
 
-            final int recordSize = convertByteArrayToShort("recordSize", index, bytes);
+            final int recordSize = toUInt16(bytes, index);
             index += 2;
 
             final boolean extendedDataset = recordSize > IPTC_NON_EXTENDED_RECORD_MAXIMUM_SIZE;

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=1441728&r1=1441727&r2=1441728&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 Sat Feb  2 10:41:39 2013
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.common.BinaryConversions;
 import org.apache.commons.imaging.common.BinaryFileParser;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
@@ -72,8 +73,9 @@ public class JpegRewriter extends Binary
         public final byte segmentData[];
 
         public JFIFPieceSegment(final int marker, final byte[] segmentData) {
-            this(marker, int2ToByteArray(marker, JPEG_BYTE_ORDER),
-                    int2ToByteArray(segmentData.length + 2, JPEG_BYTE_ORDER),
+            this(marker,
+                    BinaryConversions.toBytes((short)marker, JPEG_BYTE_ORDER),
+                    BinaryConversions.toBytes((short)(segmentData.length + 2), JPEG_BYTE_ORDER),
                     segmentData);
         }
 

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=1441728&r1=1441727&r2=1441728&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 Sat Feb  2 10:41:39 2013
@@ -261,12 +261,12 @@ public class PcxImageParser extends Imag
         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);
-        final int yMin = convertByteArrayToShort("yMin", 6, pcxHeaderBytes);
-        final int xMax = convertByteArrayToShort("xMax", 8, pcxHeaderBytes);
-        final int yMax = convertByteArrayToShort("yMax", 10, pcxHeaderBytes);
-        final int hDpi = convertByteArrayToShort("hDpi", 12, pcxHeaderBytes);
-        final int vDpi = convertByteArrayToShort("vDpi", 14, pcxHeaderBytes);
+        final int xMin = toUInt16(pcxHeaderBytes, 4);
+        final int yMin = toUInt16(pcxHeaderBytes, 6);
+        final int xMax = toUInt16(pcxHeaderBytes, 8);
+        final int yMax = toUInt16(pcxHeaderBytes, 10);
+        final int hDpi = toUInt16(pcxHeaderBytes, 12);
+        final int vDpi = toUInt16(pcxHeaderBytes, 14);
         final int[] colormap = new int[16];
         for (int i = 0; i < 16; i++) {
             colormap[i] = 0xff000000
@@ -276,14 +276,10 @@ public class PcxImageParser extends Imag
         }
         final int reserved = 0xff & pcxHeaderBytes[64];
         final int nPlanes = 0xff & pcxHeaderBytes[65];
-        final int bytesPerLine = convertByteArrayToShort("BytesPerLine", 66,
-                pcxHeaderBytes);
-        final int paletteInfo = convertByteArrayToShort("PaletteInfo", 68,
-                pcxHeaderBytes);
-        final int hScreenSize = convertByteArrayToShort("hScreenSize", 70,
-                pcxHeaderBytes);
-        final int vScreenSize = convertByteArrayToShort("vScreenSize", 72,
-                pcxHeaderBytes);
+        final int bytesPerLine = toUInt16(pcxHeaderBytes, 66);
+        final int paletteInfo = toUInt16(pcxHeaderBytes, 68);
+        final int hScreenSize = toUInt16(pcxHeaderBytes, 70);
+        final int vScreenSize = toUInt16(pcxHeaderBytes, 72);
 
         if (manufacturer != 10) {
             throw new ImageReadException(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java Sat Feb  2 10:41:39 2013
@@ -18,7 +18,7 @@ package org.apache.commons.imaging.forma
 
 import org.apache.commons.imaging.ImagingConstants;
 import org.apache.commons.imaging.common.BinaryConstant;
-import org.apache.commons.imaging.common.BinaryFileFunctions;
+import org.apache.commons.imaging.common.BinaryFunctions;
 
 public interface PngConstants extends ImagingConstants {
 
@@ -58,31 +58,31 @@ public interface PngConstants extends Im
     public final static BinaryConstant IPHYS_CHUNK_TYPE = new BinaryConstant(
             new byte[] { 'p', 'H', 'Y', 's' });
 
-    public final static int IEND = BinaryFileFunctions.charsToQuad('I', 'E',
+    public final static int IEND = BinaryFunctions.charsToQuad('I', 'E',
             'N', 'D');
-    public final static int IHDR = BinaryFileFunctions.charsToQuad('I', 'H',
+    public final static int IHDR = BinaryFunctions.charsToQuad('I', 'H',
             'D', 'R');
-    public final static int iCCP = BinaryFileFunctions.charsToQuad('i', 'C',
+    public final static int iCCP = BinaryFunctions.charsToQuad('i', 'C',
             'C', 'P');
-    public final static int tEXt = BinaryFileFunctions.charsToQuad('t', 'E',
+    public final static int tEXt = BinaryFunctions.charsToQuad('t', 'E',
             'X', 't');
-    public final static int zTXt = BinaryFileFunctions.charsToQuad('z', 'T',
+    public final static int zTXt = BinaryFunctions.charsToQuad('z', 'T',
             'X', 't');
-    public final static int pHYs = BinaryFileFunctions.charsToQuad('p', 'H',
+    public final static int pHYs = BinaryFunctions.charsToQuad('p', 'H',
             'Y', 's');
-    public final static int PLTE = BinaryFileFunctions.charsToQuad('P', 'L',
+    public final static int PLTE = BinaryFunctions.charsToQuad('P', 'L',
             'T', 'E');
-    public final static int IDAT = BinaryFileFunctions.charsToQuad('I', 'D',
+    public final static int IDAT = BinaryFunctions.charsToQuad('I', 'D',
             'A', 'T');
-    public final static int tRNS = BinaryFileFunctions.charsToQuad('t', 'R',
+    public final static int tRNS = BinaryFunctions.charsToQuad('t', 'R',
             'N', 'S');
-    public final static int gAMA = BinaryFileFunctions.charsToQuad('g', 'A',
+    public final static int gAMA = BinaryFunctions.charsToQuad('g', 'A',
             'M', 'A');
-    public final static int sRGB = BinaryFileFunctions.charsToQuad('s', 'R',
+    public final static int sRGB = BinaryFunctions.charsToQuad('s', 'R',
             'G', 'B');
 
     // XMP chunk type.
-    public final static int iTXt = BinaryFileFunctions.charsToQuad('i', 'T',
+    public final static int iTXt = BinaryFunctions.charsToQuad('i', 'T',
             'X', 't');
 
     public static final BinaryConstant PNG_Signature = new BinaryConstant(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java Sat Feb  2 10:41:39 2013
@@ -22,7 +22,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.common.BinaryFileFunctions;
+import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.BinaryInputStream;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.common.IImageMetadata;
@@ -30,7 +30,7 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.util.Debug;
 
-class RgbeInfo extends BinaryFileFunctions {
+class RgbeInfo extends BinaryFunctions {
     private static final Pattern RESOLUTION_STRING = Pattern
             .compile("-Y (\\d+) \\+X (\\d+)");
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Sat Feb  2 10:41:39 2013
@@ -180,8 +180,7 @@ public class TiffReader extends BinaryFi
 
                 final byte valueOffsetBytes[] = readByteArray("ValueOffset", 4, is,
                         "Not a Valid TIFF File");
-                final int valueOffset = convertByteArrayToInt("ValueOffset",
-                        valueOffsetBytes);
+                final int valueOffset = toInt(valueOffsetBytes);
 
                 if (tag == 0) {
                     // skip invalid fields.

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java Sat Feb  2 10:41:39 2013
@@ -18,12 +18,12 @@ package org.apache.commons.imaging.forma
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
-import org.apache.commons.imaging.common.BinaryFileFunctions;
+import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 
-public abstract class FieldType extends BinaryFileFunctions implements
+public abstract class FieldType extends BinaryFunctions implements
         TiffConstants {
     public final int type, length;
     public final String name;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java?rev=1441728&r1=1441727&r2=1441728&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java Sat Feb  2 10:41:39 2013
@@ -20,7 +20,7 @@ import java.io.UnsupportedEncodingExcept
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
-import org.apache.commons.imaging.common.BinaryFileFunctions;
+import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
@@ -162,7 +162,7 @@ public final class TagInfoGpsText extend
         }
 
         for (final TextEncoding encoding : TEXT_ENCODINGS) {
-            if (BinaryFileFunctions.compareBytes(bytes, 0, encoding.prefix, 0,
+            if (BinaryFunctions.compareBytes(bytes, 0, encoding.prefix, 0,
                     encoding.prefix.length)) {
                 try {
                     return new String(bytes, encoding.prefix.length,

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=1441728&r1=1441727&r2=1441728&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 Sat Feb  2 10:41:39 2013
@@ -28,7 +28,7 @@ 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.BinaryFileFunctions;
+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;
@@ -67,9 +67,9 @@ public class TiffImageWriterLossless ext
                 final byte bytes[] = byteSource.getBlock(last, gepLength);
                 if (bytes.length > 2 * SLICE_SIZE) {
                     Debug.debug("\t" + "head",
-                            BinaryFileFunctions.head(bytes, SLICE_SIZE));
+                            BinaryFunctions.head(bytes, SLICE_SIZE));
                     Debug.debug("\t" + "tail",
-                            BinaryFileFunctions.tail(bytes, SLICE_SIZE));
+                            BinaryFunctions.tail(bytes, SLICE_SIZE));
                 } else {
                     Debug.debug("\t" + "bytes", bytes);
                 }



Mime
View raw message