commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1441859 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: common/ formats/bmp/ formats/gif/ formats/icns/ formats/ico/ formats/jpeg/ formats/jpeg/decoder/ formats/jpeg/iptc/ formats/jpeg/segments/ formats/pcx/ fo...
Date Sun, 03 Feb 2013 05:45:10 GMT
Author: damjan
Date: Sun Feb  3 05:45:09 2013
New Revision: 1441859

URL: http://svn.apache.org/viewvc?rev=1441859&view=rev
Log:
A few more cleanups.


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/BinaryInputStream.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/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/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/iptc/IptcParser.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/ComSegment.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/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/psd/PsdImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -96,14 +96,14 @@ public class BinaryFileParser {
         return BinaryFunctions.readByte(name, is, exception);
     }
     
-    protected final byte[] readBytes(final String name, final int length, final InputStream
is,
+    protected final byte[] readBytes(final String name, final InputStream is, final int length,
             final String exception) throws IOException {
-        return BinaryFunctions.readBytes(name, length, is, exception);
+        return BinaryFunctions.readBytes(name, is, length, exception);
     }
     
-    protected final byte[] readBytes(final String name, final int length, final InputStream
is)
+    protected final byte[] readBytes(final String name, final InputStream is, final int length)
             throws IOException {
-        return BinaryFunctions.readBytes(name, length, is);
+        return BinaryFunctions.readBytes(name, is, length);
     }
     
     protected final byte[] readBytes(final InputStream is, final int count) throws IOException
{

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -49,18 +49,42 @@ public class BinaryFunctions {
         return true;
     }
 
-    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");
+    public static final byte readByte(final String name, final InputStream is, final String
exception)
+            throws IOException {
+        final int result = is.read();
+        if ((result < 0)) {
+            throw new IOException(exception);
+        }
+        return (byte) (0xff & result);
+    }
+
+    public static final byte[] readBytes(final String name, final InputStream is, final int
length)
+            throws IOException {
+        final String exception = name + " could not be read.";
+        return readBytes(name, is, length, exception);
+    }
+
+    public static final byte[] readBytes(final String name, final InputStream is, final int
length,
+            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);
+            if (count < 0) {
+                throw new IOException(exception + " count: " + count
+                        + " read: " + read + " length: " + length);
             }
-            result[i] = (byte) data;
+
+            read += count;
         }
+
         return result;
     }
 
+    public static final byte[] readBytes(final InputStream is, final int count) throws IOException
{
+        return readBytes("", is, count, "Unexpected EOF");
+    }
+
     public static final void readAndVerifyBytes(final InputStream is, final byte expected[],
             final String exception) throws ImageReadException, IOException {
         for (final byte element : expected) {
@@ -97,7 +121,7 @@ public class BinaryFunctions {
     public static final void readAndVerifyBytes(final String name, final InputStream is,
             final byte expected[], final String exception) throws ImageReadException,
             IOException {
-        final byte bytes[] = readBytes(name, expected.length, is, exception);
+        final byte bytes[] = readBytes(name, is, expected.length, exception);
 
         for (int i = 0; i < expected.length; i++) {
             if (bytes[i] != expected[i]) {
@@ -133,40 +157,7 @@ public class BinaryFunctions {
         }
     }
 
-    public static final byte readByte(final String name, final InputStream is, final String
exception)
-            throws IOException {
-        final int result = is.read();
-        if ((result < 0)) {
-            throw new IOException(exception);
-        }
-        return (byte) (0xff & result);
-    }
-
-    public static final byte[] readBytes(final String name, final int length, final InputStream
is)
-            throws IOException {
-        final String exception = name + " could not be read.";
-        return readBytes(name, length, is, exception);
-    }
-
-    public static final byte[] readBytes(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);
-            if (count < 0) {
-                throw new IOException(exception + " count: " + count
-                        + " read: " + read + " length: " + length);
-            }
-
-            read += count;
-        }
-
-        return result;
-    }
-
-    public static final byte[] remainingBytes(final String name, final byte bytes[], final
int count)
-            throws ImageReadException {
+    public static final byte[] remainingBytes(final String name, final byte bytes[], final
int count) {
         return slice(bytes, count, bytes.length - count);
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java?rev=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java
Sun Feb  3 05:45:09 2013
@@ -109,7 +109,7 @@ public class BinaryInputStream extends I
 
     public final byte[] readBytes(final String name, final int length, final String exception)
             throws IOException {
-        return BinaryFunctions.readBytes(name, length, is, exception);
+        return BinaryFunctions.readBytes(name, is, length, exception);
     }
 
     public final void debugByteArray(final String name, final byte bytes[]) {
@@ -130,27 +130,7 @@ public class BinaryInputStream extends I
 
     public final byte[] readBytes(final int length, final String error)
             throws ImageReadException, IOException {
-        return BinaryFunctions.readBytes("", length, is, error);
-    }
-
-    public final byte[] readBytes(final int length, final String error,
-            final boolean verbose, final boolean strict) throws ImageReadException,
-            IOException {
-        final byte bytes[] = new byte[length];
-        int total = 0;
-        int read;
-        while ((read = read(bytes, total, length - total)) > 0) {
-            total += read;
-        }
-        if (total < length) {
-            if (strict) {
-                throw new ImageReadException(error);
-            } else if (verbose) {
-                System.out.println(error);
-            }
-            return null;
-        }
-        return bytes;
+        return BinaryFunctions.readBytes("", is, length, error);
     }
 
     public final boolean compareBytes(final byte a[], final int aStart, final byte b[],

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -309,7 +309,7 @@ public class BmpImageParser extends Imag
                     // RLESamplesPerByte);
                     // System.out.println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                     // );
-                    final byte bytes[] = this.readBytes("bytes", size, is,
+                    final byte bytes[] = this.readBytes("bytes", is, size,
                             "RLE: Absolute Mode");
                     baos.write(bytes);
                 }
@@ -406,7 +406,7 @@ public class BmpImageParser extends Imag
 
         byte colorTable[] = null;
         if (paletteLength > 0) {
-            colorTable = this.readBytes("ColorTable", paletteLength, is,
+            colorTable = this.readBytes("ColorTable", is, paletteLength,
                     "Not a Valid BMP File");
         }
 
@@ -454,7 +454,7 @@ public class BmpImageParser extends Imag
                     + expectedDataOffset + ", paletteLength: " + paletteLength
                     + ", headerSize: " + headerSize + ")");
         } else if (extraBytes > 0) {
-            this.readBytes("BitmapDataOffset", extraBytes, is,
+            this.readBytes("BitmapDataOffset", is, extraBytes,
                     "Not a Valid BMP File");
         }
 
@@ -468,7 +468,7 @@ public class BmpImageParser extends Imag
         if (rle) {
             imageData = getRLEBytes(is, rleSamplesPerByte);
         } else {
-            imageData = this.readBytes("ImageData", imageDataSize, is,
+            imageData = this.readBytes("ImageData", is, imageDataSize,
                     "Not a Valid BMP File");
         }
 

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=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
Sun Feb  3 05:45:09 2013
@@ -186,7 +186,7 @@ public class GifImageParser extends Imag
     private byte[] readSubBlock(final InputStream is) throws IOException {
         final int block_size = 0xff & readByte("block_size", is, "GIF: corrupt block");
 
-        final byte bytes[] = readBytes("block", block_size, is,
+        final byte bytes[] = readBytes("block", is, block_size,
                 "GIF: corrupt block");
 
         return bytes;
@@ -422,7 +422,7 @@ public class GifImageParser extends Imag
             final FormatCompliance formatCompliance) throws IOException {
         final int actual_size = convertColorTableSize(ct_size);
 
-        final byte bytes[] = readBytes("block", actual_size, is,
+        final byte bytes[] = readBytes("block", is, actual_size,
                 "GIF: corrupt Color Table");
 
         return bytes;

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -218,7 +218,7 @@ public class IcnsImageParser extends Ima
                                                                                   // including
                                                                                   // this
                                                                                   // header
-        final byte[] data = readBytes("Data", elementSize - 8, is,
+        final byte[] data = readBytes("Data", is, elementSize - 8,
                 "Not a Valid ICNS File");
 
         return new IcnsElement(type, elementSize, data);

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=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
Sun Feb  3 05:45:09 2013
@@ -406,7 +406,7 @@ public class IcoImageParser extends Imag
             GreenMask = read4Bytes("GreenMask", is, "Not a Valid ICO File");
             BlueMask = read4Bytes("BlueMask", is, "Not a Valid ICO File");
         }
-        final byte[] RestOfFile = readBytes("RestOfFile", is.available(), is);
+        final byte[] RestOfFile = readBytes("RestOfFile", is, is.available());
 
         if (Size != 40) {
             throw new ImageReadException(
@@ -484,7 +484,7 @@ public class IcoImageParser extends Imag
         byte[] transparency_map = null;
         try {
             transparency_map = this.readBytes("transparency_map",
-                    tcolor_map_size_bytes, bmpInputStream,
+                    bmpInputStream, tcolor_map_size_bytes,
                     "Not a Valid ICO File");
         } catch (final IOException ioEx) {
             if (BitCount != 32) {

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -77,11 +77,11 @@ public class JpegUtils extends BinaryFil
                 }
 
                 final byte segmentLengthBytes[] = readBytes("segmentLengthBytes",
-                        2, is, "segmentLengthBytes");
+                        is, 2, "segmentLengthBytes");
                 final int segmentLength = toUInt16(segmentLengthBytes);
 
                 final byte segmentData[] = readBytes("Segment Data",
-                        segmentLength - 2, is,
+                        is, segmentLength - 2,
                         "Invalid Segment: insufficient data");
 
                 if (!visitor.visitSegment(marker, markerBytes, segmentLength,

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -68,7 +68,7 @@ public class JpegDecoder extends BinaryF
             final int segmentLength = read2Bytes("segmentLength", is,
                     "Not a Valid JPEG File");
             final byte[] sosSegmentBytes = readBytes("SosSegment",
-                    segmentLength - 2, is, "Not a Valid JPEG File");
+                    is, segmentLength - 2, "Not a Valid JPEG File");
             sosSegment = new SosSegment(marker, sosSegmentBytes);
 
             int hMax = 0;

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=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
Sun Feb  3 05:45:09 2013
@@ -29,7 +29,6 @@ import org.apache.commons.imaging.ImageR
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.ImagingConstants;
 import org.apache.commons.imaging.common.BinaryFileParser;
-import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.BinaryInputStream;
 import org.apache.commons.imaging.common.BinaryOutputStream;
 import org.apache.commons.imaging.common.ByteOrder;
@@ -283,11 +282,12 @@ public class IptcParser extends BinaryFi
             // int index = PHOTOSHOP_IDENTIFICATION_STRING.length;
     
             while (true) {
-                final byte[] imageResourceBlockSignature = bis
-                        .readBytes(CONST_8BIM.size(),
-                                "App13 Segment missing identification string",
-                                false, false);
-                if (null == imageResourceBlockSignature) {
+                final byte[] imageResourceBlockSignature;
+                try {
+                    imageResourceBlockSignature = bis.readBytes(
+                            CONST_8BIM.size(),
+                            "App13 Segment missing identification string");
+                } catch (IOException ioEx) {
                     break;
                 }
                 if (!CONST_8BIM.equals(imageResourceBlockSignature)) {
@@ -314,9 +314,13 @@ public class IptcParser extends BinaryFi
                     bis.readByte("Block name bytes", "Image Resource Block has invalid name");
                     blockNameBytes = new byte[0];
                 } else {
-                    blockNameBytes = bis.readBytes(blockNameLength,
-                            "Invalid Image Resource Block name", verbose, strict);
-                    if (null == blockNameBytes) {
+                    try {
+                        blockNameBytes = bis.readBytes(blockNameLength,
+                                "Invalid Image Resource Block name");
+                    } catch (IOException ioEx) {
+                        if (strict) {
+                            throw ioEx;
+                        }
                         break;
                     }
     
@@ -342,9 +346,13 @@ public class IptcParser extends BinaryFi
                             + blockSize + " > " + bytes.length);
                 }
     
-                final byte[] blockData = bis.readBytes(blockSize,
-                        "Invalid Image Resource Block data", verbose, strict);
-                if (null == blockData) {
+                final byte[] blockData;
+                try {
+                    blockData = bis.readBytes(blockSize, "Invalid Image Resource Block data");
+                } catch (IOException ioEx) {
+                    if (strict) {
+                        throw ioEx;
+                    }
                     break;
                 }
     

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -50,7 +50,7 @@ public class App2Segment extends AppnSeg
             marker_length -= JpegImageParser.icc_profile_label.size();
             marker_length -= (1 + 1);
 
-            icc_bytes = readBytes("App2 Data", marker_length, is,
+            icc_bytes = readBytes("App2 Data", is, marker_length,
                     "Invalid App2 Segment: insufficient data");
         } else {
             // debugByteArray("Unknown APP2 Segment Type", bytes);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java?rev=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
Sun Feb  3 05:45:09 2013
@@ -36,7 +36,7 @@ public class ComSegment extends Segment 
             System.out.println("ComSegment marker_length: " + marker_length);
         }
 
-        comment = readBytes("Comment", marker_length, is,
+        comment = readBytes("Comment", is, marker_length,
                 "Error reading JPEG comment");
 
         if (getDebug()) {

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -27,7 +27,7 @@ public abstract class GenericSegment ext
             throws IOException {
         super(marker, marker_length);
 
-        bytes = readBytes("Segment Data", marker_length, is,
+        bytes = readBytes("Segment Data", is, marker_length,
                 "Invalid Segment: insufficient data");
     }
 

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -255,7 +255,7 @@ public class PcxImageParser extends Imag
 
     private PcxHeader readPcxHeader(final InputStream is, final boolean isStrict)
             throws ImageReadException, IOException {
-        final byte[] pcxHeaderBytes = readBytes("PcxHeader", 128, is,
+        final byte[] pcxHeaderBytes = readBytes("PcxHeader", is, 128,
                 "Not a Valid PCX File");
         final int manufacturer = 0xff & pcxHeaderBytes[0];
         final int version = 0xff & pcxHeaderBytes[1];
@@ -344,7 +344,7 @@ public class PcxImageParser extends Imag
     }
 
     private int[] read256ColorPalette(final InputStream stream) throws IOException {
-        final byte[] paletteBytes = readBytes("Palette", 769, stream,
+        final byte[] paletteBytes = readBytes("Palette", stream, 769,
                 "Error reading palette");
         if (paletteBytes[0] != 12) {
             return null;

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -175,7 +175,7 @@ public class PngImageParser extends Imag
 
             byte bytes[] = null;
             if (keep) {
-                bytes = readBytes("Chunk Data", length, is,
+                bytes = readBytes("Chunk Data", is, length,
                         "Not a Valid PNG File: Couldn't read Chunk Data.");
             } else {
                 skipBytes(is, length, "Not a Valid PNG File");

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -228,7 +228,7 @@ public abstract class ScanExpediter exte
             throw new ImageReadException("PNG: missing filter type");
         }
 
-        final byte scanline[] = this.readBytes("scanline", length, is,
+        final byte scanline[] = this.readBytes("scanline", is, length,
                 "PNG: missing image data");
 
         final byte unfiltered[] = unfilterScanline(filterType, scanline, prev,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
Sun Feb  3 05:45:09 2013
@@ -106,7 +106,7 @@ public class PsdImageParser extends Imag
 
         final int Version = read2Bytes("Version", is, "Not a Valid PSD File");
 
-        final byte Reserved[] = readBytes("Reserved", 6, is,
+        final byte Reserved[] = readBytes("Reserved", is, 6,
                 "Not a Valid PSD File");
 
         final int Channels = read2Bytes("Channels", is, "Not a Valid PSD File");
@@ -202,7 +202,7 @@ public class PsdImageParser extends Imag
             final int nameLength = readByte("NameLength", is, "Not a Valid PSD File");
 
             available -= 1;
-            final byte nameBytes[] = readBytes("NameData", nameLength, is,
+            final byte nameBytes[] = readBytes("NameData", is, nameLength,
                     "Not a Valid PSD File");
             available -= nameLength;
             if (((nameLength + 1) % 2) != 0) {
@@ -217,7 +217,7 @@ public class PsdImageParser extends Imag
             // ? DataSize
             // : DataSize + 1; // pad to make even
 
-            final byte Data[] = readBytes("Data", DataSize, is,
+            final byte Data[] = readBytes("Data", is, DataSize,
                     "Not a Valid PSD File");
             available -= DataSize;
 
@@ -256,7 +256,7 @@ public class PsdImageParser extends Imag
 
             is = this.getInputStream(byteSource, PSD_SECTION_IMAGE_RESOURCES);
             final byte ImageResources[] = readBytes("ImageResources",
-                    imageContents.ImageResourcesLength, is,
+                    is, imageContents.ImageResourcesLength,
                     "Not a Valid PSD File");
 
             return readImageResourceBlocks(ImageResources, imageResourceIDs,
@@ -358,7 +358,7 @@ public class PsdImageParser extends Imag
 
             // PsdHeaderInfo header = readHeader(is);
             if (section == PSD_SECTION_HEADER) {
-                return readBytes("Header", PSD_HEADER_LENGTH, is,
+                return readBytes("Header", is, PSD_HEADER_LENGTH,
                         "Not a Valid PSD File");
             }
             skipBytes(is, PSD_HEADER_LENGTH);
@@ -367,7 +367,7 @@ public class PsdImageParser extends Imag
                     "Not a Valid PSD File");
 
             if (section == PSD_SECTION_COLOR_MODE) {
-                return readBytes("ColorModeData", ColorModeDataLength, is,
+                return readBytes("ColorModeData", is, ColorModeDataLength,
                         "Not a Valid PSD File");
             }
 
@@ -379,8 +379,8 @@ public class PsdImageParser extends Imag
                     "Not a Valid PSD File");
 
             if (section == PSD_SECTION_IMAGE_RESOURCES) {
-                return readBytes("ImageResources", ImageResourcesLength,
-                        is, "Not a Valid PSD File");
+                return readBytes("ImageResources", is,
+                        ImageResourcesLength, "Not a Valid PSD File");
             }
 
             skipBytes(is, ImageResourcesLength);
@@ -392,7 +392,7 @@ public class PsdImageParser extends Imag
 
             if (section == PSD_SECTION_LAYER_AND_MASK_DATA) {
                 return readBytes("LayerAndMaskData",
-                        LayerAndMaskDataLength, is, "Not a Valid PSD File");
+                        is, LayerAndMaskDataLength, "Not a Valid PSD File");
             }
 
             skipBytes(is, LayerAndMaskDataLength);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java?rev=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
Sun Feb  3 05:45:09 2013
@@ -66,7 +66,7 @@ public class CompressedDataReader extend
             for (int y = 0; y < height; y++) {
                 final int index = channel * height + y;
                 final byte packed[] = BinaryFunctions.readBytes("scanline",
-                        scanline_bytecounts[index], is,
+                        is, scanline_bytecounts[index],
                         "PSD: Missing Image Data");
 
                 final byte unpacked[] = new PackBits().decompress(packed, width);

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=1441859&r1=1441858&r2=1441859&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
Sun Feb  3 05:45:09 2013
@@ -178,7 +178,7 @@ public class TiffReader extends BinaryFi
                 // Debug.debug("tag*", tag + " (0x" + Integer.toHexString(tag)
                 // + ")");
 
-                final byte valueOffsetBytes[] = readBytes("ValueOffset", 4, is,
+                final byte valueOffsetBytes[] = readBytes("ValueOffset", is, 4,
                         "Not a Valid TIFF File");
                 final int valueOffset = toInt(valueOffsetBytes);
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java?rev=1441859&r1=1441858&r2=1441859&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
Sun Feb  3 05:45:09 2013
@@ -207,8 +207,8 @@ public class WbmpImageParser extends Ima
     private BufferedImage readImage(final WbmpHeader wbmpHeader, final InputStream is)
             throws IOException {
         final int rowLength = (wbmpHeader.width + 7) / 8;
-        final byte[] image = readBytes("Pixels", rowLength * wbmpHeader.height,
-                is, "Error reading image pixels");
+        final byte[] image = readBytes("Pixels", is,
+                rowLength * wbmpHeader.height, "Error reading image pixels");
         final DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
         final WritableRaster raster = WritableRaster.createPackedRaster(dataBuffer,
                 wbmpHeader.width, wbmpHeader.height, 1, null);



Mime
View raw message