commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1546091 [1/2] - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: common/ formats/bmp/ formats/dcx/ formats/gif/ formats/icns/ formats/ico/ formats/jpeg/ formats/jpeg/decoder/ formats/jpeg/exif/ formats/jpeg/iptc/ ...
Date Wed, 27 Nov 2013 16:28:02 GMT
Author: ebourg
Date: Wed Nov 27 16:28:01 2013
New Revision: 1546091

URL: http://svn.apache.org/r1546091
Log:
Removed the methods in BinaryFileParser redirecting to BinaryFunctions and use a static import instead

Modified:
    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/BinaryFunctions.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ByteConversions.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/dcx/DcxImageParser.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/icns/IcnsImageParser.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/JpegImageParser.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/decoder/JpegDecoder.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/segments/App14Segment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App2Segment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.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/jpeg/xmp/JpegXmpParser.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/PngImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterGrayscale.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterTrueColor.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.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/tiff/TiffReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -16,15 +16,11 @@
  */
 package org.apache.commons.imaging.common;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.nio.ByteOrder;
 import java.nio.charset.Charset;
 
-import org.apache.commons.imaging.ImageReadException;
-
 public class BinaryFileParser {
     // default byte order for Java, many file formats.
     private ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
@@ -48,143 +44,22 @@ public class BinaryFileParser {
     public ByteOrder getByteOrder() {
         return byteOrder;
     }
-    
+
     public boolean getDebug() {
         return debug;
     }
-    
+
     public void setDebug(final boolean debug) {
         this.debug = debug;
     }
 
-    protected final byte[] toBytes(final short value) {
-        return ByteConversions.toBytes(value, byteOrder);
-    }
-
-    protected final byte[] toBytes(final short value, final ByteOrder byteOrder) {
-        return ByteConversions.toBytes(value, byteOrder);
-    }
-
-    protected final int toInt(final byte[] bytes) {
-        return ByteConversions.toInt(bytes, byteOrder);
-    }
-    
-    protected final int toUInt16(final byte[] bytes) {
-        return ByteConversions.toUInt16(bytes, byteOrder);
-    }
-
-    protected final int toUInt16(final byte[] bytes, final int start) {
-        return ByteConversions.toUInt16(bytes, start, byteOrder);
-    }
-
-    protected byte[] getStreamBytes(final InputStream is) throws IOException {
-        return BinaryFunctions.getStreamBytes(is);
-    }
-    
-    protected final int read4Bytes(final String name, final InputStream is, final String exception)
-            throws IOException {
-        return BinaryFunctions.read4Bytes(name, is, exception, byteOrder);
-    }
-
-    protected final int read3Bytes(final String name, final InputStream is, final String exception)
-            throws IOException {
-        return BinaryFunctions.read3Bytes(name, is, exception, byteOrder);
-    }
-
-    protected final int read2Bytes(final String name, final InputStream is, final String exception)
-            throws IOException {
-        return BinaryFunctions.read2Bytes(name, is, exception, byteOrder);
-    }
-    
-    protected final byte readByte(final String name, final InputStream is, final String exception)
-            throws IOException {
-        return BinaryFunctions.readByte(name, is, exception);
-    }
-    
-    protected final byte[] readBytes(final String name, final InputStream is, final int length,
-            final String exception) throws IOException {
-        return BinaryFunctions.readBytes(name, is, length, exception);
-    }
-    
-    protected final byte[] readBytes(final String name, final InputStream is, final int length)
-            throws IOException {
-        return BinaryFunctions.readBytes(name, is, length);
-    }
-    
-    protected final byte[] readBytes(final InputStream is, final int count) throws IOException {
-        return BinaryFunctions.readBytes(is, count);
-    }
-    
-    protected final void readAndVerifyBytes(final InputStream is,
-            final BinaryConstant expected, final String exception)
-                    throws IOException, ImageReadException {
-        BinaryFunctions.readAndVerifyBytes(is, expected, exception);
-    }
-    
-    protected final void readAndVerifyBytes(final InputStream is, final byte[] expected,
-            final String exception) throws ImageReadException, IOException {
-        BinaryFunctions.readAndVerifyBytes(is, expected, exception);
-    }
-    
-    protected final void skipBytes(final InputStream is, final int length)
-            throws IOException {
-        BinaryFunctions.skipBytes(is, length);
-    }
-
-    protected final void skipBytes(final InputStream is, final long length)
-            throws IOException {
-        BinaryFunctions.skipBytes(is, length);
-    }
-
-    protected final void skipBytes(final InputStream is, final long length, final String exception)
-            throws IOException {
-        BinaryFunctions.skipBytes(is, length, exception);
-    }
-    
-    protected final byte[] remainingBytes(final String name, final byte[] bytes, final int count) {
-        return BinaryFunctions.remainingBytes(name, bytes, count);
-    }
-    
-    protected final byte[] slice(final byte[] bytes, final int start, final int count) {
-        return BinaryFunctions.slice(bytes, start, count);
-    }
-    
-    protected final int findNull(final byte[] src) {
-        return BinaryFunctions.findNull(src);
-    }
-    
-    protected final int findNull(final byte[] src, final int start) {
-        return BinaryFunctions.findNull(src, start);
-    }
-    
-    protected void printByteBits(final String msg, final byte i) {
-        BinaryFunctions.printByteBits(msg, i);
-    }
-    
-    protected void printCharQuad(final String msg, final int i) {
-        BinaryFunctions.printCharQuad(msg, i);
-    }
-
-    protected final void printCharQuad(final PrintWriter pw, final String msg, final int i) {
-        BinaryFunctions.printCharQuad(pw, msg, i);
-    }
-    
-    protected final void debugNumber(final String msg, final int data) {
-        debugNumber(msg, data, 1);
-    }
-
     protected 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();
     }
 
-    protected final void debugNumber(final PrintWriter pw, final String msg, final int data) {
-        debugNumber(pw, msg, data, 1);
-    }
-
-    protected final void debugNumber(final PrintWriter pw, final String msg, final int data,
-            final int bytes) {
+    protected 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++) {
@@ -195,31 +70,7 @@ public class BinaryFileParser {
             pw.print((char) singleByte + " [" + singleByte + "]");
             byteData >>= 8;
         }
-        pw.println(") [0x" + Integer.toHexString(data) + ", "
-                + Integer.toBinaryString(data) + "]");
+        pw.println(") [0x" + Integer.toHexString(data) + ", " + Integer.toBinaryString(data) + "]");
         pw.flush();
     }
-
-    protected final boolean compareBytes(final byte[] a, final int aStart, final byte[] b,
-            final int bStart, final int length) {
-        return BinaryFunctions.compareBytes(a, aStart, b, bStart, length);
-    }
-    
-    protected static boolean startsWith(final byte[] haystack, final BinaryConstant needle) {
-        if ((haystack == null) || (haystack.length < needle.size())) {
-            return false;
-        }
-
-        for (int i = 0; i < needle.size(); i++) {
-            if (haystack[i] != needle.get(i)) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    protected static boolean startsWith(final byte[] haystack, final byte[] needle) {
-        return BinaryFunctions.startsWith(haystack, needle);
-    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java Wed Nov 27 16:28:01 2013
@@ -53,6 +53,20 @@ public final class BinaryFunctions {
         return true;
     }
 
+    public static boolean startsWith(final byte[] haystack, final BinaryConstant needle) {
+        if ((haystack == null) || (haystack.length < needle.size())) {
+            return false;
+        }
+
+        for (int i = 0; i < needle.size(); i++) {
+            if (haystack[i] != needle.get(i)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
     public static byte readByte(final String name, final InputStream is, final String exception)
             throws IOException {
         final int result = is.read();
@@ -122,18 +136,6 @@ public final class BinaryFunctions {
         }
     }
 
-    public static void readAndVerifyBytes(final String name, final InputStream is,
-            final byte[] expected, final String exception) throws ImageReadException,
-            IOException {
-        final byte[] bytes = readBytes(name, is, expected.length, exception);
-
-        for (int i = 0; i < expected.length; i++) {
-            if (bytes[i] != expected[i]) {
-                throw new ImageReadException(exception);
-            }
-        }
-    }
-
     public static void skipBytes(final InputStream is, final long length, final String exception)
             throws IOException {
         long total = 0;
@@ -146,21 +148,6 @@ public final class BinaryFunctions {
         }
     }
 
-    public static void scanForByte(final InputStream is, final byte value)
-            throws IOException {
-        int count = 0;
-        for (int i = 0; count < 3; i++) {
-            final int b = is.read();
-            if (b < 0) {
-                return;
-            }
-            if ((0xff & b) == value) {
-                System.out.println("\t" + i + ": match.");
-                count++;
-            }
-        }
-    }
-
     public static byte[] remainingBytes(final String name, final byte[] bytes, final int count) {
         return slice(bytes, count, bytes.length - count);
     }
@@ -171,13 +158,6 @@ public final class BinaryFunctions {
         return result;
     }
 
-    public static byte[] tail(final byte[] bytes, int count) {
-        if (count > bytes.length) {
-            count = bytes.length;
-        }
-        return slice(bytes, bytes.length - count, count);
-    }
-
     public static byte[] head(final byte[] bytes, int count) {
         if (count > bytes.length) {
             count = bytes.length;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ByteConversions.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ByteConversions.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ByteConversions.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ByteConversions.java Wed Nov 27 16:28:01 2013
@@ -224,11 +224,11 @@ public final class ByteConversions {
         return result;
     }
 
-    static int toUInt16(final byte[] bytes, final ByteOrder byteOrder) {
+    public static int toUInt16(final byte[] bytes, final ByteOrder byteOrder) {
         return toUInt16(bytes, 0, byteOrder);
     }
 
-    static int toUInt16(final byte[] bytes, final int offset, final ByteOrder 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.BIG_ENDIAN) {

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -52,6 +52,8 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.palette.SimplePalette;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class BmpImageParser extends ImageParser {
     private static final String DEFAULT_EXTENSION = ".bmp";
     private static final String[] ACCEPTED_EXTENSIONS = { DEFAULT_EXTENSION, };
@@ -99,13 +101,11 @@ public class BmpImageParser extends Imag
                     new byte[]{identifier1, identifier2,});
         }
 
-        final int fileSize = read4Bytes("File Size", is, "Not a Valid BMP File");
-        final int reserved = read4Bytes("Reserved", is, "Not a Valid BMP File");
-        final int bitmapDataOffset = read4Bytes("Bitmap Data Offset", is,
-                "Not a Valid BMP File");
+        final int fileSize = read4Bytes("File Size", is, "Not a Valid BMP File", getByteOrder());
+        final int reserved = read4Bytes("Reserved", is, "Not a Valid BMP File", getByteOrder());
+        final int bitmapDataOffset = read4Bytes("Bitmap Data Offset", is, "Not a Valid BMP File", getByteOrder());
 
-        final int bitmapHeaderSize = read4Bytes("Bitmap Header Size", is,
-                "Not a Valid BMP File");
+        final int bitmapHeaderSize = read4Bytes("Bitmap Header Size", is, "Not a Valid BMP File", getByteOrder());
         int width = 0;
         int height = 0;
         int planes = 0;
@@ -135,67 +135,51 @@ public class BmpImageParser extends Imag
 
         if (bitmapHeaderSize >= 40) {
             // BITMAPINFOHEADER
-            width = read4Bytes("Width", is, "Not a Valid BMP File");
-            height = read4Bytes("Height", is, "Not a Valid BMP File");
-            planes = read2Bytes("Planes", is, "Not a Valid BMP File");
-            bitsPerPixel = read2Bytes("Bits Per Pixel", is,
-                    "Not a Valid BMP File");
-            compression = read4Bytes("Compression", is, "Not a Valid BMP File");
-            bitmapDataSize = read4Bytes("Bitmap Data Size", is,
-                    "Not a Valid BMP File");
-            hResolution = read4Bytes("HResolution", is, "Not a Valid BMP File");
-            vResolution = read4Bytes("VResolution", is, "Not a Valid BMP File");
-            colorsUsed = read4Bytes("ColorsUsed", is, "Not a Valid BMP File");
-            colorsImportant = read4Bytes("ColorsImportant", is,
-                    "Not a Valid BMP File");
+            width = read4Bytes("Width", is, "Not a Valid BMP File", getByteOrder());
+            height = read4Bytes("Height", is, "Not a Valid BMP File", getByteOrder());
+            planes = read2Bytes("Planes", is, "Not a Valid BMP File", getByteOrder());
+            bitsPerPixel = read2Bytes("Bits Per Pixel", is, "Not a Valid BMP File", getByteOrder());
+            compression = read4Bytes("Compression", is, "Not a Valid BMP File", getByteOrder());
+            bitmapDataSize = read4Bytes("Bitmap Data Size", is, "Not a Valid BMP File", getByteOrder());
+            hResolution = read4Bytes("HResolution", is, "Not a Valid BMP File", getByteOrder());
+            vResolution = read4Bytes("VResolution", is, "Not a Valid BMP File", getByteOrder());
+            colorsUsed = read4Bytes("ColorsUsed", is, "Not a Valid BMP File", getByteOrder());
+            colorsImportant = read4Bytes("ColorsImportant", is, "Not a Valid BMP File", getByteOrder());
             if (bitmapHeaderSize >= 52 || compression == BI_BITFIELDS) {
                 // 52 = BITMAPV2INFOHEADER, now undocumented
                 // see http://en.wikipedia.org/wiki/BMP_file_format
-                redMask = read4Bytes("RedMask", is, "Not a Valid BMP File");
-                greenMask = read4Bytes("GreenMask", is, "Not a Valid BMP File");
-                blueMask = read4Bytes("BlueMask", is, "Not a Valid BMP File");
+                redMask = read4Bytes("RedMask", is, "Not a Valid BMP File", getByteOrder());
+                greenMask = read4Bytes("GreenMask", is, "Not a Valid BMP File", getByteOrder());
+                blueMask = read4Bytes("BlueMask", is, "Not a Valid BMP File", getByteOrder());
             }
             if (bitmapHeaderSize >= 56) {
                 // 56 = the now undocumented BITMAPV3HEADER sometimes used by
                 // Photoshop
                 // see http://forums.adobe.com/thread/751592?tstart=1
-                alphaMask = read4Bytes("AlphaMask", is, "Not a Valid BMP File");
+                alphaMask = read4Bytes("AlphaMask", is, "Not a Valid BMP File", getByteOrder());
             }
             if (bitmapHeaderSize >= 108) {
                 // BITMAPV4HEADER
-                colorSpaceType = read4Bytes("ColorSpaceType", is,
-                        "Not a Valid BMP File");
-                colorSpace.red.x = read4Bytes("ColorSpaceRedX", is,
-                        "Not a Valid BMP File");
-                colorSpace.red.y = read4Bytes("ColorSpaceRedY", is,
-                        "Not a Valid BMP File");
-                colorSpace.red.z = read4Bytes("ColorSpaceRedZ", is,
-                        "Not a Valid BMP File");
-                colorSpace.green.x = read4Bytes("ColorSpaceGreenX", is,
-                        "Not a Valid BMP File");
-                colorSpace.green.y = read4Bytes("ColorSpaceGreenY", is,
-                        "Not a Valid BMP File");
-                colorSpace.green.z = read4Bytes("ColorSpaceGreenZ", is,
-                        "Not a Valid BMP File");
-                colorSpace.blue.x = read4Bytes("ColorSpaceBlueX", is,
-                        "Not a Valid BMP File");
-                colorSpace.blue.y = read4Bytes("ColorSpaceBlueY", is,
-                        "Not a Valid BMP File");
-                colorSpace.blue.z = read4Bytes("ColorSpaceBlueZ", is,
-                        "Not a Valid BMP File");
-                gammaRed = read4Bytes("GammaRed", is, "Not a Valid BMP File");
-                gammaGreen = read4Bytes("GammaGreen", is,
-                        "Not a Valid BMP File");
-                gammaBlue = read4Bytes("GammaBlue", is, "Not a Valid BMP File");
+                colorSpaceType = read4Bytes("ColorSpaceType", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.red.x = read4Bytes("ColorSpaceRedX", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.red.y = read4Bytes("ColorSpaceRedY", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.red.z = read4Bytes("ColorSpaceRedZ", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.green.x = read4Bytes("ColorSpaceGreenX", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.green.y = read4Bytes("ColorSpaceGreenY", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.green.z = read4Bytes("ColorSpaceGreenZ", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.blue.x = read4Bytes("ColorSpaceBlueX", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.blue.y = read4Bytes("ColorSpaceBlueY", is, "Not a Valid BMP File", getByteOrder());
+                colorSpace.blue.z = read4Bytes("ColorSpaceBlueZ", is, "Not a Valid BMP File", getByteOrder());
+                gammaRed = read4Bytes("GammaRed", is, "Not a Valid BMP File", getByteOrder());
+                gammaGreen = read4Bytes("GammaGreen", is, "Not a Valid BMP File", getByteOrder());
+                gammaBlue = read4Bytes("GammaBlue", is, "Not a Valid BMP File", getByteOrder());
             }
             if (bitmapHeaderSize >= 124) {
                 // BITMAPV5HEADER
-                intent = read4Bytes("Intent", is, "Not a Valid BMP File");
-                profileData = read4Bytes("ProfileData", is,
-                        "Not a Valid BMP File");
-                profileSize = read4Bytes("ProfileSize", is,
-                        "Not a Valid BMP File");
-                reservedV5 = read4Bytes("Reserved", is, "Not a Valid BMP File");
+                intent = read4Bytes("Intent", is, "Not a Valid BMP File", getByteOrder());
+                profileData = read4Bytes("ProfileData", is, "Not a Valid BMP File", getByteOrder());
+                profileSize = read4Bytes("ProfileSize", is, "Not a Valid BMP File", getByteOrder());
+                reservedV5 = read4Bytes("Reserved", is, "Not a Valid BMP File", getByteOrder());
             }
         } else {
             throw new ImageReadException("Invalid/unsupported BMP file");
@@ -228,15 +212,15 @@ public class BmpImageParser extends Imag
             }
             if (bitmapHeaderSize >= 108) {
                 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("colorSpace.red.x", colorSpace.red.x, 1);
+                debugNumber("colorSpace.red.y", colorSpace.red.y, 1);
+                debugNumber("colorSpace.red.z", colorSpace.red.z, 1);
+                debugNumber("colorSpace.green.x", colorSpace.green.x, 1);
+                debugNumber("colorSpace.green.y", colorSpace.green.y, 1);
+                debugNumber("colorSpace.green.z", colorSpace.green.z, 1);
+                debugNumber("colorSpace.blue.x", colorSpace.blue.x, 1);
+                debugNumber("colorSpace.blue.y", colorSpace.blue.y, 1);
+                debugNumber("colorSpace.blue.z", colorSpace.blue.z, 1);
                 debugNumber("gammaRed", gammaRed, 4);
                 debugNumber("gammaGreen", gammaGreen, 4);
                 debugNumber("gammaBlue", gammaBlue, 4);
@@ -265,9 +249,9 @@ public class BmpImageParser extends Imag
 
         boolean done = false;
         while (!done) {
-            final int a = 0xff & this.readByte("RLE a", is, "BMP: Bad RLE");
+            final int a = 0xff & readByte("RLE a", is, "BMP: Bad RLE");
             baos.write(a);
-            final int b = 0xff & this.readByte("RLE b", is, "BMP: Bad RLE");
+            final int b = 0xff & readByte("RLE b", is, "BMP: Bad RLE");
             baos.write(b);
 
             if (a == 0) {
@@ -282,9 +266,9 @@ public class BmpImageParser extends Imag
                 case 2: {
                     // System.out.println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                     // );
-                    final int c = 0xff & this.readByte("RLE c", is, "BMP: Bad RLE");
+                    final int c = 0xff & readByte("RLE c", is, "BMP: Bad RLE");
                     baos.write(c);
-                    final int d = 0xff & this.readByte("RLE d", is, "BMP: Bad RLE");
+                    final int d = 0xff & readByte("RLE d", is, "BMP: Bad RLE");
                     baos.write(d);
 
                 }
@@ -304,7 +288,7 @@ public class BmpImageParser extends Imag
                     // RLESamplesPerByte);
                     // System.out.println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                     // );
-                    final byte[] bytes = this.readBytes("bytes", is, size,
+                    final byte[] bytes = readBytes("bytes", is, size,
                             "RLE: Absolute Mode");
                     baos.write(bytes);
                 }
@@ -401,7 +385,7 @@ public class BmpImageParser extends Imag
 
         byte[] colorTable = null;
         if (paletteLength > 0) {
-            colorTable = this.readBytes("ColorTable", is, paletteLength,
+            colorTable = readBytes("ColorTable", is, paletteLength,
                     "Not a Valid BMP File");
         }
 
@@ -449,8 +433,7 @@ public class BmpImageParser extends Imag
                     + expectedDataOffset + ", paletteLength: " + paletteLength
                     + ", headerSize: " + headerSize + ")");
         } else if (extraBytes > 0) {
-            this.readBytes("BitmapDataOffset", is, extraBytes,
-                    "Not a Valid BMP File");
+            readBytes("BitmapDataOffset", is, extraBytes, "Not a Valid BMP File");
         }
 
         final int imageDataSize = bhi.height * imageLineLength;
@@ -463,7 +446,7 @@ public class BmpImageParser extends Imag
         if (rle) {
             imageData = getRLEBytes(is, rleSamplesPerByte);
         } else {
-            imageData = this.readBytes("ImageData", is, imageDataSize,
+            imageData = readBytes("ImageData", is, imageDataSize,
                     "Not a Valid BMP File");
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java Wed Nov 27 16:28:01 2013
@@ -43,6 +43,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.pcx.PcxImageParser;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class DcxImageParser extends ImageParser {
     // See http://www.fileformat.info/format/pcx/egff.htm for documentation
     private static final String DEFAULT_EXTENSION = ".dcx";
@@ -123,11 +125,11 @@ public class DcxImageParser extends Imag
         boolean canThrow = false;
         try {
             is = byteSource.getInputStream();
-            final int id = read4Bytes("Id", is, "Not a Valid DCX File");
+            final int id = read4Bytes("Id", is, "Not a Valid DCX File", getByteOrder());
             final List<Long> pageTable = new ArrayList<Long>(1024);
             for (int i = 0; i < 1024; i++) {
                 final long pageOffset = 0xFFFFffffL & read4Bytes("PageTable", is,
-                        "Not a Valid DCX File");
+                        "Not a Valid DCX File", getByteOrder());
                 if (pageOffset == 0) {
                     break;
                 }

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -47,6 +47,9 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+import static org.apache.commons.imaging.common.ByteConversions.*;
+
 public class GifImageParser extends ImageParser {
     private static final String DEFAULT_EXTENSION = ".gif";
     private static final String[] ACCEPTED_EXTENSIONS = { DEFAULT_EXTENSION, };
@@ -130,10 +133,8 @@ public class GifImageParser extends Imag
                     ((version1 << 16) | (version2 << 8) | (version3 << 0)));
         }
 
-        final int logicalScreenWidth = read2Bytes("Logical Screen Width", is,
-                "Not a Valid GIF File");
-        final int logicalScreenHeight = read2Bytes("Logical Screen Height", is,
-                "Not a Valid GIF File");
+        final int logicalScreenWidth = read2Bytes("Logical Screen Width", is, "Not a Valid GIF File", getByteOrder());
+        final int logicalScreenHeight = read2Bytes("Logical Screen Height", is, "Not a Valid GIF File", getByteOrder());
 
         if (formatCompliance != null) {
             formatCompliance.checkBounds("Width", 1, Integer.MAX_VALUE,
@@ -195,8 +196,7 @@ public class GifImageParser extends Imag
         final int dispose = (packed & 0x1c) >> 2; // disposal method
         final boolean transparency = (packed & 1) != 0;
 
-        final int delay = read2Bytes("delay in milliseconds", is,
-                "GIF: corrupt GraphicControlExt");
+        final int delay = read2Bytes("delay in milliseconds", is, "GIF: corrupt GraphicControlExt", getByteOrder());
         final int transparentColorIndex = 0xff & readByte("transparent color index",
                 is, "GIF: corrupt GraphicControlExt");
         readByte("block terminator", is, "GIF: corrupt GraphicControlExt");
@@ -334,10 +334,10 @@ public class GifImageParser extends Imag
             final int blockCode, final InputStream is, final boolean stopBeforeImageData,
             final FormatCompliance formatCompliance) throws ImageReadException,
             IOException {
-        final int imageLeftPosition = read2Bytes("Image Left Position", is, "Not a Valid GIF File");
-        final int imageTopPosition = read2Bytes("Image Top Position", is, "Not a Valid GIF File");
-        final int imageWidth = read2Bytes("Image Width", is, "Not a Valid GIF File");
-        final int imageHeight = read2Bytes("Image Height", is, "Not a Valid GIF File");
+        final int imageLeftPosition = read2Bytes("Image Left Position", is, "Not a Valid GIF File", getByteOrder());
+        final int imageTopPosition = read2Bytes("Image Top Position", is, "Not a Valid GIF File", getByteOrder());
+        final int imageWidth = read2Bytes("Image Width", is, "Not a Valid GIF File", getByteOrder());
+        final int imageHeight = read2Bytes("Image Height", is, "Not a Valid GIF File", getByteOrder());
         final byte packedFields = readByte("Packed Fields", is, "Not a Valid GIF File");
 
         if (formatCompliance != null) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java Wed Nov 27 16:28:01 2013
@@ -39,6 +39,8 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class IcnsImageParser extends ImageParser {
     static final int ICNS_MAGIC = IcnsType.typeAsInt("icns");
     private static final String DEFAULT_EXTENSION = ".icns";
@@ -155,8 +157,8 @@ public class IcnsImageParser extends Ima
 
     private IcnsHeader readIcnsHeader(final InputStream is)
             throws ImageReadException, IOException {
-        final int magic = read4Bytes("Magic", is, "Not a Valid ICNS File");
-        final int fileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File");
+        final int magic = read4Bytes("Magic", is, "Not a Valid ICNS File", getByteOrder());
+        final int fileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File", getByteOrder());
 
         if (magic != ICNS_MAGIC) {
             throw new ImageReadException("Not a Valid ICNS File: " + "magic is 0x" + Integer.toHexString(magic));
@@ -193,9 +195,9 @@ public class IcnsImageParser extends Ima
     }
 
     private IcnsElement readIcnsElement(final InputStream is) throws IOException {
-        final int type = read4Bytes("Type", is, "Not a Valid ICNS File"); // Icon type
+        final int type = read4Bytes("Type", is, "Not a Valid ICNS File", getByteOrder()); // Icon type
                                                                     // (4 bytes)
-        final int elementSize = read4Bytes("ElementSize", is, "Not a Valid ICNS File"); // Length
+        final int elementSize = read4Bytes("ElementSize", is, "Not a Valid ICNS File", getByteOrder()); // Length
                                                                                   // of
                                                                                   // data
                                                                                   // (4

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -46,6 +46,8 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.palette.SimplePalette;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class IcoImageParser extends ImageParser {
     private static final String DEFAULT_EXTENSION = ".ico";
     private static final String[] ACCEPTED_EXTENSIONS = { ".ico", ".cur", };
@@ -122,9 +124,9 @@ public class IcoImageParser extends Imag
     }
 
     private FileHeader readFileHeader(final InputStream is) throws ImageReadException, IOException {
-        final int reserved = read2Bytes("Reserved", is, "Not a Valid ICO File");
-        final int iconType = read2Bytes("IconType", is, "Not a Valid ICO File");
-        final int iconCount = read2Bytes("IconCount", is, "Not a Valid ICO File");
+        final int reserved = read2Bytes("Reserved", is, "Not a Valid ICO File", getByteOrder());
+        final int iconType = read2Bytes("IconType", is, "Not a Valid ICO File", getByteOrder());
+        final int iconCount = read2Bytes("IconCount", is, "Not a Valid ICO File", getByteOrder());
 
         if (reserved != 0) {
             throw new ImageReadException("Not a Valid ICO File: reserved is " + reserved);
@@ -185,15 +187,15 @@ public class IcoImageParser extends Imag
         // Reserved (1 byte), Not used (always 0)
         final byte reserved = readByte("Reserved", is, "Not a Valid ICO File");
         // Planes (2 bytes), always 1
-        final int planes = read2Bytes("Planes", is, "Not a Valid ICO File");
+        final int planes = read2Bytes("Planes", is, "Not a Valid ICO File", getByteOrder());
         // BitCount (2 bytes), number of bits per pixel (1 for monchrome,
         // 4 for 16 colors, 8 for 256 colors, 24 for true colors,
         // 32 for true colors + alpha channel)
-        final int bitCount = read2Bytes("BitCount", is, "Not a Valid ICO File");
+        final int bitCount = read2Bytes("BitCount", is, "Not a Valid ICO File", getByteOrder());
         // ImageSize (4 bytes), Length of resource in bytes
-        final int imageSize = read4Bytes("ImageSize", is, "Not a Valid ICO File");
+        final int imageSize = read4Bytes("ImageSize", is, "Not a Valid ICO File", getByteOrder());
         // ImageOffset (4 bytes), start of the image in the file
-        final int imageOffset = read4Bytes("ImageOffset", is, "Not a Valid ICO File");
+        final int imageOffset = read4Bytes("ImageOffset", is, "Not a Valid ICO File", getByteOrder());
 
         return new IconInfo(width, height, colorCount, reserved, planes, bitCount, imageSize, imageOffset);
     }
@@ -313,21 +315,21 @@ public class IcoImageParser extends Imag
     private IconData readBitmapIconData(final byte[] iconData, final IconInfo fIconInfo)
             throws ImageReadException, IOException {
         final ByteArrayInputStream is = new ByteArrayInputStream(iconData);
-        final int size = read4Bytes("size", is, "Not a Valid ICO File"); // Size (4
+        final int size = read4Bytes("size", is, "Not a Valid ICO File", getByteOrder()); // Size (4
                                                                    // bytes),
                                                                    // size of
                                                                    // this
                                                                    // structure
                                                                    // (always
                                                                    // 40)
-        final int width = read4Bytes("width", is, "Not a Valid ICO File"); // Width (4
+        final int width = read4Bytes("width", is, "Not a Valid ICO File", getByteOrder()); // Width (4
                                                                      // bytes),
                                                                      // width of
                                                                      // the
                                                                      // image
                                                                      // (same as
                                                                      // iconinfo.width)
-        final int height = read4Bytes("height", is, "Not a Valid ICO File"); // Height
+        final int height = read4Bytes("height", is, "Not a Valid ICO File", getByteOrder()); // Height
                                                                        // (4
                                                                        // bytes),
                                                                        // scanlines
@@ -338,12 +340,12 @@ public class IcoImageParser extends Imag
                                                                        // map
                                                                        // (iconinfo.height
                                                                        // * 2)
-        final int planes = read2Bytes("planes", is, "Not a Valid ICO File"); // Planes
+        final int planes = read2Bytes("planes", is, "Not a Valid ICO File", getByteOrder()); // Planes
                                                                        // (2
                                                                        // bytes),
                                                                        // always
                                                                        // 1
-        final int bitCount = read2Bytes("bitCount", is, "Not a Valid ICO File"); // BitCount
+        final int bitCount = read2Bytes("bitCount", is, "Not a Valid ICO File", getByteOrder()); // BitCount
                                                                            // (2
                                                                            // bytes),
                                                                            // 1,4,8,16,24,32
@@ -351,7 +353,7 @@ public class IcoImageParser extends Imag
                                                                            // iconinfo
                                                                            // for
                                                                            // details)
-        int compression = read4Bytes("compression", is, "Not a Valid ICO File"); // Compression
+        int compression = read4Bytes("compression", is, "Not a Valid ICO File", getByteOrder()); // Compression
                                                                                  // (4
                                                                                  // bytes),
                                                                                  // we
@@ -359,7 +361,7 @@ public class IcoImageParser extends Imag
                                                                                  // use
                                                                                  // this
                                                                                  // (0)
-        final int sizeImage = read4Bytes("sizeImage", is, "Not a Valid ICO File"); // SizeImage
+        final int sizeImage = read4Bytes("sizeImage", is, "Not a Valid ICO File", getByteOrder()); // SizeImage
                                                                              // (4
                                                                              // bytes),
                                                                              // we
@@ -368,12 +370,12 @@ public class IcoImageParser extends Imag
                                                                              // this
                                                                              // (0)
         final int xPelsPerMeter = read4Bytes("xPelsPerMeter", is,
-                "Not a Valid ICO File"); // XPelsPerMeter (4 bytes), we don?t
+                "Not a Valid ICO File", getByteOrder()); // XPelsPerMeter (4 bytes), we don?t
                                          // use this (0)
         final int yPelsPerMeter = read4Bytes("yPelsPerMeter", is, 
-                "Not a Valid ICO File"); // YPelsPerMeter (4 bytes), we don?t
+                "Not a Valid ICO File", getByteOrder()); // YPelsPerMeter (4 bytes), we don?t
                                          // use this (0)
-        final int colorsUsed = read4Bytes("colorsUsed", is, "Not a Valid ICO File"); // ColorsUsed
+        final int colorsUsed = read4Bytes("colorsUsed", is, "Not a Valid ICO File", getByteOrder()); // ColorsUsed
                                                                                // (4
                                                                                // bytes),
                                                                                // we
@@ -382,16 +384,16 @@ public class IcoImageParser extends Imag
                                                                                // this
                                                                                // (0)
         final int colorsImportant = read4Bytes("ColorsImportant", is,
-                "Not a Valid ICO File"); // ColorsImportant (4 bytes), we don?t
+                "Not a Valid ICO File", getByteOrder()); // ColorsImportant (4 bytes), we don?t
                                          // use this (0)
         int redMask = 0;
         int greenMask = 0;
         int blueMask = 0;
         int alphaMask = 0;
         if (compression == 3) {
-            redMask = read4Bytes("redMask", is, "Not a Valid ICO File");
-            greenMask = read4Bytes("greenMask", is, "Not a Valid ICO File");
-            blueMask = read4Bytes("blueMask", is, "Not a Valid ICO File");
+            redMask = read4Bytes("redMask", is, "Not a Valid ICO File", getByteOrder());
+            greenMask = read4Bytes("greenMask", is, "Not a Valid ICO File", getByteOrder());
+            blueMask = read4Bytes("blueMask", is, "Not a Valid ICO File", getByteOrder());
         }
         final byte[] restOfFile = readBytes("RestOfFile", is, is.available());
 
@@ -473,7 +475,7 @@ public class IcoImageParser extends Imag
         final int colorMapSizeBytes = t_scanline_size * (height / 2);
         byte[] transparencyMap = null;
         try {
-            transparencyMap = this.readBytes("transparency_map",
+            transparencyMap = readBytes("transparency_map",
                     bmpInputStream, colorMapSizeBytes,
                     "Not a Valid ICO File");
         } catch (final IOException ioEx) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java Wed Nov 27 16:28:01 2013
@@ -57,6 +57,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.imaging.util.Debug;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class JpegImageParser extends ImageParser {
     private static final String DEFAULT_EXTENSION = ".jpg";
     private static final String[] ACCEPTED_EXTENSIONS = { ".jpg", ".jpeg", };

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -22,10 +22,13 @@ import java.nio.ByteOrder;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.BinaryFileParser;
+import org.apache.commons.imaging.common.ByteConversions;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class JpegUtils extends BinaryFileParser {
     public JpegUtils() {
         setByteOrder(ByteOrder.BIG_ENDIAN);
@@ -79,9 +82,9 @@ public class JpegUtils extends BinaryFil
                 }
 
                 final byte[] segmentLengthBytes = readBytes("segmentLengthBytes", is, 2, "segmentLengthBytes");
-                final int segmentLength = toUInt16(segmentLengthBytes);
+                final int segmentLength = ByteConversions.toUInt16(segmentLengthBytes, getByteOrder());
 
-                final byte[] segmentData = readBytes("Segment Data", 
+                final byte[] segmentData = readBytes("Segment Data",
                         is, segmentLength - 2,
                         "Invalid Segment: insufficient data");
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java Wed Nov 27 16:28:01 2013
@@ -36,6 +36,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.jpeg.segments.SofnSegment;
 import org.apache.commons.imaging.formats.jpeg.segments.SosSegment;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor {
     /*
      * JPEG is an advanced image format that takes significant computation to
@@ -66,8 +68,7 @@ public class JpegDecoder extends BinaryF
     public void visitSOS(final int marker, final byte[] markerBytes, final byte[] imageData) {
         final ByteArrayInputStream is = new ByteArrayInputStream(imageData);
         try {
-            final int segmentLength = read2Bytes("segmentLength", is,
-                    "Not a Valid JPEG File");
+            final int segmentLength = read2Bytes("segmentLength", is, "Not a Valid JPEG File", getByteOrder());
             final byte[] sosSegmentBytes = readBytes("SosSegment",
                     is, segmentLength - 2, "Not a Valid JPEG File");
             sosSegment = new SosSegment(marker, sosSegmentBytes);

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -28,6 +28,7 @@ import java.util.List;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.common.BinaryFileParser;
+import org.apache.commons.imaging.common.ByteConversions;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.common.bytesource.ByteSourceArray;
 import org.apache.commons.imaging.common.bytesource.ByteSourceFile;
@@ -40,6 +41,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 /**
  * Interface for Exif write/update/remove functionality for Jpeg/JFIF images.
  * <p>
@@ -508,13 +511,13 @@ public class ExifRewriter extends Binary
             }
 
             if (!hasExif && newBytes != null) {
-                final byte[] markerBytes = toBytes((short) JpegConstants.JPEG_APP1_MARKER);
+                final byte[] markerBytes = ByteConversions.toBytes((short) JpegConstants.JPEG_APP1_MARKER, getByteOrder());
                 if (newBytes.length > 0xffff) {
                     throw new ExifOverflowException(
                             "APP1 Segment is too long: " + newBytes.length);
                 }
                 final int markerLength = newBytes.length + 2;
-                final byte[] markerLengthBytes = toBytes((short) markerLength);
+                final byte[] markerLengthBytes = ByteConversions.toBytes((short) markerLength, getByteOrder());
 
                 int index = 0;
                 final JFIFPieceSegment firstSegment = (JFIFPieceSegment) segments
@@ -540,13 +543,13 @@ public class ExifRewriter extends Binary
                         continue;
                     }
 
-                    final byte[] markerBytes = toBytes((short) JpegConstants.JPEG_APP1_MARKER);
+                    final byte[] markerBytes = ByteConversions.toBytes((short) JpegConstants.JPEG_APP1_MARKER, getByteOrder());
                     if (newBytes.length > 0xffff) {
                         throw new ExifOverflowException(
                                 "APP1 Segment is too long: " + newBytes.length);
                     }
                     final int markerLength = newBytes.length + 2;
-                    final byte[] markerLengthBytes = toBytes((short) markerLength);
+                    final byte[] markerLengthBytes = ByteConversions.toBytes((short) markerLength, getByteOrder());
 
                     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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -38,6 +38,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class IptcParser extends BinaryFileParser {
     private static final ByteOrder APP13_BYTE_ORDER = ByteOrder.BIG_ENDIAN;
 
@@ -46,7 +48,7 @@ public class IptcParser extends BinaryFi
     }
 
     public boolean isPhotoshopJpegSegment(final byte[] segmentData) {
-        if (!BinaryFileParser.startsWith(segmentData,
+        if (!startsWith(segmentData,
                 JpegConstants.PHOTOSHOP_IDENTIFICATION_STRING)) {
             return false;
         }
@@ -168,7 +170,7 @@ public class IptcParser extends BinaryFi
             }
             index++;
 
-            final int recordSize = toUInt16(bytes, index);
+            final int recordSize = ByteConversions.toUInt16(bytes, index, getByteOrder());
             index += 2;
 
             final boolean extendedDataset = recordSize > IptcConstants.IPTC_NON_EXTENDED_RECORD_MAXIMUM_SIZE;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java Wed Nov 27 16:28:01 2013
@@ -21,7 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 
-import org.apache.commons.imaging.common.BinaryFileParser;
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
 
 /**
  * http://www.aiim.org/documents/standards/PDF-Ref/References/Adobe/5116.DCT_Filter.pdf
@@ -50,7 +50,7 @@ public class App14Segment extends AppnSe
     }
 
     public boolean isAdobeJpegSegment() {
-        return BinaryFileParser.startsWith(getSegmentData(), ADOBE_PREFIX);
+        return startsWith(getSegmentData(), ADOBE_PREFIX);
     }
 
     public int getAdobeColorTransform() {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App2Segment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App2Segment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App2Segment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App2Segment.java Wed Nov 27 16:28:01 2013
@@ -21,9 +21,10 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.common.BinaryFileParser;
 import org.apache.commons.imaging.formats.jpeg.JpegConstants;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class App2Segment extends AppnSegment implements Comparable<App2Segment> {
     public final byte[] iccBytes;
     public final int curMarker, numMarkers;
@@ -37,7 +38,7 @@ public class App2Segment extends AppnSeg
             throws ImageReadException, IOException {
         super(marker, markerLength, is2);
 
-        if (BinaryFileParser.startsWith(getSegmentData(),
+        if (startsWith(getSegmentData(),
                 JpegConstants.ICC_PROFILE_LABEL)) {
             final InputStream is = new ByteArrayInputStream(getSegmentData());
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java Wed Nov 27 16:28:01 2013
@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class DhtSegment extends Segment {
     public final List<HuffmanTable> huffmanTables;
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java Wed Nov 27 16:28:01 2013
@@ -23,6 +23,8 @@ import java.util.List;
 
 import org.apache.commons.imaging.ImageReadException;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class DqtSegment extends Segment {
     public final List<QuantizationTable> quantizationTables = new ArrayList<QuantizationTable>();
 
@@ -63,8 +65,7 @@ public class DqtSegment extends Segment 
                             is, "Not a Valid JPEG File");
                     length--;
                 } else if (precision == 1) {
-                    elements[i] = read2Bytes("QuantizationTableElement", is,
-                            "Not a Valid JPEG File");
+                    elements[i] = read2Bytes("QuantizationTableElement", is, "Not a Valid JPEG File", getByteOrder());
                     length -= 2;
                 } else {
                     throw new ImageReadException(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java Wed Nov 27 16:28:01 2013
@@ -20,6 +20,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public abstract class GenericSegment extends Segment {
     protected final byte[] segmentData;
 
@@ -42,7 +44,7 @@ public abstract class GenericSegment ext
 
     public void dump(final PrintWriter pw, final int start) {
         for (int i = 0; (i < 50) && ((i + start) < segmentData.length); i++) {
-            debugNumber(pw, "\t" + (i + start), segmentData[i + start]);
+            debugNumber(pw, "\t" + (i + start), segmentData[i + start], 1);
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java Wed Nov 27 16:28:01 2013
@@ -23,6 +23,8 @@ import java.io.InputStream;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.formats.jpeg.JpegConstants;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class JfifSegment extends Segment {
     public final int jfifMajorVersion;
     public final int jfifMinorVersion;
@@ -60,8 +62,8 @@ public class JfifSegment extends Segment
         jfifMinorVersion = readByte("JFIF_minor_version", is,
                 "Not a Valid JPEG File");
         densityUnits = readByte("density_units", is, "Not a Valid JPEG File");
-        xDensity = read2Bytes("x_density", is, "Not a Valid JPEG File");
-        yDensity = read2Bytes("y_density", is, "Not a Valid JPEG File");
+        xDensity = read2Bytes("x_density", is, "Not a Valid JPEG File", getByteOrder());
+        yDensity = read2Bytes("y_density", is, "Not a Valid JPEG File", getByteOrder());
 
         xThumbnail = readByte("x_thumbnail", is, "Not a Valid JPEG File");
         yThumbnail = readByte("y_thumbnail", is, "Not a Valid JPEG File");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java Wed Nov 27 16:28:01 2013
@@ -22,6 +22,8 @@ import java.io.InputStream;
 
 import org.apache.commons.imaging.formats.jpeg.JpegConstants;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class SofnSegment extends Segment {
     public final int width, height;
     public final int numberOfComponents;
@@ -57,8 +59,8 @@ public class SofnSegment extends Segment
         }
 
         precision = readByte("Data_precision", is, "Not a Valid JPEG File");
-        height = read2Bytes("Image_height", is, "Not a Valid JPEG File");
-        width = read2Bytes("Image_Width", is, "Not a Valid JPEG File");
+        height = read2Bytes("Image_height", is, "Not a Valid JPEG File", getByteOrder());
+        width = read2Bytes("Image_Width", is, "Not a Valid JPEG File", getByteOrder());
         numberOfComponents = readByte("Number_of_components", is,
                 "Not a Valid JPEG File");
         components = new Component[numberOfComponents];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java Wed Nov 27 16:28:01 2013
@@ -20,6 +20,8 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class SosSegment extends Segment {
     public final int numberOfComponents;
     private final Component[] components;

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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -32,6 +32,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.jpeg.iptc.IptcParser;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 /**
  * Interface for Exif write/update/remove functionality for Jpeg/JFIF images.
  */

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java Wed Nov 27 16:28:01 2013
@@ -22,6 +22,7 @@ import java.nio.ByteOrder;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.BinaryFileParser;
+import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.formats.jpeg.JpegConstants;
 
 public class JpegXmpParser extends BinaryFileParser {
@@ -31,7 +32,7 @@ public class JpegXmpParser extends Binar
     }
 
     public boolean isXmpJpegSegment(final byte[] segmentData) {
-        return BinaryFileParser.startsWith(segmentData, JpegConstants.XMP_IDENTIFIER);
+        return BinaryFunctions.startsWith(segmentData, JpegConstants.XMP_IDENTIFIER);
     }
 
     public String parseXmpJpegSegment(final byte[] 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=1546091&r1=1546090&r2=1546091&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 Wed Nov 27 16:28:01 2013
@@ -48,6 +48,9 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+import static org.apache.commons.imaging.common.ByteConversions.*;
+
 public class PcxImageParser extends ImageParser {
     // ZSoft's official spec is at http://www.qzx.com/pc-gpe/pcx.txt
     // (among other places) but it's pretty thin. The fileformat.info document
@@ -256,12 +259,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 = 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 xMin = toUInt16(pcxHeaderBytes, 4, getByteOrder());
+        final int yMin = toUInt16(pcxHeaderBytes, 6, getByteOrder());
+        final int xMax = toUInt16(pcxHeaderBytes, 8, getByteOrder());
+        final int yMax = toUInt16(pcxHeaderBytes, 10, getByteOrder());
+        final int hDpi = toUInt16(pcxHeaderBytes, 12, getByteOrder());
+        final int vDpi = toUInt16(pcxHeaderBytes, 14, getByteOrder());
         final int[] colormap = new int[16];
         for (int i = 0; i < 16; i++) {
             colormap[i] = 0xff000000
@@ -271,10 +274,10 @@ public class PcxImageParser extends Imag
         }
         final int reserved = 0xff & pcxHeaderBytes[64];
         final int nPlanes = 0xff & pcxHeaderBytes[65];
-        final int bytesPerLine = toUInt16(pcxHeaderBytes, 66);
-        final int paletteInfo = toUInt16(pcxHeaderBytes, 68);
-        final int hScreenSize = toUInt16(pcxHeaderBytes, 70);
-        final int vScreenSize = toUInt16(pcxHeaderBytes, 72);
+        final int bytesPerLine = toUInt16(pcxHeaderBytes, 66, getByteOrder());
+        final int paletteInfo = toUInt16(pcxHeaderBytes, 68, getByteOrder());
+        final int hScreenSize = toUInt16(pcxHeaderBytes, 70, getByteOrder());
+        final int vScreenSize = toUInt16(pcxHeaderBytes, 72, getByteOrder());
 
         if (manufacturer != 10) {
             throw new ImageReadException(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Wed Nov 27 16:28:01 2013
@@ -61,6 +61,8 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.icc.IccProfileParser;
 import org.apache.commons.imaging.util.IoUtils;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngImageParser extends ImageParser {
     private static final String DEFAULT_EXTENSION = ".png";
     private static final String[] ACCEPTED_EXTENSIONS = { DEFAULT_EXTENSION, };
@@ -149,8 +151,8 @@ public class PngImageParser extends Imag
                 System.out.println("");
             }
 
-            final int length = read4Bytes("Length", is, "Not a Valid PNG File");
-            final int chunkType = read4Bytes("ChunkType", is, "Not a Valid PNG File");
+            final int length = read4Bytes("Length", is, "Not a Valid PNG File", getByteOrder());
+            final int chunkType = read4Bytes("ChunkType", is, "Not a Valid PNG File", getByteOrder());
 
             if (getDebug()) {
                 printCharQuad("ChunkType", chunkType);
@@ -172,7 +174,7 @@ public class PngImageParser extends Imag
                 }
             }
 
-            final int crc = read4Bytes("CRC", is, "Not a Valid PNG File");
+            final int crc = read4Bytes("CRC", is, "Not a Valid PNG File", getByteOrder());
 
             if (keep) {
                 if (chunkType == PngConstants.iCCP) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java Wed Nov 27 16:28:01 2013
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.common.BinaryFileParser;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkPlte;
 import org.apache.commons.imaging.formats.png.scanlinefilters.ScanlineFilter;
 import org.apache.commons.imaging.formats.png.scanlinefilters.ScanlineFilterAverage;
@@ -31,7 +30,9 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.png.scanlinefilters.ScanlineFilterUp;
 import org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilter;
 
-public abstract class ScanExpediter extends BinaryFileParser {
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
+public abstract class ScanExpediter {
     protected final int width;
     protected final int height;
     protected final InputStream is;
@@ -218,7 +219,7 @@ public abstract class ScanExpediter exte
             throw new ImageReadException("PNG: missing filter type");
         }
 
-        byte[] scanline = this.readBytes("scanline", is, length, "PNG: missing image data");
+        byte[] scanline = readBytes("scanline", is, length, "PNG: missing image data");
 
         return unfilterScanline(filterType, scanline, prev, bytesPerPixel);
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java Wed Nov 27 16:28:01 2013
@@ -19,6 +19,8 @@ package org.apache.commons.imaging.forma
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngChunkGama extends PngChunk {
     public final int gamma;
 
@@ -27,7 +29,7 @@ public class PngChunkGama extends PngChu
         super(length, chunkType, crc, bytes);
 
         final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
-        gamma = read4Bytes("Gamma", is, "Not a Valid Png File: gAMA Corrupt");
+        gamma = read4Bytes("Gamma", is, "Not a Valid Png File: gAMA Corrupt", getByteOrder());
     }
 
     public double getGamma() {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java Wed Nov 27 16:28:01 2013
@@ -21,7 +21,8 @@ import java.io.IOException;
 import java.util.zip.InflaterInputStream;
 
 import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.common.BinaryFunctions;
+
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
 
 public class PngChunkIccp extends PngChunk {
     // private final PngImageParser parser;
@@ -59,8 +60,7 @@ public class PngChunkIccp extends PngChu
             System.out.println("bytes.length: " + bytes.length);
         }
 
-        uncompressedProfile = BinaryFunctions.getStreamBytes(
-                new InflaterInputStream(new ByteArrayInputStream(compressedProfile)));
+        uncompressedProfile = getStreamBytes(new InflaterInputStream(new ByteArrayInputStream(compressedProfile)));
 
         if (getDebug()) {
             System.out.println("UncompressedProfile: " + Integer.toString(bytes.length));

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java Wed Nov 27 16:28:01 2013
@@ -19,6 +19,8 @@ package org.apache.commons.imaging.forma
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngChunkIhdr extends PngChunk {
     public final int width;
     public final int height;
@@ -32,8 +34,8 @@ public class PngChunkIhdr extends PngChu
         super(length, chunkType, crc, bytes);
 
         final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
-        width = read4Bytes("Width", is, "Not a Valid Png File: IHDR Corrupt");
-        height = read4Bytes("Height", is, "Not a Valid Png File: IHDR Corrupt");
+        width = read4Bytes("Width", is, "Not a Valid Png File: IHDR Corrupt", getByteOrder());
+        height = read4Bytes("Height", is, "Not a Valid Png File: IHDR Corrupt", getByteOrder());
         bitDepth = readByte("BitDepth", is, "Not a Valid Png File: IHDR Corrupt");
         colorType = readByte("ColorType", is, "Not a Valid Png File: IHDR Corrupt");
         compressionMethod = readByte("CompressionMethod", is, "Not a Valid Png File: IHDR Corrupt");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java Wed Nov 27 16:28:01 2013
@@ -21,10 +21,11 @@ import java.io.IOException;
 import java.util.zip.InflaterInputStream;
 
 import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.formats.png.PngConstants;
 import org.apache.commons.imaging.formats.png.PngText;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngChunkItxt extends PngTextChunk {
     public final String keyword;
     public final String text;
@@ -90,7 +91,7 @@ public class PngChunkItxt extends PngTex
             final byte[] compressedText = new byte[compressedTextLength];
             System.arraycopy(bytes, index, compressedText, 0, compressedTextLength);
 
-            text = new String(BinaryFunctions.getStreamBytes(
+            text = new String(getStreamBytes(
                     new InflaterInputStream(new ByteArrayInputStream(compressedText))), "utf-8");
 
         } else {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java Wed Nov 27 16:28:01 2013
@@ -19,6 +19,8 @@ package org.apache.commons.imaging.forma
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngChunkPhys extends PngChunk {
     public final int pixelsPerUnitXAxis;
     public final int pixelsPerUnitYAxis;
@@ -29,8 +31,8 @@ public class PngChunkPhys extends PngChu
 
         final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
 
-        pixelsPerUnitXAxis = read4Bytes("PixelsPerUnitXAxis", is, "Not a Valid Png File: pHYs Corrupt");
-        pixelsPerUnitYAxis = read4Bytes("PixelsPerUnitYAxis", is, "Not a Valid Png File: pHYs Corrupt");
+        pixelsPerUnitXAxis = read4Bytes("PixelsPerUnitXAxis", is, "Not a Valid Png File: pHYs Corrupt", getByteOrder());
+        pixelsPerUnitYAxis = read4Bytes("PixelsPerUnitYAxis", is, "Not a Valid Png File: pHYs Corrupt", getByteOrder());
         unitSpecifier = readByte("Unit specifier", is, "Not a Valid Png File: pHYs Corrupt");
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java Wed Nov 27 16:28:01 2013
@@ -22,6 +22,8 @@ import java.io.IOException;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.formats.png.GammaCorrection;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngChunkPlte extends PngChunk {
     private final int[] rgb;
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java?rev=1546091&r1=1546090&r2=1546091&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java Wed Nov 27 16:28:01 2013
@@ -21,6 +21,8 @@ import java.io.IOException;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.formats.png.PngText;
 
+import static org.apache.commons.imaging.common.BinaryFunctions.*;
+
 public class PngChunkText extends PngTextChunk {
     public final String keyword;
     public final String text;



Mime
View raw message